Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------
- ENGINE.CPP
- --------------------------------------------
- #include <iostream>
- #include <GLFW/glfw3.h>
- #include <thread>
- #include "Engine.h"
- Engine::Engine(int vm, int vn, GLuint prof, GLuint forcom, GLuint res, int width, int height, char* title, GLFWmonitor* fullscreen)
- {
- //variable assigning
- std::cout << "Starting OpenStellar Engine! Please wait while it initializes! (it shouldn't take long!)" << std::endl;
- major = vm;
- minor = vn;
- profile = prof;
- forwardCompat = forcom;
- resizable = res;
- screenWidth = width;
- screenHeight = height;
- screenTitleBarText = title;
- screenFullscreen = fullscreen;
- if (!GLFWinitialize())
- {
- std::cout << "ERROR::GLFW - GLFW failed to initialize!" << std::endl;
- }
- window = glfwCreateWindow(screenWidth, screenHeight, screenTitleBarText, screenFullscreen, nullptr);
- if (window == nullptr)
- {
- std::cout << "ERROR::GLFW - GLFW failed window creation!" << std::endl;
- }
- }
- bool Engine::GLFWinitialize()
- {
- if (!glfwInit())
- {
- return false;
- }
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor);
- glfwWindowHint(GLFW_OPENGL_PROFILE, profile);
- glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, forwardCompat);
- glfwWindowHint(GLFW_RESIZABLE, resizable);
- return true;
- }
- void Engine::GameLoop()
- {
- while (!glfwWindowShouldClose(window))
- {
- glfwSwapBuffers(window);
- glfwPollEvents();
- }
- }
- --------------------------------------------
- ENGINE.H
- --------------------------------------------
- #pragma once
- #include <iostream>
- #include <GLFW/glfw3.h>
- class Engine
- {
- public:
- Engine(int vm, int vn, GLuint pro, GLuint forcom, GLuint res, int widht, int height, char* title, GLFWmonitor* fullscreen);
- void GameLoop();
- private:
- int major;
- int minor;
- bool running;
- GLuint profile;
- GLuint forwardCompat;
- GLuint resizable;
- int screenWidth;
- int screenHeight;
- char* screenTitleBarText;
- GLFWmonitor* screenFullscreen;
- GLFWwindow* window;
- bool GLFWinitialize();
- protected:
- };
- --------------------------------------------
- MAIN.CPP
- --------------------------------------------
- #include <iostream>
- #include <GLFW/glfw3.h>
- #include <thread>
- #include "Engine.h"
- int main()
- {
- Engine engine = Engine::Engine(3, 2, GLFW_OPENGL_CORE_PROFILE, GL_TRUE, GL_FALSE, 800, 600, "OpenGL Test", nullptr);
- engine.GameLoop();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment