* Key buffer update : Add functions & clean the file
This commit is contained in:
jean.chalard
2008-11-21 14:13:01 +00:00
parent bd5df274e8
commit d7ea37233c
2 changed files with 727 additions and 707 deletions
+248 -228
View File
@@ -1,228 +1,248 @@
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// //
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // Licensed under the BSD license, see LICENSE in JGE root for details.
// //
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com> // Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#ifndef _JGE_H_ #ifndef _JGE_H_
#define _JGE_H_ #define _JGE_H_
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include "JTypes.h" #include "JTypes.h"
#define DEBUG_PRINT #define DEBUG_PRINT
//#define _MP3_ENABLED_ //#define _MP3_ENABLED_
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
void JGEControl(); void JGEControl();
BOOL JGEGetKeyState(int key); BOOL JGEGetKeyState(int key);
bool JGEGetButtonState(u32 button); bool JGEGetButtonState(u32 button);
bool JGEGetButtonClick(u32 button); bool JGEGetButtonClick(u32 button);
u32 JGEReadKey();
#elif LINUX void JGEResetInput();
void JGEControl(); #elif LINUX
BOOL JGEGetKeyState(int key);
bool JGEGetButtonState(uint32_t button); void JGEControl();
bool JGEGetButtonClick(uint32_t button); BOOL JGEGetKeyState(int key);
bool JGEGetButtonState(u32 button);
#else bool JGEGetButtonClick(u32 button);
u32 JGEReadKey();
#include <pspgu.h> void JGEResetInput();
#include <pspkernel.h>
#include <pspdisplay.h> #else
#include <pspdebug.h>
#include <pspctrl.h> #include <pspgu.h>
#include <time.h> #include <pspkernel.h>
#include <string.h> #include <pspdisplay.h>
#include <pspaudiolib.h> #include <pspdebug.h>
#include <psprtc.h> #include <pspctrl.h>
#include <time.h>
#endif #include <string.h>
#include <pspaudiolib.h>
//#include "JGEInit.h" #include <psprtc.h>
//#include "JTypes.h" #endif
#include "Vector2D.h" //#include "JGEInit.h"
class JApp; //#include "JTypes.h"
class JResourceManager;
class JFileSystem; #include "Vector2D.h"
class JParticleSystem;
class JMotionSystem; class JApp;
class JMusic; class JResourceManager;
class JFileSystem;
////////////////////////////////////////////////////////////////////////// class JParticleSystem;
/// Game engine main interface. class JMotionSystem;
////////////////////////////////////////////////////////////////////////// class JMusic;
class JGE
{ //////////////////////////////////////////////////////////////////////////
private: /// Game engine main interface.
JApp *mApp; //////////////////////////////////////////////////////////////////////////
// JResourceManager *mResourceManager; class JGE
// JFileSystem* mFileSystem; {
private:
// JParticleSystem* mParticleSystem; JApp *mApp;
// JMotionSystem* mMotionSystem; // JResourceManager *mResourceManager;
// JFileSystem* mFileSystem;
#if defined (WIN32) || defined (LINUX) // JParticleSystem* mParticleSystem;
float mDeltaTime; // JMotionSystem* mMotionSystem;
JMusic *mCurrentMusic;
#if defined (WIN32) || defined (LINUX)
#else float mDeltaTime;
SceCtrlData mCtrlPad;
u32 mOldButtons; JMusic *mCurrentMusic;
u64 mLastTime; #else
u32 mTickFrequency; SceCtrlData mCtrlPad;
u32 mOldButtons;
#endif
u64 mLastTime;
bool mDone; u32 mTickFrequency;
float mDelta; #endif
bool mDebug; bool mDone;
bool mPaused; float mDelta;
char mDebuggingMsg[256]; bool mDebug;
bool mCriticalAssert; bool mPaused;
const char *mAssertFile;
int mAssertLine; char mDebuggingMsg[256];
bool mCriticalAssert;
static JGE* mInstance; const char *mAssertFile;
int mAssertLine;
public:
static JGE* mInstance;
//////////////////////////////////////////////////////////////////////////
/// Get JGE instance.
/// public:
/// @return JGE instance.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
static JGE* GetInstance(); /// Get JGE instance.
static void Destroy(); ///
/// @return JGE instance.
void Init(); //////////////////////////////////////////////////////////////////////////
void Run(); static JGE* GetInstance();
void End(); static void Destroy();
void Update(); void Init();
void Render(); void Run();
void End();
void Pause();
void Resume(); void Update();
void Render();
//////////////////////////////////////////////////////////////////////////
/// Return system timer in milliseconds. void Pause();
/// void Resume();
/// @return System time in milliseconds.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int GetTime(void); /// Return system timer in milliseconds.
///
////////////////////////////////////////////////////////////////////////// /// @return System time in milliseconds.
/// Return elapsed time since last frame update. //////////////////////////////////////////////////////////////////////////
/// int GetTime(void);
/// @return Elapsed time in seconds.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetDelta(); /// Return elapsed time since last frame update.
///
////////////////////////////////////////////////////////////////////////// /// @return Elapsed time in seconds.
/// Return frame rate. //////////////////////////////////////////////////////////////////////////
/// float GetDelta();
/// @note This is just 1.0f/GetDelat().
/// //////////////////////////////////////////////////////////////////////////
/// @return Number of frames per second. /// Return frame rate.
////////////////////////////////////////////////////////////////////////// ///
float GetFPS(); /// @note This is just 1.0f/GetDelat().
///
////////////////////////////////////////////////////////////////////////// /// @return Number of frames per second.
/// Check the current state of a button. //////////////////////////////////////////////////////////////////////////
/// float GetFPS();
/// @param button - Button id.
/// //////////////////////////////////////////////////////////////////////////
/// @return Button state. /// Check the current state of a button.
////////////////////////////////////////////////////////////////////////// ///
bool GetButtonState(u32 button); /// @param button - Button id.
///
////////////////////////////////////////////////////////////////////////// /// @return Button state.
/// Check if a button is down the first time. //////////////////////////////////////////////////////////////////////////
/// bool GetButtonState(u32 button);
/// @param button - Button id.
/// //////////////////////////////////////////////////////////////////////////
/// @return Button state. /// Check if a button is down the first time.
////////////////////////////////////////////////////////////////////////// ///
bool GetButtonClick(u32 button); /// @param button - Button id.
///
////////////////////////////////////////////////////////////////////////// /// @return Button state.
/// Get x value of the analog pad. //////////////////////////////////////////////////////////////////////////
/// bool GetButtonClick(u32 button);
/// @return X value (0 to 255).
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
u8 GetAnalogX(); /// Get the next keypress.
///
////////////////////////////////////////////////////////////////////////// /// @return Next pressed button, or 0 if none.
/// Get y value of the analog pad. //////////////////////////////////////////////////////////////////////////
/// u32 ReadButton();
/// @return Y value (0 to 255).
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
u8 GetAnalogY(); /// Reset the input buffer.
/// This is necessary because there might be phases when GetButtonState
/// or GetButtonClick are used, thereby accumulating keypresses in the
////////////////////////////////////////////////////////////////////////// /// key buffer.
/// Get if the system is ended or not. ///
/// //////////////////////////////////////////////////////////////////////////
/// @return Status of the system. void ResetInput();
//////////////////////////////////////////////////////////////////////////
bool IsDone() { return mDone; } //////////////////////////////////////////////////////////////////////////
/// Get x value of the analog pad.
///
////////////////////////////////////////////////////////////////////////// /// @return X value (0 to 255).
/// Set the user's core application class. //////////////////////////////////////////////////////////////////////////
/// u8 GetAnalogX();
/// @param app - User defined application class.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetApp(JApp *app); /// Get y value of the analog pad.
///
/// @return Y value (0 to 255).
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Print debug message. u8 GetAnalogY();
///
//////////////////////////////////////////////////////////////////////////
void printf(const char *format, ...); //////////////////////////////////////////////////////////////////////////
/// Get if the system is ended or not.
///
void Assert(const char *filename, long lineNumber); /// @return Status of the system.
//////////////////////////////////////////////////////////////////////////
#if defined (WIN32) || defined (LINUX) bool IsDone() { return mDone; }
void SetDelta(int delta);
#endif
//////////////////////////////////////////////////////////////////////////
protected: /// Set the user's core application class.
JGE(); ///
~JGE(); /// @param app - User defined application class.
//////////////////////////////////////////////////////////////////////////
void SetApp(JApp *app);
};
//////////////////////////////////////////////////////////////////////////
#endif /// Print debug message.
///
//////////////////////////////////////////////////////////////////////////
void printf(const char *format, ...);
void Assert(const char *filename, long lineNumber);
#if defined (WIN32) || defined (LINUX)
void SetDelta(int delta);
#endif
protected:
JGE();
~JGE();
};
#endif
+479 -479
View File
@@ -1,479 +1,479 @@
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
// //
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // Licensed under the BSD license, see LICENSE in JGE root for details.
// //
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com> // Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#include "../include/JGE.h" #include "../include/JGE.h"
#include "../include/JApp.h" #include "../include/JApp.h"
#include "../include/JRenderer.h" #include "../include/JRenderer.h"
#include "../include/JSoundSystem.h" #include "../include/JSoundSystem.h"
#include "../include/Vector2D.h" #include "../include/Vector2D.h"
#include "../include/JResourceManager.h" #include "../include/JResourceManager.h"
#include "../include/JFileSystem.h" #include "../include/JFileSystem.h"
//#include "../include/JParticleSystem.h" //#include "../include/JParticleSystem.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#if defined (WIN32) // WIN32 specific code #if defined (WIN32) // WIN32 specific code
#include "../../Dependencies/include/png.h" #include "../../Dependencies/include/png.h"
#include "../../Dependencies/include/fmod.h" #include "../../Dependencies/include/fmod.h"
int JGE::GetTime(void) int JGE::GetTime(void)
{ {
return (int)GetTickCount(); return (int)GetTickCount();
} }
u8 JGE::GetAnalogX() u8 JGE::GetAnalogX()
{ {
if (JGEGetKeyState(VK_LEFT)) return 0; if (JGEGetKeyState(VK_LEFT)) return 0;
if (JGEGetKeyState(VK_RIGHT)) return 0xff; if (JGEGetKeyState(VK_RIGHT)) return 0xff;
return 0x80; return 0x80;
} }
u8 JGE::GetAnalogY() u8 JGE::GetAnalogY()
{ {
if (JGEGetKeyState(VK_UP)) return 0; if (JGEGetKeyState(VK_UP)) return 0;
if (JGEGetKeyState(VK_DOWN)) return 0xff; if (JGEGetKeyState(VK_DOWN)) return 0xff;
return 0x80; return 0x80;
} }
#elif defined (LINUX) // Unix specific code #elif defined (LINUX) // Unix specific code
#include "png.h" #include "png.h"
#include "../Dependencies/include/fmod.h" #include "../Dependencies/include/fmod.h"
int JGE::GetTime(void) int JGE::GetTime(void)
{ {
return (int)time(NULL); return (int)time(NULL);
} }
u8 JGE::GetAnalogX() u8 JGE::GetAnalogX()
{ {
/* FIXME /* FIXME
if (JGEGetKeyState(VK_LEFT)) return 0; if (JGEGetKeyState(VK_LEFT)) return 0;
if (JGEGetKeyState(VK_RIGHT)) return 0xff; if (JGEGetKeyState(VK_RIGHT)) return 0xff;
*/ */
return 0x80; return 0x80;
} }
u8 JGE::GetAnalogY() u8 JGE::GetAnalogY()
{ {
/* FIXME /* FIXME
if (JGEGetKeyState(VK_UP)) return 0; if (JGEGetKeyState(VK_UP)) return 0;
if (JGEGetKeyState(VK_DOWN)) return 0xff; if (JGEGetKeyState(VK_DOWN)) return 0xff;
*/ */
return 0x80; return 0x80;
} }
#endif #endif
#if defined (WIN32) || defined (LINUX) // Non-PSP code #if defined (WIN32) || defined (LINUX) // Non-PSP code
JGE::JGE() JGE::JGE()
{ {
mApp = NULL; mApp = NULL;
strcpy(mDebuggingMsg, ""); strcpy(mDebuggingMsg, "");
mCurrentMusic = NULL; mCurrentMusic = NULL;
Init(); Init();
// mResourceManager = new JResourceManager(); // mResourceManager = new JResourceManager();
// mFileSystem = new JFileSystem(); // mFileSystem = new JFileSystem();
// mParticleSystem = NULL;//new JParticleSystem(500); // mParticleSystem = NULL;//new JParticleSystem(500);
// mMotionSystem = NULL;//new JMotionSystem(); // mMotionSystem = NULL;//new JMotionSystem();
} }
JGE::~JGE() JGE::~JGE()
{ {
JRenderer::Destroy(); JRenderer::Destroy();
JFileSystem::Destroy(); JFileSystem::Destroy();
JSoundSystem::Destroy(); JSoundSystem::Destroy();
//JParticleSystem::Destroy(); //JParticleSystem::Destroy();
//DestroyGfx(); //DestroyGfx();
//DestroySfx(); //DestroySfx();
// if (mResourceManager != NULL) // if (mResourceManager != NULL)
// delete mResourceManager; // delete mResourceManager;
// //
// if (mFileSystem != NULL) // if (mFileSystem != NULL)
// delete mFileSystem; // delete mFileSystem;
// //
// if (mParticleSystem != NULL) // if (mParticleSystem != NULL)
// delete mParticleSystem; // delete mParticleSystem;
// //
// if (mMotionSystem != NULL) // if (mMotionSystem != NULL)
// delete mMotionSystem; // delete mMotionSystem;
} }
void JGE::Init() void JGE::Init()
{ {
mDone = false; mDone = false;
mPaused = false; mPaused = false;
mCriticalAssert = false; mCriticalAssert = false;
JRenderer::GetInstance(); JRenderer::GetInstance();
JFileSystem::GetInstance(); JFileSystem::GetInstance();
JSoundSystem::GetInstance(); JSoundSystem::GetInstance();
//JParticleSystem::GetInstance(); //JParticleSystem::GetInstance();
//InitSfx(); //InitSfx();
} }
void JGE::Run() void JGE::Run()
{ {
} }
void JGE::SetDelta(int delta) void JGE::SetDelta(int delta)
{ {
mDeltaTime = (float)delta / 1000.0f; // change to second mDeltaTime = (float)delta / 1000.0f; // change to second
} }
float JGE::GetDelta() float JGE::GetDelta()
{ {
return mDeltaTime; return mDeltaTime;
//return hge->Timer_GetDelta()*1000; //return hge->Timer_GetDelta()*1000;
} }
float JGE::GetFPS() float JGE::GetFPS()
{ {
//return (float)hge->Timer_GetFPS(); //return (float)hge->Timer_GetFPS();
return 0.0f; return 0.0f;
} }
bool JGE::GetButtonState(u32 button) bool JGE::GetButtonState(u32 button)
{ {
//return (gButtons&button)==button; //return (gButtons&button)==button;
return JGEGetButtonState(button); return JGEGetButtonState(button);
} }
bool JGE::GetButtonClick(u32 button) bool JGE::GetButtonClick(u32 button)
{ {
//return (gButtons&button)==button && (gOldButtons&button)!=button; //return (gButtons&button)==button && (gOldButtons&button)!=button;
return JGEGetButtonClick(button); return JGEGetButtonClick(button);
} }
u32 JGE::ReadButton() u32 JGE::ReadButton()
{ {
return JGEReadKey(); return JGEReadKey();
} }
void JGE::ResetInput() void JGE::ResetInput()
{ {
JGEResetInput(); JGEResetInput();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#else ///// PSP specified code #else ///// PSP specified code
// include all the following so we only have one .o file // include all the following so we only have one .o file
//#include "../src/JGfx.cpp" //#include "../src/JGfx.cpp"
//#include "../src/JSfx.cpp" //#include "../src/JSfx.cpp"
JGE::JGE() JGE::JGE()
{ {
mApp = NULL; mApp = NULL;
Init(); Init();
// mResourceManager = new JResourceManager(); // mResourceManager = new JResourceManager();
// mFileSystem = new JFileSystem(); // mFileSystem = new JFileSystem();
// //
// mParticleSystem = new JParticleSystem(500); // mParticleSystem = new JParticleSystem(500);
// mMotionSystem = new JMotionSystem(); // mMotionSystem = new JMotionSystem();
} }
JGE::~JGE() JGE::~JGE()
{ {
JRenderer::Destroy(); JRenderer::Destroy();
JSoundSystem::Destroy(); JSoundSystem::Destroy();
JFileSystem::Destroy(); JFileSystem::Destroy();
//DestroyGfx(); //DestroyGfx();
//DestroySfx(); //DestroySfx();
// delete mResourceManager; // delete mResourceManager;
// delete mFileSystem; // delete mFileSystem;
// delete mParticleSystem; // delete mParticleSystem;
// delete mMotionSystem; // delete mMotionSystem;
// if (mApp != NULL) // if (mApp != NULL)
// { // {
// mApp->Destroy(); // mApp->Destroy();
// delete mApp; // delete mApp;
// mApp = NULL; // mApp = NULL;
// } // }
} }
void JGE::Init() void JGE::Init()
{ {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
mDebug = true; mDebug = true;
#else #else
mDebug = false; mDebug = false;
#endif #endif
if (mDebug) if (mDebug)
pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf
strcpy(mDebuggingMsg, ""); strcpy(mDebuggingMsg, "");
sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
JRenderer::GetInstance(); JRenderer::GetInstance();
JFileSystem::GetInstance(); JFileSystem::GetInstance();
JSoundSystem::GetInstance(); JSoundSystem::GetInstance();
mDone = false; mDone = false;
mPaused = false; mPaused = false;
mCriticalAssert = false; mCriticalAssert = false;
//InitSfx(); //InitSfx();
//Create(); //Create();
// mCurrMS = 1.0f; // mCurrMS = 1.0f;
// mFPSSlice = 0; // mFPSSlice = 0;
//struct timeval tp; //struct timeval tp;
//gettimeofday(&tp, NULL); //gettimeofday(&tp, NULL);
//mTimeBase = tp.tv_sec; //mTimeBase = tp.tv_sec;
//mLastTime = GetTime(); //mLastTime = GetTime();
mTickFrequency = sceRtcGetTickResolution(); mTickFrequency = sceRtcGetTickResolution();
sceRtcGetCurrentTick(&mLastTime); sceRtcGetCurrentTick(&mLastTime);
} }
// returns number of milliseconds since game started // returns number of milliseconds since game started
int JGE::GetTime(void) int JGE::GetTime(void)
{ {
u64 curr; u64 curr;
sceRtcGetCurrentTick(&curr); sceRtcGetCurrentTick(&curr);
return (int)(curr / mTickFrequency); return (int)(curr / mTickFrequency);
} }
float JGE::GetDelta() float JGE::GetDelta()
{ {
return mDelta; return mDelta;
} }
float JGE::GetFPS() float JGE::GetFPS()
{ {
return 1.0f / mDelta; return 1.0f / mDelta;
} }
bool JGE::GetButtonState(u32 button) bool JGE::GetButtonState(u32 button)
{ {
return (mCtrlPad.Buttons&button)==button; return (mCtrlPad.Buttons&button)==button;
} }
bool JGE::GetButtonClick(u32 button) bool JGE::GetButtonClick(u32 button)
{ {
return (mCtrlPad.Buttons&button)==button && (mOldButtons&button)!=button; return (mCtrlPad.Buttons&button)==button && (mOldButtons&button)!=button;
} }
u32 JGE::ReadButton() u32 JGE::ReadButton()
{ {
return 0; return 0;
} }
void JGE::ResetInput() void JGE::ResetInput()
{ {
} }
u8 JGE::GetAnalogX() u8 JGE::GetAnalogX()
{ {
return mCtrlPad.Lx; return mCtrlPad.Lx;
} }
u8 JGE::GetAnalogY() u8 JGE::GetAnalogY()
{ {
return mCtrlPad.Ly; return mCtrlPad.Ly;
} }
void JGE::Run() void JGE::Run()
{ {
u64 curr; u64 curr;
while (!mDone) while (!mDone)
{ {
if (!mPaused) if (!mPaused)
{ {
sceRtcGetCurrentTick(&curr); sceRtcGetCurrentTick(&curr);
mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f; mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f;
mLastTime = curr; mLastTime = curr;
sceCtrlPeekBufferPositive(&mCtrlPad, 1); // using sceCtrlPeekBufferPositive is faster than sceCtrlReadBufferPositive sceCtrlPeekBufferPositive(&mCtrlPad, 1); // using sceCtrlPeekBufferPositive is faster than sceCtrlReadBufferPositive
// because sceCtrlReadBufferPositive waits for vsync internally // because sceCtrlReadBufferPositive waits for vsync internally
Update(); Update();
Render(); Render();
if (mDebug) if (mDebug)
{ {
if (strlen(mDebuggingMsg)>0) if (strlen(mDebuggingMsg)>0)
{ {
pspDebugScreenSetXY(0, 0); pspDebugScreenSetXY(0, 0);
pspDebugScreenPrintf(mDebuggingMsg); pspDebugScreenPrintf(mDebuggingMsg);
} }
} }
mOldButtons = mCtrlPad.Buttons; mOldButtons = mCtrlPad.Buttons;
} }
} }
} }
#endif ///// PSP specified code #endif ///// PSP specified code
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JGE* JGE::mInstance = NULL; JGE* JGE::mInstance = NULL;
//static int gCount = 0; //static int gCount = 0;
JGE* JGE::GetInstance() JGE* JGE::GetInstance()
{ {
if (mInstance == NULL) if (mInstance == NULL)
{ {
mInstance = new JGE(); mInstance = new JGE();
} }
//gCount++; //gCount++;
return mInstance; return mInstance;
} }
void JGE::Destroy() void JGE::Destroy()
{ {
//gCount--; //gCount--;
if (mInstance) if (mInstance)
{ {
delete mInstance; delete mInstance;
mInstance = NULL; mInstance = NULL;
} }
} }
void JGE::SetApp(JApp *app) void JGE::SetApp(JApp *app)
{ {
mApp = app; mApp = app;
} }
void JGE::Update() void JGE::Update()
{ {
if (mApp != NULL) if (mApp != NULL)
mApp->Update(); mApp->Update();
} }
void JGE::Render() void JGE::Render()
{ {
JRenderer* renderer = JRenderer::GetInstance(); JRenderer* renderer = JRenderer::GetInstance();
renderer->BeginScene(); renderer->BeginScene();
if (mApp != NULL) if (mApp != NULL)
mApp->Render(); mApp->Render();
renderer->EndScene(); renderer->EndScene();
} }
void JGE::End() void JGE::End()
{ {
mDone = true; mDone = true;
} }
void JGE::printf(const char *format, ...) void JGE::printf(const char *format, ...)
{ {
va_list list; va_list list;
va_start(list, format); va_start(list, format);
vsprintf(mDebuggingMsg, format, list); vsprintf(mDebuggingMsg, format, list);
va_end(list); va_end(list);
// FILE *f = fopen("jge.log", "a+"); // FILE *f = fopen("jge.log", "a+");
// fprintf(f, "%s\n", mDebuggingMsg); // fprintf(f, "%s\n", mDebuggingMsg);
// fclose(f); // fclose(f);
} }
void JGE::Pause() void JGE::Pause()
{ {
if (mPaused) return; if (mPaused) return;
mPaused = true; mPaused = true;
if (mApp != NULL) if (mApp != NULL)
mApp->Pause(); mApp->Pause();
} }
void JGE::Resume() void JGE::Resume()
{ {
if (mPaused) if (mPaused)
{ {
mPaused = false; mPaused = false;
if (mApp != NULL) if (mApp != NULL)
mApp->Resume(); mApp->Resume();
} }
} }
void JGE::Assert(const char *filename, long lineNumber) void JGE::Assert(const char *filename, long lineNumber)
{ {
mAssertFile = filename; mAssertFile = filename;
mAssertLine = lineNumber; mAssertLine = lineNumber;
mCriticalAssert = true; mCriticalAssert = true;
} }