xor_bitmap drawing for renderer

This commit is contained in:
Simon Robertshaw 2012-08-15 16:25:13 +01:00
parent 2f0e67433c
commit 98445721fd
3 changed files with 85 additions and 30 deletions

View File

@ -228,16 +228,16 @@ void PIXELMETHODS_CLASS::xor_rect(int x, int y, int width, int height)
void PIXELMETHODS_CLASS::xor_bitmap(unsigned char * bitmap, int x, int y, int w, int h)
{
/* Rewriting until better method can be found */
//glEnable(GL_COLOR_LOGIC_OP);
//glLogicOp(GL_XOR);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textTexture);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap);
glBegin(GL_QUADS);
glTexCoord2d(0, 0);
@ -254,22 +254,6 @@ void PIXELMETHODS_CLASS::xor_bitmap(unsigned char * bitmap, int x, int y, int w,
glDisable(GL_TEXTURE_2D);
//glDisable(GL_COLOR_LOGIC_OP);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
/*float old_size;
glGetFloatv(GL_POINT_SIZE,&old_size);
glPointSize(1.0);
glBegin(GL_POINTS);
glColor4f(1.0f,1.0f,1.0f,1.0f);
for(int i =0; i < w*h; i++)
{
if(bitmap[i]==255)
{
glVertex2f(x+i%w,y+i/w);
}
}
glEnd();
glPointSize(old_size);*/
}
void PIXELMETHODS_CLASS::draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a)

View File

@ -34,7 +34,20 @@ extern "C"
void Renderer::RenderBegin()
{
#ifndef OGLR
#ifdef OGLI
#ifdef OGLR
draw_air();
draw_grav();
render_parts();
render_fire();
DrawWalls();
draw_grav_zones();
DrawSigns();
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
glTranslated(0, MENUSIZE, 0);
#else
if(display_mode & DISPLAY_PERS)
{
std::copy(persistentVid, persistentVid+(VIDXRES*YRES), vid);
@ -46,12 +59,12 @@ void Renderer::RenderBegin()
vid = warpVid;
std::fill(warpVid, warpVid+(VIDXRES*VIDYRES), 0);
}
#endif
//draw_air();
//draw_grav();
draw_air();
draw_grav();
render_parts();
//render_fire();
#ifndef OGLR
render_fire();
if(display_mode & DISPLAY_PERS)
{
int i,r,g,b;
@ -69,17 +82,59 @@ void Renderer::RenderBegin()
persistentVid[i] = PIXRGB(r,g,b);
}
}
#endif
DrawWalls();
//draw_grav_zones();
//DrawSigns();
#ifndef OGLR
draw_grav_zones();
DrawSigns();
if(display_mode & DISPLAY_WARP)
{
vid = oldVid;
}
#endif
#ifndef OGLI
#else
if(display_mode & DISPLAY_PERS)
{
std::copy(persistentVid, persistentVid+(VIDXRES*YRES), vid);
}
pixel * oldVid;
if(display_mode & DISPLAY_WARP)
{
oldVid = vid;
vid = warpVid;
std::fill(warpVid, warpVid+(VIDXRES*VIDYRES), 0);
}
draw_air();
draw_grav();
render_parts();
render_fire();
if(display_mode & DISPLAY_PERS)
{
int i,r,g,b;
for (i = 0; i < VIDXRES*YRES; i++)
{
r = PIXR(vid[i]);
g = PIXG(vid[i]);
b = PIXB(vid[i]);
if (r>0)
r--;
if (g>0)
g--;
if (b>0)
b--;
persistentVid[i] = PIXRGB(r,g,b);
}
}
DrawWalls();
draw_grav_zones();
DrawSigns();
if(display_mode & DISPLAY_WARP)
{
vid = oldVid;
}
FinaliseParts();
#endif
}
@ -88,6 +143,8 @@ void Renderer::RenderEnd()
{
#ifdef OGLI
#ifdef OGLR
glTranslated(0, -MENUSIZE, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo);
FinaliseParts();
RenderZoom();
#else
@ -348,7 +405,7 @@ void Renderer::RenderZoom()
glGetIntegerv(GL_BLEND_SRC, &origBlendSrc);
glGetIntegerv(GL_BLEND_DST, &origBlendDst);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);//glBlendFunc(GL_ONE, GL_ZERO);
glBlendFunc(GL_ONE, GL_ZERO);
glEnable( GL_TEXTURE_2D );
//glReadBuffer(GL_AUX0);
@ -2393,6 +2450,19 @@ Renderer::Renderer(Graphics * g, Simulation * sim):
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
//Temptexture
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &textTexture);
glBindTexture(GL_TEXTURE_2D, textTexture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
loadShaders();
#endif
prepare_alpha(CELL, 1.0f);

View File

@ -85,6 +85,7 @@ public:
void checkProgram(GLuint program, char * progname);
void loadShaders();
GLuint vidBuf,textTexture;
GLint prevFbo;
#endif
pixel * vid;
pixel * persistentVid;