Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <GL/glew.h>
- #include <GLFW/glfw3.h>
- #include <iostream>
- using std::cerr;
- bool InitGraphics();
- int main( void )
- {
- InitGraphics();
- return 0;
- }
- /**
- Creates the main window and initializes OpenGL stuff.
- */
- bool InitGraphics()
- {
- GLFWwindow* window;
- // ******************** Initialise GLFW ******************** //
- if( !glfwInit() )
- {
- cerr << "Failed to initialize GLFW\n";
- return false;
- }
- glfwWindowHint(GLFW_SAMPLES, 4);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //OpenGL version 3.
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // 3.3
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //If requesting an OpenGL version below 3.2, GLFW_OPENGL_ANY_PROFILE
- // Open a window and create its OpenGL context
- window = glfwCreateWindow( 1024, 768, "Red triangle", NULL, NULL);
- if( window == NULL )
- {
- cerr << "Failed to open GLFW window. If you have an Intel GPU , they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n";
- glfwTerminate();
- return false;
- }
- glfwMakeContextCurrent(window);
- // ******************** Initialize GLEW ******************** //
- glewExperimental = true; // Needed for core profile
- if (glewInit() != GLEW_OK)
- {
- cerr << "Failed to initialize GLEW\n";
- return false;
- }
- // Ensure we can capture the escape key being pressed below
- glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
- // ******************** Initialize OpenGL ******************** //
- do{ // Loop
- // Swap buffers
- glfwSwapBuffers(window); //Displaying our finished scene
- glfwPollEvents(); //try to comment it
- } // Check if the ESC key was pressed or the window was closed
- while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
- glfwWindowShouldClose(window) == 0 );
- // Close OpenGL window and terminate GLFW
- glfwTerminate();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement