View difference between Paste ID: fG711uMv and cfYhKDXD
SHOW: | | - or go back to the newest paste.
1
// Original code by opengl-tutorials.org
2
3
// Include standard headers
4
#include <stdio.h>
5
#include <stdlib.h>
6
7
// Include GLEW
8
#include <GL/glew.h>
9
10
// Include GLFW
11
#include <GL/glfw.h>
12
13
// Include GLM
14
#include <glm/glm.hpp>
15
using namespace glm;
16
17
int main( void )
18
{
19
        GLFWwindow* window;
20
21
        // Initialise GLFW
22
        if( !glfwInit() )
23
        {
24
                fprintf( stderr, "Failed to initialize GLFW\n" );
25
                return -1;
26
        }
27
28
        glfwWindowHint(GLFW_FSAA_SAMPLES, 4);
29
        glfwWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
30
        glfwWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
31
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
32
33
        // Create the window
34
        window = glfwCreateWindow( 1024, 768, "Hello World", 0, 0);
35
36
        // Open a window and create its OpenGL context
37
        if( !window )
38
        {
39
                fprintf( stderr, "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" );
40
                glfwTerminate();
41
                return -1;
42
        }
43
44
        // Initialize GLEW
45
        if (glewInit() != GLEW_OK) {
46
                fprintf(stderr, "Failed to initialize GLEW\n");
47
                return -1;
48
        }
49
50
        // Set window as the one we currently use
51
        glfwMakeContextCurrent(window);
52
53
        // Ensure we can capture the escape key being pressed below
54
        glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
55
56
        // Dark blue background
57
        glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
58
59
        do{
60
                // Draw nothing, see you in tutorial 2 !
61
62
                // Swap buffers
63
                glfwSwapBuffers(window);
64
65
                // Update events for the window
66
                glfwPollEvents()
67
68
        } // Check if the ESC key was pressed or the window was closed
69
        while( !glfwWindowShouldClose(window) );
70
71
        // Close OpenGL window and terminate GLFW
72
        glfwTerminate();
73
74
        return 0;
75
}