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:
@@ -361,11 +361,14 @@ void JRenderer::EnableVSync(bool flag)
|
||||
|
||||
|
||||
void JRenderer::ClearScreen(PIXEL_TYPE color)
|
||||
{
|
||||
static PIXEL_TYPE previousColor = 0xFFFFFFFF;
|
||||
if (previousColor != color)
|
||||
{
|
||||
sceGuClearColor(color);
|
||||
//sceGuClearStencil( 0 );
|
||||
sceGuClear(GU_COLOR_BUFFER_BIT);
|
||||
//sceGuClear( GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT );
|
||||
previousColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -266,11 +266,13 @@ static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[]
|
||||
{ PSP_CTRL_LTRIGGER, JGE_BTN_PREV },
|
||||
{ PSP_CTRL_RTRIGGER, JGE_BTN_NEXT }
|
||||
};
|
||||
|
||||
void JGECreateDefaultBindings()
|
||||
{
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
||||
}
|
||||
|
||||
int JGEGetTime()
|
||||
{
|
||||
u64 curr;
|
||||
@@ -285,7 +287,8 @@ u8 JGEGetAnalogY() { return gCtrlPad.Ly; }
|
||||
|
||||
void Run()
|
||||
{
|
||||
static const int keyCodeList[] = {
|
||||
static const int keyCodeList[] =
|
||||
{
|
||||
PSP_CTRL_SELECT, // Select button.
|
||||
PSP_CTRL_START, // Start button.
|
||||
PSP_CTRL_UP, // Up D-Pad button.
|
||||
|
||||
@@ -125,7 +125,8 @@ typedef void (APIENTRY *_glBlendColor) (GLclampf, GLclampf, GLclampf, GLclampf);
|
||||
|
||||
struct glslFunctions
|
||||
{
|
||||
void load(){
|
||||
void load()
|
||||
{
|
||||
GLSLGETPROC(glCreateShader);
|
||||
GLSLGETPROC(glShaderSource);
|
||||
GLSLGETPROC(glShaderBinary);
|
||||
@@ -828,6 +829,7 @@ void JRenderer::BeginScene()
|
||||
#ifdef WIN32
|
||||
float scaleH = mActualHeight/SCREEN_HEIGHT_F;
|
||||
float scaleW = mActualWidth/SCREEN_WIDTH_F;
|
||||
if (scaleH != 1.0f || scaleW != 1.0f)
|
||||
glScalef(scaleW,scaleH,1.f);
|
||||
#endif
|
||||
checkGlError();
|
||||
@@ -1003,8 +1005,15 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
#else
|
||||
glPushMatrix();
|
||||
glTranslatef(xo, yo, 0.0f);
|
||||
if (angle != 0)
|
||||
{
|
||||
glRotatef(-angle*RAD2DEG, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
if (xScale != 1.0f || yScale != 1.0f)
|
||||
{
|
||||
glScalef(xScale, yScale, 1.0f);
|
||||
}
|
||||
|
||||
#if (defined GL_VERSION_ES_CM_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
@@ -1063,10 +1072,6 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
//glDisable(GL_BLEND);
|
||||
|
||||
// default color
|
||||
glColor4ub(255, 255, 255, 255);
|
||||
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
checkGlError();
|
||||
@@ -1555,11 +1560,15 @@ void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE colo
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
if (color != 0xFFFFFFFF)
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(x1, SCREEN_HEIGHT_F-y1);
|
||||
glVertex2f(x2, SCREEN_HEIGHT_F-y2);
|
||||
glEnd();
|
||||
if (color != 0xFFFFFFFF)
|
||||
glColor4ub(255, 255, 255, 255);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
#endif //#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
@@ -2407,6 +2416,9 @@ void JRenderer::EnableVSync(bool flag __attribute__((unused)))
|
||||
void JRenderer::ClearScreen(PIXEL_TYPE color)
|
||||
{
|
||||
checkGlError();
|
||||
static PIXEL_TYPE previousColor = RGBA(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
if (previousColor != color)
|
||||
{
|
||||
JColor col;
|
||||
col.color = color;
|
||||
|
||||
@@ -2415,6 +2427,9 @@ void JRenderer::ClearScreen(PIXEL_TYPE color)
|
||||
|
||||
// FillRect(0.0f, 0.0f, SCREEN_WIDTH_F, SCREEN_HEIGHT_F, color);
|
||||
checkGlError();
|
||||
|
||||
previousColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user