summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-05-12 00:35:55 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-05-12 00:35:55 (GMT)
commitd69fc052fabf38b6691970c38abe4c8525eff3e8 (patch)
tree857691fe7d792a8dde25167e134ed3e12ce01f9f /src
parentd7fa0b139e5a91c3b1d406e63cae4a6ad79d0cd0 (diff)
downloadpowder-d69fc052fabf38b6691970c38abe4c8525eff3e8.zip
powder-d69fc052fabf38b6691970c38abe4c8525eff3e8.tar.gz
Fancy motion blur for OpenGL, fix a lot of dialogues in OpenGL, fix gravity lensing in OpenGL, ensure Phot and Neut are PMODE_ADD, not FLAT
Diffstat (limited to 'src')
-rw-r--r--src/elements/neut.c5
-rw-r--r--src/elements/phot.c3
-rw-r--r--src/graphics.c119
-rw-r--r--src/interface.c134
-rw-r--r--src/main.c2
-rw-r--r--src/powder.c10
-rw-r--r--src/save.c5
7 files changed, 260 insertions, 18 deletions
diff --git a/src/elements/neut.c b/src/elements/neut.c
index 658195a..afb0523 100644
--- a/src/elements/neut.c
+++ b/src/elements/neut.c
@@ -40,6 +40,8 @@ int create_n_parts(int n, int x, int y, float vx, float vy, float temp, int t)//
parts[i].x = (float)x;
parts[i].y = (float)y;
+ parts[i].lastX = (float)x;
+ parts[i].lastY = (float)y;
parts[i].type = t;
parts[i].life = rand()%480+480;
parts[i].vx = r*cosf(a);
@@ -160,6 +162,7 @@ int graphics_NEUT(GRAPHICS_FUNC_ARGS)
*fireg = 80;
*fireb = 120;
- *pixel_mode |= FIRE_ADD;
+ *pixel_mode &= ~PMODE_FLAT;
+ *pixel_mode |= FIRE_ADD | PMODE_ADD;
return 1;
}
diff --git a/src/elements/phot.c b/src/elements/phot.c
index 66cf4eb..ba6fd25 100644
--- a/src/elements/phot.c
+++ b/src/elements/phot.c
@@ -94,6 +94,7 @@ int graphics_PHOT(GRAPHICS_FUNC_ARGS)
*fireg = *colg;
*fireb = *colb;
- *pixel_mode |= FIRE_ADD;
+ *pixel_mode &= ~PMODE_FLAT;
+ *pixel_mode |= FIRE_ADD | PMODE_ADD;
return 0;
}
diff --git a/src/graphics.c b/src/graphics.c
index d39db8e..1b1e8ce 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -24,8 +24,7 @@
#if defined(OGLR)
#ifdef MACOSX
-#include <GL/glew.h>
-#include <OpenGL/gl.h>
+#include <OpenGL/gl3.h>
#include <OpenGL/glu.h>
#elif defined(WIN32)
#include <GL/glew.h>
@@ -458,6 +457,7 @@ void clearScreenNP(float alpha)
void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale)
{
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glDrawPixels(w,h,GL_BGRA,GL_UNSIGNED_BYTE,src); //Why does this still think it's ABGR?
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D, vidBuf);
@@ -475,6 +475,7 @@ void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale)
glEnd();
glDisable( GL_TEXTURE_2D );
+ glBlendFunc(GL_ONE, GL_ONE);
glFlush();
SDL_GL_SwapBuffers ();
}
@@ -1750,12 +1751,16 @@ GLuint addV[(YRES*XRES)*2];
GLfloat addC[(YRES*XRES)*4];
GLfloat lineV[(((YRES*XRES)*2)*6)];
GLfloat lineC[(((YRES*XRES)*2)*6)];
+GLfloat blurLineV[(((YRES*XRES)*2))];
+GLfloat blurLineC[(((YRES*XRES)*2)*4)];
+GLfloat ablurLineV[(((YRES*XRES)*2))];
+GLfloat ablurLineC[(((YRES*XRES)*2)*4)];
#endif
void render_parts(pixel *vid)
{
int deca, decr, decg, decb, cola, colr, colg, colb, firea, firer, fireg, fireb, pixel_mode, q, i, t, nx, ny, x, y, caddress;
int orbd[4] = {0, 0, 0, 0}, orbl[4] = {0, 0, 0, 0};
- float gradv, flicker, fnx, fny;
+ float gradv, flicker, fnx, fny, flx, fly;
#ifdef OGLR
int cfireV = 0, cfireC = 0, cfire = 0;
int csmokeV = 0, csmokeC = 0, csmoke = 0;
@@ -1765,6 +1770,8 @@ void render_parts(pixel *vid)
int cflatV = 0, cflatC = 0, cflat = 0;
int caddV = 0, caddC = 0, cadd = 0;
int clineV = 0, clineC = 0, cline = 0;
+ int cblurLineV = 0, cblurLineC = 0, cblurLine = 0;
+ int cablurLineV = 0, cablurLineC = 0, cablurLine = 0;
GLuint origBlendSrc, origBlendDst;
glGetIntegerv(GL_BLEND_SRC, &origBlendSrc);
@@ -1792,6 +1799,8 @@ void render_parts(pixel *vid)
ny = (int)(parts[i].y+0.5f);
fnx = parts[i].x;
fny = parts[i].y;
+ flx = parts[i].lastX;
+ fly = parts[i].lastY;
if(photons[ny][nx]&0xFF && !(ptypes[t].properties & TYPE_ENERGY))
continue;
@@ -2099,6 +2108,65 @@ void render_parts(pixel *vid)
draw_line(vid , cplayer->legs[8], cplayer->legs[9], cplayer->legs[12], cplayer->legs[13], legr, legg, legb, s);
#endif
}
+#ifdef OGLR
+ if((display_mode & DISPLAY_EFFE) && (fabs(fnx-flx)>1.5f || fabs(fny-fly)>1.5f))
+ {
+ if(pixel_mode & PMODE_FLAT)
+ {
+ blurLineV[cblurLineV++] = nx;
+ blurLineV[cblurLineV++] = ny;
+ blurLineC[cblurLineC++] = ((float)colr)/255.0f;
+ blurLineC[cblurLineC++] = ((float)colg)/255.0f;
+ blurLineC[cblurLineC++] = ((float)colb)/255.0f;
+ blurLineC[cblurLineC++] = 1.0f;
+ cblurLine++;
+
+ blurLineV[cblurLineV++] = flx;
+ blurLineV[cblurLineV++] = fly;
+ blurLineC[cblurLineC++] = ((float)colr)/255.0f;
+ blurLineC[cblurLineC++] = ((float)colg)/255.0f;
+ blurLineC[cblurLineC++] = ((float)colb)/255.0f;
+ blurLineC[cblurLineC++] = 0.0f;
+ cblurLine++;
+ }
+ else if(pixel_mode & PMODE_BLEND)
+ {
+ blurLineV[cblurLineV++] = nx;
+ blurLineV[cblurLineV++] = ny;
+ blurLineC[cblurLineC++] = ((float)colr)/255.0f;
+ blurLineC[cblurLineC++] = ((float)colg)/255.0f;
+ blurLineC[cblurLineC++] = ((float)colb)/255.0f;
+ blurLineC[cblurLineC++] = ((float)cola)/255.0f;
+ cblurLine++;
+
+ blurLineV[cblurLineV++] = flx;
+ blurLineV[cblurLineV++] = fly;
+ blurLineC[cblurLineC++] = ((float)colr)/255.0f;
+ blurLineC[cblurLineC++] = ((float)colg)/255.0f;
+ blurLineC[cblurLineC++] = ((float)colb)/255.0f;
+ blurLineC[cblurLineC++] = 0.0f;
+ cblurLine++;
+ }
+ else if(pixel_mode & PMODE_ADD)
+ {
+ ablurLineV[cablurLineV++] = nx;
+ ablurLineV[cablurLineV++] = ny;
+ ablurLineC[cablurLineC++] = ((float)colr)/255.0f;
+ ablurLineC[cablurLineC++] = ((float)colg)/255.0f;
+ ablurLineC[cablurLineC++] = ((float)colb)/255.0f;
+ ablurLineC[cablurLineC++] = ((float)cola)/255.0f;
+ cablurLine++;
+
+ ablurLineV[cablurLineV++] = flx;
+ ablurLineV[cablurLineV++] = fly;
+ ablurLineC[cablurLineC++] = ((float)colr)/255.0f;
+ ablurLineC[cablurLineC++] = ((float)colg)/255.0f;
+ ablurLineC[cablurLineC++] = ((float)colb)/255.0f;
+ ablurLineC[cablurLineC++] = 0.0f;
+ cablurLine++;
+ }
+ }
+#endif
if(pixel_mode & PMODE_FLAT)
{
#ifdef OGLR
@@ -2546,6 +2614,36 @@ void render_parts(pixel *vid)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ if(cablurLine)
+ {
+ // -- BEGIN LINES -- //
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glEnable( GL_LINE_SMOOTH );
+ glColorPointer(4, GL_FLOAT, 0, &ablurLineC[0]);
+ glVertexPointer(2, GL_FLOAT, 0, &ablurLineV[0]);
+
+ glDrawArrays(GL_LINES, 0, cablurLine);
+
+ //Clear some stuff we set
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_LINE_SMOOTH);
+ // -- END LINES -- //
+ }
+ if(cblurLine)
+ {
+ // -- BEGIN LINES -- //
+ glEnable( GL_LINE_SMOOTH );
+ glColorPointer(4, GL_FLOAT, 0, &blurLineC[0]);
+ glVertexPointer(2, GL_FLOAT, 0, &blurLineV[0]);
+
+ glDrawArrays(GL_LINES, 0, cblurLine);
+
+ //Clear some stuff we set
+ glDisable(GL_LINE_SMOOTH);
+ // -- END LINES -- //
+ }
+
if(cflat)
{
// -- BEGIN FLAT -- //
@@ -3310,7 +3408,7 @@ void prepare_alpha(int size, float intensity)
for (x=0; x<CELL*3; x++)
for (y=0; y<CELL*3; y++)
{
- fire_alphaf[y][x] = intensity*temp[y][x]/((float)(CELL*CELL));
+ fire_alphaf[y][x] = (intensity*temp[y][x]/((float)(CELL*CELL)))/2.0f;
}
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fireAlpha);
@@ -3322,6 +3420,7 @@ void prepare_alpha(int size, float intensity)
c = 5;
+ glow_alphaf[c][c] = 0.8f;
glow_alphaf[c][c-1] = 0.4f;
glow_alphaf[c][c+1] = 0.4f;
glow_alphaf[c-1][c] = 0.4f;
@@ -3910,18 +4009,18 @@ int sdl_open(void)
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &partsTFX);
glBindTexture(GL_TEXTURE_2D, partsTFX);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES, YRES, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES/CELL, YRES/CELL, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
- 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_MAG_FILTER,GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
glGenTextures(1, &partsTFY);
glBindTexture(GL_TEXTURE_2D, partsTFY);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES, YRES, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, XRES/CELL, YRES/CELL, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
- 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_MAG_FILTER,GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
diff --git a/src/interface.c b/src/interface.c
index ef2891f..3b7e408 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -252,7 +252,9 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
drawtext(vid_buf, x0+5, y0+69, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255);
-
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_edit_process(mx, my, b, &ed);
@@ -533,6 +535,9 @@ void ui_list_process(pixel * vid_buf, int mx, int my, int mb, ui_list *ed)
if(!selected && mb)
break;
drawrect(vid_buf, ed->x, ystart, ed->w, ed->count*16, 255, 255, 255, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
clearrect(vid_buf, ed->x-2, ystart-2, ed->w+4, (ed->count*16)+4);
}
@@ -955,6 +960,9 @@ void error_ui(pixel *vid_buf, int err, char *txt)
drawtextwrap(vid_buf, x0+8, y0+26, 224, msg, 255, 255, 255, 255);
drawtext(vid_buf, x0+5, y0+textheight+37, "Dismiss", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+textheight+32, 240, 16, 192, 192, 192, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+240 && my>=y0+textheight+32 && my<=y0+textheight+48)
@@ -1024,6 +1032,9 @@ char *input_ui(pixel *vid_buf, char *title, char *prompt, char *text, char *shad
drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize)
@@ -1116,6 +1127,9 @@ void prop_edit_ui(pixel *vid_buf, int x, int y)
drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize)
@@ -1258,6 +1272,9 @@ void info_ui(pixel *vid_buf, char *top, char *txt)
drawtext(vid_buf, x0+8, y0+26, txt, 255, 255, 255, 255);
drawtext(vid_buf, x0+5, y0+49, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+240 && my>=y0+44 && my<=y0+60)
@@ -1286,6 +1303,9 @@ void info_box(pixel *vid_buf, char *msg)
drawrect(vid_buf, x0, y0, w, 24, 192, 192, 192, 255);
drawtext(vid_buf, x0+8, y0+8, msg, 192, 192, 240, 255);
#ifndef RENDERER
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
#endif
}
@@ -1340,6 +1360,9 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt)
drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize)
@@ -1391,6 +1414,9 @@ int confirm_ui(pixel *vid_buf, char *top, char *msg, char *btn)
drawrect(vid_buf, x0, y0+textheight+32, 160, 16, 192, 192, 192, 255);
drawrect(vid_buf, x0+160, y0+textheight+32, 80, 16, 192, 192, 192, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b && !bq && mx>=x0+160 && mx<x0+240 && my>=y0+textheight+32 && my<=y0+textheight+48)
@@ -1476,6 +1502,10 @@ void login_ui(pixel *vid_buf)
drawtext(vid_buf, x0+187-textwidth("Sign in"), y0+69, "Sign in", 255, 255, 55, 255);
drawrect(vid_buf, x0, y0+64, 192, 16, 192, 192, 192, 255);
drawrect(vid_buf, x0, y0+64, 96, 16, 192, 192, 192, 255);
+
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_edit_process(mx, my, b, &ed1);
@@ -1682,6 +1712,9 @@ int stamp_ui(pixel *vid_buf)
}
}
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (b==1&&r!=-1)
@@ -1817,6 +1850,9 @@ void tag_list_ui(pixel *vid_buf)
ui_edit_draw(vid_buf, &ed);
drawtext(vid_buf, x0+5, y0+245, "Close", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+240, 192, 16, 192, 192, 192, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_edit_process(mx, my, b, &ed);
@@ -1972,6 +2008,9 @@ int save_name_ui(pixel *vid_buf)
ui_copytext_draw(vid_buf, &ctb);
ui_copytext_process(mx, my, b, bq, &ctb);
}
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
@@ -2968,6 +3007,9 @@ char *download_ui(pixel *vid_buf, char *uri, int *len)
drawtext(vid_buf, x0+120-textwidth("Waiting...")/2, y0+48, "Waiting...", 255, 216, 32, 255);
drawrect(vid_buf, x0, y0+44, 240, 16, 192, 192, 192, 255);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
}
@@ -3819,6 +3861,9 @@ int report_ui(pixel* vid_buf, char *save_id)
return 0;
}
ui_edit_draw(vid_buf, &ed);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_edit_process(mx, my, b, &ed);
}
@@ -4329,6 +4374,9 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
if (!info_ready || !data_ready) {
info_box(vid_buf, "Loading");
}
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
if (info_ready && svf_login) {
@@ -5704,6 +5752,9 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
if (zoom_en)
render_zoom(vid_buf);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (sdl_wheel)
@@ -6020,7 +6071,9 @@ int save_filename_ui(pixel *vid_buf)
ui_edit_draw(vid_buf, &ed);
drawtext(vid_buf, x0+12+textwidth(ed.str), y0+25, ".cps", 240, 240, 255, 180);
-
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
@@ -6308,6 +6361,9 @@ void catalogue_ui(pixel * vid_buf)
//srctemp+=(XRES+BARSIZE);//*PIXELSIZE;
}
}
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
if (sdl_key==SDLK_RETURN)
break;
@@ -6382,6 +6438,8 @@ void drawIcon(pixel * vid_buf, int x, int y, int cmode)
void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
{
pixel * o_vid_buf;
+ pixel *part_vbuf; //Extra video buffer
+ pixel *part_vbuf_store;
int i, j, count, changed, temp;
int xsize;
int ysize;
@@ -6472,7 +6530,10 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
}
o_vid_buf = calloc((YRES+MENUSIZE) * (XRES+BARSIZE), PIXELSIZE);
- memcpy(o_vid_buf, vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE);
+ //memcpy(o_vid_buf, vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE);
+
+ part_vbuf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); //Extra video buffer
+ part_vbuf_store = part_vbuf;
while (!sdl_poll())
{
@@ -6487,7 +6548,64 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
b = mouse_get_state(&mx, &my);
memcpy(vid_buf, o_vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE);
- render_parts(vid_buf);
+
+ if(ngrav_enable && display_mode & DISPLAY_WARP)
+ {
+ part_vbuf = part_vbuf_store;
+ memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
+ } else {
+ part_vbuf = vid_buf;
+ }
+
+#ifdef OGLR
+ if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
+ {
+ clearScreen(0.01f);
+ memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
+ }
+ else //clear screen every frame
+ {
+ clearScreen(1.0f);
+ memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
+ if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
+ {
+ draw_air(part_vbuf);
+ }
+ }
+#else
+ if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
+ {
+ draw_air(part_vbuf);
+ }
+ else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
+ {
+ memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE);
+ memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE));
+ }
+ else //clear screen every frame
+ {
+ memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
+ }
+#endif
+
+ if(ngrav_enable && drawgrav_enable)
+ draw_grav(vid_buf);
+
+ draw_walls(part_vbuf);
+
+ render_parts(part_vbuf);
+ draw_other(part_vbuf);
+#ifndef OGLR
+ if (render_mode & FIREMODE)
+ render_fire(part_vbuf);
+#endif
+ render_signs(part_vbuf);
+
+#ifndef OGLR
+ if(ngrav_enable && display_mode & DISPLAY_WARP)
+ render_gravlensing(part_vbuf, vid_buf);
+#endif
+ draw_svf_ui(vid_buf, sdl_mod & (KMOD_LCTRL|KMOD_RCTRL));
clearrect(vid_buf, xcoord-2, ycoord-2, xsize+4, ysize+4);
drawrect(vid_buf, xcoord, ycoord, xsize, ysize, 192, 192, 192, 255);
@@ -6618,11 +6736,12 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
}
}
- sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
#ifdef OGLR
clearScreenNP(1.0f);
draw_parts_fbo();
#endif
+ sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
+
if (sdl_key==SDLK_RETURN)
break;
if (sdl_key==SDLK_ESCAPE)
@@ -6644,6 +6763,8 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
break;
}
+ free(part_vbuf);
+
free(o_vid_buf);
}
@@ -6774,6 +6895,9 @@ void simulation_ui(pixel * vid_buf)
ui_checkbox_draw(vid_buf, &cb6);
ui_list_draw(vid_buf, &list);
ui_list_draw(vid_buf, &list2);
+#ifdef OGLR
+ clearScreen(1.0f);
+#endif
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
ui_checkbox_process(mx, my, b, bq, &cb);
ui_checkbox_process(mx, my, b, bq, &cb2);
diff --git a/src/main.c b/src/main.c
index 1f014bf..87baa4a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2255,7 +2255,7 @@ int main(int argc, char *argv[])
}
if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
{
- render_ui(vid_buf, XRES+BARSIZE-(510-491), YRES-2, 3);
+ render_ui(vid_buf, XRES+BARSIZE-(510-491)+1, YRES+22, 3);
}
if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq)
sys_pause = !sys_pause;
diff --git a/src/powder.c b/src/powder.c
index 3d5ed42..4724b7a 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -888,6 +888,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{
parts[i].x = (float)x;
parts[i].y = (float)y;
+ parts[i].lastX = (float)x;
+ parts[i].lastY = (float)y;
parts[i].type = t;
parts[i].vx = 0;
parts[i].vy = 0;
@@ -1031,6 +1033,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{
parts[i].x = (float)x;
parts[i].y = (float)y;
+ parts[i].lastX = (float)x;
+ parts[i].lastY = (float)y;
parts[i].type = PT_STKM;
parts[i].vx = 0;
parts[i].vy = 0;
@@ -1053,6 +1057,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{
parts[i].x = (float)x;
parts[i].y = (float)y;
+ parts[i].lastX = (float)x;
+ parts[i].lastY = (float)y;
parts[i].type = PT_STKM2;
parts[i].vx = 0;
parts[i].vy = 0;
@@ -1077,6 +1083,8 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
{
parts[i].x = (float)x;
parts[i].y = (float)y;
+ parts[i].lastX = (float)x;
+ parts[i].lastY = (float)y;
parts[i].type = PT_FIGH;
parts[i].vx = 0;
parts[i].vy = 0;
@@ -1721,6 +1729,8 @@ void update_particles_i(pixel *vid, int start, int inc)
if (parts[i].type)
{
t = parts[i].type;
+ parts[i].lastX = parts[i].x;
+ parts[i].lastY = parts[i].y;
if (t<0 || t>=PT_NUM)
{
kill_part(i);
diff --git a/src/save.c b/src/save.c
index 320e89f..cf13994 100644
--- a/src/save.c
+++ b/src/save.c
@@ -1345,6 +1345,9 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c
if(i >= partsDataLen) goto fail;
partsptr[newIndex].tmp2 = partsData[i++];
}
+
+ partsptr[newIndex].lastX = partsptr[newIndex].x - partsptr[newIndex].vx;
+ partsptr[newIndex].lastY = partsptr[newIndex].y - partsptr[newIndex].vy;
if ((player.spwn == 1 && partsptr[newIndex].type==PT_STKM) || (player2.spwn == 1 && partsptr[newIndex].type==PT_STKM2))
{
@@ -2023,6 +2026,8 @@ int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned c
{
parts[i].vx = (d[p++]-127.0f)/16.0f;
parts[i].vy = (d[p++]-127.0f)/16.0f;
+ parts[i].lastX = parts[i].x - parts[i].vx;
+ parts[i].lastY = parts[i].y - parts[i].vy;
}
else
p += 2;