Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAIN.CPP
- #include "System.h"
- int main()
- {
- System::Initialize();
- System::Shutdown();
- return 0;
- }
- SYSTEM.H
- #define GLEW_STATIC
- #include <GL\glew.h>
- #include <GLFW\glfw3.h>
- #include <iostream>
- GLFWwindow* window;
- namespace System
- {
- //Objects and variables
- GLFWwindow* window;
- //Function prototypes
- bool Initialize();
- void Shutdown();
- }
- SYSTEM.CPP
- #include "System.h"
- #include "Settings.h"
- using namespace System;
- bool System::Initialize()
- {
- std::cout << "Initializing GLFW: OpenGL version 3.3 \n";
- //Initialize GLFW
- glfwInit();
- //Set window properties (version 3.3, core profile, not resizeable)
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
- //Create Window
- window = glfwCreateWindow(Settings::defaultScreenWidth, Settings::defaultScreenHeight, "Learn OpenGL", nullptr, nullptr);
- if (window = nullptr)
- {
- std::cout << "Failed to create GLFW window \n";
- glfwTerminate();
- return false;
- }
- //Make the context current
- glfwMakeContextCurrent(window);
- //Initialize GLEW
- glewExperimental = GL_TRUE;
- std::cout << "Initializing GLEW: Experimental = " << glewExperimental << "\n";
- if (glewInit() != GLEW_OK)
- {
- std::cout << "Falied to initialize GLEW \n";
- return false;
- }
- //Set up viewport
- glfwGetFramebufferSize(window, &Settings::defaultScreenWidth, &Settings::defaultScreenHeight);
- glViewport(0, 0, Settings::screenWidth, Settings::screenHeight);
- return true;
- }
- void System::Shutdown()
- {
- glfwTerminate();
- }
- SETTINGS.H
- namespace Settings
- {
- //Variables
- int defaultScreenWidth = 100;
- int defaultScreenHeight = 100;
- int screenWidth = defaultScreenWidth;
- int screenHeight = defaultScreenHeight;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement