MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / init

Method init

GUI/OpenGL/MiniGL.cpp:454–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454void MiniGL::init(const int width, const int height, const char *name, const bool vsync, const bool maximized, const bool alt_camera)
455{
456 fovy = 60;
457 znear = 0.5f;
458 zfar = 1000;
459
460 m_width = width;
461 m_height = height;
462 m_vsync = vsync;
463 m_alt_camera = alt_camera;
464
465 scenefunc = nullptr;
466
467 glfwSetErrorCallback(error_callback);
468
469 if (!glfwInit())
470 exit(EXIT_FAILURE);
471
472 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
473 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
474 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
475 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
476 glfwWindowHint(GLFW_SAMPLES, 4);
477
478 if (maximized)
479 glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
480
481 if (m_vsync)
482 glfwWindowHint(GLFW_DOUBLEBUFFER, GL_TRUE);
483 else
484 glfwWindowHint(GLFW_DOUBLEBUFFER, GL_FALSE);
485 m_glfw_window = glfwCreateWindow(width, height, name, NULL, NULL);
486 if (!m_glfw_window)
487 {
488 glfwTerminate();
489 exit(EXIT_FAILURE);
490 }
491
492 glfwMakeContextCurrent(m_glfw_window);
493 gladLoadGL(glfwGetProcAddress);
494 glfwSwapInterval(0);
495
496 glfwSetFramebufferSizeCallback(m_glfw_window, reshape);
497
498 getOpenGLVersion(m_context_major_version, m_context_minor_version);
499 glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &m_context_profile);
500
501 LOG_INFO << "OpenGL version " << m_context_major_version << "." << m_context_minor_version;
502 LOG_INFO << "Vendor: " << glGetString(GL_VENDOR);
503 LOG_INFO << "Renderer: " << glGetString(GL_RENDERER);
504 LOG_INFO << "Version: " << glGetString(GL_VERSION);
505
506 glEnable(GL_MULTISAMPLE);
507 glEnable (GL_DEPTH_TEST);
508 glEnable (GL_BLEND);
509 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
510
511 glClearColor(0.4f, 0.4f, 0.4f, 1.0f);

Callers

nothing calls this directly

Calls 15

glfwSetErrorCallbackFunction · 0.85
glfwInitFunction · 0.85
glfwWindowHintFunction · 0.85
glfwCreateWindowFunction · 0.85
glfwTerminateFunction · 0.85
glfwMakeContextCurrentFunction · 0.85
gladLoadGLFunction · 0.85
glfwSwapIntervalFunction · 0.85
glfwSetKeyCallbackFunction · 0.85
glfwSetCharCallbackFunction · 0.85

Tested by

no test coverage detected