zzogl-pg: Move the logging code to its own file.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3366 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-07-02 09:32:04 +00:00
parent d4fdb08049
commit cab7a894e4
8 changed files with 466 additions and 393 deletions

View File

@ -147,7 +147,7 @@ void Panels::FramelimiterPanel::Apply()
throw Exception::CannotApplySettings( this ) throw Exception::CannotApplySettings( this )
.SetDiagMsg(wxsFormat( .SetDiagMsg(wxsFormat(
L"Error while parsing either NTSC or PAL framerate settings.\n\tNTSC Input = %s\n\tPAL Input = %s", L"Error while parsing either NTSC or PAL framerate settings.\n\tNTSC Input = %s\n\tPAL Input = %s",
m_text_BaseNtsc->GetValue(), m_text_BasePal->GetValue() m_text_BaseNtsc->GetValue().c_str(), m_text_BasePal->GetValue().c_str()
) ) ) )
.SetUserMsg(_("Error while parsing either NTSC or PAL framerate settings. Settings must be valid floating point numerics.")); .SetUserMsg(_("Error while parsing either NTSC or PAL framerate settings. Settings must be valid floating point numerics."));
} }

View File

@ -83,7 +83,8 @@ set(zzoglSources
ZZoglSave.cpp ZZoglSave.cpp
ZZoglShaders.cpp ZZoglShaders.cpp
ZZoglShoots.cpp ZZoglShoots.cpp
ZZoglVB.cpp) ZZoglVB.cpp
ZZLog.cpp)
# zzogl headers # zzogl headers
set(zzoglHeaders set(zzoglHeaders
@ -104,7 +105,8 @@ set(zzoglHeaders
zerogs.h zerogs.h
zerogsmath.h zerogsmath.h
zpipe.h zpipe.h
ZZoglCRTC.h) ZZoglCRTC.h
ZZLog.h)
# zzogl S sources # zzogl S sources
set(zzoglSSources set(zzoglSSources

View File

@ -49,10 +49,10 @@ using namespace std;
GSinternal gs; GSinternal gs;
char GStitle[256]; char GStitle[256];
extern FILE *gsLog;
GSconf conf; GSconf conf;
int ppf; int ppf;
primInfo *prim; primInfo *prim;
FILE *gsLog;
int g_GSMultiThreaded = 0; int g_GSMultiThreaded = 0;
void (*GSirq)(); void (*GSirq)();
u8* g_pBasePS2Mem = NULL; u8* g_pBasePS2Mem = NULL;
@ -115,243 +115,6 @@ HWND GShwnd = NULL;
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;
namespace ZZLog
{
bool IsLogging()
{
// gsLog can be null if the config dialog is used prior to Pcsx2 starting an emulation session.
// (GSinit won't have been called then)
return (gsLog != NULL && conf.log);
}
bool OpenLog() {
bool result = true;
const std::string LogFile(s_strLogPath + "GSzzogl.log");
gsLog = fopen(LogFile.c_str(), "w");
if (gsLog != NULL)
setvbuf(gsLog, NULL, _IONBF, 0);
else {
SysMessage("Can't create log file %s\n", LogFile.c_str());
result = false;
}
return result;
}
void WriteToScreen(const char* pstr, u32 ms)
{
ZeroGS::AddMessage(pstr, ms);
}
void _Message(const char *str)
{
SysMessage(str);
}
void _Log(const char *str)
{
if (IsLogging()) fprintf(gsLog, str);
}
void _WriteToConsole(const char *str)
{
fprintf(stderr,"ZZogl-PG: %s", str);
}
void _Print(const char *str)
{
fprintf(stderr,"ZZogl-PG: %s", str);
if (IsLogging()) fprintf(gsLog, str);
}
void Message(const char *fmt, ...)
{
va_list list;
char tmp[512];
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
SysMessage(tmp);
}
void Log(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
va_end(list);
}
void WriteToConsole(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
va_end(list);
}
void Print(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
va_end(list);
}
void WriteLn(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
va_end(list);
fprintf(stderr,"\n");
}
void Greg_Log(const char *fmt, ...)
{
// Not currently used
#if 0
va_list list;
char tmp[512];
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
va_end(list);
#endif
}
void Prim_Log(const char *fmt, ...)
{
#if defined(ZEROGS_DEVBUILD) && defined(WRITE_PRIM_LOGS)
va_list list;
char tmp[512];
va_start(list, fmt);
if (conf.log /*& 0x00000010*/)
{
if (IsLogging()) vfprintf(gsLog, fmt, list);
fprintf(stderr, "ZZogl-PG(PRIM): ");
vfprintf(stderr, fmt, list);
vprintf(fmt, list);
}
va_end(list);
fprintf(stderr,"\n");
#endif
}
void GS_Log(const char *fmt, ...)
{
#ifdef ZEROGS_DEVBUILD
va_list list;
va_start(list, fmt);
if (IsLogging())
{
vfprintf(gsLog, fmt, list);
fprintf(gsLog, "\n");
}
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
va_end(list);
#endif
}
void Warn_Log(const char *fmt, ...)
{
#ifdef ZEROGS_DEVBUILD
va_list list;
va_start(list, fmt);
if (IsLogging())
{
vfprintf(gsLog, fmt, list);
fprintf(gsLog, "\n");
}
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
va_end(list);
#endif
}
void Debug_Log(const char *fmt, ...)
{
#if _DEBUG
va_list list;
va_start(list, fmt);
if (IsLogging())
{
vfprintf(gsLog, fmt, list);
fprintf(gsLog, "\n");
}
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
va_end(list);
#endif
}
void Error_Log(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging())
{
vfprintf(gsLog, fmt, list);
fprintf(gsLog, "\n");
}
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
va_end(list);
}
};
void CALLBACK GSsetBaseMem(void* pmem) void CALLBACK GSsetBaseMem(void* pmem)
{ {
g_pBasePS2Mem = (u8*)pmem; g_pBasePS2Mem = (u8*)pmem;

View File

@ -44,6 +44,7 @@ extern HWND GShwnd;
#define GSdefs #define GSdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "CRC.h" #include "CRC.h"
#include "ZZLog.h"
// need C definitions -- no mangling please! // need C definitions -- no mangling please!
extern "C" u32 CALLBACK PS2EgetLibType(void); extern "C" u32 CALLBACK PS2EgetLibType(void);
@ -246,158 +247,6 @@ typedef struct
} GSconf; } GSconf;
//Logging for errors that are called often should have a time counter.
#ifdef __LINUX__
static u32 __attribute__((unused)) lasttime = 0;
static u32 __attribute__((unused)) BigTime = 5000;
static bool __attribute__((unused)) SPAM_PASS;
#else
static u32 lasttime = 0;
static u32 BigTime = 5000;
static bool SPAM_PASS;
#endif
#define ERROR_LOG_SPAM(text) { \
if( timeGetTime() - lasttime > BigTime ) { \
ZZLog::Error_Log(text); \
lasttime = timeGetTime(); \
} \
}
// The same macro with one-argument substitution.
#define ERROR_LOG_SPAMA(fmt, value) { \
if( timeGetTime() - lasttime > BigTime ) { \
ZZLog::Error_Log(fmt, value); \
lasttime = timeGetTime(); \
} \
}
#define ERROR_LOG_SPAM_TEST(text) {\
if( timeGetTime() - lasttime > BigTime ) { \
ZZLog::Error_Log(text); \
lasttime = timeGetTime(); \
SPAM_PASS = true; \
} \
else \
SPAM_PASS = false; \
}
#if DEBUG_PROF
#define FILE_IS_IN_CHECK ((strcmp(__FILE__, "targets.cpp") == 0) || (strcmp(__FILE__, "ZZoglFlush.cpp") == 0))
#define FUNCLOG {\
static bool Was_Here = false; \
static unsigned long int waslasttime = 0; \
if (!Was_Here && FILE_IS_IN_CHECK) { \
Was_Here = true;\
ZZLog::Error_Log("%s:%d %s", __FILE__, __LINE__, __func__); \
waslasttime = timeGetTime(); \
} \
if (FILE_IS_IN_CHECK && (timeGetTime() - waslasttime > BigTime )) { \
Was_Here = false; \
} \
}
#else
#define FUNCLOG
#endif
//#define WRITE_PRIM_LOGS
#if defined(_DEBUG) && !defined(ZEROGS_DEVBUILD)
#define ZEROGS_DEVBUILD
#endif
#ifdef ZEROGS_DEVBUILD
//#define DEVBUILD
#endif
// sends a message to output window if assert fails
#define BMSG(x, str) { if( !(x) ) { ZZLog::Log(str); ZZLog::Log(str); } }
#define BMSG_RETURN(x, str) { if( !(x) ) { ZZLog::Log(str); ZZLog::Log(str); return; } }
#define BMSG_RETURNX(x, str, rtype) { if( !(x) ) { ZZLog::Log(str); ZZLog::Log(str); return (##rtype); } }
#define B(x) { if( !(x) ) { ZZLog::Log(_#x"\n"); ZZLog::Log(#x"\n"); } }
#define B_RETURN(x) { if( !(x) ) { ZZLog::Error_Log("%s:%d: %s", __FILE__, (u32)__LINE__, #x); return; } }
#define B_RETURNX(x, rtype) { if( !(x) ) { ZZLog::Error_Log("%s:%d: %s", __FILE__, (u32)__LINE__, #x); return (##rtype); } }
#define B_G(x, action) { if( !(x) ) { ZZLog::Error_Log("%s:%d: %s", __FILE__, (u32)__LINE__, #x); action; } }
#define GL_REPORT_ERROR() \
{ \
GLenum err = glGetError(); \
if( err != GL_NO_ERROR ) \
{ \
ZZLog::Error_Log("%s:%d: gl error %s(0x%x)", __FILE__, (int)__LINE__, error_name(err), err); \
ZeroGS::HandleGLError(); \
} \
}
#ifdef _DEBUG
# define GL_REPORT_ERRORD() \
{ \
GLenum err = glGetError(); \
if( err != GL_NO_ERROR ) \
{ \
ZZLog::Error_Log("%s:%d: gl error %s (0x%x)", __FILE__, (int)__LINE__, error_name(err), err); \
ZeroGS::HandleGLError(); \
} \
}
#else
# define GL_REPORT_ERRORD()
#endif
inline const char *error_name(int err)
{
switch (err)
{
case GL_NO_ERROR:
return "GL_NO_ERROR";
case GL_INVALID_ENUM:
return "GL_INVALID_ENUM";
case GL_INVALID_VALUE:
return "GL_INVALID_VALUE";
case GL_INVALID_OPERATION:
return "GL_INVALID_OPERATION";
case GL_STACK_OVERFLOW:
return "GL_STACK_OVERFLOW";
case GL_STACK_UNDERFLOW:
return "GL_STACK_UNDERFLOW";
case GL_OUT_OF_MEMORY:
return "GL_OUT_OF_MEMORY";
case GL_TABLE_TOO_LARGE:
return "GL_TABLE_TOO_LARGE";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "GL_INVALID_FRAMEBUFFER_OPERATION";
default:
return "Unknown GL error";
}
}
extern void __LogToConsole(const char *fmt, ...);
namespace ZZLog
{
extern void Message(const char *fmt, ...);
extern void Log(const char *fmt, ...);
extern void WriteToConsole(const char *fmt, ...);
extern void Print(const char *fmt, ...);
extern void WriteLn(const char *fmt, ...);
extern void Greg_Log(const char *fmt, ...);
extern void Prim_Log(const char *fmt, ...);
extern void GS_Log(const char *fmt, ...);
extern void Debug_Log(const char *fmt, ...);
extern void Warn_Log(const char *fmt, ...);
extern void Error_Log(const char *fmt, ...);
};
#define REG64(name) \ #define REG64(name) \
union name \ union name \

View File

@ -154,6 +154,7 @@
<ClCompile Include="..\x86.cpp" /> <ClCompile Include="..\x86.cpp" />
<ClCompile Include="..\zerogs.cpp" /> <ClCompile Include="..\zerogs.cpp" />
<ClCompile Include="..\zpipe.cpp" /> <ClCompile Include="..\zpipe.cpp" />
<ClCompile Include="..\ZZLog.cpp" />
<ClCompile Include="..\ZZoglCreate.cpp" /> <ClCompile Include="..\ZZoglCreate.cpp" />
<ClCompile Include="..\ZZoglCRTC.cpp" /> <ClCompile Include="..\ZZoglCRTC.cpp" />
<ClCompile Include="..\ZZoglFlush.cpp" /> <ClCompile Include="..\ZZoglFlush.cpp" />
@ -199,6 +200,7 @@
<ClInclude Include="..\targets.h" /> <ClInclude Include="..\targets.h" />
<ClInclude Include="Win32.h" /> <ClInclude Include="Win32.h" />
<ClInclude Include="..\x86.h" /> <ClInclude Include="..\x86.h" />
<ClInclude Include="..\ZZLog.h" />
<ClInclude Include="..\zerogs.h" /> <ClInclude Include="..\zerogs.h" />
<ClInclude Include="..\zerogsmath.h" /> <ClInclude Include="..\zerogsmath.h" />
</ItemGroup> </ItemGroup>

View File

@ -348,6 +348,10 @@
RelativePath="..\zpipe.cpp" RelativePath="..\zpipe.cpp"
> >
</File> </File>
<File
RelativePath="..\ZZLog.cpp"
>
</File>
<File <File
RelativePath="..\ZZoglCreate.cpp" RelativePath="..\ZZoglCreate.cpp"
> >
@ -453,6 +457,10 @@
RelativePath="..\x86.h" RelativePath="..\x86.h"
> >
</File> </File>
<File
RelativePath="..\ZZLog.h"
>
</File>
<File <File
RelativePath="..\zerogs.h" RelativePath="..\zerogs.h"
> >

View File

@ -0,0 +1,265 @@
/* 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 <stdio.h>
#include "ZZLog.h"
extern GSconf conf;
extern std::string s_strIniPath;
extern std::string s_strLogPath;
FILE *gsLog;
namespace ZZLog
{
bool IsLogging()
{
// gsLog can be null if the config dialog is used prior to Pcsx2 starting an emulation session.
// (GSinit won't have been called then)
return (gsLog != NULL && conf.log);
}
bool OpenLog()
{
bool result = true;
const std::string LogFile(s_strLogPath + "GSzzogl.log");
gsLog = fopen(LogFile.c_str(), "w");
if (gsLog != NULL)
setvbuf(gsLog, NULL, _IONBF, 0);
else
{
SysMessage("Can't create log file %s\n", LogFile.c_str());
result = false;
}
return result;
}
void WriteToScreen(const char* pstr, u32 ms)
{
ZeroGS::AddMessage(pstr, ms);
}
void _Message(const char *str)
{
SysMessage(str);
}
void _Log(const char *str)
{
if (IsLogging()) fprintf(gsLog, str);
}
void _WriteToConsole(const char *str)
{
fprintf(stderr,"ZZogl-PG: %s", str);
}
void _Print(const char *str)
{
fprintf(stderr,"ZZogl-PG: %s", str);
if (IsLogging()) fprintf(gsLog, str);
}
void Message(const char *fmt, ...)
{
va_list list;
char tmp[512];
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
SysMessage(tmp);
}
void Log(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
va_end(list);
}
void WriteToConsole(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
va_end(list);
}
void Print(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
va_end(list);
}
void WriteLn(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
va_end(list);
fprintf(stderr,"\n");
}
void Greg_Log(const char *fmt, ...)
{
// Not currently used
#if 0
va_list list;
char tmp[512];
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
va_end(list);
#endif
}
void Prim_Log(const char *fmt, ...)
{
#if defined(ZEROGS_DEVBUILD) && defined(WRITE_PRIM_LOGS)
va_list list;
char tmp[512];
va_start(list, fmt);
if (conf.log /*& 0x00000010*/)
{
if (IsLogging()) vfprintf(gsLog, fmt, list);
fprintf(stderr, "ZZogl-PG(PRIM): ");
vfprintf(stderr, fmt, list);
vprintf(fmt, list);
}
va_end(list);
fprintf(stderr,"\n");
#endif
}
void GS_Log(const char *fmt, ...)
{
#ifdef ZEROGS_DEVBUILD
va_list list;
va_start(list, fmt);
if (IsLogging())
{
vfprintf(gsLog, fmt, list);
fprintf(gsLog, "\n");
}
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
va_end(list);
#endif
}
void Warn_Log(const char *fmt, ...)
{
#ifdef ZEROGS_DEVBUILD
va_list list;
va_start(list, fmt);
if (IsLogging())
{
vfprintf(gsLog, fmt, list);
fprintf(gsLog, "\n");
}
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
va_end(list);
#endif
}
void Debug_Log(const char *fmt, ...)
{
#if _DEBUG
va_list list;
va_start(list, fmt);
if (IsLogging())
{
vfprintf(gsLog, fmt, list);
fprintf(gsLog, "\n");
}
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
va_end(list);
#endif
}
void Error_Log(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging())
{
vfprintf(gsLog, fmt, list);
fprintf(gsLog, "\n");
}
fprintf(stderr, "ZZogl-PG: ");
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
va_end(list);
}
};

View File

@ -0,0 +1,184 @@
/* 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
*/
#ifndef ZZLOG_H_INCLUDED
#define ZZLOG_H_INCLUDED
#include "Util.h"
//Logging for errors that are called often should have a time counter.
#ifdef __LINUX__
static u32 __attribute__((unused)) lasttime = 0;
static u32 __attribute__((unused)) BigTime = 5000;
static bool __attribute__((unused)) SPAM_PASS;
#else
static u32 lasttime = 0;
static u32 BigTime = 5000;
static bool SPAM_PASS;
#endif
#define ERROR_LOG_SPAM(text) { \
if( timeGetTime() - lasttime > BigTime ) { \
ZZLog::Error_Log(text); \
lasttime = timeGetTime(); \
} \
}
// The same macro with one-argument substitution.
#define ERROR_LOG_SPAMA(fmt, value) { \
if( timeGetTime() - lasttime > BigTime ) { \
ZZLog::Error_Log(fmt, value); \
lasttime = timeGetTime(); \
} \
}
#define ERROR_LOG_SPAM_TEST(text) {\
if( timeGetTime() - lasttime > BigTime ) { \
ZZLog::Error_Log(text); \
lasttime = timeGetTime(); \
SPAM_PASS = true; \
} \
else \
SPAM_PASS = false; \
}
#if DEBUG_PROF
#define FILE_IS_IN_CHECK ((strcmp(__FILE__, "targets.cpp") == 0) || (strcmp(__FILE__, "ZZoglFlush.cpp") == 0))
#define FUNCLOG {\
static bool Was_Here = false; \
static unsigned long int waslasttime = 0; \
if (!Was_Here && FILE_IS_IN_CHECK) { \
Was_Here = true;\
ZZLog::Error_Log("%s:%d %s", __FILE__, __LINE__, __func__); \
waslasttime = timeGetTime(); \
} \
if (FILE_IS_IN_CHECK && (timeGetTime() - waslasttime > BigTime )) { \
Was_Here = false; \
} \
}
#else
#define FUNCLOG
#endif
//#define WRITE_PRIM_LOGS
#if defined(_DEBUG) && !defined(ZEROGS_DEVBUILD)
#define ZEROGS_DEVBUILD
#endif
#ifdef ZEROGS_DEVBUILD
//#define DEVBUILD
#endif
// sends a message to output window if assert fails
#define BMSG(x, str) { if( !(x) ) { ZZLog::Log(str); ZZLog::Log(str); } }
#define BMSG_RETURN(x, str) { if( !(x) ) { ZZLog::Log(str); ZZLog::Log(str); return; } }
#define BMSG_RETURNX(x, str, rtype) { if( !(x) ) { ZZLog::Log(str); ZZLog::Log(str); return (##rtype); } }
#define B(x) { if( !(x) ) { ZZLog::Log(_#x"\n"); ZZLog::Log(#x"\n"); } }
#define B_RETURN(x) { if( !(x) ) { ZZLog::Error_Log("%s:%d: %s", __FILE__, (u32)__LINE__, #x); return; } }
#define B_RETURNX(x, rtype) { if( !(x) ) { ZZLog::Error_Log("%s:%d: %s", __FILE__, (u32)__LINE__, #x); return (##rtype); } }
#define B_G(x, action) { if( !(x) ) { ZZLog::Error_Log("%s:%d: %s", __FILE__, (u32)__LINE__, #x); action; } }
#define GL_REPORT_ERROR() \
{ \
GLenum err = glGetError(); \
if( err != GL_NO_ERROR ) \
{ \
ZZLog::Error_Log("%s:%d: gl error %s(0x%x)", __FILE__, (int)__LINE__, error_name(err), err); \
ZeroGS::HandleGLError(); \
} \
}
#ifdef _DEBUG
# define GL_REPORT_ERRORD() \
{ \
GLenum err = glGetError(); \
if( err != GL_NO_ERROR ) \
{ \
ZZLog::Error_Log("%s:%d: gl error %s (0x%x)", __FILE__, (int)__LINE__, error_name(err), err); \
ZeroGS::HandleGLError(); \
} \
}
#else
# define GL_REPORT_ERRORD()
#endif
inline const char *error_name(int err)
{
switch (err)
{
case GL_NO_ERROR:
return "GL_NO_ERROR";
case GL_INVALID_ENUM:
return "GL_INVALID_ENUM";
case GL_INVALID_VALUE:
return "GL_INVALID_VALUE";
case GL_INVALID_OPERATION:
return "GL_INVALID_OPERATION";
case GL_STACK_OVERFLOW:
return "GL_STACK_OVERFLOW";
case GL_STACK_UNDERFLOW:
return "GL_STACK_UNDERFLOW";
case GL_OUT_OF_MEMORY:
return "GL_OUT_OF_MEMORY";
case GL_TABLE_TOO_LARGE:
return "GL_TABLE_TOO_LARGE";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "GL_INVALID_FRAMEBUFFER_OPERATION";
default:
return "Unknown GL error";
}
}
extern void __LogToConsole(const char *fmt, ...);
namespace ZeroGS
{
extern void AddMessage(const char* pstr, u32 ms);
}
namespace ZZLog
{
extern bool IsLogging();
extern bool OpenLog();
extern void Message(const char *fmt, ...);
extern void Log(const char *fmt, ...);
extern void WriteToConsole(const char *fmt, ...);
extern void Print(const char *fmt, ...);
extern void WriteLn(const char *fmt, ...);
extern void Greg_Log(const char *fmt, ...);
extern void Prim_Log(const char *fmt, ...);
extern void GS_Log(const char *fmt, ...);
extern void Debug_Log(const char *fmt, ...);
extern void Warn_Log(const char *fmt, ...);
extern void Error_Log(const char *fmt, ...);
};
#endif // ZZLOG_H_INCLUDED