trace prints. (ignore me)

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@313 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2004-10-07 13:13:15 +00:00
parent 4c2236c015
commit 0f1a14e0a9

View file

@ -174,22 +174,31 @@ void *getglfunc(char *name)
if (!proc) if (!proc)
{ {
proc = GetProcAddress(hInstGL, name); proc = GetProcAddress(hInstGL, name);
TRACE(("dbg: getglfunc: gpa %s: success %i\n", name, !!proc));
return proc; return proc;
} }
TRACE(("dbg: getglfunc: glgpa %s: success %i\n", name, !!proc));
return proc; return proc;
} }
void *getwglfunc(char *name) void *getwglfunc(char *name)
{ {
FARPROC proc; FARPROC proc;
TRACE(("dbg: getwglfunc: %s: getting\n", name));
proc = GetProcAddress(hInstGL, name); proc = GetProcAddress(hInstGL, name);
if (!proc) if (!proc)
{ {
if (!hInstwgl) if (!hInstwgl)
{
TRACE(("dbg: getwglfunc: explicitly loading opengl32.dll\n", name));
hInstwgl = LoadLibrary("opengl32.dll"); hInstwgl = LoadLibrary("opengl32.dll");
}
TRACE(("dbg: getwglfunc: %s: wglgetting\n", name));
proc = GetProcAddress(hInstwgl, name); proc = GetProcAddress(hInstwgl, name);
TRACE(("dbg: getwglfunc: gpa %s: success %i\n", name, !!proc));
if (!proc) if (!proc)
Sys_Error("GL function %s was not found in %s\nPossibly you do not have a full enough gl implementation", name, opengldllname); Sys_Error("GL function %s was not found in %s\nPossibly you do not have a full enough gl implementation", name, opengldllname);
} }
TRACE(("dbg: getwglfunc: glgpa %s: success %i\n", name, !!proc));
return proc; return proc;
} }
@ -214,14 +223,17 @@ qboolean GLInitialise (char *renderer)
strcpy(opengldllname, renderer); strcpy(opengldllname, renderer);
Con_Printf ("Loading renderer dll %s\n", renderer);
hInstGL = LoadLibrary(opengldllname); hInstGL = LoadLibrary(opengldllname);
if (!hInstGL) if (!hInstGL)
{ {
Con_SafePrintf ("Couldn't load %s\n", opengldllname); Con_Printf ("Couldn't load %s\n", opengldllname);
return false; return false;
} }
Con_DPrintf ("Loaded renderer dll %s\n", renderer);
// windows dependant // windows dependant
qwglCreateContext = (void *)getwglfunc("wglCreateContext"); qwglCreateContext = (void *)getwglfunc("wglCreateContext");
qwglDeleteContext = (void *)getwglfunc("wglDeleteContext"); qwglDeleteContext = (void *)getwglfunc("wglDeleteContext");
@ -231,6 +243,8 @@ qboolean GLInitialise (char *renderer)
qwglMakeCurrent = (void *)getwglfunc("wglMakeCurrent"); qwglMakeCurrent = (void *)getwglfunc("wglMakeCurrent");
qSwapBuffers = SwapBuffers; qSwapBuffers = SwapBuffers;
TRACE(("dbg: GLInitialise: got wgl funcs\n"));
return true; return true;
} }
@ -522,6 +536,8 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
MSG msg; MSG msg;
// HDC hdc; // HDC hdc;
TRACE(("dbg: GLVID_SetMode\n"));
// so Con_Printfs don't mess us up by forcing vid and snd updates // so Con_Printfs don't mess us up by forcing vid and snd updates
temp = scr_disabled_for_loading; temp = scr_disabled_for_loading;
scr_disabled_for_loading = true; scr_disabled_for_loading = true;
@ -533,6 +549,7 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
{ {
if (_windowed_mouse.value && (key_dest == key_game || key_dest == key_menu)) if (_windowed_mouse.value && (key_dest == key_game || key_dest == key_menu))
{ {
TRACE(("dbg: GLVID_SetMode: VID_SetWindowedMode\n"));
stat = VID_SetWindowedMode(info); stat = VID_SetWindowedMode(info);
IN_ActivateMouse (); IN_ActivateMouse ();
IN_HideMouse (); IN_HideMouse ();
@ -541,16 +558,24 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
{ {
IN_DeactivateMouse (); IN_DeactivateMouse ();
IN_ShowMouse (); IN_ShowMouse ();
TRACE(("dbg: GLVID_SetMode: VID_SetWindowedMode 2\n"));
stat = VID_SetWindowedMode(info); stat = VID_SetWindowedMode(info);
} }
} }
else else
{ {
TRACE(("dbg: GLVID_SetMode: VID_SetFullDIBMode\n"));
stat = VID_SetFullDIBMode(info); stat = VID_SetFullDIBMode(info);
IN_ActivateMouse (); IN_ActivateMouse ();
IN_HideMouse (); IN_HideMouse ();
} }
if (!stat)
{
TRACE(("dbg: GLVID_SetMode: VID_Set... failed\n"));
return false;
}
window_width = DIBWidth; window_width = DIBWidth;
window_height = DIBHeight; window_height = DIBHeight;
VID_UpdateWindowStatus (); VID_UpdateWindowStatus ();
@ -558,11 +583,6 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
CDAudio_Resume (); CDAudio_Resume ();
scr_disabled_for_loading = temp; scr_disabled_for_loading = temp;
if (!stat)
{
return false;
}
// now we try to make sure we get the focus on the mode switch, because // now we try to make sure we get the focus on the mode switch, because
// sometimes in some systems we don't. We grab the foreground, then // sometimes in some systems we don't. We grab the foreground, then
// finish setting up, pump all our messages, and sleep for a little while // finish setting up, pump all our messages, and sleep for a little while
@ -596,9 +616,13 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
maindc = GetDC(mainwindow); maindc = GetDC(mainwindow);
GetDeviceGammaRamp(maindc, origionalgammaramps); GetDeviceGammaRamp(maindc, origionalgammaramps);
TRACE(("dbg: GLVID_SetMode: attaching gl\n"));
if (!VID_AttachGL(info)) if (!VID_AttachGL(info))
{
TRACE(("dbg: GLVID_SetMode: attaching gl failed\n"));
return false; return false;
}
TRACE(("dbg: GLVID_SetMode: attaching gl okay\n"));
return true; return true;
} }
@ -680,11 +704,13 @@ qboolean VID_AttachGL (rendererstate_t *info)
extern cvar_t gl_ztrick; extern cvar_t gl_ztrick;
int zbpp = info->bpp > 16 ? 24 : 16; int zbpp = info->bpp > 16 ? 24 : 16;
gl_canstencil = false; gl_canstencil = false;
TRACE(("dbg: VID_AttachGL: D3DInitialize\n"));
D3DInitialize(); //replacement of GLInitialise, to get the function pointers set up. D3DInitialize(); //replacement of GLInitialise, to get the function pointers set up.
if (COM_CheckParm("-zbpp")) if (COM_CheckParm("-zbpp"))
{ {
zbpp = Q_atoi(com_argv[COM_CheckParm("-zbpp")+1]); zbpp = Q_atoi(com_argv[COM_CheckParm("-zbpp")+1]);
} }
TRACE(("dbg: VID_AttachGL: d3dSetMode\n"));
d3dSetMode(info->fullscreen, info->width, info->height, info->bpp, zbpp); //d3d cheats to get it's dimensions and stuff... One that we can currently live with though. d3dSetMode(info->fullscreen, info->width, info->height, info->bpp, zbpp); //d3d cheats to get it's dimensions and stuff... One that we can currently live with though.
gl_ztrickdisabled |= 2; //ztrick does funny things. gl_ztrickdisabled |= 2; //ztrick does funny things.
@ -692,14 +718,16 @@ qboolean VID_AttachGL (rendererstate_t *info)
maindc = GetDC(mainwindow); maindc = GetDC(mainwindow);
Con_SafePrintf(S_COLOR_GREEN"OpenGL to Direct3D wrapper enabled\n"); //green to make it show. Con_Printf(S_COLOR_GREEN"OpenGL to Direct3D wrapper enabled\n"); //green to make it show.
break; break;
} }
#endif #endif
gl_ztrickdisabled &= ~2; gl_ztrickdisabled &= ~2;
TRACE(("dbg: VID_AttachGL: GLInitialise\n"));
if (GLInitialise(info->glrenderer)) if (GLInitialise(info->glrenderer))
{ {
maindc = GetDC(mainwindow); maindc = GetDC(mainwindow);
TRACE(("dbg: VID_AttachGL: bSetupPixelFormat\n"));
bSetupPixelFormat(maindc); bSetupPixelFormat(maindc);
break; break;
} }
@ -710,17 +738,21 @@ qboolean VID_AttachGL (rendererstate_t *info)
GetSystemDirectory(systemgl, sizeof(systemgl)-1); GetSystemDirectory(systemgl, sizeof(systemgl)-1);
strncat(systemgl, "\\", sizeof(systemgl)-1); strncat(systemgl, "\\", sizeof(systemgl)-1);
strncat(systemgl, info->glrenderer, sizeof(systemgl)-1); strncat(systemgl, info->glrenderer, sizeof(systemgl)-1);
TRACE(("dbg: VID_AttachGL: GLInitialise (system dir specific)\n"));
if (GLInitialise(systemgl)) if (GLInitialise(systemgl))
{ {
maindc = GetDC(mainwindow); maindc = GetDC(mainwindow);
TRACE(("dbg: VID_AttachGL: bSetupPixelFormat\n"));
bSetupPixelFormat(maindc); bSetupPixelFormat(maindc);
break; break;
} }
} }
TRACE(("dbg: VID_AttachGL: failed to find a valid dll\n"));
return false; return false;
} while(1); } while(1);
TRACE(("dbg: VID_AttachGL: qwglCreateContext\n"));
baseRC = qwglCreateContext( maindc ); baseRC = qwglCreateContext( maindc );
if (!baseRC) if (!baseRC)
@ -728,17 +760,25 @@ qboolean VID_AttachGL (rendererstate_t *info)
Con_SafePrintf(S_COLOR_RED"Could not initialize GL (wglCreateContext failed).\n\nMake sure you in are 65535 color mode, and try running -window.\n"); //green to make it show. Con_SafePrintf(S_COLOR_RED"Could not initialize GL (wglCreateContext failed).\n\nMake sure you in are 65535 color mode, and try running -window.\n"); //green to make it show.
return false; return false;
} }
TRACE(("dbg: VID_AttachGL: qwglMakeCurrent\n"));
if (!qwglMakeCurrent( maindc, baseRC )) if (!qwglMakeCurrent( maindc, baseRC ))
{ {
Con_SafePrintf(S_COLOR_RED"wglMakeCurrent failed\n"); //green to make it show. Con_SafePrintf(S_COLOR_RED"wglMakeCurrent failed\n"); //green to make it show.
return false; return false;
} }
TRACE(("dbg: VID_AttachGL: GL_Init\n"));
GL_Init(getglfunc); GL_Init(getglfunc);
qwglSwapIntervalEXT = getglfunc("wglSwapIntervalEXT"); qwglSwapIntervalEXT = getglfunc("wglSwapIntervalEXT");
if (qwglSwapIntervalEXT && _vid_wait_override.value>=0) if (qwglSwapIntervalEXT && _vid_wait_override.value>=0)
{
TRACE(("dbg: VID_AttachGL: qwglSwapIntervalEXT\n"));
qwglSwapIntervalEXT(_vid_wait_override.value); qwglSwapIntervalEXT(_vid_wait_override.value);
}
_vid_wait_override.modified = false; _vid_wait_override.modified = false;
TRACE(("dbg: VID_AttachGL: qSwapBuffers\n"));
glClearColor(0, 1, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
qSwapBuffers(maindc); qSwapBuffers(maindc);
return true; return true;
@ -883,26 +923,32 @@ BOOL bSetupPixelFormat(HDC hDC)
0, 0, 0 // layer masks ignored 0, 0, 0 // layer masks ignored
}; };
int pixelformat; int pixelformat;
TRACE(("dbg: bSetupPixelFormat: ChoosePixelFormat\n"));
if ((pixelformat = ChoosePixelFormat(hDC, &pfd))) if ((pixelformat = ChoosePixelFormat(hDC, &pfd)))
{
TRACE(("dbg: ChoosePixelFormat 1: worked\n"));
if (SetPixelFormat(hDC, pixelformat, &pfd)) if (SetPixelFormat(hDC, pixelformat, &pfd))
{ {
TRACE(("dbg: bSetupPixelFormat: we can use the stencil buffer. woot\n"));
gl_canstencil = pfd.cStencilBits; gl_canstencil = pfd.cStencilBits;
return TRUE; return TRUE;
} }
}
TRACE(("dbg: ChoosePixelFormat 1: no stencil buffer for us\n"));
pfd.cStencilBits = 0; pfd.cStencilBits = 0;
gl_canstencil = false; gl_canstencil = false;
if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ) if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 )
{ {
MessageBox(NULL, "ChoosePixelFormat failed", "Error", MB_OK); Con_Printf("bSetupPixelFormat: ChoosePixelFormat failed\n");
return FALSE; return FALSE;
} }
if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE) if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE)
{ {
MessageBox(NULL, "SetPixelFormat failed", "Error", MB_OK); Con_Printf("bSetupPixelFormat: SetPixelFormat failed\n");
return FALSE; return FALSE;
} }
@ -1272,7 +1318,10 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
wc.lpszClassName = WINDOW_CLASS_NAME; wc.lpszClassName = WINDOW_CLASS_NAME;
if (!RegisterClass (&wc) ) if (!RegisterClass (&wc) )
Sys_Error ("Couldn't register window class"); {
Con_Print("^1Couldn't register window class\n");
return false;
}
hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2)); hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2));