zzogl-pg: Work more on separating out the windowing code.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2748 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-03-19 05:24:36 +00:00
parent 686b08b7de
commit e80b5c5af5
8 changed files with 359 additions and 271 deletions

View File

@ -0,0 +1,291 @@
/* ZeroGS KOSMOS
* Copyright (C) 2005-2006 zerofrog@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "GS.h"
#include "zerogs.h"
#ifdef GL_WIN32_WINDOW
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
static int nWindowWidth = 0, nWindowHeight = 0;
switch( msg ) {
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
case WM_KEYDOWN:
// switch(wParam) {
// case VK_ESCAPE:
// SendMessage(hWnd, WM_DESTROY, 0L, 0L);
// break;
// }
break;
case WM_ACTIVATE:
if( wParam != WA_INACTIVE ) {
//DEBUG_LOG("restoring device\n");
ZeroGS::Restore();
}
break;
case WM_SIZE:
nWindowWidth = lParam&0xffff;
nWindowHeight = lParam>>16;
ZeroGS::ChangeWindowSize(nWindowWidth, nWindowHeight);
break;
case WM_SIZING:
// if button is 0, then just released so can resize
if( GetSystemMetrics(SM_SWAPBUTTON) ? !GetAsyncKeyState(VK_RBUTTON) : !GetAsyncKeyState(VK_LBUTTON) ) {
ZeroGS::SetChangeDeviceSize(nWindowWidth, nWindowHeight);
}
break;
case WM_SETCURSOR:
SetCursor(NULL);
break;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
bool GLWindow::CreateGLWindow(void *pDisplay)
{
RECT rc, rcdesktop;
rc.left = 0; rc.top = 0;
rc.right = conf.width; rc.bottom = conf.height;
WNDCLASSEX wc;
HINSTANCE hInstance = GetModuleHandle(NULL);
DWORD dwExStyle, dwStyle;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_CLASSDC;
wc.lpfnWndProc = (WNDPROC) MsgProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hIconSm = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "PS2EMU_ZEROGS";
RegisterClassEx( &wc );
if( conf.options & GSOPTION_FULLSCREEN)
{
dwExStyle = WS_EX_APPWINDOW;
dwStyle = WS_POPUP;
}
else
{
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle = WS_OVERLAPPEDWINDOW;
}
AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
GetWindowRect(GetDesktopWindow(), &rcdesktop);
GShwnd = CreateWindowEx(
dwExStyle,
"PS2EMU_ZEROGS",
"ZeroGS",
dwStyle,
(rcdesktop.right - (rc.right - rc.left)) / 2,
(rcdesktop.bottom - (rc.bottom - rc.top)) / 2,
rc.right - rc.left,
rc.bottom - rc.top,
NULL,
NULL,
hInstance,
NULL);
if (GShwnd == NULL) return false;
if (pDisplay != NULL) *(HWND*)pDisplay = GShwnd;
return (pDisplay != NULL);
}
bool GLWindow::ReleaseWindow()
{
if (hRC) // Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC=NULL; // Set RC To NULL
}
if (hDC && !ReleaseDC(GShwnd,hDC)) // Are We Able To Release The DC
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC=NULL; // Set DC To NULL
}
return true;
}
void GLWindow::CloseWindow()
{
if( GShwnd != NULL )
{
DestroyWindow(GShwnd);
GShwnd = NULL;
}
}
bool GLWindow::DisplayWindow(int _width, int _height)
{
GLuint PixelFormat; // Holds The Results After Searching For A Match
DWORD dwExStyle; // Window Extended Style
DWORD dwStyle; // Window Style
RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop);
if( conf.options & GSOPTION_FULLSCREEN) {
nBackbufferWidth = rcdesktop.right - rcdesktop.left;
nBackbufferHeight = rcdesktop.bottom - rcdesktop.top;
dwExStyle=WS_EX_APPWINDOW;
dwStyle=WS_POPUP;
ShowCursor(FALSE);
}
else {
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle=WS_OVERLAPPEDWINDOW;
}
RECT rc;
rc.left = 0; rc.top = 0;
rc.right = nBackbufferWidth; rc.bottom = nBackbufferHeight;
AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
SetWindowLong( GShwnd, GWL_STYLE, dwStyle );
SetWindowLong( GShwnd, GWL_EXSTYLE, dwExStyle );
SetWindowPos(GShwnd, HWND_TOP, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
if (conf.options & GSOPTION_FULLSCREEN) {
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize=sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = nBackbufferWidth;
dmScreenSettings.dmPelsHeight = nBackbufferHeight;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
conf.options &= ~GSOPTION_FULLSCREEN;
else
return false;
}
}
else {
// change to default resolution
ChangeDisplaySettings(NULL, 0);
}
PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
24, // 24Bit Z-Buffer (Depth Buffer)
8, // 8bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (!(hDC=GetDC(GShwnd))) {
MessageBox(NULL,"(1) Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) {
MessageBox(NULL,"(2) Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
if(!SetPixelFormat(hDC,PixelFormat,&pfd)) {
MessageBox(NULL,"(3) Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
if (!(hRC=wglCreateContext(hDC))) {
MessageBox(NULL,"(4) Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
if(!wglMakeCurrent(hDC,hRC)) {
MessageBox(NULL,"(5) Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
UpdateWindow(GShwnd);
return true;
}
void GLWindow::SwapGLBuffers()
{
static u32 lastswaptime = 0;
SwapBuffers(hDC);
lastswaptime = timeGetTime();
}
void GLWindow::SetTitle(char *strtitle)
{
SetWindowText(GShwnd, strtitle);
}
void GLWindow::ResizeCheck()
{
}
#endif

View File

@ -33,7 +33,7 @@ bool GLWindow::CreateWindow(void *pDisplay)
return true; return true;
} }
bool GLWindow::DestroyWindow() bool GLWindow::ReleaseWindow()
{ {
if (context) if (context)
{ {
@ -66,7 +66,7 @@ void GLWindow::CloseWindow()
} }
} }
void GLWindow::DisplayWindow(int _width, int _height) bool GLWindow::DisplayWindow(int _width, int _height)
{ {
int i; int i;
XVisualInfo *vi; XVisualInfo *vi;
@ -208,21 +208,23 @@ void GLWindow::DisplayWindow(int _width, int _height)
XSelectInput(GLWin.glDisplay, GLWin.glWindow, ExposureMask | KeyPressMask | KeyReleaseMask | XSelectInput(GLWin.glDisplay, GLWin.glWindow, ExposureMask | KeyPressMask | KeyReleaseMask |
ButtonPressMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
FocusChangeMask ); FocusChangeMask );
return true;
} }
void GLWindow::SwapBuffers() void GLWindow::SwapGLBuffers()
{ {
glXSwapBuffers(glDisplay, glWindow); glXSwapBuffers(glDisplay, glWindow);
} }
void GLWindow::SetTitle(char *strtitle) void GLWindow::SetTitle(char *strtitle)
{ {
XTextProperty prop; XTextProperty prop;
memset(&prop, 0, sizeof(prop)); memset(&prop, 0, sizeof(prop));
char* ptitle = strtitle; char* ptitle = strtitle;
if( XStringListToTextProperty(&ptitle, 1, &prop) ) if( XStringListToTextProperty(&ptitle, 1, &prop) )
XSetWMName(glDisplay, glWindow, &prop); XSetWMName(glDisplay, glWindow, &prop);
XFree(prop.value); XFree(prop.value);
} }
void GLWindow::ResizeCheck() void GLWindow::ResizeCheck()

View File

@ -154,12 +154,35 @@ class GLWindow
u32 width, height, depth; u32 width, height, depth;
public: public:
void SwapBuffers(); void SwapGLBuffers();
void SetTitle(char *strtitle); void SetTitle(char *strtitle);
bool CreateWindow(void *pDisplay); bool CreateWindow(void *pDisplay);
bool DestroyWindow(); bool ReleaseWindow();
void CloseWindow(); void CloseWindow();
void DisplayWindow(int _width, int _height); bool DisplayWindow(int _width, int _height);
void ResizeCheck();
};
extern GLWindow GLWin;
#else
#define GL_WIN32_WINDOW
class GLWindow
{
private:
bool fullScreen, doubleBuffered;
s32 x, y;
u32 width, height, depth;
public:
void SwapGLBuffers();
void SetTitle(char *strtitle);
bool CreateGLWindow(void *pDisplay);
bool ReleaseWindow();
void CloseWindow();
bool DisplayWindow(int _width, int _height);
void ResizeCheck(); void ResizeCheck();
}; };

View File

@ -112,6 +112,8 @@ u32 CALLBACK PS2EgetLibVersion2(u32 type) {
static u64 luPerfFreq; static u64 luPerfFreq;
GLWindow GLWin;
#ifdef _WIN32 #ifdef _WIN32
HWND GShwnd = NULL; HWND GShwnd = NULL;
@ -127,7 +129,6 @@ void SysMessage(const char *fmt, ...) {
} }
#else #else
GLWindow GLWin;
u32 THR_KeyEvent = 0; // Value for key event processing between threads u32 THR_KeyEvent = 0; // Value for key event processing between threads
bool THR_bShift = false; bool THR_bShift = false;
@ -466,7 +467,7 @@ GameHack HackinshTable[HACK_NUMBER] = {
{"***16 Full 16 bit", GAME_FULL16BITRES}, {"***16 Full 16 bit", GAME_FULL16BITRES},
{"***17 Resolve promoted", GAME_RESOLVEPROMOTED}, {"***17 Resolve promoted", GAME_RESOLVEPROMOTED},
{"***18 Fast Update", GAME_FASTUPDATE}, {"***18 Fast Update", GAME_FASTUPDATE},
{"***19 No Apha Test", GAME_NOALPHATEST}, {"***19 No Alpha Test", GAME_NOALPHATEST},
{"***20 Disable MRT deprh", GAME_DISABLEMRTDEPTH}, {"***20 Disable MRT deprh", GAME_DISABLEMRTDEPTH},
{"***21 32 bit targes", GAME_32BITTARGS}, {"***21 32 bit targes", GAME_32BITTARGS},
{"***22 path 3 hack", GAME_PATH3HACK}, {"***22 path 3 hack", GAME_PATH3HACK},
@ -516,54 +517,7 @@ void OnKeyboardF1(int shift) {
HANDLE g_hCurrentThread = NULL; HANDLE g_hCurrentThread = NULL;
#endif #endif
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) extern LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
{
static int nWindowWidth = 0, nWindowHeight = 0;
switch( msg ) {
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
case WM_KEYDOWN:
// switch(wParam) {
// case VK_ESCAPE:
// SendMessage(hWnd, WM_DESTROY, 0L, 0L);
// break;
// }
break;
case WM_ACTIVATE:
if( wParam != WA_INACTIVE ) {
//DEBUG_LOG("restoring device\n");
ZeroGS::Restore();
}
break;
case WM_SIZE:
nWindowWidth = lParam&0xffff;
nWindowHeight = lParam>>16;
ZeroGS::ChangeWindowSize(nWindowWidth, nWindowHeight);
break;
case WM_SIZING:
// if button is 0, then just released so can resize
if( GetSystemMetrics(SM_SWAPBUTTON) ? !GetAsyncKeyState(VK_RBUTTON) : !GetAsyncKeyState(VK_LBUTTON) ) {
ZeroGS::SetChangeDeviceSize(nWindowWidth, nWindowHeight);
}
break;
case WM_SETCURSOR:
SetCursor(NULL);
break;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
extern HINSTANCE hInst; extern HINSTANCE hInst;
void CALLBACK GSconfigure() { void CALLBACK GSconfigure() {
DialogBox(hInst, DialogBox(hInst,
@ -576,7 +530,9 @@ void CALLBACK GSconfigure() {
} }
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) { s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
{
bool err;
g_GSMultiThreaded = multithread; g_GSMultiThreaded = multithread;
@ -590,66 +546,14 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
LoadConfig(); LoadConfig();
strcpy(GStitle, Title); strcpy(GStitle, Title);
err = GLWin.CreateGLWindow(pDsp);
RECT rc, rcdesktop;
rc.left = 0; rc.top = 0;
rc.right = conf.width; rc.bottom = conf.height;
WNDCLASSEX wc; if (!err)
HINSTANCE hInstance = GetModuleHandle(NULL);
DWORD dwExStyle, dwStyle;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_CLASSDC;
wc.lpfnWndProc = (WNDPROC) MsgProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hIconSm = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "PS2EMU_ZEROGS";
RegisterClassEx( &wc );
if( conf.options & GSOPTION_FULLSCREEN)
{ {
dwExStyle = WS_EX_APPWINDOW;
dwStyle = WS_POPUP;
}
else
{
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle = WS_OVERLAPPEDWINDOW;
}
AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
GetWindowRect(GetDesktopWindow(), &rcdesktop);
GShwnd = CreateWindowEx(
dwExStyle,
"PS2EMU_ZEROGS",
"ZeroGS",
dwStyle,
(rcdesktop.right - (rc.right - rc.left)) / 2,
(rcdesktop.bottom - (rc.bottom - rc.top)) / 2,
rc.right - rc.left,
rc.bottom - rc.top,
NULL,
NULL,
hInstance,
NULL);
if(GShwnd == NULL) {
GS_LOG("Failed to create window. Exiting..."); GS_LOG("Failed to create window. Exiting...");
return -1; return -1;
} }
if( pDsp != NULL )
*(HWND*)pDsp = GShwnd;
ERROR_LOG("Using %s:%d.%d.%d\n", libraryName, zgsrevision, zgsbuild, zgsminor); ERROR_LOG("Using %s:%d.%d.%d\n", libraryName, zgsrevision, zgsbuild, zgsminor);
ERROR_LOG("creating zerogs\n"); ERROR_LOG("creating zerogs\n");
//if (conf.record) recOpen(); //if (conf.record) recOpen();
@ -834,14 +738,7 @@ void CALLBACK GSclose() {
ZeroGS::Destroy(1); ZeroGS::Destroy(1);
#ifdef _WIN32
if( GShwnd != NULL ) {
DestroyWindow(GShwnd);
GShwnd = NULL;
}
#else
GLWin.CloseWindow(); GLWin.CloseWindow();
#endif
SaveStateFile = NULL; SaveStateFile = NULL;
SaveStateExists = true; // default value SaveStateExists = true; // default value
@ -972,14 +869,7 @@ void CALLBACK GSvsync(int interlace)
// DEBUG_LOG("set profile\n"); // DEBUG_LOG("set profile\n");
// g_bWriteProfile = 1; // g_bWriteProfile = 1;
// } // }
if (!(conf.options & GSOPTION_FULLSCREEN)) GLWin.SetTitle(strtitle);
#ifdef _WIN32
if( !(conf.options&GSOPTION_FULLSCREEN) )
SetWindowText(GShwnd, strtitle);
#else // linux
if (!(conf.options & GSOPTION_FULLSCREEN))
GLWin.SetTitle(strtitle);
#endif
if( fFPS < 16 ) UPDATE_FRAMES = 4; if( fFPS < 16 ) UPDATE_FRAMES = 4;
else if( fFPS < 32 ) UPDATE_FRAMES = 8; else if( fFPS < 32 ) UPDATE_FRAMES = 8;

View File

@ -295,6 +295,22 @@
RelativePath="..\glprocs.c" RelativePath="..\glprocs.c"
> >
</File> </File>
<File
RelativePath="..\GLWin32.cpp"
>
</File>
<File
RelativePath="..\GLWinX11.cpp"
>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File <File
RelativePath="..\GSmain.cpp" RelativePath="..\GSmain.cpp"
> >

View File

@ -623,13 +623,7 @@ inline void AfterRenderSwapBuffers() {
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
DEBUG_LOG("glerror before swap!\n"); DEBUG_LOG("glerror before swap!\n");
#ifdef _WIN32 GLWin.SwapGLBuffers();
static u32 lastswaptime = 0;
SwapBuffers(hDC);
lastswaptime = timeGetTime();
#else
GLWin.SwapBuffers();
#endif
} }
// SnapeShoot helper // SnapeShoot helper

View File

@ -194,114 +194,8 @@ ZeroGS::Create_Window(int _width, int _height) {
nBackbufferHeight = _height; nBackbufferHeight = _height;
fiRendWidth = 1.0f / nBackbufferWidth; fiRendWidth = 1.0f / nBackbufferWidth;
fiRendHeight = 1.0f / nBackbufferHeight; fiRendHeight = 1.0f / nBackbufferHeight;
#ifdef _WIN32
GLuint PixelFormat; // Holds The Results After Searching For A Match if (!GLWin.DisplayWindow(_width, _height)) return false;
DWORD dwExStyle; // Window Extended Style
DWORD dwStyle; // Window Style
RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop);
if( conf.options & GSOPTION_FULLSCREEN) {
nBackbufferWidth = rcdesktop.right - rcdesktop.left;
nBackbufferHeight = rcdesktop.bottom - rcdesktop.top;
dwExStyle=WS_EX_APPWINDOW;
dwStyle=WS_POPUP;
ShowCursor(FALSE);
}
else {
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle=WS_OVERLAPPEDWINDOW;
}
RECT rc;
rc.left = 0; rc.top = 0;
rc.right = nBackbufferWidth; rc.bottom = nBackbufferHeight;
AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
SetWindowLong( GShwnd, GWL_STYLE, dwStyle );
SetWindowLong( GShwnd, GWL_EXSTYLE, dwExStyle );
SetWindowPos(GShwnd, HWND_TOP, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
if (conf.options & GSOPTION_FULLSCREEN) {
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize=sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = nBackbufferWidth;
dmScreenSettings.dmPelsHeight = nBackbufferHeight;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
conf.options &= ~GSOPTION_FULLSCREEN;
else
return false;
}
}
else {
// change to default resolution
ChangeDisplaySettings(NULL, 0);
}
PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
24, // 24Bit Z-Buffer (Depth Buffer)
8, // 8bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (!(hDC=GetDC(GShwnd))) {
MessageBox(NULL,"(1) Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) {
MessageBox(NULL,"(2) Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
if(!SetPixelFormat(hDC,PixelFormat,&pfd)) {
MessageBox(NULL,"(3) Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
if (!(hRC=wglCreateContext(hDC))) {
MessageBox(NULL,"(4) Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
if(!wglMakeCurrent(hDC,hRC)) {
MessageBox(NULL,"(5) Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
UpdateWindow(GShwnd);
#else //NOT _WIN32
GLWin.DisplayWindow(_width, _height);
#endif // WIN32
s_nFullscreen = (conf.options & GSOPTION_FULLSCREEN) ? 1 : 0; s_nFullscreen = (conf.options & GSOPTION_FULLSCREEN) ? 1 : 0;
conf.mrtdepth = 0; // for now conf.mrtdepth = 0; // for now
@ -914,29 +808,7 @@ void ZeroGS::Destroy(BOOL bD3D)
SAFE_DELETE(font_p); SAFE_DELETE(font_p);
#ifdef _WIN32 GLWin.ReleaseWindow();
if (hRC) // Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC=NULL; // Set RC To NULL
}
if (hDC && !ReleaseDC(GShwnd,hDC)) // Are We Able To Release The DC
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC=NULL; // Set DC To NULL
}
#else // linux
GLWin.DestroyWindow();
#endif
mapGLExtensions.clear(); mapGLExtensions.clear();
} }

View File

@ -182,9 +182,9 @@ public:
g_pbyGSClut = (u8*)_aligned_malloc(256*8, 1024); // need 512 alignment! g_pbyGSClut = (u8*)_aligned_malloc(256*8, 1024); // need 512 alignment!
memset(g_pbyGSClut, 0, 256*8); memset(g_pbyGSClut, 0, 256*8);
#ifndef _WIN32 //#ifndef _WIN32
memset(&GLWin, 0, sizeof(GLWin)); memset(&GLWin, 0, sizeof(GLWin));
#endif //#endif
} }
~ZeroGSInit() { ~ZeroGSInit() {
_aligned_free(g_pbyGSMemory); g_pbyGSMemory = NULL; _aligned_free(g_pbyGSMemory); g_pbyGSMemory = NULL;