gl_vidsdl.c, gl_vidnt.c: more sync'ing between gl_vidsdl.c and fitz-0.85

version of gl_vidnt.c.


git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@129 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2010-04-24 11:10:07 +00:00
parent e4790293d6
commit f2b1e54d8d
2 changed files with 91 additions and 91 deletions

View File

@ -251,7 +251,7 @@ void VID_Gamma_f (void)
oldgamma = vid_gamma.value; oldgamma = vid_gamma.value;
for (i=0; i<256; i++) for (i=0; i<256; i++)
vid_gammaramp[i] = vid_gammaramp[i+256] = vid_gammaramp[i+512] = vid_gammaramp[i] = vid_gammaramp[i+256] = vid_gammaramp[i+512] =
CLAMP(0, (int) (255 * pow ((i+0.5)/255.5, vid_gamma.value) + 0.5), 255) << 8; CLAMP(0, (int) (255 * pow ((i+0.5)/255.5, vid_gamma.value) + 0.5), 255) << 8;
@ -973,22 +973,19 @@ CheckArrayExtensions
*/ */
void CheckArrayExtensions (void) void CheckArrayExtensions (void)
{ {
char *tmp; const char *tmp;
/* check for texture extension */ tmp = (const char *)glGetString(GL_EXTENSIONS);
tmp = (unsigned char *)glGetString(GL_EXTENSIONS);
while (*tmp) while (*tmp)
{ {
if (strncmp((const char*)tmp, "GL_EXT_vertex_array", strlen("GL_EXT_vertex_array")) == 0) if (strncmp(tmp, "GL_EXT_vertex_array", sizeof("GL_EXT_vertex_array") -1) == 0)
{ {
if ( if (((glArrayElementEXT = wglGetProcAddress("glArrayElementEXT")) == NULL) ||
((glArrayElementEXT = wglGetProcAddress("glArrayElementEXT")) == NULL) || ((glColorPointerEXT = wglGetProcAddress("glColorPointerEXT")) == NULL) ||
((glColorPointerEXT = wglGetProcAddress("glColorPointerEXT")) == NULL) || ((glTexCoordPointerEXT = wglGetProcAddress("glTexCoordPointerEXT")) == NULL) ||
((glTexCoordPointerEXT = wglGetProcAddress("glTexCoordPointerEXT")) == NULL) || ((glVertexPointerEXT = wglGetProcAddress("glVertexPointerEXT")) == NULL) )
((glVertexPointerEXT = wglGetProcAddress("glVertexPointerEXT")) == NULL) )
{ {
Sys_Error ("GetProcAddress for vertex extension failed"); Sys_Error ("GetProcAddress for vertex extension failed");
return;
} }
return; return;
} }
@ -1114,7 +1111,7 @@ void GL_CheckExtensions (void)
if (strstr(gl_extensions, "GL_EXT_texture_filter_anisotropic")) if (strstr(gl_extensions, "GL_EXT_texture_filter_anisotropic"))
{ {
float test1,test2; float test1,test2;
int tex; GLuint tex;
// test to make sure we really have control over it // test to make sure we really have control over it
// 1.0 and 2.0 should always be legal values // 1.0 and 2.0 should always be legal values
@ -1195,10 +1192,10 @@ GL_Init
*/ */
void GL_Init (void) void GL_Init (void)
{ {
gl_vendor = glGetString (GL_VENDOR); gl_vendor = (const char *) glGetString (GL_VENDOR);
gl_renderer = glGetString (GL_RENDERER); gl_renderer = (const char *) glGetString (GL_RENDERER);
gl_version = glGetString (GL_VERSION); gl_version = (const char *) glGetString (GL_VERSION);
gl_extensions = glGetString (GL_EXTENSIONS); gl_extensions = (const char *) glGetString (GL_EXTENSIONS);
GetWGLExtensions (); //johnfitz GetWGLExtensions (); //johnfitz
GL_CheckExtensions (); //johnfitz GL_CheckExtensions (); //johnfitz
@ -1207,11 +1204,11 @@ void GL_Init (void)
Cvar_RegisterVariable (&vid_vsync, VID_Vsync_f); //johnfitz Cvar_RegisterVariable (&vid_vsync, VID_Vsync_f); //johnfitz
if (strnicmp(gl_renderer,"PowerVR",7)==0) if (strnicmp(gl_renderer,"PowerVR",7)==0)
fullsbardraw = true; fullsbardraw = true;
if (strnicmp(gl_renderer,"Permedia",8)==0) if (strnicmp(gl_renderer,"Permedia",8)==0)
isPermedia = true; isPermedia = true;
//johnfitz -- intel video workarounds from Baker //johnfitz -- intel video workarounds from Baker
if (!strcmp(gl_vendor, "Intel")) if (!strcmp(gl_vendor, "Intel"))
@ -1287,19 +1284,19 @@ void VID_SetDefaultMode (void)
void VID_Shutdown (void) void VID_Shutdown (void)
{ {
HGLRC hRC; HGLRC hRC;
HDC hDC; HDC hDC;
if (vid_initialized) if (vid_initialized)
{ {
vid_canalttab = false; vid_canalttab = false;
hRC = wglGetCurrentContext(); hRC = wglGetCurrentContext();
hDC = wglGetCurrentDC(); hDC = wglGetCurrentDC();
wglMakeCurrent(NULL, NULL); wglMakeCurrent(NULL, NULL);
if (hRC) if (hRC)
wglDeleteContext(hRC); wglDeleteContext(hRC);
VID_Gamma_Shutdown (); //johnfitz VID_Gamma_Shutdown (); //johnfitz
@ -1572,15 +1569,15 @@ LONG WINAPI MainWndProc (
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
LONG lRet = 1; LONG lRet = 1;
int fwKeys, xPos, yPos, fActive, fMinimized, temp; int fwKeys, xPos, yPos, fActive, fMinimized, temp;
extern unsigned int uiWheelMessage; extern unsigned int uiWheelMessage;
if ( uMsg == uiWheelMessage ) if ( uMsg == uiWheelMessage )
uMsg = WM_MOUSEWHEEL; uMsg = WM_MOUSEWHEEL;
switch (uMsg) switch (uMsg)
{ {
case WM_KILLFOCUS: case WM_KILLFOCUS:
if (modestate == MS_FULLDIB) if (modestate == MS_FULLDIB)
ShowWindow(mainwindow, SW_SHOWMINNOACTIVE); ShowWindow(mainwindow, SW_SHOWMINNOACTIVE);
@ -1646,17 +1643,17 @@ LONG WINAPI MainWndProc (
} }
break; break;
case WM_SIZE: case WM_SIZE:
break; break;
case WM_CLOSE: case WM_CLOSE:
if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit", if (MessageBox (mainwindow, "Are you sure you want to quit?", "Confirm Exit",
MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES) MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES)
{ {
Sys_Quit (); Sys_Quit ();
} }
break; break;
case WM_ACTIVATE: case WM_ACTIVATE:
fActive = LOWORD(wParam); fActive = LOWORD(wParam);
@ -1668,27 +1665,27 @@ LONG WINAPI MainWndProc (
break; break;
case WM_DESTROY: case WM_DESTROY:
{ {
if (dibwindow) if (dibwindow)
DestroyWindow (dibwindow); DestroyWindow (dibwindow);
PostQuitMessage (0); PostQuitMessage (0);
} }
break;
case MM_MCINOTIFY:
lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
break; break;
default: case MM_MCINOTIFY:
/* pass all unhandled messages to DefWindowProc */ lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); break;
break;
}
/* return 1 if handled message, 0 if not */ default:
return lRet; /* pass all unhandled messages to DefWindowProc */
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
break;
}
/* return 1 if handled message, 0 if not */
return lRet;
} }
//========================================================================== //==========================================================================
@ -1811,10 +1808,10 @@ VID_DescribeModes_f -- johnfitz -- changed formatting, and added refresh rates a
*/ */
void VID_DescribeModes_f (void) void VID_DescribeModes_f (void)
{ {
int i, lnummodes, t; int i, lnummodes, t;
char *pinfo; char *pinfo;
vmode_t *pv; vmode_t *pv;
int lastwidth=0, lastheight=0, lastbpp=0, count=0; int lastwidth=0, lastheight=0, lastbpp=0, count=0;
lnummodes = VID_NumModes (); lnummodes = VID_NumModes ();
@ -1863,18 +1860,18 @@ void VID_InitDIB (HINSTANCE hInstance)
int i; int i;
/* Register the frame class */ /* Register the frame class */
wc.style = 0; wc.style = 0;
wc.lpfnWndProc = (WNDPROC)MainWndProc; wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.hIcon = 0; wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW); wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = NULL; wc.hbrBackground = NULL;
wc.lpszMenuName = 0; wc.lpszMenuName = 0;
wc.lpszClassName = "FitzQuake"; //johnfitz -- was WinQuake wc.lpszClassName = "FitzQuake"; //johnfitz -- was WinQuake
if (!RegisterClass (&wc) ) if (!RegisterClass (&wc) )
Sys_Error ("Couldn't register window class"); Sys_Error ("Couldn't register window class");
modelist[0].type = MS_WINDOWED; modelist[0].type = MS_WINDOWED;
@ -2297,18 +2294,18 @@ void VID_Init (void)
VID_SetMode (vid_default); VID_SetMode (vid_default);
maindc = GetDC(mainwindow); maindc = GetDC(mainwindow);
bSetupPixelFormat(maindc); bSetupPixelFormat(maindc);
baseRC = wglCreateContext( maindc ); baseRC = wglCreateContext( maindc );
if (!baseRC) if (!baseRC)
Sys_Error ("Could not initialize GL (wglCreateContext failed).\n\nMake sure you in are 65535 color mode, and try running -window."); Sys_Error ("Could not initialize GL (wglCreateContext failed).\n\nMake sure you in are 65535 color mode, and try running -window.");
if (!wglMakeCurrent( maindc, baseRC )) if (!wglMakeCurrent( maindc, baseRC ))
Sys_Error ("VID_Init: wglMakeCurrent failed"); Sys_Error ("VID_Init: wglMakeCurrent failed");
GL_Init (); GL_Init ();
//johnfitz -- removed code to create "glquake" subdirectory //johnfitz -- removed code creating "glquake" subdirectory
vid_realmode = vid_modenum; vid_realmode = vid_modenum;

View File

@ -1,7 +1,8 @@
/* /*
Copyright (C) 1996-2001 Id Software, Inc. Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2005 John Fitzgibbons and others Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2007-2008 Kristian Duske Copyright (C) 2007-2008 Kristian Duske
Copyright (C) 2010 Ozkan Sezer and Steven Atkinson
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
@ -43,6 +44,7 @@ typedef struct {
int dib; int dib;
int fullscreen; int fullscreen;
int bpp; int bpp;
// int refreshrate; //johnfitz
int halfscreen; int halfscreen;
char modedesc[17]; char modedesc[17];
} vmode_t; } vmode_t;
@ -130,9 +132,9 @@ void GL_SetupState (void); //johnfitz
//==================================== //====================================
//johnfitz -- new cvars //johnfitz -- new cvars
cvar_t vid_fullscreen = {"vid_fullscreen", "0", true}; cvar_t vid_fullscreen = {"vid_fullscreen", "0", true}; // QuakeSpasm, was "1"
cvar_t vid_width = {"vid_width", "800", true}; cvar_t vid_width = {"vid_width", "800", true}; // QuakeSpasm, was 640
cvar_t vid_height = {"vid_height", "600", true}; cvar_t vid_height = {"vid_height", "600", true}; // QuakeSpasm, was 480
cvar_t vid_bpp = {"vid_bpp", "16", true}; cvar_t vid_bpp = {"vid_bpp", "16", true};
cvar_t vid_refreshrate = {"vid_refreshrate", "60", true}; cvar_t vid_refreshrate = {"vid_refreshrate", "60", true};
cvar_t vid_vsync = {"vid_vsync", "0", true}; cvar_t vid_vsync = {"vid_vsync", "0", true};
@ -208,7 +210,8 @@ void VID_Gamma_f (void)
for (i=0; i<256; i++) for (i=0; i<256; i++)
{ {
vid_gamma_red[i] = CLAMP(0, (int) (255 * pow ((i+0.5)/255.5, vid_gamma.value) + 0.5), 255) << 8; vid_gamma_red[i] =
CLAMP(0, (int) (255 * pow ((i+0.5)/255.5, vid_gamma.value) + 0.5), 255) << 8;
vid_gamma_green[i] = vid_gamma_red[i]; vid_gamma_green[i] = vid_gamma_red[i];
vid_gamma_blue[i] = vid_gamma_red[i]; vid_gamma_blue[i] = vid_gamma_red[i];
} }
@ -564,13 +567,12 @@ CheckArrayExtensions
*/ */
void CheckArrayExtensions (void) void CheckArrayExtensions (void)
{ {
unsigned char *tmp; const char *tmp;
/* check for texture extension */ tmp = (const char *)glGetString(GL_EXTENSIONS);
tmp = (GLubyte *)glGetString(GL_EXTENSIONS);
while (*tmp) while (*tmp)
{ {
if (strncmp((const char*)tmp, "GL_EXT_vertex_array", strlen("GL_EXT_vertex_array")) == 0) if (strncmp(tmp, "GL_EXT_vertex_array", sizeof("GL_EXT_vertex_array") -1) == 0)
{ {
if (((glArrayElementEXT = SDL_GL_GetProcAddress("glArrayElementEXT")) == NULL) || if (((glArrayElementEXT = SDL_GL_GetProcAddress("glArrayElementEXT")) == NULL) ||
((glColorPointerEXT = SDL_GL_GetProcAddress("glColorPointerEXT")) == NULL) || ((glColorPointerEXT = SDL_GL_GetProcAddress("glColorPointerEXT")) == NULL) ||
@ -578,7 +580,6 @@ void CheckArrayExtensions (void)
((glVertexPointerEXT = SDL_GL_GetProcAddress("glVertexPointerEXT")) == NULL) ) ((glVertexPointerEXT = SDL_GL_GetProcAddress("glVertexPointerEXT")) == NULL) )
{ {
Sys_Error ("GetProcAddress for vertex extension failed"); Sys_Error ("GetProcAddress for vertex extension failed");
return;
} }
return; return;
} }
@ -1052,7 +1053,7 @@ void VID_InitDIB (void)
if (COM_CheckParm("-width")) if (COM_CheckParm("-width"))
modelist[0].width = Q_atoi(com_argv[COM_CheckParm("-width")+1]); modelist[0].width = Q_atoi(com_argv[COM_CheckParm("-width")+1]);
else else
modelist[0].width = 800; modelist[0].width = 800; // QuakeSpasm, was 640
if (modelist[0].width < 320) if (modelist[0].width < 320)
modelist[0].width = 320; modelist[0].width = 320;
@ -1374,8 +1375,11 @@ void VID_Init (void)
PL_SetWindowIcon(); PL_SetWindowIcon();
VID_SetMode (vid_default); VID_SetMode (vid_default);
GL_Init (); GL_Init ();
//johnfitz -- removed code creating "glquake" subdirectory
vid_realmode = vid_modenum; vid_realmode = vid_modenum;
vid_menucmdfn = VID_Menu_f; //johnfitz vid_menucmdfn = VID_Menu_f; //johnfitz
@ -1430,7 +1434,6 @@ vrestart:
} }
} }
/* /*
================ ================
VID_SyncCvars -- johnfitz -- set vid cvars to match current video mode VID_SyncCvars -- johnfitz -- set vid cvars to match current video mode
@ -1807,39 +1810,39 @@ void VID_MenuDraw (void)
M_PrintWhite ((320-8*strlen(title))/2, 32, title); M_PrintWhite ((320-8*strlen(title))/2, 32, title);
// options // options
M_Print (16, video_cursor_table[i], " Video mode"); M_Print (16, video_cursor_table[i], " Video mode");
M_Print (216, video_cursor_table[i], va("%ix%i", (int)vid_width.value, (int)vid_height.value)); M_Print (184, video_cursor_table[i], va("%ix%i", (int)vid_width.value, (int)vid_height.value));
i++; i++;
M_Print (16, video_cursor_table[i], " Color depth"); M_Print (16, video_cursor_table[i], " Color depth");
M_Print (216, video_cursor_table[i], va("%i", (int)vid_bpp.value)); M_Print (184, video_cursor_table[i], va("%i", (int)vid_bpp.value));
i++; i++;
M_Print (16, video_cursor_table[i], " Refresh rate"); M_Print (16, video_cursor_table[i], " Refresh rate");
// M_Print (216, video_cursor_table[i], va("%i Hz", (int)vid_refreshrate.value)); refresh rates are disabled for now -- kristian // M_Print (184, video_cursor_table[i], va("%i Hz", (int)vid_refreshrate.value)); refresh rates are disabled for now -- kristian
M_Print (216, video_cursor_table[i], "N/A"); M_Print (184, video_cursor_table[i], "N/A");
i++; i++;
M_Print (16, video_cursor_table[i], " Fullscreen"); M_Print (16, video_cursor_table[i], " Fullscreen");
M_DrawCheckbox (216, video_cursor_table[i], (int)vid_fullscreen.value); M_DrawCheckbox (184, video_cursor_table[i], (int)vid_fullscreen.value);
i++; i++;
// added vsync to the video menu -- kristian // added vsync to the video menu -- kristian
M_Print (16, video_cursor_table[i], " Vertical Sync"); M_Print (16, video_cursor_table[i], " Vertical Sync");
if (gl_swap_control) if (gl_swap_control)
M_DrawCheckbox (216, video_cursor_table[i], (int)vid_vsync.value); M_DrawCheckbox (184, video_cursor_table[i], (int)vid_vsync.value);
else else
M_Print (216, video_cursor_table[i], "N/A"); M_Print (184, video_cursor_table[i], "N/A");
i++; i++;
M_Print (16, video_cursor_table[i], " Test changes"); M_Print (16, video_cursor_table[i], " Test changes");
i++; i++;
M_Print (16, video_cursor_table[i], " Apply changes"); M_Print (16, video_cursor_table[i], " Apply changes");
// cursor // cursor
M_DrawCharacter (200, video_cursor_table[video_options_cursor], 12+((int)(realtime*4)&1)); M_DrawCharacter (168, video_cursor_table[video_options_cursor], 12+((int)(realtime*4)&1));
// notes "345678901234567890123456789012345678" // notes "345678901234567890123456789012345678"
// M_Print (16, 172, "Windowed modes always use the desk- "); // M_Print (16, 172, "Windowed modes always use the desk- ");