mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
GL1 unified draw calls, chapter iv
Buffered flashblend effects.
This commit is contained in:
parent
749e70b988
commit
e8b2e36bd8
3 changed files with 45 additions and 33 deletions
|
@ -61,7 +61,7 @@ R_ApplyGLBuffer(void)
|
|||
{
|
||||
// Properties of batched draws here
|
||||
GLint vtx_size;
|
||||
qboolean texture, mtex, alpha, texenv_set;
|
||||
qboolean texture, mtex, alpha, color, texenv_set;
|
||||
|
||||
if (gl_buf.vtx_ptr == 0 || gl_buf.idx_ptr == 0)
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ R_ApplyGLBuffer(void)
|
|||
// defaults for drawing (mostly buf_singletex features)
|
||||
vtx_size = 3;
|
||||
texture = true;
|
||||
mtex = alpha = texenv_set = false;
|
||||
mtex = alpha = color = texenv_set = false;
|
||||
|
||||
// choosing features by type
|
||||
switch (gl_buf.type)
|
||||
|
@ -85,6 +85,10 @@ R_ApplyGLBuffer(void)
|
|||
case buf_alpha:
|
||||
alpha = true;
|
||||
break;
|
||||
case buf_flash:
|
||||
color = true;
|
||||
texture = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -161,10 +165,21 @@ R_ApplyGLBuffer(void)
|
|||
glTexCoordPointer(2, GL_FLOAT, 0, gl_buf.tex[0]);
|
||||
}
|
||||
|
||||
if (color)
|
||||
{
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, 0, gl_buf.clr);
|
||||
}
|
||||
|
||||
// All set, we can finally draw
|
||||
glDrawElements(GL_TRIANGLES, gl_buf.idx_ptr, GL_UNSIGNED_SHORT, gl_buf.idx);
|
||||
// ... and now, turn back everything as it was
|
||||
|
||||
if (color)
|
||||
{
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
if (texture)
|
||||
{
|
||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
@ -318,3 +333,15 @@ R_BufferMultiTex(GLfloat cs, GLfloat ct, GLfloat ls, GLfloat lt)
|
|||
gl_buf.tex[1][tx+1] = lt;
|
||||
tx += 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds color components of vertex
|
||||
*/
|
||||
void
|
||||
R_BufferColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
|
||||
{
|
||||
gl_buf.clr[cl++] = r;
|
||||
gl_buf.clr[cl++] = g;
|
||||
gl_buf.clr[cl++] = b;
|
||||
gl_buf.clr[cl++] = a;
|
||||
}
|
||||
|
|
|
@ -35,53 +35,34 @@ static float s_blocklights[34 * 34 * 3];
|
|||
void
|
||||
R_RenderDlight(dlight_t *light)
|
||||
{
|
||||
const float rad = light->intensity * 0.35;
|
||||
int i, j;
|
||||
float a;
|
||||
float rad;
|
||||
float vtx[3], a;
|
||||
|
||||
rad = light->intensity * 0.35;
|
||||
|
||||
GLfloat vtx[3*18];
|
||||
GLfloat clr[4*18];
|
||||
|
||||
unsigned int index_vtx = 3;
|
||||
unsigned int index_clr = 0;
|
||||
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_COLOR_ARRAY );
|
||||
|
||||
clr[index_clr++] = light->color [ 0 ] * 0.2;
|
||||
clr[index_clr++] = light->color [ 1 ] * 0.2;
|
||||
clr[index_clr++] = light->color [ 2 ] * 0.2;
|
||||
clr[index_clr++] = 1;
|
||||
R_SetBufferIndices(GL_TRIANGLE_FAN, 18);
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
vtx [ i ] = light->origin [ i ] - vpn [ i ] * rad;
|
||||
}
|
||||
|
||||
R_BufferVertex( vtx[0], vtx[1], vtx[2] );
|
||||
R_BufferColor( light->color[0] * 0.2, light->color[1] * 0.2,
|
||||
light->color[2] * 0.2, 1 );
|
||||
|
||||
for ( i = 16; i >= 0; i-- )
|
||||
{
|
||||
clr[index_clr++] = 0;
|
||||
clr[index_clr++] = 0;
|
||||
clr[index_clr++] = 0;
|
||||
clr[index_clr++] = 1;
|
||||
|
||||
a = i / 16.0 * M_PI * 2;
|
||||
|
||||
for ( j = 0; j < 3; j++ )
|
||||
{
|
||||
vtx[index_vtx++] = light->origin [ j ] + vright [ j ] * cos( a ) * rad
|
||||
vtx[ j ] = light->origin [ j ] + vright [ j ] * cos( a ) * rad
|
||||
+ vup [ j ] * sin( a ) * rad;
|
||||
}
|
||||
|
||||
R_BufferVertex( vtx[0], vtx[1], vtx[2] );
|
||||
R_BufferColor( 0, 0, 0, 1 );
|
||||
}
|
||||
|
||||
glVertexPointer( 3, GL_FLOAT, 0, vtx );
|
||||
glColorPointer( 4, GL_FLOAT, 0, clr );
|
||||
glDrawArrays( GL_TRIANGLE_FAN, 0, 18 );
|
||||
|
||||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
glDisableClientState( GL_COLOR_ARRAY );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -94,6 +75,7 @@ R_RenderDlights(void)
|
|||
{
|
||||
return;
|
||||
}
|
||||
R_UpdateGLBuffer(buf_flash, 0, 0, 0, 1);
|
||||
|
||||
/* because the count hasn't advanced yet for this frame */
|
||||
r_dlightframecount = r_framecount + 1;
|
||||
|
@ -110,6 +92,7 @@ R_RenderDlights(void)
|
|||
{
|
||||
R_RenderDlight(l);
|
||||
}
|
||||
R_ApplyGLBuffer();
|
||||
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glDisable(GL_BLEND);
|
||||
|
|
|
@ -112,7 +112,8 @@ typedef enum
|
|||
buf_2d,
|
||||
buf_singletex,
|
||||
buf_mtex,
|
||||
buf_alpha
|
||||
buf_alpha,
|
||||
buf_flash
|
||||
} buffered_draw_t;
|
||||
|
||||
#include "model.h"
|
||||
|
@ -297,6 +298,7 @@ void R_SetBufferIndices(GLenum type, GLuint vertices_num);
|
|||
void R_BufferVertex(GLfloat x, GLfloat y, GLfloat z);
|
||||
void R_BufferSingleTex(GLfloat s, GLfloat t);
|
||||
void R_BufferMultiTex(GLfloat cs, GLfloat ct, GLfloat ls, GLfloat lt);
|
||||
void R_BufferColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
|
||||
|
||||
#ifdef DEBUG
|
||||
void glCheckError_(const char *file, const char *function, int line);
|
||||
|
|
Loading…
Reference in a new issue