mirror of https://github.com/PCSX2/pcsx2.git
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:
parent
9f5abc9953
commit
3aabab685a
|
@ -63,6 +63,7 @@ class GLWindow
|
|||
bool DisplayWindow(int _width, int _height);
|
||||
void SetTitle(char *strtitle);
|
||||
void ResizeCheck();
|
||||
void ProcessEvents();
|
||||
};
|
||||
|
||||
|
||||
|
@ -70,5 +71,6 @@ extern GLWindow GLWin;
|
|||
extern void ChangeWindowSize(int nNewWidth, int nNewHeight);
|
||||
extern void SetChangeDeviceSize(int nNewWidth, int nNewHeight);
|
||||
extern int nBackbufferWidth, nBackbufferHeight;
|
||||
extern void OnFKey(int key, int shift);
|
||||
|
||||
#endif // GLWIN_H_INCLUDED
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#ifdef GL_WIN32_WINDOW
|
||||
|
||||
HWND GShwnd = NULL;
|
||||
HDC hDC = NULL; // Private GDI Device Context
|
||||
HGLRC hRC = NULL; // Permanent Rendering Context
|
||||
|
||||
|
@ -299,8 +300,10 @@ bool GLWindow::DisplayWindow(int _width, int _height)
|
|||
void GLWindow::SwapGLBuffers()
|
||||
{
|
||||
static u32 lastswaptime = 0;
|
||||
|
||||
if (glGetError() != GL_NO_ERROR) ZZLog::Debug_Log("glError before swap!");
|
||||
|
||||
SwapBuffers(hDC);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
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
|
||||
|
|
|
@ -300,8 +300,8 @@ bool GLWindow::DisplayWindow(int _width, int _height)
|
|||
|
||||
void GLWindow::SwapGLBuffers()
|
||||
{
|
||||
if (glGetError() != GL_NO_ERROR) ZZLog::Debug_Log("glError before swap!");
|
||||
glXSwapBuffers(glDisplay, glWindow);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void GLWindow::SetTitle(char *strtitle)
|
||||
|
@ -351,4 +351,32 @@ void GLWindow::ResizeCheck()
|
|||
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
|
||||
|
|
|
@ -16,28 +16,16 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include "Win32.h"
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include "Util.h"
|
||||
#include "GS.h"
|
||||
#include "Profile.h"
|
||||
#include "GLWin.h"
|
||||
#include "ZZoglFlushHack.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "GS.h"
|
||||
#include "Mem.h"
|
||||
#include "Regs.h"
|
||||
#include "Profile.h"
|
||||
#include "GLWin.h"
|
||||
|
||||
#include "targets.h"
|
||||
#include "ZZoglShaders.h"
|
||||
#include "ZZoglFlushHack.h"
|
||||
#include "ZZoglShoots.h"
|
||||
extern void SaveSnapshot(const char* filename);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4244)
|
||||
|
@ -45,8 +33,8 @@ using namespace std;
|
|||
|
||||
GLWindow GLWin;
|
||||
GSinternal gs;
|
||||
char GStitle[256];
|
||||
GSconf conf;
|
||||
char GStitle[256];
|
||||
|
||||
int ppf, g_GSMultiThreaded, CurrentSavestate = 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 void ProcessEvents();
|
||||
extern void WriteAA();
|
||||
extern void WriteBilinear();
|
||||
extern void ZZDestroy();
|
||||
|
@ -92,18 +79,11 @@ extern bool ZZCreate(int width, int height);
|
|||
extern void ZZGSStateReset();
|
||||
|
||||
// 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 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()
|
||||
{
|
||||
return PS2E_LT_GS;
|
||||
|
@ -304,20 +284,19 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
|
|||
{
|
||||
FUNCLOG
|
||||
|
||||
bool err;
|
||||
|
||||
bool err = false;
|
||||
g_GSMultiThreaded = multithread;
|
||||
|
||||
ZZLog::WriteLn("Calling GSopen.");
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _DEBUG
|
||||
#if defined(_WIN32) && defined(_DEBUG)
|
||||
g_hCurrentThread = GetCurrentThread();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
LoadConfig();
|
||||
strcpy(GStitle, Title);
|
||||
|
||||
ZZLog::GS_Log("Using %s:%d.%d.%d.", libraryName, zgsrevision, zgsbuild, zgsminor);
|
||||
|
||||
err = GLWin.CreateWindow(pDsp);
|
||||
if (!err)
|
||||
|
@ -326,7 +305,6 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
|
|||
return -1;
|
||||
}
|
||||
|
||||
ZZLog::GS_Log("Using %s:%d.%d.%d.", libraryName, zgsrevision, zgsbuild, zgsminor);
|
||||
ZZLog::WriteLn("Creating ZZOgl window.");
|
||||
|
||||
if (!ZZCreate(conf.width, conf.height)) return -1;
|
||||
|
@ -531,7 +509,7 @@ void CALLBACK GSvsync(int interlace)
|
|||
// !interlace? Hmmm... Fixme.
|
||||
RenderCRTC(!interlace);
|
||||
|
||||
ProcessEvents();
|
||||
GLWin.ProcessEvents();
|
||||
|
||||
if (--nToNextUpdate <= 0)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include "Utilities/RedtapeWindows.h"
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
@ -29,8 +30,6 @@
|
|||
#include <GL/glext.h>
|
||||
#include "glprocs.h"
|
||||
|
||||
extern HWND GShwnd;
|
||||
|
||||
#else // linux basic definitions
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
|
|
@ -30,8 +30,7 @@ extern char *libraryName;
|
|||
extern const unsigned char zgsversion;
|
||||
extern unsigned char zgsrevision, zgsbuild, zgsminor;
|
||||
|
||||
extern u32 THR_KeyEvent; // value for passing out key events between threads
|
||||
extern bool THR_bShift, SaveStateExists;
|
||||
extern bool SaveStateExists;
|
||||
|
||||
const char* s_aa[5] = { "AA none |", "AA 2x |", "AA 4x |", "AA 8x |", "AA 16x |" };
|
||||
const char* pbilinear[] = { "off", "normal", "forced" };
|
||||
|
@ -205,102 +204,3 @@ void WriteBilinear()
|
|||
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
|
||||
|
|
|
@ -647,7 +647,7 @@ void DrawText(const char* pstr, int left, int top, u32 color)
|
|||
}
|
||||
|
||||
// Put FPS counter on screen (not in window title)
|
||||
inline void AfterRenderDisplayFPS()
|
||||
inline void DisplayFPS()
|
||||
{
|
||||
char str[64];
|
||||
int left = 10, top = 15;
|
||||
|
@ -657,16 +657,8 @@ inline void AfterRenderDisplayFPS()
|
|||
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
|
||||
inline void AfterRenderMadeSnapshoot()
|
||||
inline void MakeSnapshot()
|
||||
{
|
||||
|
||||
if (!g_bMakeSnapshot) return;
|
||||
|
@ -685,7 +677,7 @@ inline void AfterRenderMadeSnapshoot()
|
|||
ZZAddMessage(str, 500);
|
||||
}
|
||||
|
||||
g_bMakeSnapshot = false;
|
||||
g_bMakeSnapshot = false;
|
||||
}
|
||||
|
||||
// call to destroy video resources
|
||||
|
@ -710,16 +702,8 @@ void ZZReset()
|
|||
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
|
||||
inline void AfterRenderCountStatistics()
|
||||
inline void CountStatistics()
|
||||
{
|
||||
if (s_nWriteDepthCount > 0)
|
||||
{
|
||||
|
@ -742,7 +726,6 @@ inline void AfterRenderCountStatistics()
|
|||
if (g_nDepthUsed > 0) --g_nDepthUsed;
|
||||
|
||||
s_ClutResolve = 0;
|
||||
|
||||
g_nDepthUpdateCount = 0;
|
||||
}
|
||||
|
||||
|
@ -751,27 +734,27 @@ inline void AfterRendererUnimportantJob()
|
|||
{
|
||||
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
|
||||
s_nWireframeCount = 1;
|
||||
}
|
||||
// clear all targets
|
||||
if (conf.wireframe()) s_nWireframeCount = 1;
|
||||
|
||||
if (g_bMakeSnapshot)
|
||||
{
|
||||
AfterRenderMadeSnapshoot();
|
||||
g_bMakeSnapshot = false;
|
||||
}
|
||||
if (g_bMakeSnapshot) MakeSnapshot();
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -172,20 +172,6 @@ bool IsGLExt(const char* szTargetExtension)
|
|||
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
|
||||
inline bool CreateImportantCheck()
|
||||
{
|
||||
|
@ -452,8 +438,14 @@ bool ZZCreate(int _width, int _height)
|
|||
|
||||
ZZDestroy();
|
||||
ZZGSStateReset();
|
||||
|
||||
nBackbufferWidth = _width;
|
||||
nBackbufferHeight = _height;
|
||||
|
||||
if (!GLWin.DisplayWindow(_width, _height)) return false;
|
||||
|
||||
conf.mrtdepth = 0; // for now
|
||||
|
||||
if (!Create_Window(_width, _height)) return false;
|
||||
if (!CreateFillExtensionsMap()) return false;
|
||||
if (!CreateImportantCheck()) return false;
|
||||
|
||||
|
|
|
@ -159,7 +159,6 @@ void SetChangeDeviceSize(int nNewWidth, int nNewHeight)
|
|||
void ChangeDeviceSize(int nNewWidth, int nNewHeight)
|
||||
{
|
||||
FUNCLOG
|
||||
//int oldscreen = s_nFullscreen;
|
||||
|
||||
int oldwidth = nBackbufferWidth, oldheight = nBackbufferHeight;
|
||||
|
||||
|
|
Loading…
Reference in New Issue