diff --git a/engine/client/renderer.c b/engine/client/renderer.c index bb8ba4230..a74bd2ddb 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -94,6 +94,7 @@ static cvar_t vid_fullscreen = SCVARF("vid_fullscreen", "1", CVAR_ARCHIVE|CVAR_R static cvar_t vid_width = SCVARF("vid_width", "640", CVAR_ARCHIVE|CVAR_RENDERERLATCH); //more readable defaults to match conwidth/conheight. static cvar_t vid_height = SCVARF("vid_height", "480", CVAR_ARCHIVE|CVAR_RENDERERLATCH); static cvar_t vid_refreshrate = SCVARF("vid_displayfrequency", "0", CVAR_ARCHIVE|CVAR_RENDERERLATCH); +static cvar_t vid_multisample = SCVARF("vid_multisample", "0", CVAR_ARCHIVE|CVAR_RENDERERLATCH); cvar_t gl_texturemode = SCVAR("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST"); cvar_t gl_motionblur = SCVARF("gl_motionblur", "0", CVAR_ARCHIVE); @@ -302,6 +303,7 @@ void GLRenderer_Init(void) Cvar_Register (&gl_mindist, GLRENDEREROPTIONS); Cvar_Register (&vid_conwidth, GLRENDEREROPTIONS); Cvar_Register (&vid_conheight, GLRENDEREROPTIONS); + Cvar_Register (&vid_multisample, GLRENDEREROPTIONS); Cvar_Register (&gl_fontedgeclamp, GRAPHICALNICETIES); Cvar_Register (&gl_font, GRAPHICALNICETIES); @@ -1875,6 +1877,7 @@ TRACE(("dbg: R_RestartRenderer_f\n")); newr.allow_modex = vid_allow_modex.value; + newr.multisample = vid_multisample.value; newr.bpp = vid_bpp.value; newr.fullscreen = vid_fullscreen.value; newr.rate = vid_refreshrate.value; diff --git a/engine/client/vid.h b/engine/client/vid.h index 07a8c317e..f28130c29 100644 --- a/engine/client/vid.h +++ b/engine/client/vid.h @@ -34,6 +34,7 @@ typedef struct { qboolean fullscreen; int bpp; int rate; + int multisample; //for opengl antialiasing (which requires context stuff) float streach; char glrenderer[MAX_QPATH]; r_qrenderer_t renderer; diff --git a/engine/gl/gl_vidnt.c b/engine/gl/gl_vidnt.c index 7e0af5df2..bad409dec 100644 --- a/engine/gl/gl_vidnt.c +++ b/engine/gl/gl_vidnt.c @@ -1081,13 +1081,15 @@ BOOL CheckForcePixelFormat(rendererstate_t *info) TRACE(("dbg: bSetupPixelFormat: attempting wglChoosePixelFormatARB (multisample 4)\n")); hDC = GetDC(mainwindow); + valid = qwglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelformat,&numFormats); - if (!valid || numFormats < 1) + while ((!valid || numFormats < 1) && iAttributes[19] > 1) { //failed, switch wgl_samples to 2 - iAttributes[19] = 2; - TRACE(("dbg: bSetupPixelFormat: attempting wglChoosePixelFormatARB (multisample 2)\n")); + iAttributes[19] /= 2; + TRACE(("dbg: bSetupPixelFormat: attempting wglChoosePixelFormatARB (smaller multisample)\n")); valid = qwglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelformat,&numFormats); } + ReleaseDC(mainwindow, hDC); if (valid && numFormats > 0) {