MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / Init

Function Init

test/browser/test_glfw.c:316–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void Init() {
317 const int window_width = 800,
318 window_height = 600;
319
320 if (glfwInit() != GL_TRUE) {
321 Shut_Down(1);
322 }
323
324 glfwEnable(GLFW_KEY_REPEAT); // test for issue #3059
325
326 int red_bits = glfwGetWindowParam(GLFW_RED_BITS);
327 glfwOpenWindowHint(GLFW_RED_BITS, 8);
328 assert(glfwGetWindowParam(GLFW_RED_BITS) == 8);
329 glfwOpenWindowHint(GLFW_RED_BITS, red_bits);
330
331 // 800 x 600, 16 bit color, no depth, alpha or stencil buffers, windowed
332 if (glfwOpenWindow(window_width, window_height, 5, 6, 5,
333 0, 0, 0, GLFW_WINDOW) != GL_TRUE) {
334 Shut_Down(1);
335 }
336 glfwSetWindowTitle("The GLFW Window");
337
338 glfwSetKeyCallback(OnKeyPressed);
339 glfwSetCharCallback(OnCharPressed);
340 glfwSetWindowCloseCallback(OnClose);
341 glfwSetWindowSizeCallback(OnResize);
342 if (!on_resize_called) {
343 Shut_Down(1);
344 }
345
346 glfwSetWindowRefreshCallback(OnRefresh);
347 glfwSetMouseWheelCallback(OnMouseWheel);
348 glfwSetMousePosCallback(OnMouseMove);
349 glfwSetMouseButtonCallback(OnMouseClick);
350
351 // set the projection matrix to a normal frustum with a max depth of 50
352 glMatrixMode(GL_PROJECTION);
353 glLoadIdentity();
354 float aspect_ratio = ((float)window_height) / window_width;
355 glFrustum(.5, -.5, -.5 * aspect_ratio, .5 * aspect_ratio, 1, 50);
356 glMatrixMode(GL_MODELVIEW);
357
358 PullInfo();
359}
360
361void Draw(void) {
362 int width, height, x;

Callers 1

mainFunction · 0.70

Calls 3

Shut_DownFunction · 0.85
PullInfoFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected