Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GLEW
- #define GLEW_STATIC
- #include <GL/glew.h>
- //GLFW
- #include <GLFW/glfw3.h>
- //other includes
- #include<iostream> //cout and cin stuff
- //The main method (gets called when program runs)
- int main()
- {
- //initialize GLFW
- if (!glfwInit())
- {
- std::cout << "GLFW ERROR: GLFW failed to initialize!" << std::endl;
- return EXIT_FAILURE;
- }
- //initialize GLFW options (hints)
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //say we are using version 3.X
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // say we are using version X.3
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //say we are using the core profile (not older immediate mode/fixed function pipeline)
- glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); //initialize the window as non resizable.
- //now that options are set up, its time to create the window
- GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", nullptr, nullptr);
- if (window == nullptr) //check if window creation was successful
- {
- std::cout << "GLFW ERROR: Failed to create GLFW window!" << std::endl;
- glfwTerminate(); //Don't forget to terminate GLFW!
- return EXIT_FAILURE;
- }
- glfwMakeContextCurrent(window); //Make the current window's context the current context of the OpenGL state machine.
- //Now lets initialize GLEW
- glewExperimental = GL_TRUE; //First turn on experimental glew features.
- if (glewInit() != GLEW_OK) //Init glew and test if it works at the same time.
- {
- std::cout << "GLEW ERROR: Failed to initialize GLEW!" << std::endl;
- return EXIT_FAILURE;
- }
- int width, height;// create width and height variables
- glfwGetFramebufferSize(window, &width, &height); //store the window's size in the width and height variables.
- glViewport(0, 0, width, height); //create gl viewport
- //Now the game loop!
- while (!glfwWindowShouldClose(window))
- {
- //check for input events every step.
- glfwPollEvents();
- //STEP BEGIN
- //STEP END
- //DRAW BEGIN
- //DRAW END
- //swap the buffers.
- glfwSwapBuffers(window);
- }
- //Shutting Down
- glfwTerminate(); //lets terminate GLFW
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement