MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / opengl_Setup

Function opengl_Setup

renderer/HardwareOpenGL.cpp:397–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395int SDLCALL d3SDLEventFilter(void *userdata, SDL_Event *event);
396
397int opengl_Setup(oeApplication *app, int *width, int *height) {
398 int winw = Video_res_list[Game_video_resolution].width;
399 int winh = Video_res_list[Game_video_resolution].height;
400
401 // rcg09182000 don't need to quitsubsystem anymore...
402 // SDL_QuitSubSystem(SDL_INIT_VIDEO); // here goes nothing...
403 // Already_loaded = false;
404 SDL_ClearError();
405 if (!SDL_WasInit(SDL_INIT_VIDEO)) {
406 const int rc = SDL_Init(SDL_INIT_VIDEO);
407 if (rc != 0) {
408 char buffer[512];
409 snprintf(buffer, sizeof(buffer), "SDL_GetError() reports \"%s\".\n", SDL_GetError());
410 fprintf(stderr, "SDL: SDL_Init() failed! rc == (%d).\n", rc);
411 fprintf(stderr, "%s", buffer);
412 rend_SetErrorMessage(buffer);
413 return (0);
414 }
415 }
416
417 SDL_SetEventFilter(d3SDLEventFilter, NULL);
418
419 bool fullscreen = true;
420
421 if (FindArgChar("-fullscreen", 'f')) {
422 fullscreen = true;
423 } else if (FindArgChar("-windowed", 'w')) {
424 fullscreen = false;
425 }
426
427 if (!Already_loaded) {
428#define MAX_ARGS 30
429#define MAX_CHARS_PER_ARG 100
430 extern char GameArgs[MAX_ARGS][MAX_CHARS_PER_ARG];
431
432 char gl_library[256];
433 int arg;
434 arg = FindArgChar("-gllibrary", 'g');
435 if (arg != 0) {
436 strcpy(gl_library, GameArgs[arg + 1]);
437 } else {
438 gl_library[0] = 0;
439 }
440
441 mprintf(0, "OpenGL: Attempting to use \"%s\" for OpenGL\n", gl_library[0] ? gl_library : "[system default library]");
442
443 // ryan's adds. 04/18/2000...SDL stuff on 04/25/2000
444 bool success = true;
445
446 OpenGLDLLHandle = LoadOpenGLDLL(gl_library);
447 if (!(OpenGLDLLHandle)) {
448 // rcg07072000 last ditch effort...
449#if defined(POSIX)
450 strcpy(gl_library, "libGL.so.1");
451#else
452 strcpy(gl_library, "opengl32.dll");
453#endif
454 OpenGLDLLHandle = LoadOpenGLDLL(gl_library);

Callers 1

opengl_InitFunction · 0.70

Calls 4

FindArgCharFunction · 0.85
rend_SetErrorMessageFunction · 0.70
FindArgFunction · 0.50
set_sizeposMethod · 0.45

Tested by

no test coverage detected