summaryrefslogtreecommitdiff
path: root/src/interface.c
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/interface.c
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/interface.c')
-rw-r--r--src/interface.c134
1 files changed, 129 insertions, 5 deletions
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);