mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 01:01:25 +03:00
Added support for OpenGL ES rendering ( not implemented really, just modified some renderings to render for OpenGL ES compilant code ).
This commit is contained in:
@@ -103,6 +103,10 @@ namespace EE {
|
||||
const eeFloat PId180 = PI / 180.f;
|
||||
const eeFloat d180PI = 180.f / PI;
|
||||
|
||||
#ifdef EE_GLES
|
||||
const GLubyte EE_GLES_INDICES [] = {0, 3, 1, 2};
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,11 @@ void cIsoMap::Draw() {
|
||||
glVertexPointer( 2, GL_FLOAT, 0, reinterpret_cast<char*>( T ) + sizeof(eeColor) * 4 );
|
||||
glTexCoordPointer( 2, GL_FLOAT, 0, reinterpret_cast<char*>( &TexCoords[0] ) );
|
||||
|
||||
#ifndef EE_GLES
|
||||
glDrawArrays( GL_QUADS, 0, 4 );
|
||||
#else
|
||||
glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES );
|
||||
#endif
|
||||
|
||||
if ( TileAABB.Contains( MouseMapPos ) ) {
|
||||
if ( IntersectQuad2( T->Q, eeQuad2f( MouseMapPos, MouseMapPos, MouseMapPos, MouseMapPos ) ) ) {
|
||||
|
||||
@@ -141,6 +141,7 @@ void cBatchRenderer::BatchQuad( const eeFloat& x, const eeFloat& y, const eeFloa
|
||||
center.y = y + height * 0.5f;
|
||||
}
|
||||
|
||||
#ifndef EE_GLES
|
||||
SetBlendMode( EE_GL_QUADS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
@@ -170,6 +171,37 @@ void cBatchRenderer::BatchQuad( const eeFloat& x, const eeFloat& y, const eeFloa
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
#else
|
||||
SetBlendMode( EE_GL_TRIANGLE_STRIP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x;
|
||||
mTVertex->pos.y = y;
|
||||
mTVertex->tex = mTexCoord[0];
|
||||
mTVertex->color = mVerColor[0];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 1 ];
|
||||
mTVertex->pos.x = x + width;
|
||||
mTVertex->pos.y = y;
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 2 ];
|
||||
mTVertex->pos.x = x;
|
||||
mTVertex->pos.y = y + height;
|
||||
mTVertex->tex = mTexCoord[1];
|
||||
mTVertex->color = mVerColor[1];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 3 ];
|
||||
mTVertex->pos.x = x + width;
|
||||
mTVertex->pos.y = y + height;
|
||||
mTVertex->tex = mTexCoord[2];
|
||||
mTVertex->color = mVerColor[2];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
#endif
|
||||
|
||||
AddVertexs(4);
|
||||
}
|
||||
@@ -199,6 +231,7 @@ void cBatchRenderer::BatchQuadEx( const eeFloat& x, const eeFloat& y, const eeFl
|
||||
center.x += x;
|
||||
center.y += y;
|
||||
|
||||
#ifndef EE_GLES
|
||||
SetBlendMode( EE_GL_QUADS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
@@ -228,6 +261,37 @@ void cBatchRenderer::BatchQuadEx( const eeFloat& x, const eeFloat& y, const eeFl
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
#else
|
||||
SetBlendMode( EE_GL_TRIANGLE_STRIP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = mx;
|
||||
mTVertex->pos.y = my;
|
||||
mTVertex->tex = mTexCoord[0];
|
||||
mTVertex->color = mVerColor[0];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 1 ];
|
||||
mTVertex->pos.x = mx + mwidth;
|
||||
mTVertex->pos.y = my;
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 2 ];
|
||||
mTVertex->pos.x = mx;
|
||||
mTVertex->pos.y = my + mheight;
|
||||
mTVertex->tex = mTexCoord[1];
|
||||
mTVertex->color = mVerColor[1];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 3 ];
|
||||
mTVertex->pos.x = mx + mwidth;
|
||||
mTVertex->pos.y = my + mheight;
|
||||
mTVertex->tex = mTexCoord[2];
|
||||
mTVertex->color = mVerColor[2];
|
||||
Rotate(center, &mTVertex->pos, angle);
|
||||
#endif
|
||||
|
||||
AddVertexs(4);
|
||||
}
|
||||
@@ -236,6 +300,7 @@ void cBatchRenderer::BatchQuadFree( const eeFloat& x0, const eeFloat& y0, const
|
||||
if ( mNumVertex + 3 >= mVertex.size() )
|
||||
return;
|
||||
|
||||
#ifndef EE_GLES
|
||||
SetBlendMode( EE_GL_QUADS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
@@ -261,6 +326,33 @@ void cBatchRenderer::BatchQuadFree( const eeFloat& x0, const eeFloat& y0, const
|
||||
mTVertex->pos.y = y3;
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
#else
|
||||
SetBlendMode( EE_GL_TRIANGLE_STRIP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = x0;
|
||||
mTVertex->pos.y = y0;
|
||||
mTVertex->tex = mTexCoord[0];
|
||||
mTVertex->color = mVerColor[0];
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 1 ];
|
||||
mTVertex->pos.x = x3;
|
||||
mTVertex->pos.y = y3;
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 2 ];
|
||||
mTVertex->pos.x = x1;
|
||||
mTVertex->pos.y = y1;
|
||||
mTVertex->tex = mTexCoord[1];
|
||||
mTVertex->color = mVerColor[1];
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 3 ];
|
||||
mTVertex->pos.x = x2;
|
||||
mTVertex->pos.y = y2;
|
||||
mTVertex->tex = mTexCoord[2];
|
||||
mTVertex->color = mVerColor[2];
|
||||
#endif
|
||||
|
||||
AddVertexs(4);
|
||||
}
|
||||
@@ -304,6 +396,7 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons
|
||||
if ( Angle != 0 )
|
||||
mQ = RotateQuadCentered( mQ, Angle, QCenter );
|
||||
|
||||
#ifndef EE_GLES
|
||||
SetBlendMode( EE_GL_QUADS, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
@@ -329,6 +422,33 @@ void cBatchRenderer::BatchQuadFreeEx( const eeFloat& x0, const eeFloat& y0, cons
|
||||
mTVertex->pos.y = mQ[3].y;
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
#else
|
||||
SetBlendMode( EE_GL_TRIANGLE_STRIP, mForceBlendMode );
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex ];
|
||||
mTVertex->pos.x = mQ[0].x;
|
||||
mTVertex->pos.y = mQ[0].y;
|
||||
mTVertex->tex = mTexCoord[0];
|
||||
mTVertex->color = mVerColor[0];
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 1 ];
|
||||
mTVertex->pos.x = mQ[3].x;
|
||||
mTVertex->pos.y = mQ[3].y;
|
||||
mTVertex->tex = mTexCoord[3];
|
||||
mTVertex->color = mVerColor[3];
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 2 ];
|
||||
mTVertex->pos.x = mQ[1].x;
|
||||
mTVertex->pos.y = mQ[1].y;
|
||||
mTVertex->tex = mTexCoord[1];
|
||||
mTVertex->color = mVerColor[1];
|
||||
|
||||
mTVertex = &mVertex[ mNumVertex + 3 ];
|
||||
mTVertex->pos.x = mQ[2].x;
|
||||
mTVertex->pos.y = mQ[2].y;
|
||||
mTVertex->tex = mTexCoord[2];
|
||||
mTVertex->color = mVerColor[2];
|
||||
#endif
|
||||
|
||||
AddVertexs(4);
|
||||
}
|
||||
|
||||
@@ -225,6 +225,14 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con
|
||||
numvert++;
|
||||
}
|
||||
|
||||
#ifdef EE_GLES
|
||||
glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast<char*>( &Colors[0] ) );
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast<char*>( &RenderCoords[ numvert - 4 ] ) );
|
||||
glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast<char*>( &RenderCoords[ numvert - 4 ] ) + sizeof(eeFloat) * 2 );
|
||||
|
||||
glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES );
|
||||
#endif
|
||||
|
||||
if (mVerticalDraw)
|
||||
nY += GetFontHeight();
|
||||
else
|
||||
@@ -232,11 +240,13 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef EE_GLES
|
||||
glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast<char*>( &Colors[0] ) );
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast<char*>( &RenderCoords[0] ) );
|
||||
glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast<char*>( &RenderCoords[0] ) + sizeof(eeFloat) * 2 );
|
||||
|
||||
glDrawArrays( GL_QUADS, 0, numvert );
|
||||
#endif
|
||||
|
||||
if ( Angle != 0.0f || Scale != 1.0f )
|
||||
glPopMatrix();
|
||||
@@ -336,13 +346,21 @@ void cFont::SubDraw( const std::wstring& Text, const eeFloat& X, const eeFloat&
|
||||
break;
|
||||
default:
|
||||
for ( Uint8 z = 0; z < 8; z+=2 ) {
|
||||
mRenderCoords[ numvert ].TexCoords[0] = C->TexCoords[z];
|
||||
mRenderCoords[ numvert ].TexCoords[1] = C->TexCoords[ z + 1 ];
|
||||
mRenderCoords[ numvert ].Vertex[0] = cX + C->Vertex[z] + nX;
|
||||
mRenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY;
|
||||
mRenderCoords[ numvert ].TexCoords[0] = C->TexCoords[z];
|
||||
mRenderCoords[ numvert ].TexCoords[1] = C->TexCoords[ z + 1 ];
|
||||
mRenderCoords[ numvert ].Vertex[0] = cX + C->Vertex[z] + nX;
|
||||
mRenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY;
|
||||
numvert++;
|
||||
}
|
||||
|
||||
#ifdef EE_GLES
|
||||
glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast<char*>( &mColors[0] ) );
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast<char*>( &mRenderCoords[ numvert - 4 ] ) );
|
||||
glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast<char*>( &mRenderCoords[ numvert - 4 ] ) + sizeof(eeFloat) * 2 );
|
||||
|
||||
glDrawElements( GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, EE_GLES_INDICES );
|
||||
#endif
|
||||
|
||||
if (mVerticalDraw)
|
||||
nY += GetFontHeight();
|
||||
else
|
||||
@@ -350,11 +368,13 @@ void cFont::SubDraw( const std::wstring& Text, const eeFloat& X, const eeFloat&
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef EE_GLES
|
||||
glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast<char*>( &mColors[0] ) );
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast<char*>( &mRenderCoords[0] ) );
|
||||
glVertexPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast<char*>( &mRenderCoords[0] ) + sizeof(eeFloat) * 2 );
|
||||
|
||||
glDrawArrays( GL_QUADS, 0, numvert );
|
||||
#endif
|
||||
|
||||
if ( Angle != 0.0f || Scale != 1.0f )
|
||||
glPopMatrix();
|
||||
|
||||
Reference in New Issue
Block a user