static void ID_INLINE R_Bloom_Quad_Lens(float offsert, int width, int height, float texX, float texY, float texWidth, float texHeight) { int x = 0; int y = 0; x = 0; y += glConfig.vidHeight - height; width += x; height += y; offsert = offsert * 9; // bah texWidth -= texX; texHeight -= texY; qglBegin( GL_QUADS ); qglTexCoord2f( texX, texHeight ); qglVertex2f( width + offsert, height + offsert ); qglTexCoord2f( texX, texY ); qglVertex2f( width + offsert, y - offsert); qglTexCoord2f( texWidth, texY ); qglVertex2f( x - offsert, y - offsert); qglTexCoord2f( texWidth, texHeight ); qglVertex2f( x - offsert, height + offsert); qglEnd (); }
/* ============= Draw_Pic ============= */ void Draw_Pic (int x, int y, char *pic) { image_t *gl; gl = Draw_FindPic (pic); if (!gl) { ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", pic); return; } if (scrap_dirty) Scrap_Upload (); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !gl->has_alpha) qglDisable (GL_ALPHA_TEST); GL_Bind (gl->texnum); qglBegin (GL_QUADS); qglTexCoord2f (gl->sl, gl->tl); qglVertex2f (x, y); qglTexCoord2f (gl->sh, gl->tl); qglVertex2f (x+gl->width, y); qglTexCoord2f (gl->sh, gl->th); qglVertex2f (x+gl->width, y+gl->height); qglTexCoord2f (gl->sl, gl->th); qglVertex2f (x, y+gl->height); qglEnd (); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !gl->has_alpha) qglEnable (GL_ALPHA_TEST); }
/* ============= Draw_TileClear This repeats a 64*64 tile graphic to fill the screen around a sized down refresh window. ============= */ void Draw_TileClear (int x, int y, int w, int h, char *pic) { image_t *image; image = Draw_FindPic (pic); if (!image) { ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", pic); return; } if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !image->has_alpha) qglDisable (GL_ALPHA_TEST); GL_Bind (image->texnum); qglBegin (GL_QUADS); qglTexCoord2f (x/64.0, y/64.0); qglVertex2f (x, y); qglTexCoord2f ( (x+w)/64.0, y/64.0); qglVertex2f (x+w, y); qglTexCoord2f ( (x+w)/64.0, (y+h)/64.0); qglVertex2f (x+w, y+h); qglTexCoord2f ( x/64.0, (y+h)/64.0 ); qglVertex2f (x, y+h); qglEnd (); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !image->has_alpha) qglEnable (GL_ALPHA_TEST); }
static void ID_INLINE R_Bloom_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight ) { int x = 0; int y = 0; x = 0; y += glConfig.vidHeight - height; width += x; height += y; texWidth += texX; texHeight += texY; qglBegin( GL_QUADS ); qglTexCoord2f( texX, texHeight ); qglVertex2f( x, y ); qglTexCoord2f( texX, texY ); qglVertex2f( x, height ); qglTexCoord2f( texWidth, texY ); qglVertex2f( width, height ); qglTexCoord2f( texWidth, texHeight ); qglVertex2f( width, y ); qglEnd (); }
/* ================ Draw_Char Draws one 8*8 graphics character with 0 being transparent. It can be clipped to the top of the screen to allow the console to be smoothly scrolled off. ================ */ void Draw_Char (int x, int y, int num) { int row, col; float frow, fcol, size; num &= 255; if ( (num&127) == 32 ) return; // space if (y <= -8) return; // totally off screen row = num>>4; col = num&15; frow = row*0.0625; fcol = col*0.0625; size = 0.0625; GL_Bind (draw_chars->texnum); qglBegin (GL_QUADS); qglTexCoord2f (fcol, frow); qglVertex2f (x, y); qglTexCoord2f (fcol + size, frow); qglVertex2f (x+8, y); qglTexCoord2f (fcol + size, frow + size); qglVertex2f (x+8, y+8); qglTexCoord2f (fcol, frow + size); qglVertex2f (x, y+8); qglEnd (); }
/* * ================ Draw_Char * * Draws one 8*8 graphics character with 0 being transparent. It can be clipped * to the top of the screen to allow the console to be smoothly scrolled off. * ================ */ void Draw_Char(int x, int y, int num, int alpha) { int row, col; float frow, fcol, size; num &= 255; if (alpha >= 254) alpha = 254; else if (alpha <= 1) alpha = 1; if ((num & 127) == 32) return; /* space */ if (y <= -8) return; /* totally off screen */ row = num >> 4; col = num & 15; frow = row * 0.0625; fcol = col * 0.0625; size = 0.0625; { /* GLSTATE_DISABLE_ALPHATEST */ qglDisable(GL_ALPHA_TEST); GL_TexEnv(GL_MODULATE); qglColor4ub(255, 255, 255, alpha); /* GLSTATE_ENABLE_BLEND */ qglEnable(GL_BLEND); qglDepthMask(false); } GL_Bind(draw_chars->texnum); qglBegin(GL_QUADS); qglTexCoord2f(fcol, frow); qglVertex2f(x, y); qglTexCoord2f(fcol + size, frow); qglVertex2f(x + 8, y); qglTexCoord2f(fcol + size, frow + size); qglVertex2f(x + 8, y + 8); qglTexCoord2f(fcol, frow + size); qglVertex2f(x, y + 8); qglEnd(); { qglDepthMask(true); GL_TexEnv(GL_REPLACE); /* GLSTATE_DISABLE_BLEND */ qglDisable(GL_BLEND); qglColor4f(1,1,1,1); /* GLSTATE_ENABLE_ALPHATEST */ qglEnable(GL_ALPHA_TEST); } }
/* ============= RB_DrawRotatePic2 ============= */ const void *RB_RotatePic2 ( const void *data ) { const rotatePicCommand_t *cmd; image_t *image; shader_t *shader; cmd = (const rotatePicCommand_t *)data; shader = cmd->shader; if ( shader->stages[0] ) { image = shader->stages[0]->bundle[0].image[0]; if ( image ) { if ( !backEnd.projection2D ) { RB_SetGL2D(); } // Get our current blend mode, etc. GL_State( shader->stages[0]->stateBits ); qglColor4ubv( backEnd.color2D ); qglPushMatrix(); // rotation point is going to be around the center of the passed in coordinates qglTranslatef( cmd->x, cmd->y, 0 ); qglRotatef( cmd->a, 0.0, 0.0, 1.0 ); GL_Bind( image ); qglBegin( GL_QUADS ); qglTexCoord2f( cmd->s1, cmd->t1); qglVertex2f( -cmd->w * 0.5f, -cmd->h * 0.5f ); qglTexCoord2f( cmd->s2, cmd->t1 ); qglVertex2f( cmd->w * 0.5f, -cmd->h * 0.5f ); qglTexCoord2f( cmd->s2, cmd->t2 ); qglVertex2f( cmd->w * 0.5f, cmd->h * 0.5f ); qglTexCoord2f( cmd->s1, cmd->t2 ); qglVertex2f( -cmd->w * 0.5f, cmd->h * 0.5f ); qglEnd(); qglPopMatrix(); // Hmmm, this is not too cool GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); } } return (const void *)(cmd + 1); }
/* =============== RB_ShowImages Draw all the images to the screen, on top of whatever was there. This is used to test for texture thrashing. Also called by RE_EndRegistration =============== */ void RB_ShowImages(void) { int i; image_t *image; float x, y, w, h; int start, end; if(!backEnd.projection2D) { RB_SetGL2D(); } qglClear(GL_COLOR_BUFFER_BIT); qglFinish(); start = ri.Milliseconds(); for(i = 0 ; i < tr.numImages ; i++) { image = tr.images[i]; w = glConfig.vidWidth / 40; h = glConfig.vidHeight / 30; x = i % 40 * w; y = i / 30 * h; // show in proportional size in mode 2 if(r_showImages->integer == 2) { w *= image->uploadWidth / 512.0f; h *= image->uploadHeight / 512.0f; } GL_Bind(image); qglBegin(GL_QUADS); qglTexCoord2f(0, 0); qglVertex2f(x, y); qglTexCoord2f(1, 0); qglVertex2f(x + w, y); qglTexCoord2f(1, 1); qglVertex2f(x + w, y + h); qglTexCoord2f(0, 1); qglVertex2f(x, y + h); qglEnd(); } qglFinish(); end = ri.Milliseconds(); ri.Printf(PRINT_ALL, "%i msec to draw all images\n", end - start); }
/* * ============= Draw_StretchPic -- only used for drawing console... * ============= */ void Draw_StretchPic(int x, int y, int w, int h, char *pic, float alpha) { image_t *gl; gl = Draw_FindPic(pic); if (!gl) { ri.Con_Printf(PRINT_ALL, "Can't find pic: %s\n", pic); return; } if (scrap_dirty) Scrap_Upload(); if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION)) && !gl->has_alpha) qglDisable(GL_ALPHA_TEST); /* add alpha support */ if (gl->has_alpha || alpha < 1) { qglDisable(GL_ALPHA_TEST); GL_Bind(gl->texnum); GL_TexEnv(GL_MODULATE); qglColor4f(1, 1, 1, alpha); qglEnable(GL_BLEND); qglDepthMask(false); } else GL_Bind(gl->texnum); qglBegin(GL_QUADS); qglTexCoord2f(gl->sl, gl->tl); qglVertex2f(x, y); qglTexCoord2f(gl->sh, gl->tl); qglVertex2f(x + w, y); qglTexCoord2f(gl->sh, gl->th); qglVertex2f(x + w, y + h); qglTexCoord2f(gl->sl, gl->th); qglVertex2f(x, y + h); qglEnd(); /* add alpha support */ if (gl->has_alpha || alpha < 1) { qglDepthMask(true); GL_TexEnv(GL_REPLACE); qglDisable(GL_BLEND); qglColor4f(1, 1, 1, 1); qglEnable(GL_ALPHA_TEST); } if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION)) && !gl->has_alpha) qglEnable(GL_ALPHA_TEST); }
/* * ============= Draw_Pic ============= */ void Draw_Pic(int x, int y, char *pic, float alpha) { image_t *gl; gl = Draw_FindPic(pic); if (!gl) { ri.Con_Printf(PRINT_ALL, "Can't find pic: %s\n", pic); return; } if (scrap_dirty) Scrap_Upload(); if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION)) && !gl->has_alpha) qglDisable(GL_ALPHA_TEST); /* add alpha support */ { qglDisable(GL_ALPHA_TEST); qglBindTexture(GL_TEXTURE_2D, gl->texnum); GL_TexEnv(GL_MODULATE); qglColor4f(1, 1, 1, 0.999); /* need <1 for trans to work */ qglEnable(GL_BLEND); qglDepthMask(false); } GL_Bind(gl->texnum); qglBegin(GL_QUADS); qglTexCoord2f(gl->sl, gl->tl); qglVertex2f(x, y); qglTexCoord2f(gl->sh, gl->tl); qglVertex2f(x + gl->width, y); qglTexCoord2f(gl->sh, gl->th); qglVertex2f(x + gl->width, y + gl->height); qglTexCoord2f(gl->sl, gl->th); qglVertex2f(x, y + gl->height); qglEnd(); /* add alpha support */ { qglDepthMask(true); GL_TexEnv(GL_REPLACE); qglDisable(GL_BLEND); qglColor4f(1, 1, 1, 1); qglEnable(GL_ALPHA_TEST); } if (((gl_config.renderer == GL_RENDERER_MCD) || (gl_config.renderer & GL_RENDERER_RENDITION)) && !gl->has_alpha) qglEnable(GL_ALPHA_TEST); }
/* =============== RB_ShowImages Draw all the images to the screen, on top of whatever was there. This is used to test for texture thrashing. Also called by RE_EndRegistration =============== */ void RB_ShowImages( void ) { image_t *image; float x, y, w, h; int start, end; if ( !backEnd.projection2D ) { RB_SetGL2D(); } qglFinish(); start = Sys_Milliseconds(); int i=0; // int iNumImages = R_Images_StartIteration(); while ( (image = R_Images_GetNextIteration()) != NULL) { w = glConfig.vidWidth / 20; h = glConfig.vidHeight / 15; x = i % 20 * w; y = i / 20 * h; // show in proportional size in mode 2 if ( r_showImages->integer == 2 ) { w *= image->width / 512.0; h *= image->height / 512.0; } GL_Bind( image ); #ifdef _XBOX qglBeginEXT (GL_QUADS, 4, 0, 0, 4, 0); #else qglBegin (GL_QUADS); #endif qglTexCoord2f( 0, 0 ); qglVertex2f( x, y ); qglTexCoord2f( 1, 0 ); qglVertex2f( x + w, y ); qglTexCoord2f( 1, 1 ); qglVertex2f( x + w, y + h ); qglTexCoord2f( 0, 1 ); qglVertex2f( x, y + h ); qglEnd(); i++; } qglFinish(); end = Sys_Milliseconds(); //VID_Printf( PRINT_ALL, "%i msec to draw all images\n", end - start ); }
/* * R_Bloom_Quad */ static inline void R_Bloom_Quad( int x, int y, int w, int h, float texwidth, float texheight ) { qglBegin( GL_QUADS ); qglTexCoord2f( 0, texheight ); qglVertex2f( x, glState.height-h-y ); qglTexCoord2f( 0, 0 ); qglVertex2f( x, glState.height-y ); qglTexCoord2f( texwidth, 0 ); qglVertex2f( x+w, glState.height-y ); qglTexCoord2f( texwidth, texheight ); qglVertex2f( x+w, glState.height-h ); qglEnd(); }
/* * R_Bloom_SamplePass */ static inline void R_Bloom_SamplePass( int xpos, int ypos ) { qglBegin( GL_QUADS ); qglTexCoord2f( 0, sampleText_tch ); qglVertex2f( xpos, ypos ); qglTexCoord2f( 0, 0 ); qglVertex2f( xpos, ypos+sample_height ); qglTexCoord2f( sampleText_tcw, 0 ); qglVertex2f( xpos+sample_width, ypos+sample_height ); qglTexCoord2f( sampleText_tcw, sampleText_tch ); qglVertex2f( xpos+sample_width, ypos ); qglEnd(); }
/* =============== RB_ShowImages Draw all the images to the screen, on top of whatever was there. This is used to test for texture thrashing. =============== */ void RB_ShowImages( void ) { int i; idImage *image; float x, y, w, h; int start, end; RB_SetGL2D(); //qglClearColor( 0.2, 0.2, 0.2, 1 ); //qglClear( GL_COLOR_BUFFER_BIT ); qglFinish(); start = Sys_Milliseconds(); for ( i = 0 ; i < globalImages->images.Num() ; i++ ) { image = globalImages->images[i]; if ( image->texnum == idImage::TEXTURE_NOT_LOADED && image->partialImage == NULL ) { continue; } w = glConfig.vidWidth / 20; h = glConfig.vidHeight / 15; x = i % 20 * w; y = i / 20 * h; // show in proportional size in mode 2 if ( r_showImages.GetInteger() == 2 ) { w *= image->uploadWidth / 512.0f; h *= image->uploadHeight / 512.0f; } image->Bind(); qglBegin (GL_QUADS); qglTexCoord2f( 0, 0 ); qglVertex2f( x, y ); qglTexCoord2f( 1, 0 ); qglVertex2f( x + w, y ); qglTexCoord2f( 1, 1 ); qglVertex2f( x + w, y + h ); qglTexCoord2f( 0, 1 ); qglVertex2f( x, y + h ); qglEnd(); } qglFinish(); end = Sys_Milliseconds(); common->Printf( "%i msec to draw all images\n", end - start ); }
/* =============== RB_ShowImages Draw all the images to the screen, on top of whatever was there. This is used to test for texture thrashing. Also called by RE_EndRegistration =============== */ void RB_ShowImages( void ) { image_t *image; float x, y, w, h; int start, end; if ( !backEnd.projection2D ) { RB_SetGL2D(); } qglClear( GL_COLOR_BUFFER_BIT ); qglFinish(); start = ri.Milliseconds(); int i=0; R_Images_StartIteration(); while ( (image = R_Images_GetNextIteration()) != NULL) { w = glConfig.vidWidth / 20; h = glConfig.vidHeight / 15; x = i % 20 * w; y = i / 20 * h; // show in proportional size in mode 2 if ( r_showImages->integer == 2 ) { w *= image->uploadWidth / 512.0; h *= image->uploadHeight / 512.0; } GL_Bind( image ); qglBegin (GL_QUADS); qglTexCoord2f( 0, 0 ); qglVertex2f( x, y ); qglTexCoord2f( 1, 0 ); qglVertex2f( x + w, y ); qglTexCoord2f( 1, 1 ); qglVertex2f( x + w, y + h ); qglTexCoord2f( 0, 1 ); qglVertex2f( x, y + h ); qglEnd(); i++; } qglFinish(); end = ri.Milliseconds(); ri.Printf( PRINT_ALL, "%i msec to draw all images\n", end - start ); }
void MakeSkyVec (float s, float t, int axis) { vec3_t v, b; int j, k; b[0] = s*2300; b[1] = t*2300; b[2] = 2300; for (j=0 ; j<3 ; j++) { k = st_to_vec[axis][j]; if (k < 0) v[j] = -b[-k - 1]; else v[j] = b[k - 1]; } // avoid bilerp seam s = (s+1)*0.5; t = (t+1)*0.5; if (s < sky_min) s = sky_min; else if (s > sky_max) s = sky_max; if (t < sky_min) t = sky_min; else if (t > sky_max) t = sky_max; t = 1.0 - t; qglTexCoord2f (s, t); qglVertex3fv (v); }
void R_Splash() { #ifndef _XBOX image_t *pImage; /* const char* s = Cvar_VariableString("se_language"); if (stricmp(s,"english")) { pImage = R_FindImageFile( "menu/splash_eur", qfalse, qfalse, qfalse, GL_CLAMP); } else { pImage = R_FindImageFile( "menu/splash", qfalse, qfalse, qfalse, GL_CLAMP); } */ pImage = R_FindImageFile( "menu/splash", qfalse, qfalse, qfalse, GL_CLAMP); extern void RB_SetGL2D (void); RB_SetGL2D(); if (pImage ) {//invalid paths? GL_Bind( pImage ); } GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); const int width = 640; const int height = 480; const float x1 = 320 - width / 2; const float x2 = 320 + width / 2; const float y1 = 240 - height / 2; const float y2 = 240 + height / 2; qglBegin (GL_TRIANGLE_STRIP); qglTexCoord2f( 0, 0 ); qglVertex2f(x1, y1); qglTexCoord2f( 1 , 0 ); qglVertex2f(x2, y1); qglTexCoord2f( 0, 1 ); qglVertex2f(x1, y2); qglTexCoord2f( 1, 1 ); qglVertex2f(x2, y2); qglEnd(); GLimp_EndFrame(); #endif }
/* * R_Bloom_DrawEffect */ static void R_Bloom_DrawEffect( void ) { GL_Bind( 0, r_bloomeffecttexture ); GL_TexEnv( GL_MODULATE ); GL_SetState( GLSTATE_NO_DEPTH_TEST|GLSTATE_SRCBLEND_ONE|GLSTATE_DSTBLEND_ONE ); qglColor4f( r_bloom_alpha->value, r_bloom_alpha->value, r_bloom_alpha->value, 1.0f ); qglBegin( GL_QUADS ); qglTexCoord2f( 0, sampleText_tch ); qglVertex2f( curView_x, curView_y ); qglTexCoord2f( 0, 0 ); qglVertex2f( curView_x, curView_y+curView_height ); qglTexCoord2f( sampleText_tcw, 0 ); qglVertex2f( curView_x+curView_width, curView_y+curView_height ); qglTexCoord2f( sampleText_tcw, sampleText_tch ); qglVertex2f( curView_x+curView_width, curView_y ); qglEnd(); }
/* ============= RB_DrawRotatePic ============= */ const void *RB_RotatePic ( const void *data ) { const rotatePicCommand_t *cmd; image_t *image; shader_t *shader; cmd = (const rotatePicCommand_t *)data; shader = cmd->shader; image = &shader->stages[0].bundle[0].image[0]; if ( image ) { if ( !backEnd.projection2D ) { RB_SetGL2D(); } qglColor4ubv( backEnd.color2D ); qglPushMatrix(); qglTranslatef(cmd->x+cmd->w,cmd->y,0); qglRotatef(cmd->a, 0.0, 0.0, 1.0); GL_Bind( image ); #ifdef _XBOX qglBeginEXT (GL_QUADS, 4, 0, 0, 4, 0); #else qglBegin (GL_QUADS); #endif qglTexCoord2f( cmd->s1, cmd->t1); qglVertex2f( -cmd->w, 0 ); qglTexCoord2f( cmd->s2, cmd->t1 ); qglVertex2f( 0, 0 ); qglTexCoord2f( cmd->s2, cmd->t2 ); qglVertex2f( 0, cmd->h ); qglTexCoord2f( cmd->s1, cmd->t2 ); qglVertex2f( -cmd->w, cmd->h ); qglEnd(); qglPopMatrix(); } return (const void *)(cmd + 1); }
/* ================= R_Bloom_DrawEffect ================= */ void R_Bloom_DrawEffect( refdef_t *fd ) { GL_Bind(r_bloomeffecttexture->texnum); GL_Enable(GL_BLEND); GL_BlendFunc(GL_ONE, GL_ONE); qglColor4f(r_bloom_alpha->value + fd->bloomalpha /*bc mod*/, r_bloom_alpha->value + fd->bloomalpha /*bc mod*/, r_bloom_alpha->value + fd->bloomalpha /*bc mod*/, 1.0f); GL_TexEnv(GL_MODULATE); qglBegin(GL_QUADS); qglTexCoord2f( 0, sampleText_tch ); qglVertex2f( curView_x, curView_y ); qglTexCoord2f( 0, 0 ); qglVertex2f( curView_x, curView_y + curView_height ); qglTexCoord2f( sampleText_tcw, 0 ); qglVertex2f( curView_x + curView_width, curView_y + curView_height ); qglTexCoord2f( sampleText_tcw, sampleText_tch ); qglVertex2f( curView_x + curView_width, curView_y ); qglEnd(); GL_Disable(GL_BLEND); }
void GLRB_DrawImage( const image_t* image, const float* coords, const float* texcoords, const float* color ) { GL_Bind( image ); if ( color ) qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight ); else qglColor3f( 1, 1, 1 ); qglBegin (GL_QUADS); qglTexCoord2f ( texcoords[0], texcoords[1] ); qglVertex2f (coords[0], coords[1]); qglTexCoord2f ( texcoords[2], texcoords[1] ); qglVertex2f (coords[2], coords[1]); qglTexCoord2f ( texcoords[2], texcoords[3] ); qglVertex2f (coords[2], coords[3]); qglTexCoord2f ( texcoords[0], texcoords[3] ); qglVertex2f (coords[0], coords[3]); qglEnd (); }
/* ============= Draw_StretchPic ============= */ void Draw_StretchPic (int x, int y, int w, int h, char *pic) { image_t *gl; GLint previousMagFilter; gl = Draw_FindPic (pic); if (!gl) { ri.Con_Printf (PRINT_ALL, "Can't find pic: %s\n", pic); return; } if (scrap_dirty) Scrap_Upload (); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !gl->has_alpha) qglDisable (GL_ALPHA_TEST); GL_Bind (gl->texnum); qglGetTexParameteriv( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &previousMagFilter ); qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); qglBegin (GL_QUADS); { qglTexCoord2f (gl->sl, gl->tl); qglVertex2f (x, y); qglTexCoord2f (gl->sh, gl->tl); qglVertex2f (x+w, y); qglTexCoord2f (gl->sh, gl->th); qglVertex2f (x+w, y+h); qglTexCoord2f (gl->sl, gl->th); qglVertex2f (x, y+h); } qglEnd (); qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, previousMagFilter ); if ( ( ( gl_config.renderer == GL_RENDERER_MCD ) || ( gl_config.renderer & GL_RENDERER_RENDITION ) ) && !gl->has_alpha) qglEnable (GL_ALPHA_TEST); }
/* ============= EmitWaterPolys Does a water warp on the pre-fragmented glpoly_t chain ============= */ void EmitWaterPolys (msurface_t *fa) { glpoly_t *p, *bp; float *v; int i; float s, t, os, ot; float scroll; float rdt = r_newrefdef.time; if (fa->texinfo->flags & SURF_FLOWING) scroll = -64 * ( (r_newrefdef.time*0.5) - (int)(r_newrefdef.time*0.5) ); else scroll = 0; for (bp=fa->polys ; bp ; bp=bp->next) { p = bp; qglBegin (GL_TRIANGLE_FAN); for (i=0,v=p->verts[0] ; i<p->numverts ; i++, v+=VERTEXSIZE) { os = v[3]; ot = v[4]; #if !id386 s = os + r_turbsin[(int)((ot*0.125+r_newrefdef.time) * TURBSCALE) & 255]; #else s = os + r_turbsin[Q_ftol( ((ot*0.125+rdt) * TURBSCALE) ) & 255]; #endif s += scroll; s *= (1.0/64); #if !id386 t = ot + r_turbsin[(int)((os*0.125+rdt) * TURBSCALE) & 255]; #else t = ot + r_turbsin[Q_ftol( ((os*0.125+rdt) * TURBSCALE) ) & 255]; #endif t *= (1.0/64); qglTexCoord2f (s, t); qglVertex3fv (v); } qglEnd (); } }
/* ================ DrawFullFace ================ */ void DrawFullFace (curveBlock_t *cb, cubeFace_t *cf) { int k; float *next; if (bevelBrush) { return; } // set the texturing matrix FaceTextureVectors (cf->brushFace, STfromXYZ); if (curveFile) { vec3_t vecs[4]; for (k = 0 ; k < 4 ; k++) { VectorCopy (cb->points[cf->points[k]], vecs[k]); } fprintf (curveFile, "FACE {\n"); fprintf (curveFile, "4\n"); fprintf (curveFile, "textures/%s\n", cf->brushFace->texdef.name); Write2DMatrix (curveFile, 2, 4, (float *)STfromXYZ); Write2DMatrix (curveFile, 4, 3, (float *)vecs); fprintf (curveFile, "}\n"); return; } qglBindTexture (GL_TEXTURE_2D, cf->brushFace->d_texture->texture_number); float fColor[3]; SetColor(cf->brushFace, fColor); qglBegin (GL_POLYGON); for (k = 0 ; k < 4 ; k++) { next = cb->points[cf->points[k]]; qglTexCoord2f (DotProduct(next, STfromXYZ[0]) + STfromXYZ[0][3], DotProduct(next, STfromXYZ[1]) + STfromXYZ[1][3]); qglVertex3fv (next); DecColor(fColor); } qglEnd (); }
/* ===================== RB_STD_FillDepthBuffer If we are rendering a subview with a near clip plane, use a second texture to force the alpha test to fail when behind that clip plane ===================== */ void RB_STD_FillDepthBuffer(drawSurf_t **drawSurfs, int numDrawSurfs) { // if we are just doing 2D rendering, no need to fill the depth buffer if (!backEnd.viewDef->viewEntitys) { return; } RB_LogComment("---------- RB_STD_FillDepthBuffer ----------\n"); // enable the second texture for mirror plane clipping if needed if (backEnd.viewDef->numClipPlanes) { GL_SelectTexture(1); globalImages->alphaNotchImage->Bind(); qglDisableClientState(GL_TEXTURE_COORD_ARRAY); qglEnable(GL_TEXTURE_GEN_S); qglTexCoord2f(1, 0.5); } // the first texture will be used for alpha tested surfaces GL_SelectTexture(0); qglEnableClientState(GL_TEXTURE_COORD_ARRAY); // decal surfaces may enable polygon offset qglPolygonOffset(r_offsetFactor.GetFloat(), r_offsetUnits.GetFloat()); GL_State(GLS_DEPTHFUNC_LESS); // Enable stencil test if we are going to be using it for shadows. // If we didn't do this, it would be legal behavior to get z fighting // from the ambient pass and the light passes. qglEnable(GL_STENCIL_TEST); qglStencilFunc(GL_ALWAYS, 1, 255); RB_RenderDrawSurfListWithFunction(drawSurfs, numDrawSurfs, RB_T_FillDepthBuffer); if (backEnd.viewDef->numClipPlanes) { GL_SelectTexture(1); globalImages->BindNull(); qglDisable(GL_TEXTURE_GEN_S); GL_SelectTexture(0); } }
int gld_wipe_doMelt(int ticks, int *y_lookup) { int i; int total_w, total_h; float fU1, fU2, fV1, fV2; total_w = gld_GetTexDimension(SCREENWIDTH); total_h = gld_GetTexDimension(SCREENHEIGHT); fU1 = 0.0f; fV1 = (float)SCREENHEIGHT / (float)total_h; fU2 = (float)SCREENWIDTH / (float)total_w; fV2 = 0.0f; gld_EnableTexture2D(GL_TEXTURE0_ARB, true); qglBindTexture(GL_TEXTURE_2D, wipe_scr_end_tex); qglColor3f(1.0f, 1.0f, 1.0f); qglBegin(GL_TRIANGLE_STRIP); { qglTexCoord2f(fU1, fV1); qglVertex2f(0.0f, 0.0f); qglTexCoord2f(fU1, fV2); qglVertex2f(0.0f, (float)SCREENHEIGHT); qglTexCoord2f(fU2, fV1); qglVertex2f((float)SCREENWIDTH, 0.0f); qglTexCoord2f(fU2, fV2); qglVertex2f((float)SCREENWIDTH, (float)SCREENHEIGHT); } qglEnd(); qglBindTexture(GL_TEXTURE_2D, wipe_scr_start_tex); qglColor3f(1.0f, 1.0f, 1.0f); qglBegin(GL_QUAD_STRIP); for (i=0; i <= SCREENWIDTH; i++) { int yoffs = MAX(0, y_lookup[i]); float tx = (float) i / total_w; float sx = (float) i; float sy = (float) yoffs; qglTexCoord2f(tx, fV1); qglVertex2f(sx, sy); qglTexCoord2f(tx, fV2); qglVertex2f(sx, sy + (float)SCREENHEIGHT); } qglEnd(); return 0; }
//Water caustics void EmitCausticPolys (const glpoly_t *p) { int i, nv; float txm, tym; const float *v; txm = (float)cos(r_newrefdef.time*0.3f) * 0.3f; tym = (float)sin(r_newrefdef.time*-0.3f) * 0.6f; GL_SelectTexture(1); qglDisable(GL_TEXTURE_2D); GL_SelectTexture(0); qglEnable(GL_BLEND); qglBlendFunc(GL_ZERO, GL_SRC_COLOR); qglColor4f (1, 1, 1, 0.275f); GL_Bind(r_caustictexture->texnum); v = p->verts[0]; nv = p->numverts; qglBegin (GL_POLYGON); for (i = 0; i < nv; i++, v += VERTEXSIZE) { qglTexCoord2f (v[3]+txm, v[4]+tym); qglVertex3fv (v); } qglEnd(); qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); qglColor4fv(colorWhite); qglDisable(GL_BLEND); GL_SelectTexture(1); qglEnable(GL_TEXTURE_2D); GL_SelectTexture(0); }
void MakeSkyVec (float s, float t, int axis) { vec3_t v, b; int j, k; //Knightmare- 12/26/2001- variable back clipping plane distance b[0] = s * r_skydistance->value; b[1] = t * r_skydistance->value; b[2] = r_skydistance->value; //end Knightmare for (j=0 ; j<3 ; j++) { k = st_to_vec[axis][j]; if (k < 0) v[j] = -b[-k - 1]; else v[j] = b[k - 1]; } // avoid bilerp seam s = (s+1)*0.5; t = (t+1)*0.5; if (s < sky_min) s = sky_min; else if (s > sky_max) s = sky_max; if (t < sky_min) t = sky_min; else if (t > sky_max) t = sky_max; t = 1.0 - t; qglTexCoord2f (s, t); qglVertex3fv (v); }
/* ============= RE_StretchRaw FIXME: not exactly backend Stretches a raw 32 bit power of 2 bitmap image over the given screen rectangle. Used for cinematics. ============= */ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) { int i, j; int start, end; if ( !tr.registered ) { return; } R_SyncRenderThread(); // we definately want to sync every frame for the cinematics qglFinish(); start = end = 0; if ( r_speeds->integer ) { start = ri.Milliseconds(); } // make sure rows and cols are powers of 2 for ( i = 0 ; ( 1 << i ) < cols ; i++ ) { } for ( j = 0 ; ( 1 << j ) < rows ; j++ ) { } if ( ( 1 << i ) != cols || ( 1 << j ) != rows) { ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows); } GL_Bind( tr.scratchImage[client] ); // if the scratchImage isn't in the format we want, specify it as a new texture if ( cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height ) { tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols; tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows; qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 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 ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); } else { if (dirty) { // otherwise, just subimage upload it so that drivers can tell we are going to be changing // it and don't try and do a texture compression qglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data ); } } if ( r_speeds->integer ) { end = ri.Milliseconds(); ri.Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start ); } RB_SetGL2D(); qglColor3f( tr.identityLight, tr.identityLight, tr.identityLight ); qglBegin (GL_QUADS); qglTexCoord2f ( 0.5f / cols, 0.5f / rows ); qglVertex2f (x, y); qglTexCoord2f ( ( cols - 0.5f ) / cols , 0.5f / rows ); qglVertex2f (x+w, y); qglTexCoord2f ( ( cols - 0.5f ) / cols, ( rows - 0.5f ) / rows ); qglVertex2f (x+w, y+h); qglTexCoord2f ( 0.5f / cols, ( rows - 0.5f ) / rows ); qglVertex2f (x, y+h); qglEnd (); }
void RB_DistortionFill(void) { float alpha = tr_distortionAlpha; float spost = 0.0f; float spost2 = 0.0f; if ( glConfig.stencilBits < 4 ) { return; } //ok, cap the stupid thing now I guess if (!tr_distortionPrePost) { RB_CaptureScreenImage(); } qglEnable(GL_STENCIL_TEST); qglStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF); qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); qglDisable (GL_CLIP_PLANE0); GL_Cull( CT_TWO_SIDED ); //reset the view matrices and go into ortho mode qglMatrixMode(GL_PROJECTION); qglPushMatrix(); qglLoadIdentity(); qglOrtho(0, glConfig.vidWidth, glConfig.vidHeight, 32, -1, 1); qglMatrixMode(GL_MODELVIEW); qglPushMatrix(); qglLoadIdentity(); if (tr_distortionStretch) { //override spost = tr_distortionStretch; spost2 = tr_distortionStretch; } else { //do slow stretchy effect spost = sin(tr.refdef.time*0.0005f); if (spost < 0.0f) { spost = -spost; } spost *= 0.2f; spost2 = sin(tr.refdef.time*0.0005f); if (spost2 < 0.0f) { spost2 = -spost2; } spost2 *= 0.08f; } if (alpha != 1.0f) { //blend GL_State(GLS_SRCBLEND_SRC_ALPHA|GLS_DSTBLEND_SRC_ALPHA); } else { //be sure to reset the draw state GL_State(0); } #ifdef _XBOX qglBeginEXT(GL_QUADS, 4, 0, 0, 4, 0); #else qglBegin(GL_QUADS); #endif // _XBOX 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(1-spost2, 0+spost); qglVertex2f(glConfig.vidWidth, glConfig.vidHeight); qglTexCoord2f(1-spost2, 1-spost); qglVertex2f(glConfig.vidWidth, 0); qglEnd(); if (tr_distortionAlpha == 1.0f && tr_distortionStretch == 0.0f) { //no overrides if (tr_distortionNegate) { //probably the crazy alternate saber trail alpha = 0.8f; GL_State(GLS_SRCBLEND_ZERO|GLS_DSTBLEND_ONE_MINUS_SRC_COLOR); } else { alpha = 0.5f; GL_State(GLS_SRCBLEND_SRC_ALPHA|GLS_DSTBLEND_SRC_ALPHA); } spost = sin(tr.refdef.time*0.0008f); if (spost < 0.0f) { spost = -spost; } spost *= 0.08f; spost2 = sin(tr.refdef.time*0.0008f); if (spost2 < 0.0f) { spost2 = -spost2; } spost2 *= 0.2f; #ifdef _XBOX qglBeginEXT(GL_QUADS, 4, 0, 0, 4, 0); #else qglBegin(GL_QUADS); #endif // _XBOX 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(1-spost2, 0+spost); qglVertex2f(glConfig.vidWidth, glConfig.vidHeight); qglTexCoord2f(1-spost2, 1-spost); qglVertex2f(glConfig.vidWidth, 0); qglEnd(); } //pop the view matrices back qglMatrixMode(GL_PROJECTION); qglPopMatrix(); qglMatrixMode(GL_MODELVIEW); qglPopMatrix(); qglDisable( GL_STENCIL_TEST ); }