mirror of https://github.com/PCSX2/pcsx2.git
GregMiscellaneous: zzogl-pg: Rework CreateFillExtensionsMap to be less depreciated (and so it writes the extension list to the log, but doesn't print it except in debug mode). Fix a few minor potential bugs. Other minor changes.
git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@4011 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
3aabab685a
commit
0779f7bc32
|
@ -51,6 +51,8 @@ class GLWindow
|
|||
u32 width, height, depth;
|
||||
|
||||
public:
|
||||
char title[256];
|
||||
|
||||
void SwapGLBuffers();
|
||||
bool ReleaseContext();
|
||||
|
||||
|
|
|
@ -122,7 +122,11 @@ bool GLWindow::CreateWindow(void *pDisplay)
|
|||
hInstance, // Instance
|
||||
NULL); // Don't Pass Anything To WM_CREATE
|
||||
|
||||
if (GShwnd == NULL) return false;
|
||||
if (GShwnd == NULL)
|
||||
{
|
||||
ZZLog::Error_Log("Failed to create window. Exiting...");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pDisplay != NULL) *(HWND*)pDisplay = GShwnd;
|
||||
|
||||
|
@ -135,6 +139,7 @@ bool GLWindow::CreateWindow(void *pDisplay)
|
|||
|
||||
SetFocus(GShwnd);
|
||||
|
||||
if (pDisplay == NULL) ZZLog::Error_Log("Failed to create window. Exiting...");
|
||||
return (pDisplay != NULL);
|
||||
}
|
||||
|
||||
|
@ -195,6 +200,8 @@ bool GLWindow::DisplayWindow(int _width, int _height)
|
|||
{
|
||||
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
|
||||
dwStyle = WS_OVERLAPPEDWINDOW;
|
||||
nBackbufferWidth = _width;
|
||||
nBackbufferHeight = _height;
|
||||
}
|
||||
dwStyle |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
|
||||
|
||||
|
|
|
@ -34,7 +34,11 @@ bool GLWindow::CreateWindow(void *pDisplay)
|
|||
glDisplay = XOpenDisplay(0);
|
||||
glScreen = DefaultScreen(glDisplay);
|
||||
|
||||
if (pDisplay == NULL) return false;
|
||||
if (pDisplay == NULL)
|
||||
{
|
||||
ZZLog::Error_Log("Failed to create window. Exiting...");
|
||||
return false;
|
||||
}
|
||||
|
||||
*(Display**)pDisplay = glDisplay;
|
||||
|
||||
|
@ -251,6 +255,9 @@ void GLWindow::ToggleFullscreen()
|
|||
|
||||
bool GLWindow::DisplayWindow(int _width, int _height)
|
||||
{
|
||||
nBackbufferWidth = _width;
|
||||
nBackbufferHeight = _height;
|
||||
|
||||
if (!CreateVisual()) return false;
|
||||
|
||||
/* create a GLX context */
|
||||
|
|
|
@ -34,7 +34,6 @@ extern void SaveSnapshot(const char* filename);
|
|||
GLWindow GLWin;
|
||||
GSinternal gs;
|
||||
GSconf conf;
|
||||
char GStitle[256];
|
||||
|
||||
int ppf, g_GSMultiThreaded, CurrentSavestate = 0;
|
||||
int g_LastCRC = 0, g_TransferredToGPU = 0, s_frameskipping = 0;
|
||||
|
@ -269,22 +268,23 @@ s32 CALLBACK GSinit()
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef _DEBUG
|
||||
#if defined(_WIN32) && defined(_DEBUG)
|
||||
HANDLE g_hCurrentThread = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
extern LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
extern HINSTANCE hInst;
|
||||
#endif
|
||||
__forceinline void InitMisc()
|
||||
{
|
||||
WriteBilinear();
|
||||
WriteAA();
|
||||
InitProfile();
|
||||
InitPath();
|
||||
ResetRegs();
|
||||
}
|
||||
|
||||
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
|
||||
{
|
||||
FUNCLOG
|
||||
|
||||
bool err = false;
|
||||
g_GSMultiThreaded = multithread;
|
||||
|
||||
ZZLog::WriteLn("Calling GSopen.");
|
||||
|
@ -294,28 +294,16 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
|
|||
#endif
|
||||
|
||||
LoadConfig();
|
||||
strcpy(GStitle, Title);
|
||||
strcpy(GLWin.title, Title);
|
||||
|
||||
ZZLog::GS_Log("Using %s:%d.%d.%d.", libraryName, zgsrevision, zgsbuild, zgsminor);
|
||||
|
||||
err = GLWin.CreateWindow(pDsp);
|
||||
if (!err)
|
||||
{
|
||||
ZZLog::Error_Log("Failed to create window. Exiting...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ZZLog::WriteLn("Creating ZZOgl window.");
|
||||
|
||||
if (!ZZCreate(conf.width, conf.height)) return -1;
|
||||
if ((!GLWin.CreateWindow(pDsp)) || (!ZZCreate(conf.width, conf.height))) return -1;
|
||||
|
||||
ZZLog::WriteLn("Initialization successful.");
|
||||
|
||||
WriteBilinear();
|
||||
WriteAA();
|
||||
InitProfile();
|
||||
InitPath();
|
||||
ResetRegs();
|
||||
InitMisc();
|
||||
ZZLog::GS_Log("GSopen finished.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -336,26 +324,15 @@ s32 CALLBACK GSopen2( void* pDsp, INT32 flags )
|
|||
#endif
|
||||
|
||||
LoadConfig();
|
||||
strcpy(GStitle, Title);
|
||||
|
||||
err = GLWin.GetWindow(pDsp); // Needs to be added.
|
||||
if (!err)
|
||||
{
|
||||
ZZLog::Error_Log("Failed to acquire window. Exiting...");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ZZLog::GS_Log("Using %s:%d.%d.%d.", libraryName, zgsrevision, zgsbuild, zgsminor);
|
||||
|
||||
if (!ZZCreate2(conf.width, conf.height)) return -1; // Needs to be added.
|
||||
ZZLog::WriteLn("Capturing ZZOgl window.");
|
||||
if ((!GLWin.GetWindow(pDsp)) || (!ZZCreate2(conf.width, conf.height))) return -1;// Needs to be added.
|
||||
|
||||
ZZLog::WriteLn("Initialization successful.");
|
||||
|
||||
WriteBilinear();
|
||||
WriteAA();
|
||||
InitProfile();
|
||||
InitPath();
|
||||
ResetRegs();
|
||||
InitMisc();
|
||||
ZZLog::GS_Log("GSopen2 finished.");
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ void SaveConfig()
|
|||
|
||||
fprintf(f, "mrtdepth = %hhx\n", conf.mrtdepth);
|
||||
fprintf(f, "zzoptions = %x\n", conf.zz_options._u32);
|
||||
fprintf(f, "options = %x\n", conf.hacks);
|
||||
fprintf(f, "options = %x\n", conf.hacks._u32);
|
||||
fprintf(f, "bilinear = %hhx\n", conf.bilinear);
|
||||
fprintf(f, "aliasing = %hhx\n", conf.aa);
|
||||
fprintf(f, "width = %x\n", conf.width);
|
||||
|
|
|
@ -314,7 +314,7 @@ void Dev_Log(const char *fmt, ...)
|
|||
|
||||
void Debug_Log(const char *fmt, ...)
|
||||
{
|
||||
#if _DEBUG
|
||||
#ifdef _DEBUG
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
|
|
|
@ -126,7 +126,7 @@ void (APIENTRY *zgsBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum) = NULL;
|
|||
extern u8* s_lpShaderResources;
|
||||
|
||||
// String's for shader file in developer mode
|
||||
#ifdef DEVBUILD
|
||||
#ifdef ZEROGS_DEVBUILD
|
||||
char* EFFECT_NAME = "";
|
||||
char* EFFECT_DIR = "";
|
||||
#endif
|
||||
|
@ -277,18 +277,21 @@ inline void CreateOtherCheck()
|
|||
#endif
|
||||
}
|
||||
|
||||
// open shader file according to build target
|
||||
|
||||
inline bool CreateOpenShadersFile()
|
||||
#ifdef _WIN32
|
||||
__forceinline bool LoadShadersFromRes()
|
||||
{
|
||||
#ifndef DEVBUILD
|
||||
# ifdef _WIN32
|
||||
HRSRC hShaderSrc = FindResource(hInst, MAKEINTRESOURCE(IDR_SHADERS), RT_RCDATA);
|
||||
assert(hShaderSrc != NULL);
|
||||
HGLOBAL hShaderGlob = LoadResource(hInst, hShaderSrc);
|
||||
assert(hShaderGlob != NULL);
|
||||
s_lpShaderResources = (u8*)LockResource(hShaderGlob);
|
||||
# else // not _WIN32
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
|
||||
__forceinline bool LoadShadersFromDat()
|
||||
{
|
||||
FILE* fres = fopen("ps2hw.dat", "rb");
|
||||
|
||||
if (fres == NULL)
|
||||
|
@ -309,9 +312,12 @@ inline bool CreateOpenShadersFile()
|
|||
fseek(fres, 0, SEEK_SET);
|
||||
fread(s_lpShaderResources, s, 1, fres);
|
||||
s_lpShaderResources[s] = 0;
|
||||
# endif // _WIN32
|
||||
#else // defined(ZEROGS_DEVBUILD)
|
||||
# ifndef _WIN32 // NOT WINDOWS
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
__forceinline bool LoadShadersFromFX()
|
||||
{
|
||||
// test if ps2hw.fx exists
|
||||
char tempstr[255];
|
||||
char curwd[255];
|
||||
|
@ -339,58 +345,55 @@ inline bool CreateOpenShadersFile()
|
|||
|
||||
sprintf(EFFECT_DIR, "%s/%s", curwd, tempstr);
|
||||
sprintf(EFFECT_NAME, "%sps2hw.fx", EFFECT_DIR);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// open shader file according to build target
|
||||
|
||||
inline bool CreateOpenShadersFile()
|
||||
{
|
||||
#ifndef DEVBUILD
|
||||
# ifdef _WIN32
|
||||
return LoadShadersFromRes();
|
||||
# else // not _WIN32
|
||||
return LoadShadersFromDat();
|
||||
# endif // _WIN32
|
||||
#else // defined(ZEROGS_DEVBUILD)
|
||||
# ifndef _WIN32 // NOT WINDOWS
|
||||
return LoadShadersFromFX();
|
||||
|
||||
// No else clause?
|
||||
#endif
|
||||
#endif // !defined(ZEROGS_DEVBUILD)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Read all extensions name and fill mapGLExtensions
|
||||
inline bool CreateFillExtensionsMap()
|
||||
{
|
||||
// fill the opengl extension map
|
||||
const char* ptoken = (const char*)glGetString(GL_EXTENSIONS);
|
||||
int max_ext = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);
|
||||
|
||||
if (ptoken == NULL) return false;
|
||||
PFNGLGETSTRINGIPROC glGetStringi = 0;
|
||||
glGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi");
|
||||
|
||||
int prevlog = conf.log;
|
||||
|
||||
conf.log = 1;
|
||||
|
||||
ZZLog::GS_Log("Supported OpenGL Extensions:\n%s\n", ptoken); // write to the log file
|
||||
|
||||
// Probably a better way to do it, but seems to crash.
|
||||
/*int n;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
ZZLog::GS_Log("Supported OpenGL Extensions:\n");
|
||||
for (int i = 0; i < n; i++)
|
||||
string temp("");
|
||||
for (GLint i = 0; i < max_ext; i++)
|
||||
{
|
||||
ZZLog::GS_Log("%s/n", (const char*)glGetStringi(GL_EXTENSIONS, i));
|
||||
}*/
|
||||
string extension((const char*)glGetStringi(GL_EXTENSIONS, i));
|
||||
mapGLExtensions[extension];
|
||||
|
||||
conf.log = prevlog;
|
||||
|
||||
// insert all exts into mapGLExtensions
|
||||
|
||||
const char* pend = NULL;
|
||||
|
||||
while (ptoken != NULL)
|
||||
{
|
||||
pend = strchr(ptoken, ' ');
|
||||
|
||||
if (pend != NULL)
|
||||
{
|
||||
mapGLExtensions[string(ptoken, pend-ptoken)];
|
||||
}
|
||||
else
|
||||
{
|
||||
mapGLExtensions[string(ptoken)];
|
||||
break;
|
||||
temp = temp + extension;
|
||||
if (i != (max_ext - 1)) temp += ", ";
|
||||
}
|
||||
|
||||
ptoken = pend;
|
||||
|
||||
while (*ptoken == ' ') ++ptoken;
|
||||
}
|
||||
// Write the extension list to the log, but only write it to the screen on a debug build.
|
||||
#ifndef _DEBUG
|
||||
ZZLog::Log("%d supported OpenGL Extensions: %s\n", max_ext, temp.c_str());
|
||||
#endif
|
||||
ZZLog::Debug_Log("%d supported OpenGL Extensions: %s\n", max_ext, temp.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -434,14 +437,10 @@ bool ZZCreate(int _width, int _height)
|
|||
{
|
||||
GLenum err = GL_NO_ERROR;
|
||||
bool bSuccess = true;
|
||||
int i;
|
||||
|
||||
ZZDestroy();
|
||||
ZZGSStateReset();
|
||||
|
||||
nBackbufferWidth = _width;
|
||||
nBackbufferHeight = _height;
|
||||
|
||||
if (!GLWin.DisplayWindow(_width, _height)) return false;
|
||||
|
||||
conf.mrtdepth = 0; // for now
|
||||
|
@ -560,7 +559,7 @@ bool ZZCreate(int _width, int _height)
|
|||
g_vboBuffers.resize(VB_NUMBUFFERS);
|
||||
glGenBuffers((GLsizei)g_vboBuffers.size(), &g_vboBuffers[0]);
|
||||
|
||||
for (i = 0; i < (int)g_vboBuffers.size(); ++i)
|
||||
for (int i = 0; i < (int)g_vboBuffers.size(); ++i)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, g_vboBuffers[i]);
|
||||
glBufferData(GL_ARRAY_BUFFER, 0x100*sizeof(VertexGPU), NULL, GL_STREAM_DRAW);
|
||||
|
@ -676,7 +675,7 @@ bool ZZCreate(int _width, int _height)
|
|||
|
||||
vector<u32> conv16to32data(256*256);
|
||||
|
||||
for (i = 0; i < 256*256; ++i)
|
||||
for (int i = 0; i < 256*256; ++i)
|
||||
{
|
||||
u32 tempcol = RGBA16to32(i);
|
||||
// have to flip r and b
|
||||
|
@ -700,7 +699,7 @@ bool ZZCreate(int _width, int _height)
|
|||
|
||||
u32* dst = &conv32to16data[0];
|
||||
|
||||
for (i = 0; i < 32; ++i)
|
||||
for (int i = 0; i < 32; ++i)
|
||||
{
|
||||
for (int j = 0; j < 32; ++j)
|
||||
{
|
||||
|
|
|
@ -166,7 +166,7 @@ void ChangeDeviceSize(int nNewWidth, int nNewHeight)
|
|||
{
|
||||
ZZLog::Error_Log("Failed to recreate, changing to old device.");
|
||||
|
||||
if (ZZCreate(oldwidth, oldheight))
|
||||
if (!ZZCreate(oldwidth, oldheight))
|
||||
{
|
||||
SysMessage("Failed to create device, exiting...");
|
||||
exit(0);
|
||||
|
|
Loading…
Reference in New Issue