fixing compilation errors

This commit is contained in:
Simon 2022-09-20 22:08:09 +01:00
parent c1cc1097f5
commit 11f00b4fd4
17 changed files with 815 additions and 425 deletions

View file

@ -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

View file

@ -1061,7 +1061,17 @@ public:
}
mVertexCount = VertexCount;
#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,8 +1452,57 @@ public:
// Enable And Disable Things
//---------------------------
/*
if (mGLModeEnum==GL_POINTS && qglPointParameteriNV)
{
qglEnable(GL_POINT_SPRITE_NV);
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);
//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));
@ -1454,10 +1513,15 @@ public:
qglMatrixMode(GL_MODELVIEW);
qglPushMatrix();
}
// Begin
//-------
#ifdef HAVE_GLES
int idx = 0;
#else
qglBegin(mGLModeEnum);
#endif
for (particleNum=0; particleNum<mParticleCount; particleNum++)
{
part = &(mParticles[particleNum]);
@ -1466,44 +1530,63 @@ public:
continue;
}
// If Oriented With Velocity, We Want To Calculate Vertx Offsets Differently For Each Particle
//---------------------------------------------------------------------------------------------
if (mOrientWithVelocity)
{
partDirection = part->mVelocity;
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
//---------------------------------------
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 Point
//----------------
if (mGLModeEnum==GL_POINTS)
{
#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
//-------------------
if (mVertexCount==3)
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],
@ -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
//---------------
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
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
qglEnable(GL_CULL_FACE);
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;
}

View file

@ -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;

View file

@ -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 } ;

View file

@ -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

View file

@ -31,6 +31,13 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include <png.h>
#include <map>
#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<width*height; i++) {
for (int j=0; j<3; j++)
*(dst++) = *(src++);
src++;
}
return temp;
}
byte * gles_convertRGBA4(byte * data, int width, int height)
{
byte * temp = (byte *) Z_Malloc (width*height*2, TAG_TEMP_WORKSPACE, qfalse);
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;
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,6 +668,7 @@ Upload32
===============
*/
extern qboolean charSet;
static void Upload32( unsigned *data,
GLenum format,
qboolean mipmap,
@ -571,8 +676,17 @@ static void Upload32( unsigned *data,
qboolean isLightmap,
qboolean allowTC,
int *pformat,
word *pUploadWidth, word *pUploadHeight )
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;
@ -587,6 +701,8 @@ static void Upload32( unsigned *data,
//
if ( picmip ) {
for(i = 0; i < r_picmip->integer; i++) {
if ((width>16) && (height>16)) {
R_MipMap( (byte *)data, width, height );
width >>= 1;
height >>= 1;
@ -598,6 +714,7 @@ static void Upload32( unsigned *data,
}
}
}
}
//
// clamp to the current upper OpenGL limit
@ -643,28 +760,41 @@ static void Upload32( unsigned *data,
{
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 ( r_texturebitslm->integer == 16 )
{
if ( lmBits == 16 )
*pformat = GL_RGB5;
}
else if ( r_texturebitslm->integer == 32 )
{
else
#ifdef HAVE_GLES
*pformat = GL_RGB;
#else
*pformat = GL_RGB8;
}
#endif
}
else if ( r_texturebits->integer == 16 )
{
@ -672,18 +802,30 @@ static void Upload32( unsigned *data,
}
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 )
{
@ -691,11 +833,19 @@ static void Upload32( unsigned *data,
}
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
}
}
@ -703,15 +853,63 @@ static void Upload32( unsigned *data,
*pUploadHeight = height;
// 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 );
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap)?GL_TRUE:GL_FALSE );
// 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);
}
// qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
// qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
#else
if (!mipmap)
{
qglTexImage2D (GL_TEXTURE_2D, 0, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
qglTexImage2D( uiTarget, 0, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
goto done;
}
R_LightScaleTexture (data, width, height, (qboolean)!mipmap );
qglTexImage2D (GL_TEXTURE_2D, 0, *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)
{
@ -734,21 +932,21 @@ static void Upload32( unsigned *data,
R_BlendOverTexture( (byte *)data, width * height, mipBlendColors[miplevel] );
}
qglTexImage2D (GL_TEXTURE_2D, miplevel, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
qglTexImage2D( uiTarget, miplevel, *pformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
}
}
#endif
}
else
{
}
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);
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 );
@ -756,8 +954,8 @@ done:
}
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<NUM_SCRATCH_IMAGES;x++) {
// scratchimage is usually used for cinematic drawing
tr.scratchImage[x] = R_CreateImage(va("*scratch%d",x), (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, GL_RGBA, qfalse, qfalse, qfalse, GL_CLAMP);
tr.scratchImage[x] = R_CreateImage(va("*scratch%d",x), (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, GL_RGBA, qfalse, qtrue, qfalse, GL_CLAMP);
}
R_CreateDlightImage();
R_CreateFogImage();
}

View file

@ -435,7 +435,7 @@ typedef struct {
} fogParms_t;
typedef struct shader_s {
typedef struct jk_shader_s {
char name[MAX_QPATH]; // game path, including extension
int lightmapIndex[MAXLIGHTMAPS]; // for a shader to match, both name and lightmapIndex must match
byte styles[MAXLIGHTMAPS];
@ -482,9 +482,9 @@ typedef struct shader_s {
// True if this shader has a stage with glow in it (just an optimization).
bool hasGlow;
// struct shader_s *remappedShader; // current shader this one is remapped too
struct shader_s *next;
} shader_t;
// struct jk_shader_s *remappedShader; // current shader this one is remapped too
struct jk_shader_s *next;
} jk_shader_t;
/*
@ -513,7 +513,7 @@ Ghoul2 Insert End
// skins allow models to be retextured without modifying the model file
typedef struct {
char name[MAX_QPATH];
shader_t *shader;
jk_shader_t *shader;
} skinSurface_t;
typedef struct skin_s {
@ -709,7 +709,7 @@ BRUSH MODELS
typedef struct msurface_s {
int viewCount; // if == tr.viewCount, already added
struct shader_s *shader;
struct jk_shader_s *shader;
int fogIndex;
surfaceType_t *data; // any of srf*_t
@ -1000,12 +1000,12 @@ typedef struct {
// Image used to downsample and blur scene to. - AReis
GLuint blurImage;
shader_t *defaultShader;
shader_t *shadowShader;
shader_t *distortionShader;
shader_t *projectionShadowShader;
jk_shader_t *defaultShader;
jk_shader_t *shadowShader;
jk_shader_t *distortionShader;
jk_shader_t *projectionShadowShader;
shader_t *sunShader;
jk_shader_t *sunShader;
int numLightmaps;
image_t *lightmaps[MAX_LIGHTMAPS];
@ -1051,8 +1051,8 @@ typedef struct {
// shader indexes from drawsurfs will be looked up in sortedShaders[]
// lower indexed sortedShaders must be rendered first (opaque surfaces before translucent)
int numShaders;
shader_t *shaders[MAX_SHADERS];
shader_t *sortedShaders[MAX_SHADERS];
jk_shader_t *shaders[MAX_SHADERS];
jk_shader_t *sortedShaders[MAX_SHADERS];
int iNumDeniedShaders; // used for error-messages only
int numSkins;
@ -1241,10 +1241,10 @@ void R_AddLightningBoltSurfaces( trRefEntity_t *e );
void R_AddPolygonSurfaces( void );
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 );
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 );
#define CULL_IN 0 // completely unclipped
@ -1372,8 +1372,8 @@ extern const byte stylesDefault[MAXLIGHTMAPS];
qhandle_t RE_RegisterShader( const char *name );
qhandle_t RE_RegisterShaderNoMip( const char *name );
shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage );
shader_t *R_GetShaderByHandle( qhandle_t hShader );
jk_shader_t *R_FindShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage );
jk_shader_t *R_GetShaderByHandle( qhandle_t hShader );
void R_InitShaders( void );
void R_ShaderList_f( void );
@ -1423,7 +1423,7 @@ struct shaderCommands_s
stageVars_t svars QALIGN(16);
shader_t *shader;
jk_shader_t *shader;
int fogNum;
int dlightBits; // or together of all vertexDlightBits
@ -1455,7 +1455,7 @@ extern shaderCommands_t tess;
extern color4ub_t styleColors[MAX_LIGHT_STYLES];
extern bool styleUpdated[MAX_LIGHT_STYLES];
void RB_BeginSurface(shader_t *shader, int fogNum );
void RB_BeginSurface(jk_shader_t *shader, int fogNum );
void RB_EndSurface(void);
void RB_CheckOverflow( int verts, int indexes );
#define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= 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;

View file

@ -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;

View file

@ -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;

View file

@ -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 ) {

View file

@ -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;

View file

@ -316,81 +316,14 @@ 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
}
if ( r_showtris->integer == 2 )
{
// tries to do non-xray style showtris
GL_State( GLS_POLYMODE_LINE );
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 );
@ -410,10 +343,8 @@ static void DrawTris (shaderCommands_t *input)
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;

View file

@ -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");

View file

@ -825,6 +825,30 @@ 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);
@ -839,8 +863,14 @@ void RB_DistortionFill(void)
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();

View file

@ -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;

View file

@ -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;
}
#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 );
}
@ -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,6 +2072,7 @@ 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] );
@ -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 ) {

View file

@ -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;