diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/elements/pipe.c | 6 | ||||
| -rw-r--r-- | src/graphics.c | 176 | ||||
| -rw-r--r-- | src/interface.c | 7 | ||||
| -rw-r--r-- | src/main.c | 6 |
4 files changed, 111 insertions, 84 deletions
diff --git a/src/elements/pipe.c b/src/elements/pipe.c index 3ee5262..3f370a1 100644 --- a/src/elements/pipe.c +++ b/src/elements/pipe.c @@ -191,14 +191,16 @@ int update_PIPE(UPDATE_FUNC_ARGS) { // make a border for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) + { if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) { r = pmap[y+ry][x+rx]; if (!r) create_part(-1,x+rx,y+ry,PT_BRCK);//BRCK border, people didn't like DMND } - if (parts[i].life==1) - parts[i].ctype = 1; + } + if (parts[i].life<=1) + parts[i].ctype = 1; } } else if (parts[i].ctype==1)//wait for empty space before starting to generate automatic pipe pattern diff --git a/src/graphics.c b/src/graphics.c index 8f5fe8c..9b29a6b 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1846,7 +1846,10 @@ void render_parts(pixel *vid) //Pixel rendering if(pixel_mode & PSPEC_STICKMAN) { - //Special case for stickman + char buff[20]; //Buffer for HP + int s; + int legr, legg, legb; + pixel pc; playerst *cplayer; if(t==PT_STKM) cplayer = &player; @@ -1892,10 +1895,6 @@ void render_parts(pixel *vid) glEnd(); glDisable(GL_LINE_SMOOTH); #else - char buff[20]; //Buffer for HP - int s; - int legr, legg, legb; - pixel pc; if (mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head { @@ -2512,54 +2511,61 @@ void render_parts(pixel *vid) glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); //Drawing the FBO onto the screen sounds like a cool idea now - glEnable( GL_TEXTURE_2D ); - if(cmode==CM_FANCY) - { - glUseProgram(lensProg); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, partsFboTex); - glUniform1i(glGetUniformLocation(lensProg, "pTex"), 0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, partsTFX); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES, YRES, GL_RED, GL_FLOAT, gravxf); - glUniform1i(glGetUniformLocation(lensProg, "tfX"), 1); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, partsTFY); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES, YRES, GL_GREEN, GL_FLOAT, gravyf); - glUniform1i(glGetUniformLocation(lensProg, "tfY"), 2); - glActiveTexture(GL_TEXTURE0); - //glUniform1f(glGetUniformLocation(lensProg, "xres"), (float)XRES); - //glUniform1f(glGetUniformLocation(lensProg, "yres"), (float)YRES); - } - else - { - glBindTexture(GL_TEXTURE_2D, partsFboTex); - glBlendFunc(GL_ONE, GL_ONE); - } - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - glTexCoord2d(1, 0); - glVertex3f(XRES*sdl_scale, (YRES+MENUSIZE)*sdl_scale, 1.0); - glTexCoord2d(0, 0); - glVertex3f(0, (YRES+MENUSIZE)*sdl_scale, 1.0); - glTexCoord2d(0, 1); - glVertex3f(0, MENUSIZE*sdl_scale, 1.0); - glTexCoord2d(1, 1); - glVertex3f(XRES*sdl_scale, MENUSIZE*sdl_scale, 1.0); - glEnd(); - - if(cmode==CM_FANCY) - { - glUseProgram(0); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - glDisable( GL_TEXTURE_2D ); glBlendFunc(origBlendSrc, origBlendDst); #endif } +#ifdef OGLR +void draw_parts_fbo() +{ + glEnable( GL_TEXTURE_2D ); + if(cmode==CM_FANCY) + { + float xres = XRES, yres = YRES; + glUseProgram(lensProg); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, partsFboTex); + glUniform1i(glGetUniformLocation(lensProg, "pTex"), 0); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, partsTFX); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES, YRES, GL_RED, GL_FLOAT, gravxf); + glUniform1i(glGetUniformLocation(lensProg, "tfX"), 1); + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, partsTFY); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, XRES, YRES, GL_GREEN, GL_FLOAT, gravyf); + glUniform1i(glGetUniformLocation(lensProg, "tfY"), 2); + glActiveTexture(GL_TEXTURE0); + glUniform1fv(glGetUniformLocation(lensProg, "xres"), 1, &xres); + glUniform1fv(glGetUniformLocation(lensProg, "yres"), 1, &yres); + } + else + { + glBindTexture(GL_TEXTURE_2D, partsFboTex); + glBlendFunc(GL_ONE, GL_ONE); + } + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glBegin(GL_QUADS); + glTexCoord2d(1, 0); + glVertex3f(XRES*sdl_scale, (YRES+MENUSIZE)*sdl_scale, 1.0); + glTexCoord2d(0, 0); + glVertex3f(0, (YRES+MENUSIZE)*sdl_scale, 1.0); + glTexCoord2d(0, 1); + glVertex3f(0, MENUSIZE*sdl_scale, 1.0); + glTexCoord2d(1, 1); + glVertex3f(XRES*sdl_scale, MENUSIZE*sdl_scale, 1.0); + glEnd(); + + if(cmode==CM_FANCY) + { + glUseProgram(0); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + glDisable( GL_TEXTURE_2D ); +} +#endif + void draw_walls(pixel *vid) { int x, y, i, j, cr, cg, cb; @@ -3240,30 +3246,18 @@ void render_zoom(pixel *img) //draws the zoom box { #ifdef OGLR int origBlendSrc, origBlendDst; - float zcx1, zcx0, zcy1, zcy0, yfactor, xfactor; //X-Factor is shit, btw + float zcx1, zcx0, zcy1, zcy0, yfactor, xfactor, i; //X-Factor is shit, btw xfactor = 1.0f/(float)XRES; yfactor = 1.0f/(float)YRES; - + zcx0 = (zoom_x)*xfactor; zcx1 = (zoom_x+ZSIZE)*xfactor; zcy0 = (zoom_y)*yfactor; zcy1 = ((zoom_y+ZSIZE))*yfactor; - - glLineWidth(sdl_scale); - glEnable(GL_LINE_SMOOTH); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_LINE_STRIP); - glVertex3i((zoom_wx-1)*sdl_scale, (YRES+MENUSIZE-zoom_wy)*sdl_scale, 0); - glVertex3i((zoom_wx-1)*sdl_scale, (YRES+MENUSIZE-(zoom_wy+ZSIZE*ZFACTOR))*sdl_scale, 0); - glVertex3i((zoom_wx+ZSIZE*ZFACTOR)*sdl_scale, (YRES+MENUSIZE-(zoom_wy+ZSIZE*ZFACTOR))*sdl_scale, 0); - glVertex3i((zoom_wx+ZSIZE*ZFACTOR)*sdl_scale, (YRES+MENUSIZE-zoom_wy)*sdl_scale, 0); - glVertex3i((zoom_wx-1)*sdl_scale, (YRES+MENUSIZE-zoom_wy)*sdl_scale, 0); - glEnd(); - glDisable(GL_LINE_SMOOTH); - + glGetIntegerv(GL_BLEND_SRC, &origBlendSrc); glGetIntegerv(GL_BLEND_DST, &origBlendDst); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_ONE, GL_ZERO); glEnable( GL_TEXTURE_2D ); //glReadBuffer(GL_AUX0); @@ -3283,8 +3277,33 @@ void render_zoom(pixel *img) //draws the zoom box glBindTexture(GL_TEXTURE_2D, 0); glDisable( GL_TEXTURE_2D ); - glBlendFunc(origBlendSrc, origBlendDst); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glLineWidth(sdl_scale); + glEnable(GL_LINE_SMOOTH); + glBegin(GL_LINES); + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + for(i = 0; i < ZSIZE; i++) + { + glVertex2f((zoom_wx+ZSIZE*ZFACTOR)*sdl_scale, (YRES+MENUSIZE-(zoom_wy+ZSIZE*ZFACTOR)+i*ZFACTOR)*sdl_scale); + glVertex2f(zoom_wx*sdl_scale, (YRES+MENUSIZE-(zoom_wy+ZSIZE*ZFACTOR)+i*ZFACTOR)*sdl_scale); + glVertex2f((zoom_wx+i*ZFACTOR)*sdl_scale, (YRES+MENUSIZE-(zoom_wy+ZSIZE*ZFACTOR))*sdl_scale); + glVertex2f((zoom_wx+i*ZFACTOR)*sdl_scale, (YRES+MENUSIZE-zoom_wy)*sdl_scale); + } + glEnd(); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glBegin(GL_LINE_STRIP); + glVertex3i((zoom_wx-1)*sdl_scale, (YRES+MENUSIZE-zoom_wy)*sdl_scale, 0); + glVertex3i((zoom_wx-1)*sdl_scale, (YRES+MENUSIZE-(zoom_wy+ZSIZE*ZFACTOR))*sdl_scale, 0); + glVertex3i((zoom_wx+ZSIZE*ZFACTOR)*sdl_scale, (YRES+MENUSIZE-(zoom_wy+ZSIZE*ZFACTOR))*sdl_scale, 0); + glVertex3i((zoom_wx+ZSIZE*ZFACTOR)*sdl_scale, (YRES+MENUSIZE-zoom_wy)*sdl_scale, 0); + glVertex3i((zoom_wx-1)*sdl_scale, (YRES+MENUSIZE-zoom_wy)*sdl_scale, 0); + glEnd(); + glDisable(GL_LINE_SMOOTH); + + glDisable(GL_LINE_SMOOTH); + if(zoom_en) { glEnable(GL_COLOR_LOGIC_OP); @@ -3299,8 +3318,9 @@ void render_zoom(pixel *img) //draws the zoom box glVertex3i((zoom_x-1)*sdl_scale, (YRES+MENUSIZE-(zoom_y-1))*sdl_scale, 0); glEnd(); glDisable(GL_COLOR_LOGIC_OP); - } - glLineWidth(1); + } + glLineWidth(1); + glBlendFunc(origBlendSrc, origBlendDst); #else int x, y, i, j; pixel pix; @@ -3617,6 +3637,7 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry) 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) { + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); glBegin(GL_LINE_LOOP); @@ -3627,29 +3648,30 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry) rx *= sdl_scale; 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) { for (i = 0; i < 360; i++) { 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) { - 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+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+1, (/*(YRES+MENUSIZE)*sdl_scale-*/y)+ry+1); } glEnd(); glDisable(GL_COLOR_LOGIC_OP); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); } #else int i,j,c; diff --git a/src/interface.c b/src/interface.c index 28a89de..3309868 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1429,9 +1429,10 @@ fail: int stamp_ui(pixel *vid_buf) { - int b=1,bq,mx,my,d=-1,i,j,k,x,gx,gy,y,w,h,r=-1,stamp_page=0,per_page=STAMP_X*STAMP_Y,page_count; + int b=1,bq,mx,my,d=-1,i,j,k,x,gx,gy,y,w,h,r=-1,stamp_page=0,per_page=GRID_X*GRID_Y,page_count; char page_info[64]; - page_count = ceil((float)stamp_count/(float)per_page); + // stamp_count-1 to avoid an extra page when there are per_page stamps on each page + page_count = (stamp_count-1)/per_page+1; while (!sdl_poll()) { @@ -1447,7 +1448,7 @@ int stamp_ui(pixel *vid_buf) mx /= sdl_scale; my /= sdl_scale; - clearrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE+1); + clearrect(vid_buf, -1, -1, XRES+BARSIZE+1, YRES+MENUSIZE+1); k = stamp_page*per_page;//0; r = -1; d = -1; @@ -150,7 +150,7 @@ static const char *it_msg = "\n" "Contributors: \bgStanislaw K Skowronek (\brhttp://powder.unaligned.org\bg, \bbirc.unaligned.org #wtf\bg),\n" "\bgSimon Robertshaw, Skresanov Savely, cracker64, Catelite, Bryan Hoyle, Nathan Cousins, jacksonmj,\n" - "\bgLieuwe Mosch, Anthony Boot, Matthew Miller, MaksProg\n" + "\bgLieuwe Mosch, Anthony Boot, Matthew \"me4502\", MaksProg\n" "\n" "\bgTo use online features such as saving, you need to register at: \brhttp://powdertoy.co.uk/Register.html" ; @@ -3399,7 +3399,9 @@ int main(int argc, char *argv[]) mousex = mx/sdl_scale; mousey = my/sdl_scale; } - +#ifdef OGLR + draw_parts_fbo(); +#endif if (zoom_en) render_zoom(vid_buf); |
