GregMiscellaneous: zzogl-pg: Get rid of an extraneous function or two, straighten up some includes, and move some things around to appropriate places.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@4009 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-11-09 12:04:07 +00:00
parent 9f5abc9953
commit 3aabab685a
9 changed files with 145 additions and 191 deletions

View File

@ -63,6 +63,7 @@ class GLWindow
bool DisplayWindow(int _width, int _height); bool DisplayWindow(int _width, int _height);
void SetTitle(char *strtitle); void SetTitle(char *strtitle);
void ResizeCheck(); void ResizeCheck();
void ProcessEvents();
}; };
@ -70,5 +71,6 @@ extern GLWindow GLWin;
extern void ChangeWindowSize(int nNewWidth, int nNewHeight); extern void ChangeWindowSize(int nNewWidth, int nNewHeight);
extern void SetChangeDeviceSize(int nNewWidth, int nNewHeight); extern void SetChangeDeviceSize(int nNewWidth, int nNewHeight);
extern int nBackbufferWidth, nBackbufferHeight; extern int nBackbufferWidth, nBackbufferHeight;
extern void OnFKey(int key, int shift);
#endif // GLWIN_H_INCLUDED #endif // GLWIN_H_INCLUDED

View File

@ -22,6 +22,7 @@
#ifdef GL_WIN32_WINDOW #ifdef GL_WIN32_WINDOW
HWND GShwnd = NULL;
HDC hDC = NULL; // Private GDI Device Context HDC hDC = NULL; // Private GDI Device Context
HGLRC hRC = NULL; // Permanent Rendering Context HGLRC hRC = NULL; // Permanent Rendering Context
@ -299,8 +300,10 @@ bool GLWindow::DisplayWindow(int _width, int _height)
void GLWindow::SwapGLBuffers() void GLWindow::SwapGLBuffers()
{ {
static u32 lastswaptime = 0; static u32 lastswaptime = 0;
if (glGetError() != GL_NO_ERROR) ZZLog::Debug_Log("glError before swap!");
SwapBuffers(hDC); SwapBuffers(hDC);
//glClear(GL_COLOR_BUFFER_BIT);
lastswaptime = timeGetTime(); lastswaptime = timeGetTime();
} }
@ -314,4 +317,74 @@ void GLWindow::ResizeCheck()
} }
extern void ChangeDeviceSize(int nNewWidth, int nNewHeight);
void GLWindow::ProcessEvents()
{
MSG msg;
ZeroMemory(&msg, sizeof(msg));
while (1)
{
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
switch (msg.message)
{
case WM_KEYDOWN :
int my_KeyEvent = msg.wParam;
bool my_bShift = !!(GetKeyState(VK_SHIFT) & 0x8000);
switch (msg.wParam)
{
case VK_F5:
case VK_F6:
case VK_F7:
case VK_F9:
OnFKey(msg.wParam - VK_F1 + 1, my_bShift);
break;
case VK_ESCAPE:
if (conf.fullscreen())
{
// destroy that msg
conf.setFullscreen(false);
ChangeDeviceSize(conf.width, conf.height);
UpdateWindow(GShwnd);
continue; // so that msg doesn't get sent
}
else
{
SendMessage(GShwnd, WM_DESTROY, 0, 0);
return;
}
break;
}
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
break;
}
}
if ((GetKeyState(VK_MENU) & 0x8000) && (GetKeyState(VK_RETURN) & 0x8000))
{
conf.zz_options.fullscreen = !conf.zz_options.fullscreen;
SetChangeDeviceSize(
(conf.fullscreen()) ? 1280 : conf.width,
(conf.fullscreen()) ? 960 : conf.height);
}
}
#endif #endif

View File

@ -300,8 +300,8 @@ bool GLWindow::DisplayWindow(int _width, int _height)
void GLWindow::SwapGLBuffers() void GLWindow::SwapGLBuffers()
{ {
if (glGetError() != GL_NO_ERROR) ZZLog::Debug_Log("glError before swap!");
glXSwapBuffers(glDisplay, glWindow); glXSwapBuffers(glDisplay, glWindow);
//glClear(GL_COLOR_BUFFER_BIT);
} }
void GLWindow::SetTitle(char *strtitle) void GLWindow::SetTitle(char *strtitle)
@ -351,4 +351,32 @@ void GLWindow::ResizeCheck()
XUnlockDisplay(glDisplay); XUnlockDisplay(glDisplay);
} }
u32 THR_KeyEvent = 0; // Value for key event processing between threads
bool THR_bShift = false;
void GLWindow::ProcessEvents()
{
FUNCLOG
// check resizing
ResizeCheck();
if (THR_KeyEvent) // This value was passed from GSKeyEvents which could be in another thread
{
int my_KeyEvent = THR_KeyEvent;
bool my_bShift = THR_bShift;
THR_KeyEvent = 0;
switch (my_KeyEvent)
{
case XK_F5:
case XK_F6:
case XK_F7:
case XK_F9:
OnFKey(my_KeyEvent - XK_F1 + 1, my_bShift);
break;
}
}
}
#endif #endif

View File

@ -17,27 +17,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#if defined(_WIN32) #include "Util.h"
#include <windows.h> #include "GS.h"
#include "Win32.h" #include "Profile.h"
#include <io.h> #include "GLWin.h"
#endif #include "ZZoglFlushHack.h"
#include <stdlib.h>
#include <string>
using namespace std; using namespace std;
#include "GS.h" extern void SaveSnapshot(const char* filename);
#include "Mem.h"
#include "Regs.h"
#include "Profile.h"
#include "GLWin.h"
#include "targets.h"
#include "ZZoglShaders.h"
#include "ZZoglFlushHack.h"
#include "ZZoglShoots.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4244) #pragma warning(disable:4244)
@ -45,8 +33,8 @@ using namespace std;
GLWindow GLWin; GLWindow GLWin;
GSinternal gs; GSinternal gs;
char GStitle[256];
GSconf conf; GSconf conf;
char GStitle[256];
int ppf, g_GSMultiThreaded, CurrentSavestate = 0; int ppf, g_GSMultiThreaded, CurrentSavestate = 0;
int g_LastCRC = 0, g_TransferredToGPU = 0, s_frameskipping = 0; int g_LastCRC = 0, g_TransferredToGPU = 0, s_frameskipping = 0;
@ -84,7 +72,6 @@ char *libraryName = "ZZ Ogl PG ";
extern int g_nPixelShaderVer, g_nFrameRender, g_nFramesSkipped; extern int g_nPixelShaderVer, g_nFrameRender, g_nFramesSkipped;
extern void ProcessEvents();
extern void WriteAA(); extern void WriteAA();
extern void WriteBilinear(); extern void WriteBilinear();
extern void ZZDestroy(); extern void ZZDestroy();
@ -92,18 +79,11 @@ extern bool ZZCreate(int width, int height);
extern void ZZGSStateReset(); extern void ZZGSStateReset();
// switches the render target to the real target, flushes the current render targets and renders the real image // switches the render target to the real target, flushes the current render targets and renders the real image
void RenderCRTC(int interlace); extern void RenderCRTC(int interlace);
extern int VALIDATE_THRESH; extern int VALIDATE_THRESH;
extern u32 TEXDESTROY_THRESH; extern u32 TEXDESTROY_THRESH;
#ifdef _WIN32
HWND GShwnd = NULL;
#endif
u32 THR_KeyEvent = 0; // Value for key event processing between threads
bool THR_bShift = false;
u32 CALLBACK PS2EgetLibType() u32 CALLBACK PS2EgetLibType()
{ {
return PS2E_LT_GS; return PS2E_LT_GS;
@ -304,21 +284,20 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
{ {
FUNCLOG FUNCLOG
bool err; bool err = false;
g_GSMultiThreaded = multithread; g_GSMultiThreaded = multithread;
ZZLog::WriteLn("Calling GSopen."); ZZLog::WriteLn("Calling GSopen.");
#ifdef _WIN32 #if defined(_WIN32) && defined(_DEBUG)
#ifdef _DEBUG
g_hCurrentThread = GetCurrentThread(); g_hCurrentThread = GetCurrentThread();
#endif
#endif #endif
LoadConfig(); LoadConfig();
strcpy(GStitle, Title); strcpy(GStitle, Title);
ZZLog::GS_Log("Using %s:%d.%d.%d.", libraryName, zgsrevision, zgsbuild, zgsminor);
err = GLWin.CreateWindow(pDsp); err = GLWin.CreateWindow(pDsp);
if (!err) if (!err)
{ {
@ -326,7 +305,6 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
return -1; return -1;
} }
ZZLog::GS_Log("Using %s:%d.%d.%d.", libraryName, zgsrevision, zgsbuild, zgsminor);
ZZLog::WriteLn("Creating ZZOgl window."); ZZLog::WriteLn("Creating ZZOgl window.");
if (!ZZCreate(conf.width, conf.height)) return -1; if (!ZZCreate(conf.width, conf.height)) return -1;
@ -531,7 +509,7 @@ void CALLBACK GSvsync(int interlace)
// !interlace? Hmmm... Fixme. // !interlace? Hmmm... Fixme.
RenderCRTC(!interlace); RenderCRTC(!interlace);
ProcessEvents(); GLWin.ProcessEvents();
if (--nToNextUpdate <= 0) if (--nToNextUpdate <= 0)
{ {

View File

@ -22,6 +22,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include <io.h>
#include "Utilities/RedtapeWindows.h" #include "Utilities/RedtapeWindows.h"
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
@ -29,8 +30,6 @@
#include <GL/glext.h> #include <GL/glext.h>
#include "glprocs.h" #include "glprocs.h"
extern HWND GShwnd;
#else // linux basic definitions #else // linux basic definitions
#include <GL/glew.h> #include <GL/glew.h>

View File

@ -30,8 +30,7 @@ extern char *libraryName;
extern const unsigned char zgsversion; extern const unsigned char zgsversion;
extern unsigned char zgsrevision, zgsbuild, zgsminor; extern unsigned char zgsrevision, zgsbuild, zgsminor;
extern u32 THR_KeyEvent; // value for passing out key events between threads extern bool SaveStateExists;
extern bool THR_bShift, SaveStateExists;
const char* s_aa[5] = { "AA none |", "AA 2x |", "AA 4x |", "AA 8x |", "AA 16x |" }; const char* s_aa[5] = { "AA none |", "AA 2x |", "AA 4x |", "AA 8x |", "AA 16x |" };
const char* pbilinear[] = { "off", "normal", "forced" }; const char* pbilinear[] = { "off", "normal", "forced" };
@ -205,102 +204,3 @@ void WriteBilinear()
break; break;
} }
} }
#ifdef _WIN32
extern void ChangeDeviceSize(int nNewWidth, int nNewHeight);
void ProcessEvents()
{
MSG msg;
ZeroMemory(&msg, sizeof(msg));
while (1)
{
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
switch (msg.message)
{
case WM_KEYDOWN :
int my_KeyEvent = msg.wParam;
bool my_bShift = !!(GetKeyState(VK_SHIFT) & 0x8000);
switch (msg.wParam)
{
case VK_F5:
case VK_F6:
case VK_F7:
case VK_F9:
OnFKey(msg.wParam - VK_F1 + 1, my_bShift);
break;
case VK_ESCAPE:
if (conf.fullscreen())
{
// destroy that msg
conf.setFullscreen(false);
ChangeDeviceSize(conf.width, conf.height);
UpdateWindow(GShwnd);
continue; // so that msg doesn't get sent
}
else
{
SendMessage(GShwnd, WM_DESTROY, 0, 0);
return;
}
break;
}
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
break;
}
}
if ((GetKeyState(VK_MENU) & 0x8000) && (GetKeyState(VK_RETURN) & 0x8000))
{
conf.zz_options.fullscreen = !conf.zz_options.fullscreen;
SetChangeDeviceSize(
(conf.fullscreen()) ? 1280 : conf.width,
(conf.fullscreen()) ? 960 : conf.height);
}
}
#else // linux
void ProcessEvents()
{
FUNCLOG
// check resizing
GLWin.ResizeCheck();
if (THR_KeyEvent) // This value was passed from GSKeyEvents which could be in another thread
{
int my_KeyEvent = THR_KeyEvent;
bool my_bShift = THR_bShift;
THR_KeyEvent = 0;
switch (my_KeyEvent)
{
case XK_F5:
case XK_F6:
case XK_F7:
case XK_F9:
OnFKey(my_KeyEvent - XK_F1 + 1, my_bShift);
break;
}
}
}
#endif // linux

View File

@ -647,7 +647,7 @@ void DrawText(const char* pstr, int left, int top, u32 color)
} }
// Put FPS counter on screen (not in window title) // Put FPS counter on screen (not in window title)
inline void AfterRenderDisplayFPS() inline void DisplayFPS()
{ {
char str[64]; char str[64];
int left = 10, top = 15; int left = 10, top = 15;
@ -657,16 +657,8 @@ inline void AfterRenderDisplayFPS()
DrawText(str, left, top, 0xffc0ffff); DrawText(str, left, top, 0xffc0ffff);
} }
// Swapping buffers, so we could use another window
inline void AfterRenderSwapBuffers()
{
if (glGetError() != GL_NO_ERROR) ZZLog::Debug_Log("glError before swap!");
GLWin.SwapGLBuffers();
}
// SnapeShoot helper // SnapeShoot helper
inline void AfterRenderMadeSnapshoot() inline void MakeSnapshot()
{ {
if (!g_bMakeSnapshot) return; if (!g_bMakeSnapshot) return;
@ -685,7 +677,7 @@ inline void AfterRenderMadeSnapshoot()
ZZAddMessage(str, 500); ZZAddMessage(str, 500);
} }
g_bMakeSnapshot = false; g_bMakeSnapshot = false;
} }
// call to destroy video resources // call to destroy video resources
@ -710,16 +702,8 @@ void ZZReset()
if (ZZKick != NULL) delete ZZKick; if (ZZKick != NULL) delete ZZKick;
} }
// If needed reset
inline void AfterRendererResizeWindow()
{
ZZReset();
ChangeDeviceSize(s_nNewWidth, s_nNewHeight);
s_nNewWidth = s_nNewHeight = -1;
}
// Put new values on statistic variable // Put new values on statistic variable
inline void AfterRenderCountStatistics() inline void CountStatistics()
{ {
if (s_nWriteDepthCount > 0) if (s_nWriteDepthCount > 0)
{ {
@ -742,7 +726,6 @@ inline void AfterRenderCountStatistics()
if (g_nDepthUsed > 0) --g_nDepthUsed; if (g_nDepthUsed > 0) --g_nDepthUsed;
s_ClutResolve = 0; s_ClutResolve = 0;
g_nDepthUpdateCount = 0; g_nDepthUpdateCount = 0;
} }
@ -751,27 +734,27 @@ inline void AfterRendererUnimportantJob()
{ {
ProcessMessages(); ProcessMessages();
if (g_bDisplayFPS) AfterRenderDisplayFPS(); if (g_bDisplayFPS) DisplayFPS();
AfterRenderSwapBuffers(); // Swapping buffers, so we could use another window
GLWin.SwapGLBuffers();
if (conf.wireframe()) // clear all targets
{ if (conf.wireframe()) s_nWireframeCount = 1;
// clear all targets
s_nWireframeCount = 1;
}
if (g_bMakeSnapshot) if (g_bMakeSnapshot) MakeSnapshot();
{
AfterRenderMadeSnapshoot();
g_bMakeSnapshot = false;
}
CaptureFrame(); CaptureFrame();
CountStatistics();
AfterRenderCountStatistics(); if (s_nNewWidth >= 0 && s_nNewHeight >= 0)
{
// If needed reset
ZZReset();
if (s_nNewWidth >= 0 && s_nNewHeight >= 0) AfterRendererResizeWindow(); ChangeDeviceSize(s_nNewWidth, s_nNewHeight);
s_nNewWidth = s_nNewHeight = -1;
}
maxmin = 608; maxmin = 608;
} }

View File

@ -172,20 +172,6 @@ bool IsGLExt(const char* szTargetExtension)
return mapGLExtensions.find(string(szTargetExtension)) != mapGLExtensions.end(); return mapGLExtensions.find(string(szTargetExtension)) != mapGLExtensions.end();
} }
inline bool Create_Window(int _width, int _height)
{
nBackbufferWidth = _width;
nBackbufferHeight = _height;
if (!GLWin.DisplayWindow(_width, _height)) return false;
//s_nFullscreen = (conf.fullscreen()) ? 1 : 0;
conf.mrtdepth = 0; // for now
return true;
}
// Function asks about different OGL extensions, that are required to setup accordingly. Return false if checks failed // Function asks about different OGL extensions, that are required to setup accordingly. Return false if checks failed
inline bool CreateImportantCheck() inline bool CreateImportantCheck()
{ {
@ -453,7 +439,13 @@ bool ZZCreate(int _width, int _height)
ZZDestroy(); ZZDestroy();
ZZGSStateReset(); ZZGSStateReset();
if (!Create_Window(_width, _height)) return false; nBackbufferWidth = _width;
nBackbufferHeight = _height;
if (!GLWin.DisplayWindow(_width, _height)) return false;
conf.mrtdepth = 0; // for now
if (!CreateFillExtensionsMap()) return false; if (!CreateFillExtensionsMap()) return false;
if (!CreateImportantCheck()) return false; if (!CreateImportantCheck()) return false;

View File

@ -159,7 +159,6 @@ void SetChangeDeviceSize(int nNewWidth, int nNewHeight)
void ChangeDeviceSize(int nNewWidth, int nNewHeight) void ChangeDeviceSize(int nNewWidth, int nNewHeight)
{ {
FUNCLOG FUNCLOG
//int oldscreen = s_nFullscreen;
int oldwidth = nBackbufferWidth, oldheight = nBackbufferHeight; int oldwidth = nBackbufferWidth, oldheight = nBackbufferHeight;