From 58fb771fc98f2d04990c947944cd199007ea1666 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 22 Sep 2002 00:19:43 +0000 Subject: [PATCH] VID_Init now takes an int bpp parameter finished some work on the wgl VID_Init code git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2413 d7cf8633-e32d-0410-b094-e92efae38249 --- host.c | 2 +- vid.h | 2 +- vid_glx.c | 2 +- vid_null.c | 2 +- vid_wgl.c | 43 +++++++++++++++++++++---------------------- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/host.c b/host.c index 18b5c1a0..a5e620d6 100644 --- a/host.c +++ b/host.c @@ -885,7 +885,7 @@ void Host_Init (void) #ifndef _WIN32 // on non win32, mouse comes before video for security reasons IN_Init (); #endif - VID_Init (vid_fullscreen.integer, vid_width.integer, vid_height.integer); + VID_Init (vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer); Render_Init(); S_Init (); diff --git a/vid.h b/vid.h index f3da2f42..8076076c 100644 --- a/vid.h +++ b/vid.h @@ -102,7 +102,7 @@ void GL_Init (void); void VID_CheckExtensions(void); -void VID_Init (int fullscreen, int width, int height); +void VID_Init (int fullscreen, int width, int height, int bpp); // Called at startup void VID_Shutdown (void); diff --git a/vid_glx.c b/vid_glx.c index 33ecded7..a80277ff 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -636,7 +636,7 @@ int VID_SetGamma(float prescale, float gamma, float scale, float base) #endif } -void VID_Init(int fullscreen, int width, int height) +void VID_Init(int fullscreen, int width, int height, int bpp) { int i; // LordHavoc: FIXME: finish this code, we need to allocate colors before we can store them diff --git a/vid_null.c b/vid_null.c index 2b4d3b02..6a14679b 100644 --- a/vid_null.c +++ b/vid_null.c @@ -67,7 +67,7 @@ int VID_SetGamma(float prescale, float gamma, float scale, float base) return FALSE; } -void VID_Init(int fullscreen, int width, int height) +void VID_Init(int fullscreen, int width, int height, int bpp) { InitSig(); // trap evil signals } diff --git a/vid_wgl.c b/vid_wgl.c index 2562f488..0e9b2944 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -33,14 +33,16 @@ BOOL (WINAPI *qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *); BOOL (WINAPI *qwglSwapBuffers)(HDC); HGLRC (WINAPI *qwglCreateContext)(HDC); BOOL (WINAPI *qwglDeleteContext)(HGLRC); +HGLRC (WINAPI *qwglGetCurrentContext)(VOID); +HDC (WINAPI *qwglGetCurrentDC)(VOID); PROC (WINAPI *qwglGetProcAddress)(LPCSTR); BOOL (WINAPI *qwglMakeCurrent)(HDC, HGLRC); BOOL (WINAPI *qwglSwapIntervalEXT)(int interval); -const char *(WINAPI *wglGetExtensionsStringARB)(HDC hdc); +const char *(WINAPI *qwglGetExtensionsStringARB)(HDC hdc); static gl_extensionfunctionlist_t getextensionsstringfuncs[] = { - {"wglGetExtensionsString", (void **) &qwglGetExtensionsString}, + {"wglGetExtensionsString", (void **) &qwglGetExtensionsStringARB}, {NULL, NULL} }; @@ -986,14 +988,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL) - { - // if the width is more than twice the height, reduce it by half because this - // is probably a dual-screen monitor - if ((!COM_CheckParm("-noadjustaspect")) && (devmode.dmPelsWidth > (devmode.dmPelsHeight << 1))) - VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth >> 1, devmode.dmPelsHeight, 0, 1, 1, 1, devmode.dmBitsPerPel); - else - VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth, devmode.dmPelsHeight, 0, 0, 1, 1, devmode.dmBitsPerPel); - } + VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth, devmode.dmPelsHeight, 0, 1, 1, devmode.dmBitsPerPel); } modenum++; @@ -1015,7 +1010,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if (ChangeDisplaySettings (&devmode, CDS_TEST | CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL) - VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth, devmode.dmPelsHeight, 0, 0, 1, 1, devmode.dmBitsPerPel); + VID_AddMode(MS_FULLDIB, devmode.dmPelsWidth, devmode.dmPelsHeight, 0, 1, 1, devmode.dmBitsPerPel); } switch (bpp) { @@ -1233,10 +1228,11 @@ void *GL_GetProcAddress(const char *name) VID_Init =================== */ -void VID_Init (int fullscreen, int width, int height) +void VID_Init (int fullscreen, int width, int height, int bpp) { - int i; - int basenummodes, bpp, findbpp, done; + int i, bestmode; + double rating, bestrating; + int basenummodes, done; HDC hdc; DEVMODE devmode; @@ -1287,11 +1283,14 @@ void VID_Init (int fullscreen, int width, int height) bestrating = 1000000000; for (i = 0;i < nummodes;i++) { - rating = VID_CompareMode(fullscreen, width, height, bpp, modelist[i].fullscreen, modelist[i].width, modelist[i].height, modelist[i].bpp); - if (bestrating > rating) + if (fullscreen == modelist[i].fullscreen) { - bestrating = rating; - bestmode = i; + rating = VID_CompareMode(width, height, bpp, modelist[i].width, modelist[i].height, modelist[i].bpp); + if (bestrating > rating) + { + bestrating = rating; + bestmode = i; + } } } @@ -1306,7 +1305,7 @@ void VID_Init (int fullscreen, int width, int height) maindc = GetDC(mainwindow); bSetupPixelFormat(maindc); - if (!gl_checkextension("wgl", wglfuncs, NULL, false)) + if (!GL_CheckExtension("wgl", wglfuncs, NULL, false)) Sys_Error("wgl functions not found\n"); baseRC = qwglCreateContext( maindc ); @@ -1319,13 +1318,13 @@ void VID_Init (int fullscreen, int width, int height) gl_vendor = qglGetString(GL_VENDOR); gl_version = qglGetString(GL_VERSION); gl_extensions = qglGetString(GL_EXTENSIONS); - gl_platformname = "WGL"; + gl_platform = "WGL"; gl_platformextensions = ""; - if (gl_checkextension("WGL_ARB_extensions_string", extensionsstringfuncs, NULL, false)) + if (GL_CheckExtension("WGL_ARB_extensions_string", getextensionsstringfuncs, NULL, false)) gl_platformextensions = qwglGetExtensionsStringARB(maindc); - gl_videosyncavailable = gl_checkextension("WGL_EXT_swap_control", wglswapintervalfuncs, NULL, false); + gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, NULL, false); GL_Init (); -- 2.39.2