Mostly formatting cleanup, but a couple of openGL related fixes : don't call state change functions if their params haven't changed. In particular, we call ClearScreen() in several places in the code, but BeginScene() already does this. According to several openGL performance guides I skimmed through, if you call clear more than once per frame draw, performance will suffer.
This seems to help with issue r103 - on my win machine, it's substantially better; on psp, not quite as drastic, but it's still better than before.
This commit is contained in:
+5
-2
@@ -362,10 +362,13 @@ void JRenderer::EnableVSync(bool flag)
|
|||||||
|
|
||||||
void JRenderer::ClearScreen(PIXEL_TYPE color)
|
void JRenderer::ClearScreen(PIXEL_TYPE color)
|
||||||
{
|
{
|
||||||
|
static PIXEL_TYPE previousColor = 0xFFFFFFFF;
|
||||||
|
if (previousColor != color)
|
||||||
|
{
|
||||||
sceGuClearColor(color);
|
sceGuClearColor(color);
|
||||||
//sceGuClearStencil( 0 );
|
|
||||||
sceGuClear(GU_COLOR_BUFFER_BIT);
|
sceGuClear(GU_COLOR_BUFFER_BIT);
|
||||||
//sceGuClear( GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT );
|
previousColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+13
-10
@@ -29,16 +29,16 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifdef DEVHOOK
|
#ifdef DEVHOOK
|
||||||
PSP_MODULE_INFO(JGEApp_Title, 0, 1, 1);
|
PSP_MODULE_INFO(JGEApp_Title, 0, 1, 1);
|
||||||
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
|
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
|
||||||
//256 is not enough for the network to correctly start,
|
//256 is not enough for the network to correctly start,
|
||||||
// let's find an appropriate value the day JGE has working network
|
// let's find an appropriate value the day JGE has working network
|
||||||
PSP_HEAP_SIZE_KB(-256);
|
PSP_HEAP_SIZE_KB(-256);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
PSP_MODULE_INFO(JGEApp_Title, 0x1000, 1, 1);
|
PSP_MODULE_INFO(JGEApp_Title, 0x1000, 1, 1);
|
||||||
PSP_MAIN_THREAD_ATTR(0);
|
PSP_MAIN_THREAD_ATTR(0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ __attribute__((constructor)) void handlerInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
||||||
{
|
{
|
||||||
{ PSP_CTRL_START, JGE_BTN_MENU },
|
{ PSP_CTRL_START, JGE_BTN_MENU },
|
||||||
{ PSP_CTRL_SELECT, JGE_BTN_CTRL },
|
{ PSP_CTRL_SELECT, JGE_BTN_CTRL },
|
||||||
{ PSP_CTRL_RIGHT, JGE_BTN_RIGHT },
|
{ PSP_CTRL_RIGHT, JGE_BTN_RIGHT },
|
||||||
@@ -265,12 +265,14 @@ static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[]
|
|||||||
{ PSP_CTRL_CROSS, JGE_BTN_SEC },
|
{ PSP_CTRL_CROSS, JGE_BTN_SEC },
|
||||||
{ PSP_CTRL_LTRIGGER, JGE_BTN_PREV },
|
{ PSP_CTRL_LTRIGGER, JGE_BTN_PREV },
|
||||||
{ PSP_CTRL_RTRIGGER, JGE_BTN_NEXT }
|
{ PSP_CTRL_RTRIGGER, JGE_BTN_NEXT }
|
||||||
};
|
};
|
||||||
|
|
||||||
void JGECreateDefaultBindings()
|
void JGECreateDefaultBindings()
|
||||||
{
|
{
|
||||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||||
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int JGEGetTime()
|
int JGEGetTime()
|
||||||
{
|
{
|
||||||
u64 curr;
|
u64 curr;
|
||||||
@@ -285,7 +287,8 @@ u8 JGEGetAnalogY() { return gCtrlPad.Ly; }
|
|||||||
|
|
||||||
void Run()
|
void Run()
|
||||||
{
|
{
|
||||||
static const int keyCodeList[] = {
|
static const int keyCodeList[] =
|
||||||
|
{
|
||||||
PSP_CTRL_SELECT, // Select button.
|
PSP_CTRL_SELECT, // Select button.
|
||||||
PSP_CTRL_START, // Start button.
|
PSP_CTRL_START, // Start button.
|
||||||
PSP_CTRL_UP, // Up D-Pad button.
|
PSP_CTRL_UP, // Up D-Pad button.
|
||||||
|
|||||||
+30
-15
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
#if (!defined IOS) && (!defined QT_CONFIG)
|
#if (!defined IOS) && (!defined QT_CONFIG)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma warning(disable : 4786)
|
#pragma warning(disable : 4786)
|
||||||
#pragma comment( lib, "giflib.lib" )
|
#pragma comment( lib, "giflib.lib" )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
@@ -125,7 +125,8 @@ typedef void (APIENTRY *_glBlendColor) (GLclampf, GLclampf, GLclampf, GLclampf);
|
|||||||
|
|
||||||
struct glslFunctions
|
struct glslFunctions
|
||||||
{
|
{
|
||||||
void load(){
|
void load()
|
||||||
|
{
|
||||||
GLSLGETPROC(glCreateShader);
|
GLSLGETPROC(glCreateShader);
|
||||||
GLSLGETPROC(glShaderSource);
|
GLSLGETPROC(glShaderSource);
|
||||||
GLSLGETPROC(glShaderBinary);
|
GLSLGETPROC(glShaderBinary);
|
||||||
@@ -478,7 +479,7 @@ void esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB)
|
|||||||
(srcA->m[i][2] * srcB->m[2][3]) +
|
(srcA->m[i][2] * srcB->m[2][3]) +
|
||||||
(srcA->m[i][3] * srcB->m[3][3]) ;
|
(srcA->m[i][3] * srcB->m[3][3]) ;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Actually, srcA and srcB are column-major order matrixes, while they
|
* Actually, srcA and srcB are column-major order matrixes, while they
|
||||||
* use row-major multiplication. Then above result equals to (B * A) likes these:
|
* use row-major multiplication. Then above result equals to (B * A) likes these:
|
||||||
|
|
||||||
@@ -718,7 +719,7 @@ void JRenderer::InitRenderer()
|
|||||||
mCurrTexBlendSrc = BLEND_SRC_ALPHA;
|
mCurrTexBlendSrc = BLEND_SRC_ALPHA;
|
||||||
mCurrTexBlendDest = BLEND_ONE_MINUS_SRC_ALPHA;
|
mCurrTexBlendDest = BLEND_ONE_MINUS_SRC_ALPHA;
|
||||||
|
|
||||||
// mLineWidth = 1.0f;
|
// mLineWidth = 1.0f;
|
||||||
mCurrentTex = -1;
|
mCurrentTex = -1;
|
||||||
mFOV = 75.0f;
|
mFOV = 75.0f;
|
||||||
|
|
||||||
@@ -828,6 +829,7 @@ void JRenderer::BeginScene()
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
float scaleH = mActualHeight/SCREEN_HEIGHT_F;
|
float scaleH = mActualHeight/SCREEN_HEIGHT_F;
|
||||||
float scaleW = mActualWidth/SCREEN_WIDTH_F;
|
float scaleW = mActualWidth/SCREEN_WIDTH_F;
|
||||||
|
if (scaleH != 1.0f || scaleW != 1.0f)
|
||||||
glScalef(scaleW,scaleH,1.f);
|
glScalef(scaleW,scaleH,1.f);
|
||||||
#endif
|
#endif
|
||||||
checkGlError();
|
checkGlError();
|
||||||
@@ -1003,8 +1005,15 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
|||||||
#else
|
#else
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(xo, yo, 0.0f);
|
glTranslatef(xo, yo, 0.0f);
|
||||||
|
if (angle != 0)
|
||||||
|
{
|
||||||
glRotatef(-angle*RAD2DEG, 0.0f, 0.0f, 1.0f);
|
glRotatef(-angle*RAD2DEG, 0.0f, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xScale != 1.0f || yScale != 1.0f)
|
||||||
|
{
|
||||||
glScalef(xScale, yScale, 1.0f);
|
glScalef(xScale, yScale, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
#if (defined GL_VERSION_ES_CM_1_1)
|
#if (defined GL_VERSION_ES_CM_1_1)
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
@@ -1063,10 +1072,6 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
|||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
//glDisable(GL_BLEND);
|
|
||||||
|
|
||||||
// default color
|
|
||||||
glColor4ub(255, 255, 255, 255);
|
|
||||||
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||||
|
|
||||||
checkGlError();
|
checkGlError();
|
||||||
@@ -1500,7 +1505,7 @@ void JRenderer::FillRect(float x, float y, float width, float height, JColor* co
|
|||||||
void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE color)
|
void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE color)
|
||||||
{
|
{
|
||||||
checkGlError();
|
checkGlError();
|
||||||
// glLineWidth (mLineWidth);
|
// glLineWidth (mLineWidth);
|
||||||
JColor col;
|
JColor col;
|
||||||
col.color = color;
|
col.color = color;
|
||||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||||
@@ -1555,11 +1560,15 @@ void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE colo
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
if (color != 0xFFFFFFFF)
|
||||||
glColor4ub(col.r, col.g, col.b, col.a);
|
glColor4ub(col.r, col.g, col.b, col.a);
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glVertex2f(x1, SCREEN_HEIGHT_F-y1);
|
glVertex2f(x1, SCREEN_HEIGHT_F-y1);
|
||||||
glVertex2f(x2, SCREEN_HEIGHT_F-y2);
|
glVertex2f(x2, SCREEN_HEIGHT_F-y2);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
if (color != 0xFFFFFFFF)
|
||||||
glColor4ub(255, 255, 255, 255);
|
glColor4ub(255, 255, 255, 255);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
#endif //#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
#endif //#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||||
@@ -2397,24 +2406,30 @@ JTexture* JRenderer::CreateTexture(int width, int height, int mode __attribute__
|
|||||||
|
|
||||||
void JRenderer::EnableVSync(bool flag __attribute__((unused)))
|
void JRenderer::EnableVSync(bool flag __attribute__((unused)))
|
||||||
{
|
{
|
||||||
// if (flag)
|
// if (flag)
|
||||||
// hge->System_SetState(HGE_FPS, 60); // HGEFPS_VSYNC
|
// hge->System_SetState(HGE_FPS, 60); // HGEFPS_VSYNC
|
||||||
// else
|
// else
|
||||||
// hge->System_SetState(HGE_FPS, HGEFPS_UNLIMITED);
|
// hge->System_SetState(HGE_FPS, HGEFPS_UNLIMITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JRenderer::ClearScreen(PIXEL_TYPE color)
|
void JRenderer::ClearScreen(PIXEL_TYPE color)
|
||||||
{
|
{
|
||||||
checkGlError();
|
checkGlError();
|
||||||
|
static PIXEL_TYPE previousColor = RGBA(0xFF, 0xFF, 0xFF, 0xFF);
|
||||||
|
if (previousColor != color)
|
||||||
|
{
|
||||||
JColor col;
|
JColor col;
|
||||||
col.color = color;
|
col.color = color;
|
||||||
|
|
||||||
glClearColor(col.r, col.g, col.b, col.a);
|
glClearColor(col.r, col.g, col.b, col.a);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
// FillRect(0.0f, 0.0f, SCREEN_WIDTH_F, SCREEN_HEIGHT_F, color);
|
// FillRect(0.0f, 0.0f, SCREEN_WIDTH_F, SCREEN_HEIGHT_F, color);
|
||||||
checkGlError();
|
checkGlError();
|
||||||
|
|
||||||
|
previousColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user