/* * * UpdateHardwareGamma * * * We are using gamma relative to the desktop, so that we can share it * with * software renderer and don't require to change desktop gamma * to match * hardware gamma image brightness. It seems that Quake 3 is * using the * opposite approach, but it has no software renderer after * all. */ void UpdateHardwareGamma(void) { float g = (1.3 - vid_gamma->value + 1); g = (g > 1 ? g : 1); SDL_SetGamma(g, g, g); }
void UpdateHardwareGamma(void) { float gamma; gamma = (vid_gamma->value); SDL_SetGamma(gamma, gamma, gamma); }
void OpenGLWindow::set_gamma(float r, float g, float b) { if (SDL_SetGamma(r, g, b) == -1) { // Couldn't set gamma } }
bool GL_SDL_SetGammaValue(float gamma) { if (gamma < 0.1) { Console_Printf("Invalid gamma value of %f\n", gamma); return false; } return (SDL_SetGamma(gamma, gamma, gamma) == 0); //0 == success }
// Gamma static mrb_value mrb_sdl_video_set_gamma (mrb_state *mrb, mrb_value self) { mrb_float red; mrb_float green; mrb_float blue; mrb_get_args(mrb, "|f", &red); mrb_get_args(mrb, "|f", &green); mrb_get_args(mrb, "|f", &blue); return mrb_fixnum_value(SDL_SetGamma(red, green, blue)); }
static void VID_SetGamma (void) { float value; if ((v_gamma.value != 0)&&(v_gamma.value > (1/GAMMA_MAX))) value = 1.0/v_gamma.value; else value = GAMMA_MAX; SDL_SetGamma(value,value,value); }
void GraphicsManager::setGamma(float gamma) { if (!Common::isMainThread()) { // Not the main thread, send a request instead RequestMan.dispatchAndWait(RequestMan.changeGamma(gamma)); return; } _gamma = gamma; SDL_SetGamma(gamma, gamma, gamma); }
int SDL_SetWindowBrightness( SDL_Window *w, float bright ) { int result1; int result2; result1 = SDL_SetGamma( bright, bright, bright ); // Mysteriously, if you use an NVidia graphics card and multiple monitors, // SDL_SetGamma will incorrectly return false... the first time; ask // again and you get the correct answer. This is a suspected driver bug, see // http://bugzilla.icculus.org/show_bug.cgi?id=4316 result2 = SDL_SetGamma( bright, bright, bright ); if ( result1 >= 0 || result2 >= 0 ) { return 0; } return -1; }
void GraphicsManager::setGamma(float gamma) { // Force calling it from the main thread if (!Common::isMainThread()) { Events::MainThreadFunctor<void> functor(boost::bind(&GraphicsManager::setGamma, this, gamma)); return RequestMan.callInMainThread(functor); } _gamma = gamma; SDL_SetGamma(gamma, gamma, gamma); }
void VideoEngine::SetBrightness(float value) { _brightness_value = value; // Limit min/max brightness if(_brightness_value > 2.0f) { _brightness_value = 2.0f; } else if(_brightness_value < 0.0f) { _brightness_value = 0.0f; } // Note: To replace with: SDL_SetWindowBrightness() in SDL 2 SDL_SetGamma(_brightness_value, _brightness_value, _brightness_value); }
void cleanup() { recorder::stop(); cleanupserver(); SDL_ShowCursor(1); SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_SetGamma(1, 1, 1); freeocta(worldroot); extern void clear_command(); clear_command(); extern void clear_console(); clear_console(); extern void clear_mdls(); clear_mdls(); extern void clear_sound(); clear_sound(); SDL_Quit(); }
void VideoEngine::SetGamma(float value) { _gamma_value = value; // Limit min/max gamma if(_gamma_value > 2.0f) { IF_PRINT_WARNING(VIDEO_DEBUG) << "tried to set gamma over 2.0f" << std::endl; _gamma_value = 2.0f; } else if(_gamma_value < 0.0f) { IF_PRINT_WARNING(VIDEO_DEBUG) << "tried to set gamma below 0.0f" << std::endl; _gamma_value = 0.0f; } SDL_SetGamma(_gamma_value, _gamma_value, _gamma_value); }
void toggle_full_screen() { #ifdef WINDOWS full_screen=!full_screen; set_var_unsaved("full_screen", INI_FILE_VAR); LOG_TO_CONSOLE(c_green2, video_restart_str); #else reload_tab_map = 1; full_screen=!full_screen; switch_video(video_mode, full_screen); build_video_mode_array(); if (!disable_gamma_adjust) SDL_SetGamma(gamma_var, gamma_var, gamma_var); SDL_SetModState(KMOD_NONE); // force ALL keys up #endif }
void COptions::UpdateGammaChanges() { #ifndef DISABLE_GAMMA if (iData.iGamma < KMinGamma) iData.iGamma = KMinGamma; if (iData.iGamma > KMaxGamma) iData.iGamma = KMaxGamma; int err = SDL_SetGamma( iData.iGamma, iData.iGamma, iData.iGamma ); if ( err == -1 ) { iData.iGamma = 1; LOG0("Gamma is not supported by the hardware\n"); } #endif }
/* =============== GLimp_Init This routine is responsible for initializing the OS specific portions of OpenGL =============== */ void GLimp_Init(void) { qboolean success = qtrue; r_sdlDriver = ri.Cvar_Get("r_sdlDriver", "", CVAR_ROM); // Sys_GLimpInit(); // create the window and set up the context if(!GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer)) { if(r_mode->integer != R_MODE_FALLBACK) { ri.Printf(PRINT_ALL, "Setting r_mode %d failed, falling back on r_mode %d\n", r_mode->integer, R_MODE_FALLBACK); if(!GLimp_StartDriverAndSetMode(R_MODE_FALLBACK, r_fullscreen->integer)) success = qfalse; } else success = qfalse; } if(!success) ri.Error(ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem\n"); // This values force the UI to disable driver selection glConfig.driverType = GLDRV_DEFAULT; glConfig.hardwareType = GLHW_GENERIC; glConfig.deviceSupportsGamma = !!(SDL_SetGamma(1.0f, 1.0f, 1.0f) >= 0); // get our config strings Q_strncpyz(glConfig.vendor_string, "Microsoft", sizeof(glConfig.vendor_string)); Q_strncpyz(glConfig.renderer_string, "D3D", sizeof(glConfig.renderer_string)); if(*glConfig.renderer_string && glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] == '\n') glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] = 0; Q_strncpyz(glConfig.version_string, "10.0", sizeof(glConfig.version_string)); Q_strncpyz(glConfig.extensions_string, "None", sizeof(glConfig.extensions_string)); ri.Cvar_Get("r_availableModes", "", CVAR_ROM); // This depends on SDL_INIT_VIDEO, hence having it here ri.IN_Init(); }
/* ================= GLimp_SetGamma ================= */ void GLimp_SetGamma( unsigned char red[ 256 ], unsigned char green[ 256 ], unsigned char blue[ 256 ] ) { #if defined( IPHONE ) UNIMPL(); #else #if 1 Uint16 table[ 256 ]; int i, value, lastvalue = 0; for ( i = 0; i < 256; i++ ) { value = ( ( ( Uint16 ) red[ i ] ) << 8 ) | red[ i ]; if ( i < 128 && ( value > ( ( 128 + i ) << 8 ) ) ) { value = ( 128 + i ) << 8; } if ( i && ( value < lastvalue ) ) { value = lastvalue; } lastvalue = table[ i ] = value; } if ( SDL_SetGammaRamp( table, table, table ) == -1 ) { Com_Printf( "SDL_SetGammaRamp failed.\n" ); } #else float g = Cvar_Get( "r_gamma", "1.0", 0 )->value; if ( SDL_SetGamma( g, g, g ) == -1 ) { Com_Printf( "SDL_SetGamma failed.\n" ); } #endif }
/* =============== GLimp_Init This routine is responsible for initializing the OS specific portions of OpenGL =============== */ void GLimp_Init( void ) { qboolean success = qtrue; r_allowSoftwareGL = ri.Cvar_Get( "r_allowSoftwareGL", "0", CVAR_LATCH ); r_sdlDriver = ri.Cvar_Get( "r_sdlDriver", "", CVAR_ROM ); Sys_GLimpInit( ); // create the window and set up the context if( !GLimp_StartDriverAndSetMode( qfalse, r_fullscreen->integer ) ) { if( !GLimp_StartDriverAndSetMode( qtrue, r_fullscreen->integer ) ) success = qfalse; } if( !success ) ri.Error( ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem\n" ); // This values force the UI to disable driver selection glConfig.driverType = GLDRV_ICD; glConfig.hardwareType = GLHW_GENERIC; glConfig.deviceSupportsGamma = !!( SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0 ); // get our config strings Q_strncpyz( glConfig.vendor_string, (char *) qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) ); Q_strncpyz( glConfig.renderer_string, (char *) qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) ); if (*glConfig.renderer_string && glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] == '\n') glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] = 0; Q_strncpyz( glConfig.version_string, (char *) qglGetString (GL_VERSION), sizeof( glConfig.version_string ) ); Q_strncpyz( glConfig.extensions_string, (char *) qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) ); // initialize extensions GLimp_InitExtensions( ); ri.Cvar_Get( "r_availableModes", "", CVAR_ROM ); // This depends on SDL_INIT_VIDEO, hence having it here IN_Init( ); }
void fatal(const char *s, ...) { static int errors = 0; errors++; // print up to one extra recursive error if(errors <= 2) { defvformatstring(msg,s,s); puts(msg); // avoid recursion if(errors <= 1) { if(SDL_WasInit(SDL_INIT_VIDEO)) { SDL_ShowCursor(1); SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_SetGamma(1, 1, 1); } #ifdef WIN32 MessageBox(NULL, msg, "Cube 2: Sauerbraten fatal error", MB_OK|MB_SYSTEMMODAL); #endif SDL_Quit(); } } exit(EXIT_FAILURE); }
/** * @sa R_RenderFrame * @sa R_BeginFrame */ void R_EndFrame (void) { R_EnableBlend(true); R_DrawChars(); /* draw all chars accumulated above */ /* restore draw color */ R_Color(NULL); R_EnableBlend(false); if (vid_gamma->modified) { if (!vid_ignoregamma->integer) { const float g = vid_gamma->value; SDL_SetGamma(g, g, g); } vid_gamma->modified = false; } R_ClearScene(); SDL_GL_SwapBuffers(); }
int RunGLTest(int argc, char *argv[], int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa, int sync, int accel) { int i; int rgb_size[3]; int w = 640; int h = 480; int done = 0; int frames; Uint32 start_time, this_time; float color[8][3] = { {1.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, 0.0, 1.0}, {0.0, 0.0, 1.0} }; float cube[8][3] = { {0.5, 0.5, -0.5}, {0.5, -0.5, -0.5}, {-0.5, -0.5, -0.5}, {-0.5, 0.5, -0.5}, {-0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}, {0.5, -0.5, 0.5}, {-0.5, -0.5, 0.5} }; Uint32 video_flags; int value; if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } /* See if we should detect the display depth */ if (bpp == 0) { if (SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8) { bpp = 8; } else { bpp = 16; /* More doesn't seem to work */ } } /* Set the flags we want to use for setting the video mode */ video_flags = SDL_OPENGL; for (i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-fullscreen") == 0) { video_flags |= SDL_FULLSCREEN; } } if (noframe) { video_flags |= SDL_NOFRAME; } /* Initialize the display */ switch (bpp) { case 8: rgb_size[0] = 3; rgb_size[1] = 3; rgb_size[2] = 2; break; case 15: case 16: rgb_size[0] = 5; rgb_size[1] = 5; rgb_size[2] = 5; break; default: rgb_size[0] = 8; rgb_size[1] = 8; rgb_size[2] = 8; break; } SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (fsaa) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); } if (accel >= 0) { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, accel); } if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) { fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); SDL_Quit(); exit(1); } if (sync) { SDL_GL_SetSwapInterval(1); } else { SDL_GL_SetSwapInterval(0); } printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel); printf("\n"); printf("Vendor : %s\n", glGetString(GL_VENDOR)); printf("Renderer : %s\n", glGetString(GL_RENDERER)); printf("Version : %s\n", glGetString(GL_VERSION)); printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); printf("\n"); SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); printf("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value); SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value); SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value); SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value); SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &value); printf("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); if (fsaa) { SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); } if (accel >= 0) { SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel, value); } if (sync) { printf("Buffer swap interval: requested 1, got %d\n", SDL_GL_GetSwapInterval()); } /* Set the window manager title bar */ SDL_WM_SetCaption("SDL GL test", "testgl"); /* Set the gamma for the window */ if (gamma != 0.0) { SDL_SetGamma(gamma, gamma, gamma); } glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glShadeModel(GL_SMOOTH); /* Loop until done. */ start_time = SDL_GetTicks(); frames = 0; while (!done) { GLenum gl_error; char *sdl_error; SDL_Event event; /* Do our drawing, too. */ glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBegin(GL_QUADS); #ifdef SHADED_CUBE glColor3fv(color[0]); glVertex3fv(cube[0]); glColor3fv(color[1]); glVertex3fv(cube[1]); glColor3fv(color[2]); glVertex3fv(cube[2]); glColor3fv(color[3]); glVertex3fv(cube[3]); glColor3fv(color[3]); glVertex3fv(cube[3]); glColor3fv(color[4]); glVertex3fv(cube[4]); glColor3fv(color[7]); glVertex3fv(cube[7]); glColor3fv(color[2]); glVertex3fv(cube[2]); glColor3fv(color[0]); glVertex3fv(cube[0]); glColor3fv(color[5]); glVertex3fv(cube[5]); glColor3fv(color[6]); glVertex3fv(cube[6]); glColor3fv(color[1]); glVertex3fv(cube[1]); glColor3fv(color[5]); glVertex3fv(cube[5]); glColor3fv(color[4]); glVertex3fv(cube[4]); glColor3fv(color[7]); glVertex3fv(cube[7]); glColor3fv(color[6]); glVertex3fv(cube[6]); glColor3fv(color[5]); glVertex3fv(cube[5]); glColor3fv(color[0]); glVertex3fv(cube[0]); glColor3fv(color[3]); glVertex3fv(cube[3]); glColor3fv(color[4]); glVertex3fv(cube[4]); glColor3fv(color[6]); glVertex3fv(cube[6]); glColor3fv(color[1]); glVertex3fv(cube[1]); glColor3fv(color[2]); glVertex3fv(cube[2]); glColor3fv(color[7]); glVertex3fv(cube[7]); #else /* flat cube */ glColor3f(1.0, 0.0, 0.0); glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); glColor3f(0.0, 1.0, 0.0); glVertex3fv(cube[3]); glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[2]); glColor3f(0.0, 0.0, 1.0); glVertex3fv(cube[0]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[1]); glColor3f(0.0, 1.0, 1.0); glVertex3fv(cube[5]); glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glColor3f(1.0, 1.0, 0.0); glVertex3fv(cube[5]); glVertex3fv(cube[0]); glVertex3fv(cube[3]); glVertex3fv(cube[4]); glColor3f(1.0, 0.0, 1.0); glVertex3fv(cube[6]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[7]); #endif /* SHADED_CUBE */ glEnd(); glMatrixMode(GL_MODELVIEW); glRotatef(5.0, 1.0, 1.0, 1.0); /* Draw 2D logo onto the 3D display */ if (logo) { DrawLogoTexture(); } if (logocursor) { DrawLogoCursor(); } SDL_GL_SwapBuffers(); /* Check for error conditions. */ gl_error = glGetError(); if (gl_error != GL_NO_ERROR) { fprintf(stderr, "testgl: OpenGL error: %d\n", gl_error); } sdl_error = (char *)SDL_GetError(); if (sdl_error[0] != '\0') { fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error); SDL_ClearError(); } /* Allow the user to see what's happening */ if (slowly) { SDL_Delay(20); } /* Check if there's a pending event. */ while (SDL_PollEvent(&event)) { done |= HandleEvent(&event); } ++frames; } /* Print out the frames per second */ this_time = SDL_GetTicks(); if (this_time != start_time) { printf("%2.2f FPS\n", ((float) frames / (this_time - start_time)) * 1000.0); } if (global_image) { SDL_FreeSurface(global_image); global_image = NULL; } if (global_texture) { glDeleteTextures(1, &global_texture); global_texture = 0; } if (cursor_texture) { glDeleteTextures(1, &cursor_texture); cursor_texture = 0; } /* Destroy our GL context, etc. */ SDL_Quit(); return (0); }
bool CVideoMode::InitSDL() { ENSURE(!m_IsInitialised); ReadConfig(); EnableS3TC(); // preferred video mode = current desktop settings // (command line params may override these) gfx::GetVideoMode(&m_PreferredW, &m_PreferredH, &m_PreferredBPP, &m_PreferredFreq); int w = m_ConfigW; int h = m_ConfigH; if (m_ConfigFullscreen) { // If fullscreen and no explicit size set, default to the desktop resolution if (w == 0 || h == 0) { w = m_PreferredW; h = m_PreferredH; } } // If no size determined, default to something sensible if (w == 0 || h == 0) { w = DEFAULT_WINDOW_W; h = DEFAULT_WINDOW_H; } if (!m_ConfigFullscreen) { // Limit the window to the screen size (if known) if (m_PreferredW) w = std::min(w, m_PreferredW); if (m_PreferredH) h = std::min(h, m_PreferredH); } int bpp = GetBestBPP(); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); #if !SDL_VERSION_ATLEAST(1, 3, 0) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, g_VSync ? 1 : 0); #endif if (!SetVideoMode(w, h, bpp, m_ConfigFullscreen)) { // Fall back to a smaller depth buffer // (The rendering may be ugly but this helps when running in VMware) SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); if (!SetVideoMode(w, h, bpp, m_ConfigFullscreen)) return false; } #if SDL_VERSION_ATLEAST(1, 3, 0) SDL_GL_SetSwapInterval(g_VSync ? 1 : 0); #endif // Work around a bug in the proprietary Linux ATI driver (at least versions 8.16.20 and 8.14.13). // The driver appears to register its own atexit hook on context creation. // If this atexit hook is called before SDL_Quit destroys the OpenGL context, // some kind of double-free problem causes a crash and lockup in the driver. // Calling SDL_Quit twice appears to be harmless, though, and avoids the problem // by destroying the context *before* the driver's atexit hook is called. // (Note that atexit hooks are guaranteed to be called in reverse order of their registration.) atexit(SDL_Quit); // End work around. ogl_Init(); // required after each mode change // (TODO: does that mean we need to call this when toggling fullscreen later?) if (SDL_SetGamma(g_Gamma, g_Gamma, g_Gamma) < 0) LOGWARNING(L"SDL_SetGamma failed"); m_IsInitialised = true; if (!m_ConfigFullscreen) { m_WindowedW = w; m_WindowedH = h; } return true; }
/* =============== GLimp_Init This routine is responsible for initializing the OS specific portions of Direct3D =============== */ void GLimp_Init( void ) { qboolean success = qtrue; //glConfig.driverType = GLDRV_DEFAULT; r_sdlDriver = ri.Cvar_Get( "r_sdlDriver", "", CVAR_ROM ); r_allowResize = ri.Cvar_Get( "r_allowResize", "0", CVAR_ARCHIVE ); r_centerWindow = ri.Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE ); if ( ri.Cvar_VariableIntegerValue( "com_abnormalExit" ) ) { ri.Cvar_Set( "r_mode", va( "%d", R_MODE_FALLBACK ) ); ri.Cvar_Set( "r_fullscreen", "0" ); ri.Cvar_Set( "r_centerWindow", "0" ); ri.Cvar_Set( "com_abnormalExit", "0" ); } #if 0 //def WIN32 || __WIN64__ if ( !SDL_VIDEODRIVER_externallySet ) { // It's a little bit weird having in_mouse control the // video driver, but from ioq3's point of view they're // virtually the same except for the mouse input anyway if ( ri.Cvar_VariableIntegerValue( "in_mouse" ) == -1 ) { // Use the windib SDL backend, which is closest to // the behaviour of idq3 with in_mouse set to -1 _putenv( "SDL_VIDEODRIVER=windib" ); } else { // Use the DirectX SDL backend _putenv( "SDL_VIDEODRIVER=directx" ); } } #endif // create the window and set up the context if ( !GLimp_StartDriverAndSetMode( r_mode->integer, r_fullscreen->integer, qfalse ) ) { if ( r_mode->integer != R_MODE_FALLBACK ) { ri.Printf( PRINT_ALL, "Setting r_mode %d failed, falling back on r_mode %d\n", r_mode->integer, R_MODE_FALLBACK ); if ( !GLimp_StartDriverAndSetMode( R_MODE_FALLBACK, r_fullscreen->integer, qfalse ) ) { success = qfalse; } } else { success = qfalse; } } if ( !success ) { ri.Error( ERR_FATAL, "GLimp_Init() - could not load Direct3D subsystem\n" ); } // This values force the UI to disable driver selection glConfig.hardwareType = GLHW_GENERIC; glConfig.deviceSupportsGamma = !!( SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0 ); // get our config strings Q_strncpyz( glConfig.vendor_string, "Microsoft", sizeof( glConfig.vendor_string ) ); Q_strncpyz( glConfig.renderer_string, "D3D", sizeof( glConfig.renderer_string ) ); if ( *glConfig.renderer_string && glConfig.renderer_string[ strlen( glConfig.renderer_string ) - 1 ] == '\n' ) { glConfig.renderer_string[ strlen( glConfig.renderer_string ) - 1 ] = 0; } Q_strncpyz( glConfig.version_string, "10.0", sizeof( glConfig.version_string ) ); Q_strncpyz( glConfig.extensions_string, "None", sizeof( glConfig.extensions_string ) ); // initialize extensions GLimp_InitExtensions(); ri.Cvar_Get( "r_availableModes", "", CVAR_ROM ); // This depends on SDL_INIT_VIDEO, hence having it here ri.IN_Init(); }
/* =============== GLimp_Init This routine is responsible for initializing the OS specific portions of OpenGL =============== */ void GLimp_Init( void ) { r_allowSoftwareGL = ri.Cvar_Get( "r_allowSoftwareGL", "0", CVAR_LATCH ); r_sdlDriver = ri.Cvar_Get( "r_sdlDriver", "", CVAR_ROM ); r_allowResize = ri.Cvar_Get( "r_allowResize", "0", CVAR_ARCHIVE ); r_centerWindow = ri.Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE ); if( ri.Cvar_VariableIntegerValue( "com_abnormalExit" ) ) { ri.Cvar_Set( "r_mode", va( "%d", R_MODE_FALLBACK ) ); ri.Cvar_Set( "r_fullscreen", "0" ); ri.Cvar_Set( "r_centerWindow", "0" ); ri.Cvar_Set( "com_abnormalExit", "0" ); } ri.Sys_SetEnv( "SDL_VIDEO_CENTERED", r_centerWindow->integer ? "1" : "" ); ri.Sys_GLimpInit( ); // Create the window and set up the context if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, r_noborder->integer)) goto success; // Try again, this time in a platform specific "safe mode" ri.Sys_GLimpSafeInit( ); if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, qfalse)) goto success; // Finally, try the default screen resolution if( r_mode->integer != R_MODE_FALLBACK ) { ri.Printf( PRINT_ALL, "Setting r_mode %d failed, falling back on r_mode %d\n", r_mode->integer, R_MODE_FALLBACK ); if(GLimp_StartDriverAndSetMode(R_MODE_FALLBACK, qfalse, qfalse)) goto success; } // Nothing worked, give up ri.Error( ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem" ); success: // This values force the UI to disable driver selection glConfig.driverType = GLDRV_ICD; glConfig.hardwareType = GLHW_GENERIC; glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0; // Mysteriously, if you use an NVidia graphics card and multiple monitors, // SDL_SetGamma will incorrectly return false... the first time; ask // again and you get the correct answer. This is a suspected driver bug, see // http://bugzilla.icculus.org/show_bug.cgi?id=4316 glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0; if ( -1 == r_ignorehwgamma->integer) glConfig.deviceSupportsGamma = 1; if ( 1 == r_ignorehwgamma->integer) glConfig.deviceSupportsGamma = 0; // get our config strings Q_strncpyz( glConfig.vendor_string, (char *) qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) ); Q_strncpyz( glConfig.renderer_string, (char *) qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) ); if (*glConfig.renderer_string && glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] == '\n') glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] = 0; Q_strncpyz( glConfig.version_string, (char *) qglGetString (GL_VERSION), sizeof( glConfig.version_string ) ); Q_strncpyz( glConfig.extensions_string, (char *) qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) ); // initialize extensions GLimp_InitExtensions( ); ri.Cvar_Get( "r_availableModes", "", CVAR_ROM ); // This depends on SDL_INIT_VIDEO, hence having it here ri.IN_Init( ); }
// -------------------------------------------------------------------------------------------------------- void KikiController::setGamma ( int g ) { float gf = 1.0+g/10.0; gamma = g; SDL_SetGamma (gf, gf, gf); }
int main(int argc, char *argv[]) { SDL_Surface *screen; SDL_Surface *image; float gamma; int i; int w, h, bpp; Uint32 flags; Uint16 ramp[256]; Uint16 red_ramp[256]; Uint32 then, timeout; argv += get_video_args(argv, &w, &h, &bpp, &flags); if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return(1); } screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_HWPALETTE); if ( screen == NULL ) { fprintf(stderr, "Couldn't set %dx%d video mode: %s\n", w, h, SDL_GetError()); quit(1); } SDL_WM_SetCaption("SDL gamma test", "testgamma"); gamma = 1.0f; if ( *argv ) { gamma = (float)atof(*argv); } if ( SDL_SetGamma(gamma, gamma, gamma) < 0 ) { fprintf(stderr, "Unable to set gamma: %s\n", SDL_GetError()); quit(1); } #if 0 float real[3]; if ( SDL_GetGamma(&real[0], &real[1], &real[2]) < 0 ) { printf("Couldn't get gamma: %s\n", SDL_GetError()); } else { printf("Set gamma values: R=%2.2f, G=%2.2f, B=%2.2f\n", real[0], real[1], real[2]); } #endif image = SDL_LoadBMP("sample.bmp"); if ( image ) { SDL_Rect dst; dst.x = (screen->w - image->w)/2; dst.y = (screen->h - image->h)/2; dst.w = image->w; dst.h = image->h; SDL_BlitSurface(image, NULL, screen, &dst); SDL_UpdateRects(screen, 1, &dst); } then = SDL_GetTicks(); timeout = (5*1000); while ( (SDL_GetTicks()-then) < timeout ) { SDL_Event event; while ( SDL_PollEvent(&event) ) { switch (event.type) { case SDL_QUIT: timeout = 0; break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_SPACE: timeout += (5*1000); break; case SDLK_UP: gamma += 0.2f; SDL_SetGamma(gamma, gamma, gamma); break; case SDLK_DOWN: gamma -= 0.2f; SDL_SetGamma(gamma, gamma, gamma); break; case SDLK_ESCAPE: timeout = 0; break; default: break; } break; } } } while ( gamma < 10.0 ) { gamma += 0.1f; CalculateGamma(gamma, red_ramp); CalculateGamma(1.0/gamma, ramp); SDL_SetGammaRamp(red_ramp, ramp, ramp); } memset(red_ramp, 255, sizeof(red_ramp)); memset(ramp, 0, sizeof(ramp)); SDL_SetGammaRamp(red_ramp, ramp, ramp); for ( i=(red_ramp[0] >> 8); i >= 0; --i ) { memset(red_ramp, i, sizeof(red_ramp)); SDL_SetGammaRamp(red_ramp, NULL, NULL); } SDL_Delay(1*1000); SDL_Quit(); return(0); }
/* =============== GLimp_Init This routine is responsible for initializing the OS specific portions of OpenGL =============== */ void GLimp_Init(void) { qboolean success = qtrue; glConfig.driverType = GLDRV_DEFAULT; r_sdlDriver = ri.Cvar_Get("r_sdlDriver", "", CVAR_ROM); r_allowResize = ri.Cvar_Get("r_allowResize", "0", CVAR_ARCHIVE); r_centerWindow = ri.Cvar_Get("r_centerWindow", "0", CVAR_ARCHIVE); if(ri.Cvar_VariableIntegerValue("com_abnormalExit")) { ri.Cvar_Set("r_mode", va("%d", R_MODE_FALLBACK)); ri.Cvar_Set("r_fullscreen", "0"); ri.Cvar_Set("r_centerWindow", "0"); ri.Cvar_Set("com_abnormalExit", "0"); } //Sys_SetEnv("SDL_VIDEO_CENTERED", r_centerWindow->integer ? "1" : ""); //Sys_GLimpInit(); #if 0 //defined(WIN32) if(!SDL_VIDEODRIVER_externallySet) { // It's a little bit weird having in_mouse control the // video driver, but from ioq3's point of view they're // virtually the same except for the mouse input anyway if(ri.Cvar_VariableIntegerValue("in_mouse") == -1) { // Use the windib SDL backend, which is closest to // the behaviour of idq3 with in_mouse set to -1 _putenv("SDL_VIDEODRIVER=windib"); } else { // Use the DirectX SDL backend _putenv("SDL_VIDEODRIVER=directx"); } } #endif // Create the window and set up the context if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, qfalse)) goto success; // Try again, this time in a platform specific "safe mode" //Sys_GLimpSafeInit(); #if 0 //defined(WIN32) if(!SDL_VIDEODRIVER_externallySet) { // Here, we want to let SDL decide what do to unless // explicitly requested otherwise _putenv("SDL_VIDEODRIVER="); } #endif if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, qfalse)) goto success; // Finally, try the default screen resolution if(r_mode->integer != R_MODE_FALLBACK) { ri.Printf(PRINT_ALL, "Setting r_mode %d failed, falling back on r_mode %d\n", r_mode->integer, R_MODE_FALLBACK); if(GLimp_StartDriverAndSetMode(R_MODE_FALLBACK, qfalse, qfalse)) goto success; } // Nothing worked, give up ri.Error(ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem\n"); success: // This values force the UI to disable driver selection glConfig.hardwareType = GLHW_GENERIC; glConfig.deviceSupportsGamma = SDL_SetGamma(1.0f, 1.0f, 1.0f) >= 0; // Mysteriously, if you use an NVidia graphics card and multiple monitors, // SDL_SetGamma will incorrectly return false... the first time; ask // again and you get the correct answer. This is a suspected driver bug, see // http://bugzilla.icculus.org/show_bug.cgi?id=4316 glConfig.deviceSupportsGamma = SDL_SetGamma(1.0f, 1.0f, 1.0f) >= 0; // get our config strings Q_strncpyz(glConfig.vendor_string, (char *)glGetString(GL_VENDOR), sizeof(glConfig.vendor_string)); Q_strncpyz(glConfig.renderer_string, (char *)glGetString(GL_RENDERER), sizeof(glConfig.renderer_string)); if(*glConfig.renderer_string && glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] == '\n') glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] = 0; Q_strncpyz(glConfig.version_string, (char *)glGetString(GL_VERSION), sizeof(glConfig.version_string)); if(glConfig.driverType != GLDRV_OPENGL3) { Q_strncpyz(glConfig.extensions_string, (char *)glGetString(GL_EXTENSIONS), sizeof(glConfig.extensions_string)); } if( Q_stristr(glConfig.renderer_string, "mesa") || Q_stristr(glConfig.renderer_string, "gallium") || Q_stristr(glConfig.vendor_string, "nouveau") || Q_stristr(glConfig.vendor_string, "mesa")) { // suckage glConfig.driverType = GLDRV_MESA; } if(Q_stristr(glConfig.renderer_string, "geforce")) { if(Q_stristr(glConfig.renderer_string, "8400") || Q_stristr(glConfig.renderer_string, "8500") || Q_stristr(glConfig.renderer_string, "8600") || Q_stristr(glConfig.renderer_string, "8800") || Q_stristr(glConfig.renderer_string, "9500") || Q_stristr(glConfig.renderer_string, "9600") || Q_stristr(glConfig.renderer_string, "9800") || Q_stristr(glConfig.renderer_string, "gts 240") || Q_stristr(glConfig.renderer_string, "gts 250") || Q_stristr(glConfig.renderer_string, "gtx 260") || Q_stristr(glConfig.renderer_string, "gtx 275") || Q_stristr(glConfig.renderer_string, "gtx 280") || Q_stristr(glConfig.renderer_string, "gtx 285") || Q_stristr(glConfig.renderer_string, "gtx 295") || Q_stristr(glConfig.renderer_string, "gt 320") || Q_stristr(glConfig.renderer_string, "gt 330") || Q_stristr(glConfig.renderer_string, "gt 340") || Q_stristr(glConfig.renderer_string, "gt 415") || Q_stristr(glConfig.renderer_string, "gt 420") || Q_stristr(glConfig.renderer_string, "gt 425") || Q_stristr(glConfig.renderer_string, "gt 430") || Q_stristr(glConfig.renderer_string, "gt 435") || Q_stristr(glConfig.renderer_string, "gt 440") || Q_stristr(glConfig.renderer_string, "gt 520") || Q_stristr(glConfig.renderer_string, "gt 525") || Q_stristr(glConfig.renderer_string, "gt 540") || Q_stristr(glConfig.renderer_string, "gt 550") || Q_stristr(glConfig.renderer_string, "gt 555") || Q_stristr(glConfig.renderer_string, "gts 450") || Q_stristr(glConfig.renderer_string, "gtx 460") || Q_stristr(glConfig.renderer_string, "gtx 470") || Q_stristr(glConfig.renderer_string, "gtx 480") || Q_stristr(glConfig.renderer_string, "gtx 485") || Q_stristr(glConfig.renderer_string, "gtx 560") || Q_stristr(glConfig.renderer_string, "gtx 570") || Q_stristr(glConfig.renderer_string, "gtx 580") || Q_stristr(glConfig.renderer_string, "gtx 590")) glConfig.hardwareType = GLHW_NV_DX10; } else if(Q_stristr(glConfig.renderer_string, "quadro fx")) { if(Q_stristr(glConfig.renderer_string, "3600")) glConfig.hardwareType = GLHW_NV_DX10; } else if(Q_stristr(glConfig.renderer_string, "rv770")) { glConfig.hardwareType = GLHW_ATI_DX10; } else if(Q_stristr(glConfig.renderer_string, "radeon hd")) { glConfig.hardwareType = GLHW_ATI_DX10; } else if(Q_stristr(glConfig.renderer_string, "eah4850") || Q_stristr(glConfig.renderer_string, "eah4870")) { glConfig.hardwareType = GLHW_ATI_DX10; } else if(Q_stristr(glConfig.renderer_string, "radeon")) { glConfig.hardwareType = GLHW_ATI; } // initialize extensions GLimp_InitExtensions(); ri.Cvar_Get("r_availableModes", "", CVAR_ROM); // This depends on SDL_INIT_VIDEO, hence having it here ri.IN_Init(); }
/* =============== GLimp_Init This routine is responsible for initializing the OS specific portions of OpenGL =============== */ void GLimp_Init( void ) { r_allowSoftwareGL = ri.Cvar_Get( "r_allowSoftwareGL", "0", CVAR_LATCH ); r_sdlDriver = ri.Cvar_Get( "r_sdlDriver", "", CVAR_ROM ); r_allowResize = ri.Cvar_Get( "r_allowResize", "0", CVAR_ARCHIVE ); r_centerWindow = ri.Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE ); if( ri.Cvar_VariableIntegerValue( "com_abnormalExit" ) ) { ri.Cvar_Set( "r_width", va( "%d", R_FAILSAFE_WIDTH ) ); ri.Cvar_Set( "r_height", va( "%d", R_FAILSAFE_HEIGHT ) ); ri.Cvar_Set( "r_fullscreen", "0" ); ri.Cvar_Set( "r_centerWindow", "0" ); ri.Cvar_Set( "com_abnormalExit", "0" ); } ri.Sys_SetEnv( "SDL_VIDEO_CENTERED", r_centerWindow->integer ? "1" : "" ); ri.Sys_GLimpInit( ); // Create the window and set up the context if( GLimp_StartDriverAndSetMode( qfalse, r_fullscreen->integer, r_noborder->integer ) ) goto success; // Try again, this time in a platform specific "safe mode" ri.Sys_GLimpSafeInit( ); if( GLimp_StartDriverAndSetMode( qfalse, r_fullscreen->integer, qfalse ) ) goto success; // Finally, try the default screen resolution if( GLimp_StartDriverAndSetMode( qtrue, r_fullscreen->integer, qfalse ) ) goto success; // Nothing worked, give up ri.Error( ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem" ); success: // This values force the UI to disable driver selection glConfig.driverType = GLDRV_ICD; glConfig.hardwareType = GLHW_GENERIC; // Remove call to SDL_SetGamma for Mac OS X // It causes a crash, but is apparently fixed in SDL2 // somewhere upstream in ioq3. For more details, see // http://www.ioquake.org/forums/viewtopic.php?f=12&t=1928 #ifndef MACOS_X glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0; #endif // Mysteriously, if you use an NVidia graphics card and multiple monitors, // SDL_SetGamma will incorrectly return false... the first time; ask // again and you get the correct answer. This is a suspected driver bug, see // http://bugzilla.icculus.org/show_bug.cgi?id=4316 #ifndef MACOS_X glConfig.deviceSupportsGamma = SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0; #endif if ( -1 == r_ignorehwgamma->integer) glConfig.deviceSupportsGamma = 1; if ( 1 == r_ignorehwgamma->integer) glConfig.deviceSupportsGamma = 0; // get our config strings Q_strncpyz( glConfig.vendor_string, (char *) qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) ); Q_strncpyz( glConfig.renderer_string, (char *) qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) ); if (*glConfig.renderer_string && glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] == '\n') glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] = 0; Q_strncpyz( glConfig.version_string, (char *) qglGetString (GL_VERSION), sizeof( glConfig.version_string ) ); Q_strncpyz( glConfig.extensions_string, (char *) qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) ); // initialize extensions GLimp_InitExtensions( ); ri.Cvar_Get( "r_availableModes", "", CVAR_ROM ); // This depends on SDL_INIT_VIDEO, hence having it here ri.IN_Init( ); }
int main(int argc, char *argv[]) { /* Check command line arguments */ argv += get_video_args(argv, &w, &h, &bpp, &flags); /* Initialize SDL */ if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return(1); } /* Initialize the display, always use hardware palette */ screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_HWPALETTE); if ( screen == NULL ) { fprintf(stderr, "Couldn't set %dx%d video mode: %s\n", w, h, SDL_GetError()); quit(1); } /* Set the window manager title bar */ SDL_WM_SetCaption("SDL gamma test", "testgamma"); /* Set the desired gamma, if any */ gamma = 1.0f; if ( *argv ) { gamma = (float)atof(*argv); } if ( SDL_SetGamma(gamma, gamma, gamma) < 0 ) { fprintf(stderr, "Unable to set gamma: %s\n", SDL_GetError()); quit(1); } #if 0 /* This isn't supported. Integrating the gamma ramps isn't exact */ /* See what gamma was actually set */ float real[3]; if ( SDL_GetGamma(&real[0], &real[1], &real[2]) < 0 ) { printf("Couldn't get gamma: %s\n", SDL_GetError()); } else { printf("Set gamma values: R=%2.2f, G=%2.2f, B=%2.2f\n", real[0], real[1], real[2]); } #endif /* Do all the drawing work */ image = SDL_LoadBMP("sample.bmp"); if ( image ) { SDL_Rect dst; dst.x = (screen->w - image->w)/2; dst.y = (screen->h - image->h)/2; dst.w = image->w; dst.h = image->h; SDL_BlitSurface(image, NULL, screen, &dst); SDL_UpdateRects(screen, 1, &dst); } /* Wait a bit, handling events */ then = SDL_GetTicks(); timeout = (5*1000); #ifndef EMSCRIPTEN while ( (SDL_GetTicks()-then) < timeout ) { #else emscripten_set_main_loop(&main_loop, 0, 1); } void main_loop() { if ( (SDL_GetTicks()-then) < timeout ) { #endif SDL_Event event; while ( SDL_PollEvent(&event) ) { switch (event.type) { case SDL_QUIT: /* Quit now */ timeout = 0; break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_SPACE: /* Go longer.. */ timeout += (5*1000); break; case SDLK_UP: gamma += 0.2f; SDL_SetGamma(gamma, gamma, gamma); break; case SDLK_DOWN: gamma -= 0.2f; SDL_SetGamma(gamma, gamma, gamma); break; case SDLK_ESCAPE: timeout = 0; break; default: break; } break; } } } #ifdef EMSCRIPTEN else { #endif /* Perform a gamma flash to red using color ramps */ while ( gamma < 10.0 ) { /* Increase the red gamma and decrease everything else... */ gamma += 0.1f; CalculateGamma(gamma, red_ramp); CalculateGamma(1.0/gamma, ramp); SDL_SetGammaRamp(red_ramp, ramp, ramp); } /* Finish completely red */ memset(red_ramp, 255, sizeof(red_ramp)); memset(ramp, 0, sizeof(ramp)); SDL_SetGammaRamp(red_ramp, ramp, ramp); /* Now fade out to black */ for ( i=(red_ramp[0] >> 8); i >= 0; --i ) { memset(red_ramp, i, sizeof(red_ramp)); SDL_SetGammaRamp(red_ramp, NULL, NULL); } #ifndef EMSCRIPTEN SDL_Delay(1*1000); #else emscripten_pause_main_loop(); emscripten_async_call(&end_main, 0, 1*1000); } } void end_main() { #endif SDL_Quit(); #ifndef EMSCRIPTEN return(0); #else exit(0); #endif }
void GLimp_Init( void ) { ri.Cvar_Get( "r_restartOnResize", "1", CVAR_ARCHIVE ); ri.Cvar_Get( "r_resizeDelay", "1000", CVAR_ARCHIVE ); r_allowSoftwareGL = ri.Cvar_Get( "r_allowSoftwareGL", "0", CVAR_LATCH ); r_sdlDriver = ri.Cvar_Get( "r_sdlDriver", "", CVAR_ROM ); r_allowResize = ri.Cvar_Get( "r_allowResize", "0", CVAR_ARCHIVE ); r_centerWindow = ri.Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE ); r_noborder = ri.Cvar_Get( "r_noborder", "0", CVAR_ARCHIVE ); /* if( Cvar_VariableIntegerValue( "com_abnormalExit" ) ) { Cvar_Set( "r_mode", va( "%d", R_MODE_FALLBACK ) ); Cvar_Set( "r_picmap", "1" ); Cvar_Set( "r_texturebits", "0" ); Cvar_Set( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST" ); Cvar_Set( "r_fullscreen", "0" ); Cvar_Set( "r_centerWindow", "0" ); Cvar_Set( "com_abnormalExit", "0" ); }*/ Sys_SetEnv( "SDL_VIDEO_CENTERED", r_centerWindow->integer ? "1" : "" ); // Create the window and set up the context if(GLimp_StartDriverAndSetMode(r_mode->integer, (qboolean)r_fullscreen->integer, (qboolean)r_noborder->integer)) goto success; // Try again, this time in a platform specific "safe mode" /* Sys_GLimpSafeInit( ); if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, qfalse)) goto success; */ /* // Finally, try the default screen resolution if( r_mode->integer != R_MODE_FALLBACK ) { Com_Printf( "Setting r_mode %d failed, falling back on r_mode %d\n", r_mode->integer, R_MODE_FALLBACK ); if(GLimp_StartDriverAndSetMode(R_MODE_FALLBACK, qfalse, qfalse)) goto success; }*/ // Nothing worked, give up Com_Error( ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem" ); success: // This values force the UI to disable driver selection // glConfig.driverType = GLDRV_ICD; // glConfig.hardwareType = GLHW_GENERIC; glConfig.deviceSupportsGamma = (qboolean)(SDL_SetGamma( screen, 1.0f, 1.0f, 1.0f ) >= 0); // Mysteriously, if you use an NVidia graphics card and multiple monitors, // SDL_SetGamma will incorrectly return false... the first time; ask // again and you get the correct answer. This is a suspected driver bug, see // http://bugzilla.icculus.org/show_bug.cgi?id=4316 glConfig.deviceSupportsGamma = (qboolean)(SDL_SetGamma( screen, 1.0f, 1.0f, 1.0f ) >= 0); if ( -1 == r_ignorehwgamma->integer) glConfig.deviceSupportsGamma = qtrue; if ( 1 == r_ignorehwgamma->integer) glConfig.deviceSupportsGamma = qfalse; // get our config strings /* Q_strncpyz( glConfig.vendor_string, (char *) qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) ); Q_strncpyz( glConfig.renderer_string, (char *) qglGetString (GL_RENDERER), sizeof( glConfig.renderer_string ) ); if (*glConfig.renderer_string && glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] == '\n') glConfig.renderer_string[strlen(glConfig.renderer_string) - 1] = 0; Q_strncpyz( glConfig.version_string, (char *) qglGetString (GL_VERSION), sizeof( glConfig.version_string ) ); Q_strncpyz( glConfig.extensions_string, (char *) qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) );*/ glConfig.vendor_string = (const char *) qglGetString (GL_VENDOR); glConfig.renderer_string = (const char *) qglGetString (GL_RENDERER); glConfig.version_string = (const char *) qglGetString (GL_VERSION); glConfig.extensions_string = (const char *) qglGetString (GL_EXTENSIONS); // OpenGL driver constants qglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.maxTextureSize ); // stubbed or broken drivers may have reported 0... if ( glConfig.maxTextureSize <= 0 ) { glConfig.maxTextureSize = 0; } // initialize extensions GLimp_InitExtensions( ); ri.Cvar_Get( "r_availableModes", "", CVAR_ROM ); // This depends on SDL_INIT_VIDEO, hence having it here ri.IN_Init( screen ); }
void OglSdlSetGamma(float r, float g, float b) { SDL_SetGamma(r, g, b); }