-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitOpenGL_1.cpp
More file actions
executable file
·68 lines (56 loc) · 1.76 KB
/
InitOpenGL_1.cpp
File metadata and controls
executable file
·68 lines (56 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//-----------------------------------------------------------------------------
// InitOpenGL_1.cpp by Steve Jones
// Copyright (c) 2015-2016 Game Institute. All Rights Reserved.
//
// Creates a basic resizeable window and OpenGL 3.3 context using GLFW.
//
//-----------------------------------------------------------------------------
#include <iostream>
#define GLEW_STATIC
#include "GL/glew.h"
#include "GLFW/glfw3.h"
// Global Variables
const char* APP_TITLE = "Introduction to Modern OpenGL - Hello Window 1";
const int gWindowWidth = 800;
const int gWindowHeight = 600;
//-----------------------------------------------------------------------------
// Main Application Entry Point
//-----------------------------------------------------------------------------
int main()
{
if (!glfwInit())
{
std::cerr << "GLFW initialization failed" << std::endl;
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
GLFWwindow* pWindow = glfwCreateWindow(gWindowWidth, gWindowHeight, APP_TITLE, NULL, NULL);
if (pWindow == NULL)
{
std::cerr << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(pWindow);
// Initialize GLEW
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK)
{
std::cerr << "Failed to initialize GLEW" << std::endl;
return -1;
}
// Rendering loop
while (!glfwWindowShouldClose(pWindow))
{
glfwPollEvents();
glClearColor(0.23f, 0.38f, 0.47f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(pWindow);
}
// Clean up
glfwTerminate();
return 0;
}