-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframework.cpp
More file actions
81 lines (64 loc) · 2.56 KB
/
framework.cpp
File metadata and controls
81 lines (64 loc) · 2.56 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
69
70
71
72
73
74
75
76
77
78
79
80
81
///////////////////////////////////////////////////////////////////////
// Provides the framework for graphics projects, mostly just GLFW
// initialization and main loop.
////////////////////////////////////////////////////////////////////////
#include "framework.h"
// If you are running on a laptop with both an INTEL integrated GPU and a discrete GPU
// AND if your program is not running correctly on the INTEL GPU
// AND if your laptop is not set up to use the discrete GPU by default
// AND you don't know how to force it to use the discrete GPU
// THEN uncomment the following to force this application to run on the discrete GPU
// OTHERWISE leave this untouched.
//
//#ifdef _WIN32
//extern "C"
//{
// __declspec(dllexport) unsigned long NvOptimusEnablement = 1;
// __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
//}
//#endif
Scene scene;
static void error_callback(int error, const char* msg)
{
fputs(msg, stderr);
}
////////////////////////////////////////////////////////////////////////
// Do the OpenGL/GLFW setup and then enter the interactive loop.
int main(int argc, char** argv)
{
glfwSetErrorCallback(error_callback);
// Initialize the OpenGL bindings
glbinding::Binding::initialize(false);
// Initialize glfw open a window
if (!glfwInit()) exit(EXIT_FAILURE);
glfwWindowHint(GLFW_RESIZABLE, 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, 0);
scene.window = glfwCreateWindow(750,750, "Graphics Framework", NULL, NULL);
if (!scene.window) { glfwTerminate(); exit(-1); }
glfwMakeContextCurrent(scene.window);
glfwSwapInterval(1);
ImGui::CreateContext();
//ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui_ImplGlfw_InitForOpenGL(scene.window, true);
ImGui_ImplOpenGL3_Init();
printf("OpenGL Version: %s\n", glGetString(GL_VERSION));
printf("GLSL Version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
printf("Rendered by: %s\n", glGetString(GL_RENDERER));
fflush(stdout);
// Initialize interaction and the scene to be drawn.
InitInteraction();
scene.InitializeScene();
// Enter the event loop.
while (!glfwWindowShouldClose(scene.window)) {
glfwPollEvents();
scene.DrawScene();
scene.DrawMenu();
glfwSwapBuffers(scene.window); }
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwTerminate();
}