From 11f00b4fd4c396084116b855ac3f224457a96d53 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 20 Sep 2022 22:08:09 +0100 Subject: [PATCH] fixing compilation errors --- .../jni/OpenJK/code/rd-vanilla/G2_misc.cpp | 8 +- .../code/rd-vanilla/tr_WorldEffects.cpp | 252 ++++++-- .../jni/OpenJK/code/rd-vanilla/tr_backend.cpp | 10 +- .../jni/OpenJK/code/rd-vanilla/tr_bsp.cpp | 6 +- .../jni/OpenJK/code/rd-vanilla/tr_ghoul2.cpp | 18 +- .../jni/OpenJK/code/rd-vanilla/tr_image.cpp | 583 ++++++++++++------ .../jni/OpenJK/code/rd-vanilla/tr_local.h | 42 +- .../jni/OpenJK/code/rd-vanilla/tr_main.cpp | 10 +- .../jni/OpenJK/code/rd-vanilla/tr_mesh.cpp | 4 +- .../jni/OpenJK/code/rd-vanilla/tr_model.cpp | 4 +- .../jni/OpenJK/code/rd-vanilla/tr_scene.cpp | 2 +- .../jni/OpenJK/code/rd-vanilla/tr_shade.cpp | 123 +--- .../jni/OpenJK/code/rd-vanilla/tr_shader.cpp | 40 +- .../jni/OpenJK/code/rd-vanilla/tr_shadows.cpp | 50 +- .../jni/OpenJK/code/rd-vanilla/tr_sky.cpp | 4 +- .../jni/OpenJK/code/rd-vanilla/tr_surface.cpp | 82 ++- .../jni/OpenJK/code/rd-vanilla/tr_world.cpp | 2 +- 17 files changed, 815 insertions(+), 425 deletions(-) diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/G2_misc.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/G2_misc.cpp index 9a6162f..58ad732 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/G2_misc.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/G2_misc.cpp @@ -214,7 +214,7 @@ public: const int entNum; const int modelIndex; const skin_t *skin; - const shader_t *cust_shader; + const jk_shader_t *cust_shader; intptr_t *TransformedVertsArray; const EG2_Collision eG2TraceType; bool hitOne; @@ -243,7 +243,7 @@ public: int initentNum, int initmodelIndex, const skin_t *initskin, - const shader_t *initcust_shader, + const jk_shader_t *initcust_shader, intptr_t *initTransformedVertsArray, const EG2_Collision einitG2TraceType, #ifdef _G2_GORE @@ -1181,7 +1181,7 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ hitPoint, &x_pos, &y_pos,newCol.mBarycentricI,newCol.mBarycentricJ); /* - const shader_t *shader = 0; + const jk_shader_t *shader = 0; // now, we know what surface this hit belongs to, we need to go get the shader handle so we can get the correct hit location and hit material info if ( cust_shader ) { @@ -1562,7 +1562,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, CColl { int i, lod; skin_t *skin; - shader_t *cust_shader; + jk_shader_t *cust_shader; #if !defined(JK2_MODE) || defined(_G2_GORE) qboolean firstModelOnly = qfalse; #endif // !JK2_MODE || _G2_GORE diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_WorldEffects.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_WorldEffects.cpp index 6b63507..c52ebe4 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_WorldEffects.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_WorldEffects.cpp @@ -1061,7 +1061,17 @@ public: } mVertexCount = VertexCount; - mGLModeEnum = (mVertexCount==3)?(GL_TRIANGLES):(GL_QUADS); +#if defined(HAVE_GLES) // Check for point sprite use + if(mVertexCount == 1) + mGLModeEnum = GL_POINTS; + else +#endif + +#ifdef HAVE_GLES + mGLModeEnum = (mVertexCount==3)?(GL_TRIANGLES):(GL_TRIANGLE_FAN); +#else + mGLModeEnum = (mVertexCount==3)?(GL_TRIANGLES):(GL_QUADS); +#endif } @@ -1442,22 +1452,76 @@ public: // Enable And Disable Things //--------------------------- - qglEnable(GL_TEXTURE_2D); - qglDisable(GL_CULL_FACE); + /* + if (mGLModeEnum==GL_POINTS && qglPointParameteriNV) + { + qglEnable(GL_POINT_SPRITE_NV); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (mFilterMode==0)?(GL_LINEAR):(GL_NEAREST)); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (mFilterMode==0)?(GL_LINEAR):(GL_NEAREST)); + qglPointSize(mWidth); + qglPointParameterfEXT( GL_POINT_SIZE_MIN_EXT, 4.0f ); + qglPointParameterfEXT( GL_POINT_SIZE_MAX_EXT, 2047.0f ); + + qglTexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, GL_TRUE); + } + else + */ +#ifdef HAVE_GLES + GLfloat tex[2*6*mParticleCount]; + GLfloat vtx[3*6*mParticleCount]; + GLfloat col[4*6*mParticleCount]; + GLfloat curcol[4]; + qglGetFloatv(GL_CURRENT_COLOR, curcol); + GLboolean text = qglIsEnabled(GL_TEXTURE_COORD_ARRAY); + GLboolean glcol = qglIsEnabled(GL_COLOR_ARRAY); + if (!text) + qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + if (!glcol) + qglEnableClientState( GL_COLOR_ARRAY ); + + if (mGLModeEnum==GL_POINTS) + { + qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); + // Nothing to do ?! + } +#else + //FIXME use this extension? + const float attenuation[3] = + { + 1, 0.0, 0.0004 + }; + if (mGLModeEnum == GL_POINTS && qglPointParameterfEXT) + { //fixme use custom parameters but gotta make sure it expects them on same scale first + qglPointSize(10.0); + qglPointParameterfEXT(GL_POINT_SIZE_MIN_EXT, 1.0); + qglPointParameterfEXT(GL_POINT_SIZE_MAX_EXT, 4.0); + qglPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, (float *)attenuation); + } +#endif + else + { + qglEnable(GL_TEXTURE_2D); + //qglDisable(GL_CULL_FACE); + //naughty, you are making the assumption that culling is on when you get here. -rww + GL_Cull(CT_TWO_SIDED); + + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (mFilterMode==0)?(GL_LINEAR):(GL_NEAREST)); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (mFilterMode==0)?(GL_LINEAR):(GL_NEAREST)); - // Setup Matrix Mode And Translation - //----------------------------------- - qglMatrixMode(GL_MODELVIEW); - qglPushMatrix(); + // Setup Matrix Mode And Translation + //----------------------------------- + qglMatrixMode(GL_MODELVIEW); + qglPushMatrix(); + } // Begin //------- +#ifdef HAVE_GLES + int idx = 0; +#else qglBegin(mGLModeEnum); +#endif for (particleNum=0; particleNummVelocity; - VectorNormalize(partDirection.v); - mCameraDown = partDirection; - mCameraDown *= (mHeight * -1); - if (mVertexCount==4) - { - mCameraLeftPlusUp = (mCameraLeft - mCameraDown); - mCameraLeftMinusUp = (mCameraLeft + mCameraDown); - } - else - { - mCameraLeftPlusUp = (mCameraDown + mCameraLeft); - } - } - // Blend Mode Zero -> Apply Alpha Just To Alpha Channel //------------------------------------------------------ if (mBlendMode==0) { +#ifdef HAVE_GLES + curcol[0]=mColor[0]; curcol[1]=mColor[1], curcol[2]=mColor[2]; curcol[3]=part->mAlpha; +#else qglColor4f(mColor[0], mColor[1], mColor[2], part->mAlpha); +#endif } - // Otherwise Apply Alpha To All Channels - //--------------------------------------- + // Otherwise Apply Alpha To All Channels + //--------------------------------------- else { +#ifdef HAVE_GLES + curcol[0]=mColor[0]*part->mAlpha; curcol[1]=mColor[1]*part->mAlpha, curcol[2]=mColor[2]*part->mAlpha; curcol[3]=mColor[3]*part->mAlpha; +#else qglColor4f(mColor[0]*part->mAlpha, mColor[1]*part->mAlpha, mColor[2]*part->mAlpha, mColor[3]*part->mAlpha); +#endif } - - // Render A Triangle - //------------------- - if (mVertexCount==3) + // Render A Point + //---------------- + if (mGLModeEnum==GL_POINTS) { - qglTexCoord2f(1.0, 0.0); +#ifdef HAVE_GLES + memcpy(vtx+idx*3, part->mPosition.v, 3*sizeof(GLfloat)); + memcpy(col+idx*4, curcol, 4*sizeof(GLfloat)); + idx++; +#else + qglVertex3fv(part->mPosition.v); +#endif + } + + // Render A Triangle + //------------------- + else if (mVertexCount==3) + { +#ifdef HAVE_GLES + memcpy(col+idx*4, curcol, 4*sizeof(GLfloat)); + tex[idx*2+0]=1.0f; tex[idx*2+1]=0.0f; + vtx[idx*3+0]=part->mPosition[0]; + vtx[idx*3+1]=part->mPosition[1]; + vtx[idx*3+2]=part->mPosition[2]; + memcpy(col+idx*4+4, curcol, 4*sizeof(GLfloat)); + tex[idx*2+2]=0.0f; tex[idx*2+3]=1.0f; + vtx[idx*3+3]=part->mPosition[0] + mCameraLeft[0]; + vtx[idx*3+4]=part->mPosition[1] + mCameraLeft[1]; + vtx[idx*3+5]=part->mPosition[2] + mCameraLeft[2]; + memcpy(col+idx*4+8, curcol, 4*sizeof(GLfloat)); + tex[idx*2+4]=0.0f; tex[idx*2+5]=0.0f; + vtx[idx*3+6]=part->mPosition[0] + mCameraLeftPlusUp[0]; + vtx[idx*3+7]=part->mPosition[1] + mCameraLeftPlusUp[1]; + vtx[idx*3+8]=part->mPosition[2] + mCameraLeftPlusUp[2]; + idx+=3; +#else + qglTexCoord2f(1.0, 0.0); qglVertex3f(part->mPosition[0], part->mPosition[1], part->mPosition[2]); @@ -1518,12 +1601,71 @@ public: qglVertex3f(part->mPosition[0] + mCameraLeftPlusUp[0], part->mPosition[1] + mCameraLeftPlusUp[1], part->mPosition[2] + mCameraLeftPlusUp[2]); +#endif } - // Render A Quad - //--------------- + // Render A Quad + //--------------- else { +#ifdef HAVE_GLES + /*tex[0]=0.0f; tex[1]=0.0f; + vtx[0]=part->mPosition[0] - mCameraLeftMinusUp[0]; + vtx[1]=part->mPosition[1] - mCameraLeftMinusUp[1]; + vtx[2]=part->mPosition[2] - mCameraLeftMinusUp[2]; + tex[2]=1.0f; tex[3]=0.0f; + vtx[3]=part->mPosition[0] - mCameraLeftPlusUp[0]; + vtx[4]=part->mPosition[1] - mCameraLeftPlusUp[1]; + vtx[5]=part->mPosition[2] - mCameraLeftPlusUp[2]; + tex[4]=1.0f; tex[5]=1.0f; + vtx[6]=part->mPosition[0] + mCameraLeftMinusUp[0]; + vtx[7]=part->mPosition[1] + mCameraLeftMinusUp[1]; + vtx[8]=part->mPosition[2] + mCameraLeftMinusUp[2]; + tex[6]=0.0f; tex[7]=1.0f; + vtx[9]=part->mPosition[0] + mCameraLeftPlusUp[0]; + vtx[10]=part->mPosition[1] + mCameraLeftPlusUp[1]; + vtx[11]=part->mPosition[2] + mCameraLeftPlusUp[2]; + qglTexCoordPointer( 2, GL_FLOAT, 0, tex ); + qglVertexPointer ( 3, GL_FLOAT, 0, vtx ); + qglDrawArrays( GL_TRIANGLE_FAN, 0, 4 );*/ + memcpy(col+idx*4, curcol, 4*sizeof(GLfloat)); + tex[idx*2+0]=0.0f; tex[idx*2+1]=0.0f; + vtx[idx*3+0]=part->mPosition[0] - mCameraLeftMinusUp[0]; + vtx[idx*3+1]=part->mPosition[1] - mCameraLeftMinusUp[1]; + vtx[idx*3+2]=part->mPosition[2] - mCameraLeftMinusUp[2]; + idx++; + memcpy(col+idx*4, curcol, 4*sizeof(GLfloat)); + tex[idx*2+0]=1.0f; tex[idx*2+1]=0.0f; + vtx[idx*3+0]=part->mPosition[0] - mCameraLeftPlusUp[0]; + vtx[idx*3+1]=part->mPosition[1] - mCameraLeftPlusUp[1]; + vtx[idx*3+2]=part->mPosition[2] - mCameraLeftPlusUp[2]; + idx++; + memcpy(col+idx*4, curcol, 4*sizeof(GLfloat)); + tex[idx*2+0]=1.0f; tex[idx*2+1]=1.0f; + vtx[idx*3+0]=part->mPosition[0] + mCameraLeftMinusUp[0]; + vtx[idx*3+1]=part->mPosition[1] + mCameraLeftMinusUp[1]; + vtx[idx*3+2]=part->mPosition[2] + mCameraLeftMinusUp[2]; + idx++; + // triangle 2 + memcpy(col+idx*4, curcol, 4*sizeof(GLfloat)); + tex[idx*2+0]=0.0f; tex[idx*2+1]=0.0f; + vtx[idx*3+0]=part->mPosition[0] - mCameraLeftMinusUp[0]; + vtx[idx*3+1]=part->mPosition[1] - mCameraLeftMinusUp[1]; + vtx[idx*3+2]=part->mPosition[2] - mCameraLeftMinusUp[2]; + idx++; + memcpy(col+idx*4, curcol, 4*sizeof(GLfloat)); + tex[idx*2+0]=1.0f; tex[idx*2+1]=1.0f; + vtx[idx*3+0]=part->mPosition[0] + mCameraLeftMinusUp[0]; + vtx[idx*3+1]=part->mPosition[1] + mCameraLeftMinusUp[1]; + vtx[idx*3+2]=part->mPosition[2] + mCameraLeftMinusUp[2]; + idx++; + memcpy(col+idx*4, curcol, 4*sizeof(GLfloat)); + tex[idx*2+0]=0.0f; tex[idx*2+1]=1.0f; + vtx[idx*3+0]=part->mPosition[0] + mCameraLeftPlusUp[0]; + vtx[idx*3+1]=part->mPosition[1] + mCameraLeftPlusUp[1]; + vtx[idx*3+2]=part->mPosition[2] + mCameraLeftPlusUp[2]; + idx++; +#else // Left bottom. qglTexCoord2f( 0.0, 0.0 ); qglVertex3f(part->mPosition[0] - mCameraLeftMinusUp[0], @@ -1547,12 +1689,44 @@ public: qglVertex3f(part->mPosition[0] + mCameraLeftPlusUp[0], part->mPosition[1] + mCameraLeftPlusUp[1], part->mPosition[2] + mCameraLeftPlusUp[2] ); +#endif } } +#ifndef HAVE_GLES qglEnd(); +#endif - qglEnable(GL_CULL_FACE); - qglPopMatrix(); + if (mGLModeEnum==GL_POINTS) + { + //qglDisable(GL_POINT_SPRITE_NV); + //qglTexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, GL_FALSE); + } + else + { + //qglEnable(GL_CULL_FACE); + //you don't need to do this when you are properly setting cull state. +#ifdef HAVE_GLES + // if (mGLModeEnum==GL_TRIANGLES) { + qglTexCoordPointer( 2, GL_FLOAT, 0, tex ); + qglVertexPointer ( 3, GL_FLOAT, 0, vtx ); + qglColorPointer (4, GL_FLOAT, 0, col ); + qglDrawArrays( GL_TRIANGLES, 0, idx ); +// } +#endif + + qglPopMatrix(); + } +#ifdef HAVE_GLES + if (!glcol) + qglDisableClientState( GL_COLOR_ARRAY ); + if (mGLModeEnum == GL_POINTS ) { + if (!text) + qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); + } else { + if (text) + qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + } +#endif mParticlesRendered += mParticleCountRender; } diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_backend.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_backend.cpp index bca7c13..ddc5df7 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_backend.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_backend.cpp @@ -641,14 +641,14 @@ typedef struct int dlighted; int depthRange; drawSurf_t *drawSurf; - shader_t *shader; + jk_shader_t *shader; } postRender_t; static postRender_t g_postRenders[MAX_POST_RENDERS]; static int g_numPostRenders = 0; void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { - shader_t *shader, *oldShader; + jk_shader_t *shader, *oldShader; int fogNum, oldFogNum; int entityNum, oldEntityNum; int dlighted, oldDlighted; @@ -1033,7 +1033,7 @@ RB_StretchPic */ const void *RB_StretchPic ( const void *data ) { const stretchPicCommand_t *cmd; - shader_t *shader; + jk_shader_t *shader; int numVerts, numIndexes; cmd = (const stretchPicCommand_t *)data; @@ -1111,7 +1111,7 @@ RB_RotatePic const void *RB_RotatePic ( const void *data ) { const rotatePicCommand_t *cmd; - shader_t *shader; + jk_shader_t *shader; cmd = (const rotatePicCommand_t *)data; @@ -1199,7 +1199,7 @@ RB_RotatePic2 const void *RB_RotatePic2 ( const void *data ) { const rotatePicCommand_t *cmd; - shader_t *shader; + jk_shader_t *shader; cmd = (const rotatePicCommand_t *)data; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_bsp.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_bsp.cpp index 4f93403..9216ac6 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_bsp.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_bsp.cpp @@ -316,8 +316,8 @@ static void R_LoadVisibility( lump_t *l, world_t &worldData ) { ShaderForShaderNum =============== */ -static shader_t *ShaderForShaderNum( int shaderNum, const int *lightmapNum, const byte *lightmapStyles, const byte *vertexStyles, world_t &worldData ) { - shader_t *shader; +static jk_shader_t *ShaderForShaderNum( int shaderNum, const int *lightmapNum, const byte *lightmapStyles, const byte *vertexStyles, world_t &worldData ) { + jk_shader_t *shader; dshader_t *dsh; const byte *styles; @@ -988,7 +988,7 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump, world int count, brushesCount, sidesCount; int sideNum; int planeNum; - shader_t *shader; + jk_shader_t *shader; float d; int firstSide=0; int lightmaps[MAXLIGHTMAPS] = { LIGHTMAP_NONE } ; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_ghoul2.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_ghoul2.cpp index e95decb..6502946 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_ghoul2.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_ghoul2.cpp @@ -658,7 +658,7 @@ class CRenderSurface public: int surfaceNum; surfaceInfo_v &rootSList; - const shader_t *cust_shader; + const jk_shader_t *cust_shader; int fogNum; qboolean personalModel; CBoneCache *boneCache; @@ -668,14 +668,14 @@ public: int lod; boltInfo_v &boltList; #ifdef _G2_GORE - shader_t *gore_shader; + jk_shader_t *gore_shader; CGoreSet *gore_set; #endif CRenderSurface( int initsurfaceNum, surfaceInfo_v &initrootSList, - const shader_t *initcust_shader, + const jk_shader_t *initcust_shader, int initfogNum, qboolean initpersonalModel, CBoneCache *initboneCache, @@ -685,7 +685,7 @@ public: int initlod, #ifdef _G2_GORE boltInfo_v &initboltList, - shader_t *initgore_shader, + jk_shader_t *initgore_shader, CGoreSet *initgore_set): #else boltInfo_v &initboltList): @@ -2239,7 +2239,7 @@ void G2API_SetSurfaceOnOffFromSkin (CGhoul2Info *ghlInfo, qhandle_t renderSkin) void RenderSurfaces(CRenderSurface &RS) { int i; - const shader_t *shader = 0; + const jk_shader_t *shader = 0; int offFlags = 0; #ifdef _G2_GORE bool drawGore = true; @@ -2385,7 +2385,7 @@ void RenderSurfaces(CRenderSurface &RS) newSurf2->scale=1.0f; } } - shader_t *gshader; + jk_shader_t *gshader; if ((*kcur).second.shader) { gshader=R_GetShaderByHandle((*kcur).second.shader); @@ -2556,9 +2556,9 @@ R_AddGHOULSurfaces ============== */ void R_AddGhoulSurfaces( trRefEntity_t *ent ) { - shader_t *cust_shader = 0; + jk_shader_t *cust_shader = 0; #ifdef _G2_GORE - shader_t *gore_shader = 0; + jk_shader_t *gore_shader = 0; #endif int fogNum = 0; qboolean personalModel; @@ -3501,7 +3501,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean mdxmSurface_t *surf; int version; int size; - shader_t *sh; + jk_shader_t *sh; mdxmSurfHierarchy_t *surfInfo; #ifdef Q3_BIG_ENDIAN diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_image.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_image.cpp index 644cf9e..48ee3bf 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_image.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_image.cpp @@ -31,6 +31,13 @@ along with this program; if not, see . #include #include +#if !defined(GL_RGB5) +#define GL_RGB5 0x8050 // same as GL_RGB5_EXT +#endif +#if !defined(GL_RGBA4) +#define GL_RGBA4 0x8056 // same as GL_RGBA4_EXT and GL_RGBA4_OES +#endif + static byte s_intensitytable[256]; static unsigned char s_gammatable[256]; @@ -40,6 +47,103 @@ int gl_filter_max = GL_LINEAR; #define FILE_HASH_SIZE 1024 // actually, the shader code needs this (from another module, great). //static image_t* hashTable[FILE_HASH_SIZE]; + +#ifdef HAVE_GLES +// helper function for GLES format conversions +byte * gles_convertRGB(byte * data, int width, int height) +{ + byte * temp = (byte *) Z_Malloc (width*height*3, TAG_TEMP_WORKSPACE, qfalse); + byte *src = data; + byte *dst = temp; + + for (int i=0; i> 8) & 0xff; + unsigned int b = (pixel >> 16) & 0xff; + unsigned int a = (pixel >> 24) & 0xff; + // Convert to 4 bit vales + r >>= 4; g >>= 4; b >>= 4; a >>= 4; + output[i] = r << 12 | g << 8 | b << 4 | a; + } + return temp; +} + +byte * gles_convertRGB5(byte * data, int width, int height) +{ + byte * temp = (byte *) Z_Malloc (width*height*2, TAG_TEMP_WORKSPACE, qfalse); + byte *src = data; + byte *dst = temp; + byte r,g,b; + + unsigned int * input = ( unsigned int *)(data); + unsigned short* output = (unsigned short*)(temp); + for (int i = 0; i < width*height; i++) { + unsigned int pixel = input[i]; + // Unpack the source data as 8 bit values + unsigned int r = pixel & 0xff; + unsigned int g = (pixel >> 8) & 0xff; + unsigned int b = (pixel >> 16) & 0xff; + // Convert to 4 bit vales + r >>= 3; g >>= 2; b >>= 3; + output[i] = r << 11 | g << 5 | b; + } + return temp; +} +byte * gles_convertLuminance(byte * data, int width, int height) +{ + byte * temp = (byte *) Z_Malloc (width*height, TAG_TEMP_WORKSPACE, qfalse); + byte *src = data; + byte *dst = temp; + byte r,g,b; + int i; + + unsigned int * input = ( unsigned int *)(data); + byte* output = (byte*)(temp); + for (i = 0; i < width*height; i++) { + unsigned int pixel = input[i]; + // Unpack the source data as 8 bit values + unsigned int r = pixel & 0xff; + output[i] = r; + } + return temp; +} +byte * gles_convertLuminanceAlpha(byte * data, int width, int height) +{ + byte * temp = (byte *) Z_Malloc (width*height*2, TAG_TEMP_WORKSPACE, qfalse); + byte *src = data; + byte *dst = temp; + byte r,g,b; + int i; + + unsigned int * input = ( unsigned int *)(data); + unsigned short* output = (unsigned short*)(temp); + for (i = 0; i < width*height; i++) { + unsigned int pixel = input[i]; + // Unpack the source data as 8 bit values + unsigned int r = pixel & 0xff; + unsigned int a = (pixel >> 24) & 0xff; + output[i] = r | a<<8; + } + return temp; +} +#endif + /* ** R_GammaCorrect */ @@ -188,6 +292,7 @@ static float R_BytesPerTex (int format) #endif break; +#ifndef HAVE_GLES case GL_RGBA4: //"RGBA4" return 2; @@ -197,7 +302,6 @@ static float R_BytesPerTex (int format) return 2; break; -#ifndef HAVE_GLES case GL_RGBA8: //"RGBA8" return 4; @@ -329,9 +433,9 @@ void R_ImageList_f( void ) { case GL_CLAMP: ri.Printf( PRINT_ALL, "clmp " ); break; - case GL_CLAMP_TO_EDGE: - ri.Printf( PRINT_ALL, "clpE " ); - break; +// case GL_CLAMP_TO_EDGE: +// ri.Printf( PRINT_ALL, "clpE " ); +// break; default: ri.Printf( PRINT_ALL, "%4i ", image->wrapClampMode ); break; @@ -564,200 +668,294 @@ Upload32 =============== */ +extern qboolean charSet; static void Upload32( unsigned *data, - GLenum format, - qboolean mipmap, - qboolean picmip, - qboolean isLightmap, - qboolean allowTC, - int *pformat, - word *pUploadWidth, word *pUploadHeight ) + GLenum format, + qboolean mipmap, + qboolean picmip, + qboolean isLightmap, + qboolean allowTC, + int *pformat, + word *pUploadWidth, word *pUploadHeight, bool bRectangle = false ) { + GLuint uiTarget = GL_TEXTURE_2D; +#ifndef HAVE_GLES + if ( bRectangle ) + { + uiTarget = GL_TEXTURE_RECTANGLE_EXT; + } +#else + //Humm.. +#endif if (format == GL_RGBA) { - int samples; - int i, c; - byte *scan; - float rMax = 0, gMax = 0, bMax = 0; - int width = *pUploadWidth; - int height = *pUploadHeight; + int samples; + int i, c; + byte *scan; + float rMax = 0, gMax = 0, bMax = 0; + int width = *pUploadWidth; + int height = *pUploadHeight; - // - // perform optional picmip operation - // - if ( picmip ) { - for(i = 0; i < r_picmip->integer; i++) { - R_MipMap( (byte *)data, width, height ); - width >>= 1; - height >>= 1; - if (width < 1) { - width = 1; - } - if (height < 1) { - height = 1; - } - } - } + // + // perform optional picmip operation + // + if ( picmip ) { + for(i = 0; i < r_picmip->integer; i++) { - // - // clamp to the current upper OpenGL limit - // scale both axis down equally so we don't have to - // deal with a half mip resampling - // - while ( width > glConfig.maxTextureSize || height > glConfig.maxTextureSize ) { - R_MipMap( (byte *)data, width, height ); - width >>= 1; - height >>= 1; - } + if ((width>16) && (height>16)) { + R_MipMap( (byte *)data, width, height ); + width >>= 1; + height >>= 1; + if (width < 1) { + width = 1; + } + if (height < 1) { + height = 1; + } + } + } + } - // - // scan the texture for each channel's max values - // and verify if the alpha channel is being used or not - // - c = width*height; - scan = ((byte *)data); - samples = 3; - for ( i = 0; i < c; i++ ) - { - if ( scan[i*4+0] > rMax ) - { - rMax = scan[i*4+0]; - } - if ( scan[i*4+1] > gMax ) - { - gMax = scan[i*4+1]; - } - if ( scan[i*4+2] > bMax ) - { - bMax = scan[i*4+2]; - } - if ( scan[i*4 + 3] != 255 ) - { - samples = 4; - break; - } - } + // + // clamp to the current upper OpenGL limit + // scale both axis down equally so we don't have to + // deal with a half mip resampling + // + while ( width > glConfig.maxTextureSize || height > glConfig.maxTextureSize ) { + R_MipMap( (byte *)data, width, height ); + width >>= 1; + height >>= 1; + } - // select proper internal format - if ( samples == 3 ) - { - if ( glConfig.textureCompression == TC_S3TC && allowTC ) - { - *pformat = GL_RGB4_S3TC; - } - else if ( glConfig.textureCompression == TC_S3TC_DXT && allowTC ) - { // Compress purely color - no alpha - if ( r_texturebits->integer == 16 ) { - *pformat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; //this format cuts to 16 bit - } - else {//if we aren't using 16 bit then, use 32 bit compression - *pformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - } - else if ( isLightmap && r_texturebitslm->integer > 0 ) - { - // Allow different bit depth when we are a lightmap - if ( r_texturebitslm->integer == 16 ) - { - *pformat = GL_RGB5; - } - else if ( r_texturebitslm->integer == 32 ) - { - *pformat = GL_RGB8; - } - } - else if ( r_texturebits->integer == 16 ) - { - *pformat = GL_RGB5; - } - else if ( r_texturebits->integer == 32 ) - { - *pformat = GL_RGB8; - } - else - { - *pformat = 3; - } - } - else if ( samples == 4 ) - { - if ( glConfig.textureCompression == TC_S3TC_DXT && allowTC) - { // Compress both alpha and color - *pformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - else if ( r_texturebits->integer == 16 ) - { - *pformat = GL_RGBA4; - } - else if ( r_texturebits->integer == 32 ) - { - *pformat = GL_RGBA8; - } - else - { - *pformat = 4; - } - } + // + // scan the texture for each channel's max values + // and verify if the alpha channel is being used or not + // + c = width*height; + scan = ((byte *)data); + samples = 3; + for ( i = 0; i < c; i++ ) + { + if ( scan[i*4+0] > rMax ) + { + rMax = scan[i*4+0]; + } + if ( scan[i*4+1] > gMax ) + { + gMax = scan[i*4+1]; + } + if ( scan[i*4+2] > bMax ) + { + bMax = scan[i*4+2]; + } + if ( scan[i*4 + 3] != 255 ) + { + samples = 4; + break; + } + } + + // select proper internal format + if ( samples == 3 ) + { + if ( glConfig.textureCompression == TC_S3TC && allowTC ) + { +#ifdef HAVE_GLES + assert(0); +#else + *pformat = GL_RGB4_S3TC; +#endif + } + else if ( glConfig.textureCompression == TC_S3TC_DXT && allowTC ) + { // Compress purely color - no alpha + if ( r_texturebits->integer == 16 ) { +#ifdef HAVE_GLES + assert(0); +#else + *pformat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; //this format cuts to 16 bit +#endif + } + else {//if we aren't using 16 bit then, use 32 bit compression +#ifdef HAVE_GLES + assert(0); +#else + *pformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; +#endif + } + } + else if ( isLightmap && r_texturebitslm->integer > 0 ) + { + int lmBits = r_texturebitslm->integer & 0x30; // 16 or 32 + // Allow different bit depth when we are a lightmap + if ( lmBits == 16 ) + *pformat = GL_RGB5; + else +#ifdef HAVE_GLES + *pformat = GL_RGB; +#else + *pformat = GL_RGB8; +#endif + } + else if ( r_texturebits->integer == 16 ) + { + *pformat = GL_RGB5; + } + else if ( r_texturebits->integer == 32 ) + { +#ifdef HAVE_GLES + *pformat = GL_RGB; +#else + *pformat = GL_RGB8; +#endif + } + else + { +#ifdef HAVE_GLES + *pformat = GL_RGB; +#else + *pformat = 3; +#endif + } + } + else if ( samples == 4 ) + { + if ( glConfig.textureCompression == TC_S3TC_DXT && allowTC) + { // Compress both alpha and color +#ifdef HAVE_GLES + assert(0); +#else + *pformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; +#endif + } + else if ( r_texturebits->integer == 16 ) + { + *pformat = GL_RGBA4; + } + else if ( r_texturebits->integer == 32 ) + { +#ifdef HAVE_GLES + *pformat = GL_RGBA; +#else + *pformat = GL_RGBA8; +#endif + } + else + { +#ifdef HAVE_GLES + *pformat = GL_RGBA; +#else + *pformat = 4; +#endif + } + } *pUploadWidth = width; *pUploadHeight = height; - // copy or resample data as appropriate for first MIP level - if (!mipmap) - { - qglTexImage2D (GL_TEXTURE_2D, 0, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); - goto done; - } + // copy or resample data as appropriate for first MIP level +#ifdef HAVE_GLES + #ifdef PANDORA + // SGX Workaround#2 : if width or height<=16 => make it bigger + #endif + //*pformat = GL_RGBA; + R_LightScaleTexture (data, width, height, mipmap?qfalse:qtrue ); - R_LightScaleTexture (data, width, height, (qboolean)!mipmap); + glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap)?GL_TRUE:GL_FALSE ); - qglTexImage2D (GL_TEXTURE_2D, 0, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); + // and now, convert if needed and upload + // GLES doesn't do convertion itself, so we have to handle that + byte *temp; + switch ( *pformat ) { + case GL_RGB5: + temp = gles_convertRGB5((byte*)data, width, height); + qglTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, temp); + Z_Free(temp); + break; + case GL_RGBA4: + temp = gles_convertRGBA4((byte*)data, width, height); + qglTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, temp); + Z_Free(temp); + break; + case 3: + case GL_RGB: + temp = gles_convertRGB((byte*)data, width, height); + qglTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, temp); + Z_Free(temp); + break; + case 1: + temp = gles_convertLuminance((byte*)data, width, height); + qglTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, temp); + Z_Free(temp); + break; + case 2: + temp = gles_convertLuminanceAlpha((byte*)data, width, height); + qglTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, temp); + Z_Free(temp); + break; + default: + *pformat = GL_RGBA; + qglTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + } - if (mipmap) - { - int miplevel; - miplevel = 0; - while (width > 1 || height > 1) - { - R_MipMap( (byte *)data, width, height ); - width >>= 1; - height >>= 1; - if (width < 1) - width = 1; - if (height < 1) - height = 1; - miplevel++; + // qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + // qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); +#else + if (!mipmap) + { + qglTexImage2D( uiTarget, 0, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); + goto done; + } - if ( r_colorMipLevels->integer ) - { - R_BlendOverTexture( (byte *)data, width * height, mipBlendColors[miplevel] ); - } + R_LightScaleTexture (data, width, height, (qboolean)!mipmap ); - qglTexImage2D (GL_TEXTURE_2D, miplevel, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); - } - } + qglTexImage2D( uiTarget, 0, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); + + if (mipmap) + { + int miplevel; + + miplevel = 0; + while (width > 1 || height > 1) + { + R_MipMap( (byte *)data, width, height ); + width >>= 1; + height >>= 1; + if (width < 1) + width = 1; + if (height < 1) + height = 1; + miplevel++; + + if ( r_colorMipLevels->integer ) + { + R_BlendOverTexture( (byte *)data, width * height, mipBlendColors[miplevel] ); + } + + qglTexImage2D( uiTarget, miplevel, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); + } + } +#endif } else { - } -done: + done: if (mipmap) { - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); - if( r_ext_texture_filter_anisotropic->integer > 1 && glConfig.maxTextureFilterAnisotropy > 0 ) + qglTexParameterf(uiTarget, GL_TEXTURE_MIN_FILTER, gl_filter_min); + qglTexParameterf(uiTarget, GL_TEXTURE_MAG_FILTER, gl_filter_max); + if(r_ext_texture_filter_anisotropic->integer>1 && glConfig.maxTextureFilterAnisotropy>0) { qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, r_ext_texture_filter_anisotropic->value ); } } else { - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + qglTexParameterf(uiTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexParameterf(uiTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } GL_CheckErrors(); @@ -1280,7 +1478,9 @@ static void R_CreateFogImage( void ) { borderColor[2] = 1.0; borderColor[3] = 1; +#ifndef HAVE_GLES qglTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor ); +#endif } /* @@ -1334,31 +1534,31 @@ void R_CreateBuiltinImages( void ) { // we use a solid white image instead of disabling texturing memset( data, 255, sizeof( data ) ); - - tr.whiteImage = R_CreateImage("*white", (byte *)data, 8, 8, GL_RGBA, qfalse, qfalse, qtrue, GL_REPEAT); + tr.whiteImage = R_CreateImage("*white", (byte *)data, 8, 8, GL_RGBA, qfalse, qfalse, qfalse, GL_REPEAT); tr.screenImage = R_CreateImage("*screen", (byte *)data, 8, 8, GL_RGBA, qfalse, qfalse, qfalse, GL_REPEAT ); +#ifndef HAVE_GLES // Create the scene glow image. - AReis tr.screenGlow = 1024 + giTextureBindNum++; qglDisable( GL_TEXTURE_2D ); - qglEnable( GL_TEXTURE_RECTANGLE_ARB ); - qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, tr.screenGlow ); - qglTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA16, glConfig.vidWidth, glConfig.vidHeight, 0, GL_RGB, GL_FLOAT, 0 ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + qglEnable( GL_TEXTURE_RECTANGLE_EXT ); + qglBindTexture( GL_TEXTURE_RECTANGLE_EXT, tr.screenGlow ); + qglTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA16, glConfig.vidWidth, glConfig.vidHeight, 0, GL_RGB, GL_FLOAT, 0 ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP ); // Create the scene image. - AReis tr.sceneImage = 1024 + giTextureBindNum++; - qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, tr.sceneImage ); - qglTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA16, glConfig.vidWidth, glConfig.vidHeight, 0, GL_RGB, GL_FLOAT, 0 ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + qglBindTexture( GL_TEXTURE_RECTANGLE_EXT, tr.sceneImage ); + qglTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA16, glConfig.vidWidth, glConfig.vidHeight, 0, GL_RGB, GL_FLOAT, 0 ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP ); // Create the minimized scene blur image. if ( r_DynamicGlowWidth->integer > glConfig.vidWidth ) @@ -1370,13 +1570,13 @@ void R_CreateBuiltinImages( void ) { r_DynamicGlowHeight->integer = glConfig.vidHeight; } tr.blurImage = 1024 + giTextureBindNum++; - qglBindTexture( GL_TEXTURE_RECTANGLE_ARB, tr.blurImage ); - qglTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA16, r_DynamicGlowWidth->integer, r_DynamicGlowHeight->integer, 0, GL_RGB, GL_FLOAT, 0 ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - qglTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - qglDisable( GL_TEXTURE_RECTANGLE_ARB ); + qglBindTexture( GL_TEXTURE_RECTANGLE_EXT, tr.blurImage ); + qglTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA16, r_DynamicGlowWidth->integer, r_DynamicGlowHeight->integer, 0, GL_RGB, GL_FLOAT, 0 ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP ); + qglTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP ); + qglDisable( GL_TEXTURE_RECTANGLE_EXT ); qglEnable( GL_TEXTURE_2D ); @@ -1391,16 +1591,17 @@ void R_CreateBuiltinImages( void ) { } } +#endif // HAVE_GLES - tr.identityLightImage = R_CreateImage("*identityLight", (byte *)data, 8, 8, GL_RGBA, qfalse, qfalse, qtrue, GL_REPEAT); + tr.identityLightImage = R_CreateImage("*identityLight", (byte *)data, 8, 8, GL_RGBA, qfalse, qfalse, qfalse, GL_REPEAT); - // scratchimage is usually used for cinematic drawing for(x=0;x= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);} @@ -1736,7 +1736,7 @@ typedef struct { typedef struct { int commandId; - shader_t *shader; + jk_shader_t *shader; float x, y; float w, h; float s1, t1; @@ -1745,7 +1745,7 @@ typedef struct { typedef struct { int commandId; - shader_t *shader; + jk_shader_t *shader; float x, y; float w, h; float s1, t1; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_main.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_main.cpp index 09bbe4d..1def3ba 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_main.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_main.cpp @@ -891,7 +891,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 float shortest = 1000000000; int entityNum; int numTriangles; - shader_t *shader; + jk_shader_t *shader; int fogNum; int dlighted; vec4_t clip, eye; @@ -1159,7 +1159,7 @@ static void R_RadixSort( drawSurf_t *source, int size ) R_AddDrawSurf ================= */ -void R_AddDrawSurf( const surfaceType_t *surface, const shader_t *shader, int fogIndex, int dlightMap ) +void R_AddDrawSurf( const surfaceType_t *surface, const jk_shader_t *shader, int fogIndex, int dlightMap ) { int index; @@ -1190,7 +1190,7 @@ void R_AddDrawSurf( const surfaceType_t *surface, const shader_t *shader, int fo R_DecomposeSort ================= */ -void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, +void R_DecomposeSort( unsigned sort, int *entityNum, jk_shader_t **shader, int *fogNum, int *dlightMap ) { *fogNum = ( sort >> QSORT_FOGNUM_SHIFT ) & 31; *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1) ]; @@ -1204,7 +1204,7 @@ R_SortDrawSurfs ================= */ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { - shader_t *shader; + jk_shader_t *shader; int fogNum; int entityNum; int dlighted; @@ -1260,7 +1260,7 @@ R_AddEntitySurfaces */ void R_AddEntitySurfaces (void) { trRefEntity_t *ent; - shader_t *shader; + jk_shader_t *shader; if ( !r_drawentities->integer ) { return; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_mesh.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_mesh.cpp index bea685f..17b6412 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_mesh.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_mesh.cpp @@ -304,8 +304,8 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { md3Header_t *header = 0; md3Surface_t *surface = 0; md3Shader_t *md3Shader = 0; - shader_t *shader = 0; - shader_t *main_shader = 0; + jk_shader_t *shader = 0; + jk_shader_t *main_shader = 0; int cull; int lod; int fogNum; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_model.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_model.cpp index 9b2d74f..058fb1c 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_model.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_model.cpp @@ -223,7 +223,7 @@ void *RE_RegisterModels_Malloc(int iSize, void *pvDiskBufferIfJustLoaded, const const char *const psShaderName = &((char*)ModelBin.pModelDiskImage)[iShaderNameOffset]; int *const piShaderPokePtr= (int *) &((char*)ModelBin.pModelDiskImage)[iShaderPokeOffset]; - shader_t *sh = R_FindShader( psShaderName, lightmapsNone, stylesDefault, qtrue ); + jk_shader_t *sh = R_FindShader( psShaderName, lightmapsNone, stylesDefault, qtrue ); if ( sh->defaultShader ) { @@ -921,7 +921,7 @@ static qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_ // register the shaders shader = (md3Shader_t *) ( (byte *)surf + surf->ofsShaders ); for ( j = 0 ; j < surf->numShaders ; j++, shader++ ) { - shader_t *sh; + jk_shader_t *sh; sh = R_FindShader( shader->name, lightmapsNone, stylesDefault, qtrue ); if ( sh->defaultShader ) { diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_scene.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_scene.cpp index 3e58fa8..fb271bb 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_scene.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_scene.cpp @@ -98,7 +98,7 @@ Adds all the scene's polys into this view's drawsurf list */ void R_AddPolygonSurfaces( void ) { int i; - shader_t *sh; + jk_shader_t *sh; srfPoly_t *poly; tr.currentEntityNum = REFENTITYNUM_WORLD; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shade.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shade.cpp index 5c6a14f..046a72a 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shade.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shade.cpp @@ -316,103 +316,34 @@ DrawTris Draws triangle outlines for debugging ================ */ -static void DrawTris (shaderCommands_t *input) -{ +static void DrawTris (shaderCommands_t *input) { + if (input->numVertexes <= 0) { + return; + } + GL_Bind( tr.whiteImage ); + qglColor3f (1,1,1); - if ( r_showtriscolor->integer ) - { - int i = r_showtriscolor->integer; - if (i == 42) { - i = Q_irand(0,8); - } - switch (i) - { - case 1: - qglColor3f( 1.0, 0.0, 0.0); //red - break; - case 2: - qglColor3f( 0.0, 1.0, 0.0); //green - break; - case 3: - qglColor3f( 1.0, 1.0, 0.0); //yellow - break; - case 4: - qglColor3f( 0.0, 0.0, 1.0); //blue - break; - case 5: - qglColor3f( 0.0, 1.0, 1.0); //cyan - break; - case 6: - qglColor3f( 1.0, 0.0, 1.0); //magenta - break; - case 7: - qglColor3f( 0.8f, 0.8f, 0.8f); //white/grey - break; - case 8: - qglColor3f( 0.0, 0.0, 0.0); //black - break; - } - } - else - { - qglColor3f( 1.0, 1.0, 1.0); //white + GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE ); + qglDepthRange( 0, 0 ); + + qglDisableClientState (GL_COLOR_ARRAY); + qglDisableClientState (GL_TEXTURE_COORD_ARRAY); + + qglVertexPointer (3, GL_FLOAT, 16, input->xyz); // padded for SIMD + + if (qglLockArraysEXT) { + qglLockArraysEXT(0, input->numVertexes); + GLimp_LogComment( "glLockArraysEXT\n" ); } - if ( r_showtris->integer == 2 ) - { - // tries to do non-xray style showtris - GL_State( GLS_POLYMODE_LINE ); + R_DrawElements( input->numIndexes, input->indexes ); - qglEnable( GL_POLYGON_OFFSET_LINE ); - qglPolygonOffset( -1, -2 ); - - qglDisableClientState( GL_COLOR_ARRAY ); - qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); - - qglVertexPointer( 3, GL_FLOAT, 16, input->xyz ); // padded for SIMD - - if ( qglLockArraysEXT ) - { - qglLockArraysEXT( 0, input->numVertexes ); - GLimp_LogComment( "glLockArraysEXT\n" ); - } - - R_DrawElements( input->numIndexes, input->indexes ); - - if ( qglUnlockArraysEXT ) - { - qglUnlockArraysEXT( ); - GLimp_LogComment( "glUnlockArraysEXT\n" ); - } - - qglDisable( GL_POLYGON_OFFSET_LINE ); - } - else - { - // same old showtris - GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE ); - qglDepthRange( 0, 0 ); - - qglDisableClientState (GL_COLOR_ARRAY); - qglDisableClientState (GL_TEXTURE_COORD_ARRAY); - - qglVertexPointer (3, GL_FLOAT, 16, input->xyz); // padded for SIMD - - if (qglLockArraysEXT) { - qglLockArraysEXT(0, input->numVertexes); - GLimp_LogComment( "glLockArraysEXT\n" ); - } - - R_DrawElements( input->numIndexes, input->indexes ); - - if (qglUnlockArraysEXT) { - qglUnlockArraysEXT(); - GLimp_LogComment( "glUnlockArraysEXT\n" ); - } - - qglDepthRange( 0, 1 ); + if (qglUnlockArraysEXT) { + qglUnlockArraysEXT(); + GLimp_LogComment( "glUnlockArraysEXT\n" ); } + qglDepthRange( 0, 1 ); } /* @@ -431,6 +362,9 @@ static void DrawNormals (shaderCommands_t *input) { qglDepthRange( 0, 0 ); // never occluded GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE ); +#ifdef HAVE_GLES + /*SEB *TODO* */ +#else qglBegin (GL_LINES); for (i = 0 ; i < input->numVertexes ; i++) { qglVertex3fv (input->xyz[i]); @@ -438,6 +372,7 @@ static void DrawNormals (shaderCommands_t *input) { qglVertex3fv (temp); } qglEnd (); +#endif qglDepthRange( 0, 1 ); } @@ -452,9 +387,9 @@ because a surface may be forced to perform a RB_End due to overflow. ============== */ -void RB_BeginSurface( shader_t *shader, int fogNum ) { -// shader_t *state = (shader->remappedShader) ? shader->remappedShader : shader; - shader_t *state = shader; +void RB_BeginSurface( jk_shader_t *shader, int fogNum ) { +// jk_shader_t *state = (shader->remappedShader) ? shader->remappedShader : shader; + jk_shader_t *state = shader; tess.numIndexes = 0; tess.numVertexes = 0; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shader.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shader.cpp index 4533aef..c319025 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shader.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shader.cpp @@ -35,7 +35,7 @@ static char *s_shaderText; // the shader is parsed into these global variables, then copied into // dynamically allocated memory if it is valid. static shaderStage_t stages[MAX_SHADER_STAGES]; -static shader_t shader; +static jk_shader_t shader; static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; // Hash value (generated using the generateHashValueForText function) for the original @@ -48,7 +48,7 @@ static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; #define FILE_HASH_SIZE 1024 -static shader_t* sh_hashTable[FILE_HASH_SIZE]; +static jk_shader_t* sh_hashTable[FILE_HASH_SIZE]; const int lightmapsNone[MAXLIGHTMAPS] = { @@ -130,7 +130,7 @@ way to ask for different implicit lighting modes (vertex, lightmap, etc) */ qhandle_t RE_RegisterShaderLightMap( const char *name, const int *lightmapIndex, const byte *styles ) { - shader_t *sh; + jk_shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { Com_Printf( "Shader name exceeds MAX_QPATH\n" ); @@ -159,10 +159,10 @@ Will always return a valid shader, but it might be the default shader if the real one can't be found. ================== */ -shader_t *R_FindShaderByName( const char *name ) { +jk_shader_t *R_FindShaderByName( const char *name ) { char strippedName[MAX_QPATH]; int hash; - shader_t *sh; + jk_shader_t *sh; if ( (name==NULL) || (name[0] == 0) ) { // bk001205 return tr.defaultShader; @@ -193,7 +193,7 @@ shader_t *R_FindShaderByName( const char *name ) { void R_RemapShader(const char *shaderName, const char *newShaderName, const char *timeOffset) { char strippedName[MAX_QPATH]; int hash; - shader_t *sh, *sh2; + jk_shader_t *sh, *sh2; qhandle_t h; sh = R_FindShaderByName( shaderName ); @@ -2698,7 +2698,7 @@ static void FixRenderCommandList( int newShader ) { { int i; drawSurf_t *drawSurf; - shader_t *shader; + jk_shader_t *shader; int fogNum; int entityNum; int dlightMap; @@ -2758,7 +2758,7 @@ Sets shader->sortedIndex static void SortNewShader( void ) { int i; float sort; - shader_t *newShader; + jk_shader_t *newShader; newShader = tr.shaders[ tr.numShaders - 1 ]; sort = newShader->sort; @@ -2785,8 +2785,8 @@ static void SortNewShader( void ) { GeneratePermanentShader ==================== */ -static shader_t *GeneratePermanentShader( void ) { - shader_t *newShader; +static jk_shader_t *GeneratePermanentShader( void ) { + jk_shader_t *newShader; int i, b; int size; @@ -2796,7 +2796,7 @@ static shader_t *GeneratePermanentShader( void ) { return tr.defaultShader; } - newShader = (shader_t *)R_Hunk_Alloc( sizeof( shader_t ), qtrue ); + newShader = (jk_shader_t *)R_Hunk_Alloc( sizeof( jk_shader_t ), qtrue ); *newShader = shader; @@ -2967,7 +2967,7 @@ Returns a freshly allocated shader with all the needed info from the current global working shader ========================= */ -static shader_t *FinishShader( void ) { +static jk_shader_t *FinishShader( void ) { int stage, lmStage, stageIndex; qboolean hasLightmapStage; @@ -3323,7 +3323,7 @@ static const char *FindShaderInShaderText( const char *shadername ) { #endif } -inline qboolean IsShader(shader_t *sh, const char *name, const int *lightmapIndex, const byte *styles) +inline qboolean IsShader(jk_shader_t *sh, const char *name, const int *lightmapIndex, const byte *styles) { int i; @@ -3422,12 +3422,12 @@ and src*dest blending applied with the texture, as apropriate for most world construction surfaces. =============== */ -shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage ) { +jk_shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage ) { char strippedName[MAX_QPATH]; int hash; const char *shaderText; image_t *image; - shader_t *sh; + jk_shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { Com_Printf( S_COLOR_RED"Shader name exceeds MAX_QPATH! %s\n",name ); @@ -3569,7 +3569,7 @@ way to ask for different implicit lighting modes (vertex, lightmap, etc) ==================== */ qhandle_t RE_RegisterShader( const char *name ) { - shader_t *sh; + jk_shader_t *sh; sh = R_FindShader( name, lightmaps2d, stylesDefault, qtrue ); @@ -3594,7 +3594,7 @@ For menu graphics that should never be picmiped ==================== */ qhandle_t RE_RegisterShaderNoMip( const char *name ) { - shader_t *sh; + jk_shader_t *sh; sh = R_FindShader( name, lightmaps2d, stylesDefault, qfalse ); @@ -3616,10 +3616,10 @@ qhandle_t RE_RegisterShaderNoMip( const char *name ) { R_GetShaderByHandle When a handle is passed in by another module, this range checks -it and returns a valid (possibly default) shader_t to be used internally. +it and returns a valid (possibly default) jk_shader_t to be used internally. ==================== */ -shader_t *R_GetShaderByHandle( qhandle_t hShader ) { +jk_shader_t *R_GetShaderByHandle( qhandle_t hShader ) { if ( hShader < 0 ) { ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); return tr.defaultShader; @@ -3642,7 +3642,7 @@ A second parameter will cause it to print in sorted order void R_ShaderList_f (void) { int i; int count; - shader_t *shader; + jk_shader_t *shader; ri.Printf (PRINT_ALL, "-----------------------\n"); diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shadows.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shadows.cpp index f383433..e76968c 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shadows.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_shadows.cpp @@ -825,22 +825,52 @@ void RB_DistortionFill(void) } spost2 *= 0.2f; +#ifdef HAVE_GLES + qglColor4f(1.0f, 1.0f, 1.0f, alpha); +/* GLboolean text = qglIsEnabled(GL_TEXTURE_COORD_ARRAY); + GLboolean glcol = qglIsEnabled(GL_COLOR_ARRAY); + if (!text) + qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + if (glcol) + qglDisableClientState( GL_COLOR_ARRAY );*/ + GLfloat tex[] = { + 0+spost2, 1-spost, + 0+spost2, 0+spost, + 1-spost2, 0+spost, + 1-spost2, 1-spost + }; + GLfloat vtx[] = { + 0, 0, + 0, glConfig.vidHeight, + glConfig.vidWidth, glConfig.vidHeight, + glConfig.vidWidth, 0 + }; + qglTexCoordPointer( 2, GL_FLOAT, 0, tex ); + qglVertexPointer ( 2, GL_FLOAT, 0, vtx ); + qglDrawArrays( GL_TRIANGLE_FAN, 0, 4 ); +#else qglBegin(GL_QUADS); - qglColor4f(1.0f, 1.0f, 1.0f, alpha); - qglTexCoord2f(0+spost2, 1-spost); - qglVertex2f(0, 0); + qglColor4f(1.0f, 1.0f, 1.0f, alpha); + qglTexCoord2f(0+spost2, 1-spost); + qglVertex2f(0, 0); - qglTexCoord2f(0+spost2, 0+spost); - qglVertex2f(0, glConfig.vidHeight); + qglTexCoord2f(0+spost2, 0+spost); + qglVertex2f(0, glConfig.vidHeight); - qglTexCoord2f(1-spost2, 0+spost); - qglVertex2f(glConfig.vidWidth, glConfig.vidHeight); + qglTexCoord2f(1-spost2, 0+spost); + qglVertex2f(glConfig.vidWidth, glConfig.vidHeight); - qglTexCoord2f(1-spost2, 1-spost); - qglVertex2f(glConfig.vidWidth, 0); + qglTexCoord2f(1-spost2, 1-spost); + qglVertex2f(glConfig.vidWidth, 0); qglEnd(); +#endif } - +#ifdef HAVE_GLES + if (glcol) + qglEnableClientState( GL_COLOR_ARRAY ); + if (!text) + qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); +#endif //pop the view matrices back qglMatrixMode(GL_PROJECTION); qglPopMatrix(); diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_sky.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_sky.cpp index bc48e3d..73ec427 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_sky.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_sky.cpp @@ -429,7 +429,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max #endif } -static void DrawSkyBox( shader_t *shader ) +static void DrawSkyBox( jk_shader_t *shader ) { int i; @@ -549,7 +549,7 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad } } -static void FillCloudBox( const shader_t *shader, int stage ) +static void FillCloudBox( const jk_shader_t *shader, int stage ) { int i; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_surface.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_surface.cpp index 1e51e71..4607226 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_surface.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_surface.cpp @@ -1096,29 +1096,38 @@ static void RB_SurfaceBeam( void ) GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); - switch(e->skinNum) - { - case 1://Green - qglColor3f( 0, 1, 0 ); - break; - case 2://Blue - qglColor3f( 0.5, 0.5, 1 ); - break; - case 0://red - default: - qglColor3f( 1, 0, 0 ); - break; - } + qglColor3f( 1, 0, 0 ); +#ifdef HAVE_GLES + GLboolean text = qglIsEnabled(GL_TEXTURE_COORD_ARRAY); + GLboolean glcol = qglIsEnabled(GL_COLOR_ARRAY); + if (glcol) + qglDisableClientState(GL_COLOR_ARRAY); + if (text) + qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); + GLfloat vtx[NUM_BEAM_SEGS*6+6]; + for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) { + memcpy(vtx+i*6, start_points[ i % NUM_BEAM_SEGS], sizeof(GLfloat)*3); + memcpy(vtx+i*6+3, end_points[ i % NUM_BEAM_SEGS], sizeof(GLfloat)*3); + } + qglVertexPointer (3, GL_FLOAT, 0, vtx); + qglDrawArrays(GL_TRIANGLE_STRIP, 0, NUM_BEAM_SEGS*2+2); + if (glcol) + qglEnableClientState(GL_COLOR_ARRAY); + if (text) + qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); +#else qglBegin( GL_TRIANGLE_STRIP ); for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) { qglVertex3fv( start_points[ i % NUM_BEAM_SEGS] ); qglVertex3fv( end_points[ i % NUM_BEAM_SEGS] ); } qglEnd(); +#endif } + //------------------ // DoSprite //------------------ @@ -1920,6 +1929,38 @@ static void RB_SurfaceAxis( void ) { GL_Bind( tr.whiteImage ); GL_State( GLS_DEFAULT ); qglLineWidth( 3 ); + +#ifdef HAVE_GLES + GLfloat col[] = { + 1,0,0, 1, + 1,0,0, 1, + 0,1,0, 1, + 0,1,0, 1, + 0,0,1, 1, + 0,0,1, 1 + }; + GLfloat vtx[] = { + 0,0,0, + 16,0,0, + 0,0,0, + 0,16,0, + 0,0,0, + 0,0,16 + }; + GLboolean text = qglIsEnabled(GL_TEXTURE_COORD_ARRAY); + GLboolean glcol = qglIsEnabled(GL_COLOR_ARRAY); + if (text) + qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); + if (!glcol) + qglEnableClientState( GL_COLOR_ARRAY); + qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, col ); + qglVertexPointer (3, GL_FLOAT, 0, vtx); + qglDrawArrays(GL_LINES, 0, 6); + if (text) + qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); + if (!glcol) + qglDisableClientState( GL_COLOR_ARRAY); +#else qglBegin( GL_LINES ); qglColor3f( 1,0,0 ); qglVertex3f( 0,0,0 ); @@ -1931,6 +1972,7 @@ static void RB_SurfaceAxis( void ) { qglVertex3f( 0,0,0 ); qglVertex3f( 0,0,16 ); qglEnd(); +#endif qglLineWidth( 1 ); } @@ -1998,7 +2040,7 @@ static bool RB_TestZFlare( vec3_t point) { // if the point is off the screen, don't bother adding it // calculate screen coordinates and depth R_TransformModelToClip( point, backEnd.ori.modelMatrix, - backEnd.viewParms.projectionMatrix, eye, clip ); + backEnd.viewParms.projectionMatrix, eye, clip ); // check to see if the point is completely off screen for ( i = 0 ; i < 3 ; i++ ) { @@ -2010,7 +2052,7 @@ static bool RB_TestZFlare( vec3_t point) { R_TransformClipToWindow( clip, &backEnd.viewParms, normalized, window ); if ( window[0] < 0 || window[0] >= backEnd.viewParms.viewportWidth - || window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) { + || window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) { return qfalse; // shouldn't happen, since we check the clip[] above, except for FP rounding } @@ -2020,6 +2062,9 @@ static bool RB_TestZFlare( vec3_t point) { float screenZ; // read back the z buffer contents +#if defined(HAVE_GLES) + depth = 0.0f; +#else if ( r_flares->integer !=1 ) { //skipping the the z-test return true; } @@ -2027,9 +2072,10 @@ static bool RB_TestZFlare( vec3_t point) { // don't bother with another sync glState.finishCalled = qfalse; qglReadPixels( backEnd.viewParms.viewportX + window[0],backEnd.viewParms.viewportY + window[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth ); +#endif screenZ = backEnd.viewParms.projectionMatrix[14] / - ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); + ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); visible = ( -eye[2] - -screenZ ) < 24; return visible; @@ -2092,7 +2138,11 @@ void RB_SurfaceFlare( srfFlare_t *surf ) { void RB_SurfaceDisplayList( srfDisplayList_t *surf ) { // all appropriate state must be set in RB_BeginSurface // this isn't implemented yet... +#ifdef HAVE_GLES + assert(0); +#else qglCallList( surf->listNum ); +#endif } void RB_SurfaceSkip( void *surf ) { diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_world.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_world.cpp index 4a472e2..7cec420 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_world.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_world.cpp @@ -113,7 +113,7 @@ added to the sorting list. This will also allow mirrors on both sides of a model without recursion. ================ */ -static qboolean R_CullSurface( surfaceType_t *surface, shader_t *shader ) { +static qboolean R_CullSurface( surfaceType_t *surface, jk_shader_t *shader ) { srfSurfaceFace_t *sface; float d;