MCPcopy Create free account
hub / github.com/cginternals/globjects / main

Function main

source/examples/shaderincludes/main.cpp:83–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82
83int main(int /*argc*/, char * /*argv*/[])
84{
85 // Initialize GLFW
86 if (!glfwInit())
87 return 1;
88
89 glfwSetErrorCallback(error);
90 glfwDefaultWindowHints();
91 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
92 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
93 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, true);
94
95 // Create a context and, if valid, make it current
96 GLFWwindow * window = glfwCreateWindow(640, 480, "globjects Shader Includes", NULL, NULL);
97 if (window == nullptr)
98 {
99 globjects::critical() << "Context creation failed. Terminate execution.";
100
101 glfwTerminate();
102 return -1;
103 }
104 glfwSetKeyCallback(window, key_callback);
105 glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
106
107 glfwMakeContextCurrent(window);
108
109 // Initialize globjects (internally initializes glbinding, and registers the current context)
110 globjects::init();
111
112 std::cout << std::endl
113 << "OpenGL Version: " << glbinding::ContextInfo::version() << std::endl
114 << "OpenGL Vendor: " << glbinding::ContextInfo::vendor() << std::endl
115 << "OpenGL Renderer: " << glbinding::ContextInfo::renderer() << std::endl << std::endl;
116
117 globjects::info() << "Press F5 to reload shaders." << std::endl << std::endl;
118
119
120 glfwGetFramebufferSize(window, &g_size[0], &g_size[1]);
121 initialize();
122
123 // Main loop
124 while (!glfwWindowShouldClose(window))
125 {
126 glfwPollEvents();
127 draw();
128 glfwSwapBuffers(window);
129 }
130 deinitialize();
131
132 // Properly shutdown GLFW
133 glfwTerminate();
134
135 return 0;
136}

Callers

nothing calls this directly

Calls 9

criticalFunction · 0.85
initFunction · 0.85
versionFunction · 0.85
vendorFunction · 0.85
rendererFunction · 0.85
infoFunction · 0.85
initializeFunction · 0.70
drawFunction · 0.70
deinitializeFunction · 0.70

Tested by

no test coverage detected