summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/defines.h6
-rw-r--r--includes/graphics.h38
-rw-r--r--src/elements/pipe.c6
-rw-r--r--src/graphics.c176
-rw-r--r--src/interface.c7
-rw-r--r--src/main.c6
6 files changed, 139 insertions, 100 deletions
diff --git a/includes/defines.h b/includes/defines.h
index a96b95b..fb1212c 100644
--- a/includes/defines.h
+++ b/includes/defines.h
@@ -9,9 +9,9 @@
//VersionInfoStart
#define SAVE_VERSION 68
-#define MINOR_VERSION 1
+#define MINOR_VERSION 3
#define BETA
-#define BUILD_NUM 106
+#define BUILD_NUM 109
//VersionInfoEnd
#define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter.
@@ -86,8 +86,6 @@ extern unsigned char ZSIZE;
#define CATALOGUE_S 6
#define CATALOGUE_Z 3
-#define STAMP_X 4
-#define STAMP_Y 4
#define STAMP_MAX 240
#define NGOL 25
diff --git a/includes/graphics.h b/includes/graphics.h
index b9d39bb..b704a54 100644
--- a/includes/graphics.h
+++ b/includes/graphics.h
@@ -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);
+#ifdef OGLR
+void draw_parts_fbo();
+#endif
+
void draw_parts(pixel *vid);
void draw_walls(pixel *vid);
@@ -224,21 +228,24 @@ void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale);
#ifdef INCLUDE_SHADERS
#ifndef SHADERS_H
#define SHADERS_H
-const char * fireFragment = "uniform sampler2D fireAlpha;\
+const char * fireFragment = "#version 120\n\
+uniform sampler2D fireAlpha;\
void main () {\
vec4 texColor = texture2D(fireAlpha, gl_PointCoord);\
gl_FragColor = vec4(gl_Color.rgb, texColor.a*gl_Color.a);\
}";
-const char * fireVertex = "void main(void)\
+const char * fireVertex = "#version 120\n\
+void main(void)\
{\
gl_Position = ftransform();;\
gl_FrontColor = gl_Color;\
}";
-const char * lensFragment = "uniform sampler2D pTex;\
+const char * lensFragment = "#version 120\n\
+uniform sampler2D pTex;\
uniform sampler2D tfX;\
uniform sampler2D tfY;\
-uniform float xres = 612.0;\
-uniform float yres = 384.0;\
+uniform float xres;\
+uniform float yres;\
void main () {\
vec4 transformX = texture2D(tfX, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\
vec4 transformY = -texture2D(tfY, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\
@@ -252,13 +259,15 @@ void main () {\
);\
gl_FragColor = texColor;\
}";
-const char * lensVertex = "void main(void)\
+const char * lensVertex = "#version 120\n\
+void main(void)\
{\
gl_TexCoord[0] = gl_MultiTexCoord0;\
gl_Position = ftransform();;\
gl_FrontColor = gl_Color;\
}";
-const char * airVFragment = "uniform sampler2D airX;\
+const char * airVFragment = "#version 120\n\
+uniform sampler2D airX;\
uniform sampler2D airY;\
uniform sampler2D airP;\
void main () {\
@@ -267,26 +276,30 @@ void main () {\
vec4 texP = texture2D(airP, gl_TexCoord[0].st);\
gl_FragColor = vec4(abs(texX.r)/2.0, texP.b/2.0, abs(texY.g)/2.0, 1.0);\
}";
-const char * airVVertex = "void main(void)\
+const char * airVVertex = "#version 120\n\
+void main(void)\
{\
gl_TexCoord[0] = gl_MultiTexCoord0;\
gl_Position = ftransform();;\
gl_FrontColor = gl_Color;\
}";
-const char * airPFragment = "uniform sampler2D airX;\
+const char * airPFragment = "#version 120\n\
+uniform sampler2D airX;\
uniform sampler2D airY;\
uniform sampler2D airP;\
void main () {\
vec4 texP = texture2D(airP, gl_TexCoord[0].st);\
gl_FragColor = vec4(max(texP.b/2.0, 0), 0, abs(min(texP.b/2.0, 0)), 1.0);\
}";
-const char * airPVertex = "void main(void)\
+const char * airPVertex = "#version 120\n\
+void main(void)\
{\
gl_TexCoord[0] = gl_MultiTexCoord0;\
gl_Position = ftransform();;\
gl_FrontColor = gl_Color;\
}";
-const char * airCFragment = "uniform sampler2D airX;\
+const char * airCFragment = "#version 120\n\
+uniform sampler2D airX;\
uniform sampler2D airY;\
uniform sampler2D airP;\
void main () {\
@@ -295,7 +308,8 @@ void main () {\
vec4 texP = texture2D(airP, gl_TexCoord[0].st);\
gl_FragColor = vec4(max(texP.b/2.0, 0), 0, abs(min(texP.b/2.0, 0)), 1.0) + vec4(abs(texX.r)/8.0, abs(texX.r)/8.0, abs(texX.r)/8.0, 1.0) + vec4(abs(texY.g)/8.0, abs(texY.g)/8.0, abs(texY.g)/8.0, 1.0);\
}";
-const char * airCVertex = "void main(void)\
+const char * airCVertex = "#version 120\n\
+void main(void)\
{\
gl_TexCoord[0] = gl_MultiTexCoord0;\
gl_Position = ftransform();;\
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;
diff --git a/src/main.c b/src/main.c
index 798f4f8..3d61f42 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);