#include "quakedef.h"
#include "cdaudio.h"
+#include "image.h"
#ifdef SUPPORTD3D
#include <d3d9.h>
cvar_t vid_gl20 = {0, "vid_gl20", "1", "enables faster rendering using OpenGL 2.0 features (such as GL_ARB_fragment_shader extension)"};
cvar_t gl_finish = {0, "gl_finish", "0", "make the cpu wait for the graphics processor at the end of each rendered frame (can help with strange input or video lag problems on some machines)"};
cvar_t vid_sRGB = {CVAR_SAVE, "vid_sRGB", "0", "if hardware is capable, modify rendering to be gamma corrected for the sRGB color standard (computer monitors, TVs), recommended"};
+cvar_t vid_sRGB_fallback = {CVAR_SAVE, "vid_sRGB_fallback", "0", "do an approximate sRGB fallback if not properly supported by hardware (2: also use the fallback if framebuffer is 8bit, 3: always use the fallback even if sRGB is supported)"};
cvar_t vid_touchscreen = {0, "vid_touchscreen", "0", "Use touchscreen-style input (no mouse grab, track mouse motion only while button is down, screen areas for mimicing joystick axes and buttons"};
cvar_t vid_stick_mouse = {CVAR_SAVE, "vid_stick_mouse", "0", "have the mouse stuck in the center of the screen" };
cvar_t v_glslgamma_2d = {CVAR_SAVE, "v_glslgamma_2d", "0", "applies GLSL gamma to 2d pictures (HUD, fonts)"};
cvar_t v_psycho = {0, "v_psycho", "0", "easter egg"};
+extern cvar_t r_viewfbo;
+
// brand of graphics chip
const char *gl_vendor;
// graphics chip model and other information
vid.sRGBcapable3D = true;
vid.useinterleavedarrays = false;
Con_Printf("vid.support.arb_multisample %i\n", vid.support.arb_multisample);
- Con_Printf("vid.mode.samples %i\n", vid.mode.samples);
Con_Printf("vid.support.gl20shaders %i\n", vid.support.gl20shaders);
vid.allowalphatocoverage = true; // but see below, it may get turned to false again if GL_SAMPLES_ARB is <= 1
}
{
int samples = 0;
qglGetIntegerv(GL_SAMPLES_ARB, &samples);
+ vid.samples = samples;
if (samples > 1)
- {
qglEnable(GL_MULTISAMPLE_ARB);
-
- // currently, multisampling is not supported by our FBO paths
- // so for now, disable FBOs if multisample is requested
- // FIXME instead, support FBOs + multisampling, and turn off
- // multisampling on chipsets that don't support this combination
- vid.support.ext_framebuffer_object = false;
- }
else
vid.allowalphatocoverage = false;
}
else
+ {
vid.allowalphatocoverage = false;
+ vid.samples = 1;
+ }
// VorteX: set other info (maybe place them in VID_InitMode?)
Cvar_SetQuick(&gl_info_vendor, gl_vendor);
qboolean vid_gammatables_trivial = true;
void VID_BuildGammaTables(unsigned short *ramps, int rampsize)
{
- float srgbmul = (vid.sRGB2D || vid.sRGB3D) ? 2.2f : 1.0f;
if (cachecolorenable)
{
- BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[0]) * srgbmul, cachewhite[0], cacheblack[0], cachecontrastboost, ramps, rampsize);
- BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[1]) * srgbmul, cachewhite[1], cacheblack[1], cachecontrastboost, ramps + rampsize, rampsize);
- BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[2]) * srgbmul, cachewhite[2], cacheblack[2], cachecontrastboost, ramps + rampsize*2, rampsize);
+ BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[0]), cachewhite[0], cacheblack[0], cachecontrastboost, ramps, rampsize);
+ BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[1]), cachewhite[1], cacheblack[1], cachecontrastboost, ramps + rampsize, rampsize);
+ BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[2]), cachewhite[2], cacheblack[2], cachecontrastboost, ramps + rampsize*2, rampsize);
}
else
{
- BuildGammaTable16(1.0f, cachegamma * srgbmul, cachecontrast, cachebrightness, cachecontrastboost, ramps, rampsize);
- BuildGammaTable16(1.0f, cachegamma * srgbmul, cachecontrast, cachebrightness, cachecontrastboost, ramps + rampsize, rampsize);
- BuildGammaTable16(1.0f, cachegamma * srgbmul, cachecontrast, cachebrightness, cachecontrastboost, ramps + rampsize*2, rampsize);
+ BuildGammaTable16(1.0f, cachegamma, cachecontrast, cachebrightness, cachecontrastboost, ramps, rampsize);
+ BuildGammaTable16(1.0f, cachegamma, cachecontrast, cachebrightness, cachecontrastboost, ramps + rampsize, rampsize);
+ BuildGammaTable16(1.0f, cachegamma, cachecontrast, cachebrightness, cachecontrastboost, ramps + rampsize*2, rampsize);
+ }
+
+ if(vid.sRGB2D || vid.sRGB3D)
+ {
+ int i;
+ for(i = 0; i < 3*rampsize; ++i)
+ ramps[i] = (int)floor(bound(0.0f, Image_sRGBFloatFromLinearFloat(ramps[i] / 65535.0), 1.0f) * 65535.0 + 0.5);
}
// LordHavoc: this code came from Ben Winslow and Zinx Verituse, I have
Cvar_RegisterVariable(&vid_gl20);
Cvar_RegisterVariable(&gl_finish);
Cvar_RegisterVariable(&vid_sRGB);
+ Cvar_RegisterVariable(&vid_sRGB_fallback);
Cvar_RegisterVariable(&joy_active);
#ifdef WIN32
mode.samples = samples;
cl_ignoremousemoves = 2;
VID_ClearExtensions();
+
+ vid.samples = vid.mode.samples;
if (VID_InitMode(&mode))
{
// accept the (possibly modified) mode
vid.refreshrate = vid.mode.refreshrate;
vid.userefreshrate = vid.mode.userefreshrate;
vid.stereobuffer = vid.mode.stereobuffer;
- vid.samples = vid.mode.samples;
vid.stencil = vid.mode.bitsperpixel > 16;
vid.sRGB2D = vid_sRGB.integer >= 1 && vid.sRGBcapable2D;
vid.sRGB3D = vid_sRGB.integer >= 1 && vid.sRGBcapable3D;
+ if(
+ (vid_sRGB_fallback.integer >= 3) // force fallback
+ ||
+ (vid_sRGB_fallback.integer >= 2 && // fallback if framebuffer is 8bit
+ !(r_viewfbo.integer >= 2 && vid.support.ext_framebuffer_object && vid.samples < 2))
+ )
+ vid.sRGB2D = vid.sRGB3D = false;
+
+ if(vid.samples != vid.mode.samples)
+ Con_Printf("NOTE: requested %dx AA, got %dx AA\n", vid.mode.samples, vid.samples);
+
Con_Printf("Video Mode: %s %dx%dx%dx%.2fhz%s%s\n", mode.fullscreen ? "fullscreen" : "window", mode.width, mode.height, mode.bitsperpixel, mode.refreshrate, mode.stereobuffer ? " stereo" : "", mode.samples > 1 ? va(" (%ix AA)", mode.samples) : "");
Cvar_SetValueQuick(&vid_fullscreen, vid.mode.fullscreen);