Cursor in ZooM

This commit is contained in:
Simon Robertshaw 2011-11-08 12:35:07 +00:00
parent bc2b5e7945
commit c983de144d
3 changed files with 73 additions and 58 deletions

View File

@ -174,6 +174,10 @@ void blend_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b,
void render_parts(pixel *vid); void render_parts(pixel *vid);
#ifdef OGLR
void draw_parts_fbo();
#endif
void draw_parts(pixel *vid); void draw_parts(pixel *vid);
void draw_walls(pixel *vid); void draw_walls(pixel *vid);

View File

@ -2511,6 +2511,14 @@ void render_parts(pixel *vid)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
//Drawing the FBO onto the screen sounds like a cool idea now //Drawing the FBO onto the screen sounds like a cool idea now
glBlendFunc(origBlendSrc, origBlendDst);
#endif
}
#ifdef OGLR
void draw_parts_fbo()
{
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
if(cmode==CM_FANCY) if(cmode==CM_FANCY)
{ {
@ -2555,10 +2563,8 @@ void render_parts(pixel *vid)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} }
glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_2D );
glBlendFunc(origBlendSrc, origBlendDst);
#endif
} }
#endif
void draw_walls(pixel *vid) void draw_walls(pixel *vid)
{ {
@ -3251,7 +3257,7 @@ void render_zoom(pixel *img) //draws the zoom box
glGetIntegerv(GL_BLEND_SRC, &origBlendSrc); glGetIntegerv(GL_BLEND_SRC, &origBlendSrc);
glGetIntegerv(GL_BLEND_DST, &origBlendDst); glGetIntegerv(GL_BLEND_DST, &origBlendDst);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_ONE, GL_ZERO);
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
//glReadBuffer(GL_AUX0); //glReadBuffer(GL_AUX0);
@ -3271,7 +3277,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); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(sdl_scale); glLineWidth(sdl_scale);
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
@ -3314,6 +3320,7 @@ void render_zoom(pixel *img) //draws the zoom box
glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_LOGIC_OP);
} }
glLineWidth(1); glLineWidth(1);
glBlendFunc(origBlendSrc, origBlendDst);
#else #else
int x, y, i, j; int x, y, i, j;
pixel pix; pixel pix;
@ -3630,6 +3637,7 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
int i; int i;
if (t<PT_NUM||(t&0xFF)==PT_LIFE||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM||t==SPC_WIND||t==SPC_PGRV||t==SPC_NGRV) if (t<PT_NUM||(t&0xFF)==PT_LIFE||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM||t==SPC_WIND||t==SPC_PGRV||t==SPC_NGRV)
{ {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
glEnable(GL_COLOR_LOGIC_OP); glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR); glLogicOp(GL_XOR);
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
@ -3640,29 +3648,30 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
rx *= sdl_scale; rx *= sdl_scale;
if (CURRENT_BRUSH==SQUARE_BRUSH) if (CURRENT_BRUSH==SQUARE_BRUSH)
{ {
glVertex2f(x-rx+1, ((YRES+MENUSIZE)*sdl_scale-y)-ry+1); glVertex2f(x-rx+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)-ry+1);
glVertex2f(x+rx+1, ((YRES+MENUSIZE)*sdl_scale-y)-ry+1); glVertex2f(x+rx+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)-ry+1);
glVertex2f(x+rx+1, ((YRES+MENUSIZE)*sdl_scale-y)+ry+1); glVertex2f(x+rx+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)+ry+1);
glVertex2f(x-rx+1, ((YRES+MENUSIZE)*sdl_scale-y)+ry+1); glVertex2f(x-rx+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)+ry+1);
glVertex2f(x-rx+1, ((YRES+MENUSIZE)*sdl_scale-y)-ry+1); glVertex2f(x-rx+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)-ry+1);
} }
else if (CURRENT_BRUSH==CIRCLE_BRUSH) else if (CURRENT_BRUSH==CIRCLE_BRUSH)
{ {
for (i = 0; i < 360; i++) for (i = 0; i < 360; i++)
{ {
float degInRad = i*(M_PI/180.0f); float degInRad = i*(M_PI/180.0f);
glVertex2f((cos(degInRad)*rx)+x, (sin(degInRad)*ry)+(YRES+MENUSIZE)*sdl_scale-y); glVertex2f((cos(degInRad)*rx)+x, (sin(degInRad)*ry)+/*(YRES+MENUSIZE)*sdl_scale-*/y);
} }
} }
else if (CURRENT_BRUSH==TRI_BRUSH) else if (CURRENT_BRUSH==TRI_BRUSH)
{ {
glVertex2f(x+1, ((YRES+MENUSIZE)*sdl_scale-y)+ry+1); glVertex2f(x+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)+ry+1);
glVertex2f(x+rx+1, ((YRES+MENUSIZE)*sdl_scale-y)-ry+1); glVertex2f(x+rx+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)-ry+1);
glVertex2f(x-rx+1, ((YRES+MENUSIZE)*sdl_scale-y)-ry+1); glVertex2f(x-rx+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)-ry+1);
glVertex2f(x+1, ((YRES+MENUSIZE)*sdl_scale-y)+ry+1); glVertex2f(x+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)+ry+1);
} }
glEnd(); glEnd();
glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_LOGIC_OP);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
} }
#else #else
int i,j,c; int i,j,c;

View File

@ -3399,7 +3399,9 @@ int main(int argc, char *argv[])
mousex = mx/sdl_scale; mousex = mx/sdl_scale;
mousey = my/sdl_scale; mousey = my/sdl_scale;
} }
#ifdef OGLR
draw_parts_fbo();
#endif
if (zoom_en) if (zoom_en)
render_zoom(vid_buf); render_zoom(vid_buf);