summaryrefslogtreecommitdiff
path: root/source/gl_draw.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2009-07-14 13:51:46 +0000
committerAndrey Nazarov <skuller@skuller.net>2009-07-14 13:51:46 +0000
commit271411ff5b5bf38388b373879f9c46983a372d4b (patch)
treef459b43c2d61c2ab815b8f3c2f1522b3b12020ec /source/gl_draw.c
parent722aa347cc98d59c05a42a0af0c2cfab23e10d1c (diff)
Moved GL_StretchPic into gl_draw.c so that it gets inlined by the compiler.
Don't use r_images slots for auto textures, use constant texnums for them instead. Don't include ‘gl_showstats’ cvar into release builds. Draw polyblend effect only inside 3D viewport, not over the whole screen.
Diffstat (limited to 'source/gl_draw.c')
-rw-r--r--source/gl_draw.c70
1 files changed, 64 insertions, 6 deletions
diff --git a/source/gl_draw.c b/source/gl_draw.c
index 67728ac..c0cfc12 100644
--- a/source/gl_draw.c
+++ b/source/gl_draw.c
@@ -22,6 +22,63 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
drawStatic_t draw;
+static inline void _GL_StretchPic(
+ float x, float y, float w, float h,
+ float s1, float t1, float s2, float t2,
+ const byte *color, int texnum, int flags )
+{
+ vec_t *dst_vert;
+ uint32_t *dst_color;
+
+ if( tess.numverts + 4 > TESS_MAX_VERTICES ||
+ ( tess.numverts && tess.texnum[0] != texnum ) )
+ {
+ GL_Flush2D();
+ }
+
+ tess.texnum[0] = texnum;
+
+ dst_vert = tess.vertices + tess.numverts * 4;
+ Vector4Set( dst_vert, x, y, s1, t1 );
+ Vector4Set( dst_vert + 4, x + w, y, s2, t1 );
+ Vector4Set( dst_vert + 8, x + w, y + h, s2, t2 );
+ Vector4Set( dst_vert + 12, x, y + h, s1, t2 );
+
+ dst_color = ( uint32_t * )tess.colors + tess.numverts;
+ dst_color[0] = *( const uint32_t * )color;
+ dst_color[1] = *( const uint32_t * )color;
+ dst_color[2] = *( const uint32_t * )color;
+ dst_color[3] = *( const uint32_t * )color;
+
+ if( flags & if_transparent ) {
+ if( ( flags & if_paletted ) && draw.scale == 1 ) {
+ tess.flags |= 1;
+ } else {
+ tess.flags |= 2;
+ }
+ }
+ if( color[3] != 255 ) {
+ tess.flags |= 2;
+ }
+
+ tess.numverts += 4;
+}
+
+#define GL_StretchPic(x,y,w,h,s1,t1,s2,t2,color,image) \
+ _GL_StretchPic(x,y,w,h,s1,t1,s2,t2,color,(image)->texnum,(image)->flags)
+
+void GL_Blend( void ) {
+ color_t color = {
+ glr.fd.blend[0] * 255,
+ glr.fd.blend[1] * 255,
+ glr.fd.blend[2] * 255,
+ glr.fd.blend[3] * 255
+ };
+
+ _GL_StretchPic( glr.fd.x, glr.fd.y, glr.fd.width, glr.fd.height, 0, 0, 1, 1,
+ color, TEXNUM_WHITE, 0 );
+}
+
void R_SetColor( int flags, const color_t color ) {
draw.flags &= ~DRAW_COLOR_MASK;
@@ -159,19 +216,17 @@ void R_DrawPic( int x, int y, qhandle_t pic ) {
#define DIV64 ( 1.0f / 64.0f )
void R_TileClear( int x, int y, int w, int h, qhandle_t pic ) {
- image_t *image = IMG_ForHandle( pic );
-
GL_StretchPic( x, y, w, h, x * DIV64, y * DIV64,
- ( x + w ) * DIV64, ( y + h ) * DIV64, colorWhite, image );
+ ( x + w ) * DIV64, ( y + h ) * DIV64, colorWhite, IMG_ForHandle( pic ) );
}
void R_DrawFill( int x, int y, int w, int h, int c ) {
- GL_StretchPic( x, y, w, h, 0, 0, 1, 1, ( byte * )&d_8to24table[c & 255],
- r_whiteimage );
+ _GL_StretchPic( x, y, w, h, 0, 0, 1, 1, ( byte * )&d_8to24table[c & 255],
+ TEXNUM_WHITE, 0 );
}
void R_DrawFillEx( int x, int y, int w, int h, const color_t color ) {
- GL_StretchPic( x, y, w, h, 0, 0, 1, 1, color, r_whiteimage );
+ _GL_StretchPic( x, y, w, h, 0, 0, 1, 1, color, TEXNUM_WHITE, 0 );
}
void R_FadeScreen( void ) {
@@ -239,6 +294,8 @@ int R_DrawString( int x, int y, int flags, size_t maxChars,
return x;
}
+#ifdef _DEBUG
+
image_t *r_charset;
void Draw_Stringf( int x, int y, const char *fmt, ... ) {
@@ -302,3 +359,4 @@ void Draw_Stats( void ) {
}
}
+#endif