MCPcopy Create free account
hub / github.com/ddnet/ddnet / BackendInitGlew

Function BackendInitGlew

src/engine/client/backend_sdl.cpp:475–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473
474#if !defined(CONF_HEADLESS_CLIENT)
475static bool BackendInitGlew(EBackendType BackendType, int &GlewMajor, int &GlewMinor, int &GlewPatch)
476{
477 if(BackendType == BACKEND_TYPE_OPENGL)
478 {
479#if !defined(CONF_BACKEND_OPENGL_ES)
480 // Support graphic cards that are pretty old (and Linux)
481 glewExperimental = GL_TRUE;
482#ifdef CONF_GLEW_HAS_CONTEXT_INIT
483 const GLenum InitResult = glewContextInit();
484 if(InitResult != GLEW_OK)
485 {
486 log_error("gfx", "Unable to init glew (glewContextInit): %s", glewGetErrorString(InitResult));
487 return false;
488 }
489#else
490 const GLenum InitResult = glewInit();
491 if(InitResult != GLEW_OK)
492 {
493 // With wayland the glewInit function is allowed to fail with GLEW_ERROR_NO_GLX_DISPLAY,
494 // as it will already have initialized the context with glewContextInit internally.
495 const char *pVideoDriver = SDL_GetCurrentVideoDriver();
496 if(pVideoDriver == nullptr || str_comp(pVideoDriver, "wayland") != 0 || InitResult != GLEW_ERROR_NO_GLX_DISPLAY)
497 {
498 log_error("gfx", "Unable to init glew (glewInit): %s", glewGetErrorString(InitResult));
499 return false;
500 }
501 }
502#endif
503
504#ifdef GLEW_VERSION_4_6
505 if(GLEW_VERSION_4_6)
506 {
507 GlewMajor = 4;
508 GlewMinor = 6;
509 GlewPatch = 0;
510 return true;
511 }
512#endif
513#ifdef GLEW_VERSION_4_5
514 if(GLEW_VERSION_4_5)
515 {
516 GlewMajor = 4;
517 GlewMinor = 5;
518 GlewPatch = 0;
519 return true;
520 }
521#endif
522// Don't allow GL 3.3, if the driver doesn't support at least OpenGL 4.5
523#ifndef CONF_FAMILY_WINDOWS
524 if(GLEW_VERSION_4_4)
525 {
526 GlewMajor = 4;
527 GlewMinor = 4;
528 GlewPatch = 0;
529 return true;
530 }
531 if(GLEW_VERSION_4_3)
532 {

Callers 1

InitMethod · 0.85

Calls 3

glewContextInitFunction · 0.85
glewGetErrorStringFunction · 0.85
str_compFunction · 0.85

Tested by

no test coverage detected