Skip to content

Commit

Permalink
Merge branch 'master' into game/eliteforce
Browse files Browse the repository at this point in the history
  • Loading branch information
zturtleman committed Dec 2, 2014
2 parents 475e145 + b21a59a commit 6557800
Show file tree
Hide file tree
Showing 31 changed files with 281 additions and 498 deletions.
12 changes: 3 additions & 9 deletions code/cgame/cg_draw.c
Expand Up @@ -49,8 +49,6 @@ int CG_Text_Width(const char *text, float scale, int limit) {
float out;
glyphInfo_t *glyph;
float useScale;
// FIXME: see ui_main.c, same problem
// const unsigned char *s = text;
const char *s = text;
fontInfo_t *font = &cgDC.Assets.textFont;
if (scale <= cg_smallFont.value) {
Expand All @@ -71,7 +69,7 @@ int CG_Text_Width(const char *text, float scale, int limit) {
s += 2;
continue;
} else {
glyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build
glyph = &font->glyphs[*s & 255];
out += glyph->xSkip;
s++;
count++;
Expand All @@ -86,8 +84,6 @@ int CG_Text_Height(const char *text, float scale, int limit) {
float max;
glyphInfo_t *glyph;
float useScale;
// TTimo: FIXME
// const unsigned char *s = text;
const char *s = text;
fontInfo_t *font = &cgDC.Assets.textFont;
if (scale <= cg_smallFont.value) {
Expand All @@ -108,7 +104,7 @@ int CG_Text_Height(const char *text, float scale, int limit) {
s += 2;
continue;
} else {
glyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build
glyph = &font->glyphs[*s & 255];
if (max < glyph->height) {
max = glyph->height;
}
Expand Down Expand Up @@ -141,8 +137,6 @@ void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text
}
useScale = scale * font->glyphScale;
if (text) {
// TTimo: FIXME
// const unsigned char *s = text;
const char *s = text;
trap_R_SetColor( color );
memcpy(&newColor[0], &color[0], sizeof(vec4_t));
Expand All @@ -152,7 +146,7 @@ void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text
}
count = 0;
while (s && *s && count < len) {
glyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build
glyph = &font->glyphs[*s & 255];
//int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;
//float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);
if ( Q_IsColorString( s ) ) {
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_newdraw.c
Expand Up @@ -1214,7 +1214,7 @@ static void CG_Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4
}
count = 0;
while (s && *s && count < len) {
glyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build
glyph = &font->glyphs[*s & 255];
if ( Q_IsColorString( s ) ) {
memcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );
newColor[3] = color[3];
Expand Down
17 changes: 11 additions & 6 deletions code/renderercommon/tr_font.c
Expand Up @@ -397,7 +397,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {

// Com_Memcpy(font, faceData, sizeof(fontInfo_t));
Q_strncpyz(font->name, name, sizeof(font->name));
for (i = GLYPH_START; i < GLYPH_END; i++) {
for (i = GLYPH_START; i <= GLYPH_END; i++) {
font->glyphs[i].glyph = RE_RegisterShaderNoMip(font->glyphs[i].shaderName);
}
Com_Memcpy(&registeredFont[registeredFontCount++], font, sizeof(fontInfo_t));
Expand Down Expand Up @@ -445,7 +445,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {

maxHeight = 0;

for (i = GLYPH_START; i < GLYPH_END; i++) {
for (i = GLYPH_START; i <= GLYPH_END; i++) {
RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qtrue);
}

Expand All @@ -455,11 +455,16 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
lastStart = i;
imageNumber = 0;

while ( i <= GLYPH_END ) {
while ( i <= GLYPH_END + 1 ) {

glyph = RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qfalse);
if ( i == GLYPH_END + 1 ) {
// upload/save current image buffer
xOut = yOut = -1;
} else {
glyph = RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qfalse);
}

if (xOut == -1 || yOut == -1 || i == GLYPH_END) {
if (xOut == -1 || yOut == -1) {
// ran out of room
// we need to create an image from the bitmap, set all the handles in the glyphs to this point
//
Expand Down Expand Up @@ -504,7 +509,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
xOut = 0;
yOut = 0;
ri.Free(imageBuff);
if(i == GLYPH_END)
if ( i == GLYPH_END + 1 )
i++;
} else {
Com_Memcpy(&font->glyphs[i], glyph, sizeof(glyphInfo_t));
Expand Down
2 changes: 1 addition & 1 deletion code/renderergl1/tr_backend.c
Expand Up @@ -481,7 +481,7 @@ void RB_BeginDrawingView (void) {
// clip to the plane of the portal
if ( backEnd.viewParms.isPortal ) {
float plane[4];
double plane2[4];
GLdouble plane2[4];

plane[0] = backEnd.viewParms.portalPlane.normal[0];
plane[1] = backEnd.viewParms.portalPlane.normal[1];
Expand Down
12 changes: 0 additions & 12 deletions code/renderergl1/tr_image.c
Expand Up @@ -899,7 +899,6 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height,
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrapClampMode );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrapClampMode );

// FIXME: this stops fog from setting border color?
glState.currenttextures[glState.currenttmu] = 0;
qglBindTexture( GL_TEXTURE_2D, 0 );

Expand Down Expand Up @@ -1168,7 +1167,6 @@ static void R_CreateFogImage( void ) {
int x,y;
byte *data;
float d;
float borderColor[4];

data = ri.Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 );

Expand All @@ -1183,18 +1181,8 @@ static void R_CreateFogImage( void ) {
data[(y*FOG_S+x)*4+3] = 255*d;
}
}
// standard openGL clamping doesn't really do what we want -- it includes
// the border color at the edges. OpenGL 1.2 has clamp-to-edge, which does
// what we want.
tr.fogImage = R_CreateImage("*fog", (byte *)data, FOG_S, FOG_T, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE, 0 );
ri.Hunk_FreeTempMemory( data );

borderColor[0] = 1.0;
borderColor[1] = 1.0;
borderColor[2] = 1.0;
borderColor[3] = 1;

qglTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor );
}

/*
Expand Down
6 changes: 0 additions & 6 deletions code/renderergl1/tr_local.h
Expand Up @@ -478,7 +478,6 @@ typedef enum {
SF_IQM,
SF_FLARE,
SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity
SF_DISPLAY_LIST,

SF_NUM_SURFACE_TYPES,
SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int )
Expand All @@ -504,11 +503,6 @@ typedef struct srfPoly_s {
polyVert_t *verts;
} srfPoly_t;

typedef struct srfDisplayList_s {
surfaceType_t surfaceType;
int listNum;
} srfDisplayList_t;


typedef struct srfFlare_s {
surfaceType_t surfaceType;
Expand Down
4 changes: 2 additions & 2 deletions code/renderergl1/tr_shade.c
Expand Up @@ -421,7 +421,7 @@ static void ProjectDlightTexture_altivec( void ) {
byte clipBits[SHADER_MAX_VERTEXES];
float texCoordsArray[SHADER_MAX_VERTEXES][2];
byte colorArray[SHADER_MAX_VERTEXES][4];
unsigned hitIndexes[SHADER_MAX_INDEXES];
glIndex_t hitIndexes[SHADER_MAX_INDEXES];
int numIndexes;
float scale;
float radius;
Expand Down Expand Up @@ -593,7 +593,7 @@ static void ProjectDlightTexture_scalar( void ) {
byte clipBits[SHADER_MAX_VERTEXES];
float texCoordsArray[SHADER_MAX_VERTEXES][2];
byte colorArray[SHADER_MAX_VERTEXES][4];
unsigned hitIndexes[SHADER_MAX_INDEXES];
glIndex_t hitIndexes[SHADER_MAX_INDEXES];
int numIndexes;
float scale;
float radius;
Expand Down
20 changes: 8 additions & 12 deletions code/renderergl1/tr_shadows.c
Expand Up @@ -44,6 +44,7 @@ typedef struct {
static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS];
static int numEdgeDefs[SHADER_MAX_VERTEXES];
static int facing[SHADER_MAX_INDEXES/3];
static vec3_t shadowXyz[SHADER_MAX_VERTEXES];

void R_AddEdgeDef( int i1, int i2, int facing ) {
int c;
Expand Down Expand Up @@ -80,13 +81,13 @@ void R_RenderShadowEdges( void ) {

qglBegin( GL_TRIANGLE_STRIP );
qglVertex3fv( tess.xyz[ i1 ] );
qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );
qglVertex3fv( shadowXyz[ i1 ] );
qglVertex3fv( tess.xyz[ i2 ] );
qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
qglVertex3fv( shadowXyz[ i2 ] );
qglVertex3fv( tess.xyz[ i3 ] );
qglVertex3fv( tess.xyz[ i3 + tess.numVertexes ] );
qglVertex3fv( shadowXyz[ i3 ] );
qglVertex3fv( tess.xyz[ i1 ] );
qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );
qglVertex3fv( shadowXyz[ i1 ] );
qglEnd();
}
#else
Expand Down Expand Up @@ -126,9 +127,9 @@ void R_RenderShadowEdges( void ) {
if ( hit[ 1 ] == 0 ) {
qglBegin( GL_TRIANGLE_STRIP );
qglVertex3fv( tess.xyz[ i ] );
qglVertex3fv( tess.xyz[ i + tess.numVertexes ] );
qglVertex3fv( shadowXyz[ i ] );
qglVertex3fv( tess.xyz[ i2 ] );
qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
qglVertex3fv( shadowXyz[ i2 ] );
qglEnd();
c_edges++;
} else {
Expand Down Expand Up @@ -157,11 +158,6 @@ void RB_ShadowTessEnd( void ) {
vec3_t lightDir;
GLboolean rgba[4];

// we can only do this if we have enough space in the vertex buffers
if ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) {
return;
}

if ( glConfig.stencilBits < 4 ) {
return;
}
Expand All @@ -170,7 +166,7 @@ void RB_ShadowTessEnd( void ) {

// project vertexes away from light direction
for ( i = 0 ; i < tess.numVertexes ; i++ ) {
VectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] );
VectorMA( tess.xyz[i], -512, lightDir, shadowXyz[i] );
}

// decide which triangles face the light
Expand Down
12 changes: 3 additions & 9 deletions code/renderergl1/tr_surface.c
Expand Up @@ -1485,7 +1485,8 @@ RB_SurfaceFace
*/
static void RB_SurfaceFace( srfSurfaceFace_t *surf ) {
int i;
unsigned *indices, *tessIndexes;
unsigned *indices;
glIndex_t *tessIndexes;
float *v;
float *normal;
int ndx;
Expand Down Expand Up @@ -1821,12 +1822,6 @@ static void RB_SurfaceFlare(srfFlare_t *surf)
RB_AddFlare(surf, tess.fogNum, surf->origin, surf->color, surf->normal);
}

static void RB_SurfaceDisplayList( srfDisplayList_t *surf ) {
// all apropriate state must be set in RB_BeginSurface
// this isn't implemented yet...
qglCallList( surf->listNum );
}

static void RB_SurfaceSkip( void *surf ) {
}

Expand All @@ -1842,6 +1837,5 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = {
(void(*)(void*))RB_MDRSurfaceAnim, // SF_MDR,
(void(*)(void*))RB_IQMSurfaceAnim, // SF_IQM,
(void(*)(void*))RB_SurfaceFlare, // SF_FLARE,
(void(*)(void*))RB_SurfaceEntity, // SF_ENTITY
(void(*)(void*))RB_SurfaceDisplayList // SF_DISPLAY_LIST
(void(*)(void*))RB_SurfaceEntity // SF_ENTITY
};
33 changes: 0 additions & 33 deletions code/renderergl2/glsl/generic_fp.glsl
@@ -1,45 +1,12 @@
uniform sampler2D u_DiffuseMap;

#if defined(USE_LIGHTMAP)
uniform sampler2D u_LightMap;

uniform int u_Texture1Env;
#endif

varying vec2 var_DiffuseTex;

#if defined(USE_LIGHTMAP)
varying vec2 var_LightTex;
#endif

varying vec4 var_Color;


void main()
{
vec4 color = texture2D(u_DiffuseMap, var_DiffuseTex);
#if defined(USE_LIGHTMAP)
vec4 color2 = texture2D(u_LightMap, var_LightTex);
#if defined(RGBM_LIGHTMAP)
color2.rgb *= color2.a;
color2.a = 1.0;
#endif

if (u_Texture1Env == TEXENV_MODULATE)
{
color *= color2;
}
else if (u_Texture1Env == TEXENV_ADD)
{
color += color2;
}
else if (u_Texture1Env == TEXENV_REPLACE)
{
color = color2;
}

//color = color * (u_Texture1Env.xxxx + color2 * u_Texture1Env.z) + color2 * u_Texture1Env.y;
#endif

gl_FragColor = color * var_Color;
}
9 changes: 1 addition & 8 deletions code/renderergl2/glsl/generic_vp.glsl
Expand Up @@ -9,7 +9,7 @@ attribute vec3 attr_Normal2;
attribute vec4 attr_Color;
attribute vec4 attr_TexCoord0;

#if defined(USE_LIGHTMAP) || defined(USE_TCGEN)
#if defined(USE_TCGEN)
attribute vec4 attr_TexCoord1;
#endif

Expand Down Expand Up @@ -57,9 +57,6 @@ uniform float u_VertexLerp;
#endif

varying vec2 var_DiffuseTex;
#if defined(USE_LIGHTMAP)
varying vec2 var_LightTex;
#endif
varying vec4 var_Color;

#if defined(USE_DEFORM_VERTEXES)
Expand Down Expand Up @@ -230,10 +227,6 @@ void main()
var_DiffuseTex = tex;
#endif

#if defined(USE_LIGHTMAP)
var_LightTex = attr_TexCoord1.st;
#endif

#if defined(USE_RGBAGEN)
var_Color = CalcColor(position, normal);
#else
Expand Down

0 comments on commit 6557800

Please sign in to comment.