OpenGl Improvements

This commit is contained in:
Simon Robertshaw 2011-11-01 11:42:44 +00:00
parent ec3fdfed1c
commit a9046fe7a6
3 changed files with 40 additions and 9 deletions

View File

@ -13,7 +13,7 @@ int graphics_PLSM(GRAPHICS_FUNC_ARGS)
*fireg = *colg; *fireg = *colg;
*fireb = *colb; *fireb = *colb;
*pixel_mode = PMODE_GLOW; //Clear default, don't draw pixel *pixel_mode = PMODE_GLOW | PMODE_ADD; //Clear default, don't draw pixel
*pixel_mode |= FIRE_ADD; *pixel_mode |= FIRE_ADD;
//Returning 0 means dynamic, do not cache //Returning 0 means dynamic, do not cache
return 0; return 0;

View File

@ -1622,6 +1622,8 @@ GLuint glowV[(YRES*XRES)*2];
GLfloat glowC[(YRES*XRES)*4]; GLfloat glowC[(YRES*XRES)*4];
GLuint flatV[(YRES*XRES)*2]; GLuint flatV[(YRES*XRES)*2];
GLfloat flatC[(YRES*XRES)*4]; GLfloat flatC[(YRES*XRES)*4];
GLuint addV[(YRES*XRES)*2];
GLfloat addC[(YRES*XRES)*4];
GLfloat lineV[(((YRES*XRES)*2)*6)]; GLfloat lineV[(((YRES*XRES)*2)*6)];
GLfloat lineC[(((YRES*XRES)*2)*6)]; GLfloat lineC[(((YRES*XRES)*2)*6)];
#endif #endif
@ -1637,6 +1639,7 @@ void render_parts(pixel *vid)
int cblurV = 0, cblurC = 0, cblur = 0; int cblurV = 0, cblurC = 0, cblur = 0;
int cglowV = 0, cglowC = 0, cglow = 0; int cglowV = 0, cglowC = 0, cglow = 0;
int cflatV = 0, cflatC = 0, cflat = 0; int cflatV = 0, cflatC = 0, cflat = 0;
int caddV = 0, caddC = 0, cadd = 0;
int clineV = 0, clineC = 0, cline = 0; int clineV = 0, clineC = 0, cline = 0;
GLuint origBlendSrc, origBlendDst; GLuint origBlendSrc, origBlendDst;
//Set coord offset //Set coord offset
@ -1777,7 +1780,7 @@ void render_parts(pixel *vid)
case CM_VEL: case CM_VEL:
case CM_PRESS: case CM_PRESS:
case CM_GRAD: case CM_GRAD:
if(pixel_mode & FIRE_ADD) pixel_mode = (pixel_mode & ~FIRE_ADD) | PMODE_GLOW | PMODE_FLAT; if(pixel_mode & FIRE_ADD) pixel_mode = (pixel_mode & ~(FIRE_ADD|PMODE_FLAT)) | PMODE_GLOW | PMODE_ADD;
if(pixel_mode & FIRE_BLEND) pixel_mode = (pixel_mode & ~FIRE_BLEND) | PMODE_BLUR; if(pixel_mode & FIRE_BLEND) pixel_mode = (pixel_mode & ~FIRE_BLEND) | PMODE_BLUR;
case CM_FIRE: case CM_FIRE:
if(pixel_mode & PMODE_BLOB) pixel_mode = (pixel_mode & ~PMODE_BLOB) | PMODE_FLAT; if(pixel_mode & PMODE_BLOB) pixel_mode = (pixel_mode & ~PMODE_BLOB) | PMODE_FLAT;
@ -1934,13 +1937,13 @@ void render_parts(pixel *vid)
if(pixel_mode & PMODE_ADD) if(pixel_mode & PMODE_ADD)
{ {
#ifdef OGLR #ifdef OGLR
flatV[cflatV++] = nx; addV[caddV++] = nx;
flatV[cflatV++] = ny; addV[caddV++] = ny;
flatC[cflatC++] = ((float)colr)/255.0f; addC[caddC++] = ((float)colr)/255.0f;
flatC[cflatC++] = ((float)colg)/255.0f; addC[caddC++] = ((float)colg)/255.0f;
flatC[cflatC++] = ((float)colb)/255.0f; addC[caddC++] = ((float)colb)/255.0f;
flatC[cflatC++] = ((float)cola)/255.0f; addC[caddC++] = ((float)cola)/255.0f;
cflat++; cadd++;
#else #else
addpixel(vid, nx, ny, colr, colg, colb, cola); addpixel(vid, nx, ny, colr, colg, colb, cola);
#endif #endif
@ -2378,6 +2381,22 @@ void render_parts(pixel *vid)
// -- END GLOW -- // // -- END GLOW -- //
} }
if(cadd)
{
// -- BEGIN ADD -- //
//Set point size (size of fire texture)
glPointSize(1.0f);
glColorPointer(4, GL_FLOAT, 0, &addC[0]);
glVertexPointer(2, GL_INT, 0, &addV[0]);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glDrawArrays(GL_POINTS, 0, cadd);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//Clear some stuff we set
// -- END ADD -- //
}
if(cline) if(cline)
{ {
// -- BEGIN LINES -- // // -- BEGIN LINES -- //
@ -3181,6 +3200,7 @@ void dim_copy_pers(pixel *dst, pixel *src) //for persistent view, reduces rgb sl
void render_zoom(pixel *img) //draws the zoom box void render_zoom(pixel *img) //draws the zoom box
{ {
#ifdef OGLR #ifdef OGLR
int origBlendSrc, origBlendDst;
float zcx1, zcx0, zcy1, zcy0, yfactor, xfactor; //X-Factor is shit, btw float zcx1, zcx0, zcy1, zcy0, yfactor, xfactor; //X-Factor is shit, btw
xfactor = 1.0f/(float)XRES; xfactor = 1.0f/(float)XRES;
yfactor = 1.0f/(float)YRES; yfactor = 1.0f/(float)YRES;
@ -3201,6 +3221,10 @@ void render_zoom(pixel *img) //draws the zoom box
glEnd(); glEnd();
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);
glGetIntegerv(GL_BLEND_SRC, &origBlendSrc);
glGetIntegerv(GL_BLEND_DST, &origBlendDst);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
//glReadBuffer(GL_AUX0); //glReadBuffer(GL_AUX0);
glBindTexture(GL_TEXTURE_2D, partsFboTex); glBindTexture(GL_TEXTURE_2D, partsFboTex);
@ -3219,6 +3243,7 @@ void render_zoom(pixel *img) //draws the zoom box
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_2D );
glBlendFunc(origBlendSrc, origBlendDst);
if(zoom_en) if(zoom_en)
{ {

View File

@ -1800,6 +1800,9 @@ int main(int argc, char *argv[])
update_airh(); update_airh();
} }
#ifdef OGLR
part_vbuf = vid_buf;
#else
if(ngrav_enable && cmode==CM_FANCY) if(ngrav_enable && cmode==CM_FANCY)
{ {
part_vbuf = part_vbuf_store; part_vbuf = part_vbuf_store;
@ -1807,6 +1810,7 @@ int main(int argc, char *argv[])
} else { } else {
part_vbuf = vid_buf; part_vbuf = vid_buf;
} }
#endif
if(gravwl_timeout) if(gravwl_timeout)
{ {
@ -1978,8 +1982,10 @@ int main(int argc, char *argv[])
render_signs(part_vbuf); render_signs(part_vbuf);
#ifndef OGLR
if(ngrav_enable && cmode==CM_FANCY) if(ngrav_enable && cmode==CM_FANCY)
render_gravlensing(part_vbuf, vid_buf); render_gravlensing(part_vbuf, vid_buf);
#endif
memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE);//clear menu areas memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE);//clear menu areas
clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES);