diff --git a/plugins/zzogl-pg/opengl/GLWin32.cpp b/plugins/zzogl-pg/opengl/GLWin32.cpp
index 6b7bf995a8..1e6e462fef 100644
--- a/plugins/zzogl-pg/opengl/GLWin32.cpp
+++ b/plugins/zzogl-pg/opengl/GLWin32.cpp
@@ -21,6 +21,9 @@
#ifdef GL_WIN32_WINDOW
+HDC hDC = NULL; // Private GDI Device Context
+HGLRC hRC = NULL; // Permanent Rendering Context
+
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int nWindowWidth = 0, nWindowHeight = 0;
diff --git a/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp b/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp
index ff8f004e54..2dd8d5f899 100644
--- a/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp
+++ b/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp
@@ -146,6 +146,7 @@
+
diff --git a/plugins/zzogl-pg/opengl/Regs.cpp b/plugins/zzogl-pg/opengl/Regs.cpp
index 4bb405841e..3d7e906ed1 100644
--- a/plugins/zzogl-pg/opengl/Regs.cpp
+++ b/plugins/zzogl-pg/opengl/Regs.cpp
@@ -215,8 +215,6 @@ void __fastcall GIFPackedRegHandlerNOP(u32* data)
FUNCLOG
}
-extern int g_PrevBitwiseTexX, g_PrevBitwiseTexY;
-
void tex0Write(int i, u32 *data)
{
FUNCLOG
diff --git a/plugins/zzogl-pg/opengl/ZZGl.h b/plugins/zzogl-pg/opengl/ZZGl.h
index 4eb205214d..95f3e08dfb 100644
--- a/plugins/zzogl-pg/opengl/ZZGl.h
+++ b/plugins/zzogl-pg/opengl/ZZGl.h
@@ -31,7 +31,9 @@ inline void* wglGetProcAddress(const char* x)
#include
#include
#include "zerogsmath.h"
+#include "ZeroGSShaders/zerogsshaders.h"
+extern u32 s_stencilfunc, s_stencilref, s_stencilmask;
// Defines
#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
@@ -59,9 +61,20 @@ inline void* wglGetProcAddress(const char* x)
glVertexPointer(4, GL_SHORT, sizeof(VertexGPU), (void*)0); \
}
+
+// global alpha blending settings
+extern GLenum g_internalFloatFmt;
+extern GLenum g_internalRGBAFloatFmt;
+extern GLenum g_internalRGBAFloat16Fmt;
+
+extern CGprogram g_vsprog, g_psprog;
+extern CGparameter g_vparamPosXY[2], g_fparamFogColor;
+
extern const char* ShaderCallerName;
extern const char* ShaderHandleName;
+extern const GLenum primtype[8];
+
inline void SetShaderCaller(const char* Name)
{
ShaderCallerName = Name;
@@ -202,6 +215,11 @@ struct FRAGMENTSHADER
}
};
+/////////////////////
+// graphics resources
+extern map mapGLExtensions;
+//extern map mapShaderResources;
+
struct VERTEXSHADER
{
VERTEXSHADER() : prog(0), sBitBltPos(0), sBitBltTex(0) {}
@@ -210,6 +228,12 @@ struct VERTEXSHADER
CGparameter sBitBltPos, sBitBltTex, fBitBltTrans; // vertex shader constants
};
+extern CGprofile cgvProf, cgfProf;
+extern CGprogram pvs[16];
+extern FRAGMENTSHADER ppsRegular[4], ppsTexture[NUM_SHADERS];
+extern FRAGMENTSHADER ppsCRTC[2], ppsCRTC24[2], ppsCRTCTarg[2];
+extern GLenum s_srcrgb, s_dstrgb, s_srcalpha, s_dstalpha; // set by zgsBlendFuncSeparateEXT
+
// GL prototypes
extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
diff --git a/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp b/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp
index 56a08f5404..7401aa1562 100644
--- a/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp
+++ b/plugins/zzogl-pg/opengl/ZZoglCRTC.cpp
@@ -34,12 +34,18 @@ bool g_bSaveFrame = 0; // saves the current psurfTarget
bool g_bSaveFinalFrame = 0; // saves the input to the CRTC
#endif // !defined(ZEROGS_DEVBUILD)
-
-bool g_bCRTCBilinear = true, g_bDisplayFPS = false;
+extern int maxmin;
+extern bool g_bCRTCBilinear;
+bool g_bDisplayFPS = false;
int g_nFrameRender = 10, g_nFramesSkipped = 0, s_nResolved = 0; // s_nResolved == number of targets resolved this frame
// Helper for skip frames.
int TimeLastSkip = 0;
+
+vector s_vecTempTextures; // temporary textures, released at the end of every frame
+
+// Snapshot variables.
extern bool g_bMakeSnapshot;
+extern string strSnapshot;
// Adjusts vertex shader BitBltPos vector v to preserve aspect ratio. It used to emulate 4:3 or 16:9.
void ZeroGS::AdjustTransToAspect(Vector& v)
@@ -656,6 +662,9 @@ inline void AfterRenderSwapBuffers()
// SnapeShoot helper
inline void AfterRenderMadeSnapshoot()
{
+
+ if (!g_bMakeSnapshot) return;
+
char str[64];
int left = 200, top = 15;
sprintf(str, "ZeroGS %d.%d.%d - %.1f fps %s", zgsrevision, zgsbuild, zgsminor, fFPS, s_frameskipping ? " - frameskipping" : "");
@@ -669,6 +678,8 @@ inline void AfterRenderMadeSnapshoot()
sprintf(str, "saved %s\n", strSnapshot.c_str());
AddMessage(str, 500);
}
+
+ g_bMakeSnapshot = false;
}
// If needed reset
@@ -728,8 +739,7 @@ inline void AfterRendererUnimportantJob()
g_bMakeSnapshot = false;
}
- if (s_avicapturing)
- CaptureFrame();
+ CaptureFrame();
AfterRenderCountStatistics();
diff --git a/plugins/zzogl-pg/opengl/ZZoglCRTC.h b/plugins/zzogl-pg/opengl/ZZoglCRTC.h
index 04630a5053..ac68f72539 100644
--- a/plugins/zzogl-pg/opengl/ZZoglCRTC.h
+++ b/plugins/zzogl-pg/opengl/ZZoglCRTC.h
@@ -35,11 +35,10 @@ extern int s_nResolveCounts[30]; // resolve counts for last 30 frames
static int s_nCurResolveIndex = 0;
extern int g_nDepthUsed; // ffx2 pal movies
-extern vector s_vecTempTextures; // temporary textures, released at the end of every frame
-
-
//------------------ Namespace
+extern u32 s_ptexInterlace; // holds interlace fields
+
namespace ZeroGS
{
extern int s_nNewWidth, s_nNewHeight;
diff --git a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp
index fd75980c12..f75bbf9bc7 100644
--- a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp
+++ b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp
@@ -140,7 +140,7 @@ void (APIENTRY *zgsBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum) = NULL;
// State parameters
float fiRendWidth, fiRendHeight;
-u8* s_lpShaderResources = NULL;
+extern u8* s_lpShaderResources;
CGprogram pvs[16] = {NULL};
// String's for shader file in developer mode
@@ -173,7 +173,7 @@ int g_nPixelShaderVer = 0; // default
RasterFont* font_p = NULL;
float g_fBlockMult = 1;
-int s_nFullscreen = 0;
+//int s_nFullscreen = 0;
u32 ptexBlocks = 0, ptexConv16to32 = 0; // holds information on block tiling
u32 ptexBilinearBlocks = 0;
@@ -199,7 +199,7 @@ ZeroGS::Create_Window(int _width, int _height)
if (!GLWin.DisplayWindow(_width, _height)) return false;
- s_nFullscreen = (conf.fullscreen()) ? 1 : 0;
+ //s_nFullscreen = (conf.fullscreen()) ? 1 : 0;
conf.mrtdepth = 0; // for now
@@ -899,13 +899,7 @@ bool ZeroGS::Create(int _width, int _height)
void ZeroGS::Destroy(bool bD3D)
{
- if (s_aviinit)
- {
- StopCapture();
- Stop_Avi();
- ZZLog::Error_Log("zerogs.avi stopped.");
- s_aviinit = 0;
- }
+ Delete_Avi_Capture();
g_MemTargs.Destroy();
diff --git a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp
index b77d5a05ba..3537f77777 100644
--- a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp
+++ b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp
@@ -118,6 +118,8 @@ void Draw(const VB& curvb)
//------------------ variables
extern bool g_bIsLost;
+extern int g_nDepthBias;
+extern float g_fBlockMult;
bool g_bUpdateStencil = 1;
u32 g_SaveFrameNum = 0; // ZZ
@@ -144,8 +146,8 @@ static const u32 g_dwZCmp[] = { GL_NEVER, GL_ALWAYS, GL_GEQUAL, GL_GREATER };
u32 s_ptexCurSet[2] = {0};
static u32 s_ptexNextSet[2] = {0}; // ZZ
-vector s_vecTempTextures; // temporary textures, released at the end of every frame
+extern vector s_vecTempTextures; // temporary textures, released at the end of every frame
extern bool s_bTexFlush;
bool s_bWriteDepth = false;
bool s_bDestAlphaTest = false;
@@ -188,6 +190,8 @@ static alphaInfo s_alphaInfo; // ZZ
extern u8* g_pbyGSClut;
extern int ppf;
+int s_nWireframeCount = 0;
+
//------------------ Namespace
namespace ZeroGS
diff --git a/plugins/zzogl-pg/opengl/ZZoglShaders.cpp b/plugins/zzogl-pg/opengl/ZZoglShaders.cpp
index 0e847799e8..38e5998e0e 100644
--- a/plugins/zzogl-pg/opengl/ZZoglShaders.cpp
+++ b/plugins/zzogl-pg/opengl/ZZoglShaders.cpp
@@ -41,6 +41,13 @@ FRAGMENTSHADER ppsBaseTexture, ppsConvert16to32, ppsConvert32to16;
const char* ShaderCallerName = "";
const char* ShaderHandleName = "";
+extern u32 ptexBlocks; // holds information on block tiling
+extern u32 ptexConv16to32;
+extern u32 ptexConv32to16;
+bool g_bCRTCBilinear = true;
+u8* s_lpShaderResources = NULL;
+map mapShaderResources;
+
//------------------ Code
// Error handler. Setup in ZZogl_Create once.
diff --git a/plugins/zzogl-pg/opengl/ZZoglShoots.cpp b/plugins/zzogl-pg/opengl/ZZoglShoots.cpp
index c906419bb3..0ff88eaaf3 100644
--- a/plugins/zzogl-pg/opengl/ZZoglShoots.cpp
+++ b/plugins/zzogl-pg/opengl/ZZoglShoots.cpp
@@ -31,8 +31,10 @@
#include "targets.h"
#include "Mem.h"
-
+// AVI Capture
+int s_avicapturing = 0;
bool g_bMakeSnapshot = false;
+
extern "C"
{
#ifdef _WIN32
@@ -58,6 +60,8 @@ extern "C"
int TexNumber = 0;
int s_aviinit = 0;
+string strSnapshot;
+
//------------------ Code
// Set variables need to made a snapshoot when it's possible
@@ -345,7 +349,7 @@ void ZeroGS::StopCapture()
// And capture frame does not work on linux.
void ZeroGS::CaptureFrame()
{
- assert(s_avicapturing && s_aviinit);
+ if ((!s_avicapturing) || (!s_aviinit)) return;
vector data(nBackbufferWidth*nBackbufferHeight);
glReadPixels(0, 0, nBackbufferWidth, nBackbufferHeight, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
@@ -635,3 +639,14 @@ void ZeroGS::Stop_Avi()
// Does not support yet
#endif
}
+
+void ZeroGS::Delete_Avi_Capture()
+{
+ if (s_aviinit)
+ {
+ StopCapture();
+ Stop_Avi();
+ ZZLog::Error_Log("zerogs.avi stopped.");
+ s_aviinit = 0;
+ }
+}
diff --git a/plugins/zzogl-pg/opengl/ZeroGSShaders/zerogsshaders.h b/plugins/zzogl-pg/opengl/ZeroGSShaders/zerogsshaders.h
index b5b0f75248..e429544950 100644
--- a/plugins/zzogl-pg/opengl/ZeroGSShaders/zerogsshaders.h
+++ b/plugins/zzogl-pg/opengl/ZeroGSShaders/zerogsshaders.h
@@ -5,6 +5,11 @@
#include
#include "PS2Edefs.h"
+#include
+#include
+
+using namespace std;
+
#define NUM_FILTERS 2 // texture filtering
#define NUM_TYPES 5 // types of texture read modes
#define NUM_TEXWRAPS 4 // texture wrapping
diff --git a/plugins/zzogl-pg/opengl/targets.cpp b/plugins/zzogl-pg/opengl/targets.cpp
index 5b318b91ef..7c79eec4dd 100644
--- a/plugins/zzogl-pg/opengl/targets.cpp
+++ b/plugins/zzogl-pg/opengl/targets.cpp
@@ -34,7 +34,6 @@ using namespace ZeroGS;
extern int g_TransferredToGPU;
extern bool g_bIsLost;
extern bool g_bUpdateStencil;
-extern u32 s_uFramebuffer;
#if !defined(ZEROGS_DEVBUILD)
# define INC_RESOLVE()
@@ -58,8 +57,6 @@ CMemoryTargetMngr g_MemTargs;
}
extern u32 s_ptexCurSet[2];
-extern u32 ptexBilinearBlocks;
-extern u32 ptexConv32to16;
bool g_bSaveZUpdate = 0;
int VALIDATE_THRESH = 8;
@@ -959,8 +956,6 @@ void ZeroGS::CDepthTarget::Resolve(int startrange, int endrange)
}
}
-extern int g_nDepthUpdateCount;
-
void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
{
FUNCLOG
diff --git a/plugins/zzogl-pg/opengl/zerogs.cpp b/plugins/zzogl-pg/opengl/zerogs.cpp
index 28a20961ca..0fdabeedc7 100644
--- a/plugins/zzogl-pg/opengl/zerogs.cpp
+++ b/plugins/zzogl-pg/opengl/zerogs.cpp
@@ -44,21 +44,15 @@ extern u32 g_nGenVars, g_nTexVars, g_nAlphaVars, g_nResolve;
extern char *libraryName;
extern int g_nFrame, g_nRealFrame;
+//extern int s_nFullscreen;
//-------------------------- Variables
-#ifdef _WIN32
-HDC hDC = NULL; // Private GDI Device Context
-HGLRC hRC = NULL; // Permanent Rendering Context
-#endif
+// Context is lost -- could not draw.
+// Setting this variable to true is also lost. Fixme.
+bool g_bIsLost = false;
-// This is always false? Fixme.
-bool g_bIsLost = false;
-
-string strSnapshot;
primInfo *prim;
CGprogram g_vsprog = 0, g_psprog = 0; // 2 -- ZZ
-// AVI Capture
-int s_avicapturing = 0;
inline u32 FtoDW(float f) { return (*((u32*)&f)); }
@@ -91,11 +85,8 @@ PFNGLDRAWBUFFERSPROC glDrawBuffers = NULL;
// graphics resources
CGparameter g_vparamPosXY[2] = {0}, g_fparamFogColor = 0;
-map mapShaderResources;
-
bool s_bTexFlush = false;
int s_nLastResolveReset = 0;
-int s_nWireframeCount = 0;
int s_nResolveCounts[30] = {0}; // resolve counts for last 30 frames
////////////////////
@@ -354,6 +345,7 @@ void ZeroGS::AddMessage(const char* pstr, u32 ms)
ZZLog::Log("%s\n", pstr);
}
+extern RasterFont* font_p;
void ZeroGS::DrawText(const char* pstr, int left, int top, u32 color)
{
FUNCLOG
@@ -1132,7 +1124,7 @@ bool ZeroGS::CheckChangeInClut(u32 highdword, u32 psm)
void ZeroGS::texClutWrite(int ctx)
{
FUNCLOG
- s_bTexFlush = 0;
+ s_bTexFlush = false;
if (g_bIsLost) return;
diff --git a/plugins/zzogl-pg/opengl/zerogs.h b/plugins/zzogl-pg/opengl/zerogs.h
index 7fb0ccc8d8..b593fa39d1 100644
--- a/plugins/zzogl-pg/opengl/zerogs.h
+++ b/plugins/zzogl-pg/opengl/zerogs.h
@@ -85,92 +85,34 @@ extern float g_fiGPU_TEXWIDTH;
#define MASKDIVISOR 0
#define GPU_TEXMASKWIDTH (1024 >> MASKDIVISOR) // bitwise mask width for region repeat mode
-#ifdef _WIN32
-extern HDC hDC; // Private GDI Device Context
-extern HGLRC hRC; // Permanent Rendering Context
-#endif
-
-extern bool g_bIsLost; // Context is lost -- could not draw
-
-extern u32 ptexBlocks; // holds information on block tiling
-extern u32 ptexConv16to32;
extern u32 ptexBilinearBlocks;
-extern u32 ptexConv32to16;
-extern int g_MaxTexWidth, g_MaxTexHeight;
-extern float g_fBlockMult;
-extern bool g_bDisplayMsg;
-extern bool g_bDisplayFPS;
-extern int g_nDepthBias;
-extern u32 g_bSaveFlushedFrame; // this is currently *not* used as a bool, in spite of its moniker --air
-extern u8* s_lpShaderResources;
-extern u32 g_SaveFrameNum;
-extern int s_nWriteDepthCount;
-extern int s_nWireframeCount;
-extern int s_nWriteDestAlphaTest;
+// this is currently *not* used as a bool, in spite of its moniker --air
+// Actually, the only thing written to it is 1 or 0, which makes the (g_bSaveFlushedFrame & 0x80000000) check rather bizzare.
+extern u32 g_bSaveFlushedFrame;
//////////////////////////
// State parameters
-extern float fiRendWidth, fiRendHeight;
-extern int g_PrevBitwiseTexX, g_PrevBitwiseTexY; // textures stored in SAMP_BITWISEANDX and SAMP_BITWISEANDY
-extern bool s_bDestAlphaTest;
-extern int s_ClutResolve;
-extern int s_nLastResolveReset;
-extern int g_nDepthUpdateCount;
-extern int s_nResolveCounts[30]; // resolve counts for last 30 frames
-extern int g_nDepthUsed; // ffx2 pal movies
-/////////////////////
-// graphics resources
-extern map mapGLExtensions;
-extern map mapShaderResources;
#ifdef DEVBUILD
extern char* EFFECT_NAME;
extern char* EFFECT_DIR;
extern u32 g_nGenVars, g_nTexVars, g_nAlphaVars, g_nResolve;
extern bool g_bSaveTrans, g_bUpdateEffect, g_bSaveTex, g_bSaveResolved;
-
#endif
-extern RasterFont* font_p;
extern u32 s_uFramebuffer;
-extern CGprofile cgvProf, cgfProf;
extern int g_nPixelShaderVer;
-extern CGprogram pvs[16];
-extern FRAGMENTSHADER ppsRegular[4], ppsTexture[NUM_SHADERS];
-extern FRAGMENTSHADER ppsCRTC[2], ppsCRTC24[2], ppsCRTCTarg[2];
-extern GLenum s_srcrgb, s_dstrgb, s_srcalpha, s_dstalpha; // set by zgsBlendFuncSeparateEXT
-extern u32 s_stencilfunc, s_stencilref, s_stencilmask;
-extern GLenum s_drawbuffers[];
-extern bool s_bTexFlush;
+
extern bool s_bWriteDepth;
-extern int maxmin;
-extern const GLenum primtype[8];
extern u32 ptexLogo;
extern int nLogoWidth, nLogoHeight;
-extern u32 s_ptexInterlace; // holds interlace fields
-extern int s_nFullscreen;
-
-extern vector s_vecTempTextures; // temporary textures, released at the end of every frame
-// global alpha blending settings
-extern GLenum g_internalFloatFmt;
-extern GLenum g_internalRGBAFloatFmt;
-extern GLenum g_internalRGBAFloat16Fmt;
-
-extern CGprogram g_vsprog, g_psprog;
-extern string strSnapshot;
-extern bool g_bCRTCBilinear;
-
-// AVI Capture
-extern int s_aviinit;
-extern int s_avicapturing;
-
extern int nBackbufferWidth, nBackbufferHeight;
+
extern u8* g_pbyGSMemory;
extern u8* g_pbyGSClut; // the temporary clut buffer
-extern CGparameter g_vparamPosXY[2], g_fparamFogColor;
namespace ZeroGS
{
@@ -584,6 +526,7 @@ bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int he
bool SaveJPEG(const char* filename, int width, int height, const void* pdata, int quality);
bool SaveTGA(const char* filename, int width, int height, void* pdata);
void Stop_Avi();
+void Delete_Avi_Capture();
// private methods
void FlushSysMem(const RECT* prc);