- wait for SDL events intead of pooling them, this allow very smooth CPU usage
- added texture deactivate around each renderer call implemented in opengl es 1.1. It fixes a couple of artifacts but a couple are remaining - added a compilation switch to allow simulation of opengl es 1.1 on desktop
This commit is contained in:
@@ -113,6 +113,15 @@ enum {
|
||||
# include <QtOpenGL>
|
||||
#endif
|
||||
|
||||
#if (defined FORCE_GLES)
|
||||
#undef GL_ES_VERSION_2_0
|
||||
#undef GL_VERSION_2_0
|
||||
#define GL_VERSION_ES_CM_1_1 1
|
||||
#define glOrthof glOrtho
|
||||
#define glClearDepthf glClearDepth
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (PSP)
|
||||
|
||||
#ifndef ABGR8888
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <SDL.h>
|
||||
#ifndef ANDROID
|
||||
#include <SDL_opengl.h>
|
||||
#else
|
||||
#if (defined ANDROID)
|
||||
#include <SDL_opengles.h>
|
||||
#else
|
||||
#include <SDL_opengl.h>
|
||||
#endif
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JTypes.h"
|
||||
@@ -14,7 +14,14 @@
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#if (defined FORCE_GLES)
|
||||
#undef GL_ES_VERSION_2_0
|
||||
#undef GL_VERSION_2_0
|
||||
#define GL_VERSION_ES_CM_1_1 1
|
||||
#define glOrthof glOrtho
|
||||
#define glClearDepthf glClearDepth
|
||||
#endif
|
||||
|
||||
#define ACTUAL_SCREEN_WIDTH (SCREEN_WIDTH)
|
||||
#define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT)
|
||||
@@ -43,19 +50,14 @@ class SdlApp {
|
||||
|
||||
SDL_Event Event;
|
||||
|
||||
while(Running) {
|
||||
while(SDL_PollEvent(&Event)) {
|
||||
OnEvent(&Event);
|
||||
}
|
||||
|
||||
OnLoop();
|
||||
// OnRender();
|
||||
while(Running && SDL_WaitEventTimeout(&Event, 50)) {
|
||||
OnEvent(&Event);
|
||||
}
|
||||
|
||||
OnCleanup();
|
||||
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
bool OnInit();
|
||||
@@ -150,13 +152,20 @@ class SdlApp {
|
||||
case WAGIC_UPDATE_EVENT:
|
||||
OnUpdate();
|
||||
break;
|
||||
case SDL_MULTIGESTURE:
|
||||
{
|
||||
DebugTrace("Multigesure : touchId " << Event->mgesture.touchId
|
||||
<< ", x " << Event->mgesture.x
|
||||
<< ", y " << Event->mgesture.y
|
||||
<< ", dTheta " << Event->mgesture.dTheta
|
||||
<< ", dDist " << Event->mgesture.dDist
|
||||
<< ", numFinder " << Event->mgesture.numFingers);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void OnUpdate();
|
||||
void OnRender();
|
||||
void OnLoop() {
|
||||
};
|
||||
|
||||
void OnCleanup() {
|
||||
SDL_FreeSurface(Surf_Display);
|
||||
SDL_Quit();
|
||||
@@ -469,11 +478,11 @@ void SdlApp::OnRender() {
|
||||
if(g_engine)
|
||||
g_engine->Render();
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
SDL_GL_SwapBuffers();
|
||||
};
|
||||
|
||||
|
||||
#ifdef ANDROID
|
||||
#if (defined ANDROID)
|
||||
int SDL_main(int argc, char * argv[])
|
||||
#else
|
||||
int main(int argc, char* argv[])
|
||||
|
||||
@@ -820,7 +820,7 @@ void JRenderer::BeginScene()
|
||||
esMatrixLoadIdentity(&theMvpMatrix);
|
||||
esOrtho(&theMvpMatrix, 0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f,-1.0f, 1.0f);
|
||||
#endif //(!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
#if (defined WIN32) || (defined ANDROID)
|
||||
#if (defined WIN32) || (defined GL_VERSION_ES_CM_1_1)
|
||||
float scaleH = mActualHeight/SCREEN_HEIGHT_F;
|
||||
float scaleW = mActualWidth/SCREEN_WIDTH_F;
|
||||
if (scaleH != 1.0f || scaleW != 1.0f)
|
||||
@@ -1242,6 +1242,7 @@ void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -1265,8 +1266,9 @@ void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
#else
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
|
||||
@@ -1337,6 +1339,7 @@ void JRenderer::DrawRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
glDrawArrays(GL_LINE_LOOP,0,4);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -1360,6 +1363,7 @@ void JRenderer::DrawRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4ub(col.r, col.g, col.b, col.a);
|
||||
@@ -1435,6 +1439,7 @@ void JRenderer::FillRect(float x, float y, float width, float height, JColor* co
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -1458,6 +1463,7 @@ void JRenderer::FillRect(float x, float y, float width, float height, JColor* co
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
@@ -1525,6 +1531,7 @@ void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE colo
|
||||
glDrawArrays(GL_LINES,0,2);
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -1544,6 +1551,7 @@ void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE colo
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
@@ -2700,6 +2708,7 @@ void JRenderer::FillPolygon(float* x, float* y, int count, PIXEL_TYPE color)
|
||||
delete[] colors;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -2727,6 +2736,7 @@ void JRenderer::FillPolygon(float* x, float* y, int count, PIXEL_TYPE color)
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
@@ -2805,6 +2815,7 @@ void JRenderer::DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color)
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -2837,6 +2848,7 @@ void JRenderer::DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color)
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
@@ -2945,6 +2957,7 @@ void JRenderer::DrawCircle(float x, float y, float radius, PIXEL_TYPE color)
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -2979,6 +2992,7 @@ void JRenderer::DrawCircle(float x, float y, float radius, PIXEL_TYPE color)
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
@@ -3057,6 +3071,7 @@ void JRenderer::FillCircle(float x, float y, float radius, PIXEL_TYPE color)
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -3095,6 +3110,7 @@ void JRenderer::FillCircle(float x, float y, float radius, PIXEL_TYPE color)
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
#else
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
@@ -3176,7 +3192,7 @@ void JRenderer::DrawPolygon(float x, float y, float size, int count, float start
|
||||
delete[] colors;
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -3207,6 +3223,7 @@ void JRenderer::DrawPolygon(float x, float y, float size, int count, float start
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
@@ -3300,6 +3317,7 @@ void JRenderer::FillPolygon(float x, float y, float size, int count, float start
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -3338,6 +3356,7 @@ void JRenderer::FillPolygon(float x, float y, float size, int count, float start
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
@@ -3452,6 +3471,7 @@ void JRenderer::DrawRoundRect(float x, float y, float w, float h, float radius,
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -3503,6 +3523,7 @@ void JRenderer::DrawRoundRect(float x, float y, float w, float h, float radius,
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
@@ -3639,6 +3660,7 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
|
||||
|
||||
#elif (defined GL_VERSION_ES_CM_1_1)
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
@@ -3696,6 +3718,7 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
delete[] vVertices;
|
||||
delete[] colors;
|
||||
|
||||
Reference in New Issue
Block a user