diff --git a/includes/graphics.h b/includes/graphics.h index 22986a5d3..986052262 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -195,6 +195,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_before(pixel *part_vbuf); + +void render_after(pixel *part_vbuf, pixel *vid_buf); + #ifdef OGLR void draw_parts_fbo(); #endif diff --git a/includes/powdergraphics.h b/includes/powdergraphics.h index 66286c6fa..0abe06c9e 100644 --- a/includes/powdergraphics.h +++ b/includes/powdergraphics.h @@ -65,6 +65,5 @@ #define DISPLAY_AIR 0x0000000F #define DISPLAY_WARP 0x00000010 #define DISPLAY_PERS 0x00000020 -#define DISPLAY_EFFE 0x00000040 #endif diff --git a/src/graphics.c b/src/graphics.c index 3916ffdf0..6d4853131 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1693,7 +1693,7 @@ void draw_other(pixel *vid) // EMP effect if (emp_decor>0 && !sys_pause) emp_decor-=emp_decor/25+2; if (emp_decor>40) emp_decor=40; if (emp_decor<0) emp_decor = 0; - if (!(display_mode & DISPLAY_EFFE)) // no in nothing mode + if (!(render_mode & EFFECT)) // not in nothing mode return; if (emp_decor>0) { @@ -2869,10 +2869,82 @@ void draw_parts_fbo() } #endif +// draw the graphics that appear before update_particles is called +void render_before(pixel *part_vbuf) +{ +#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(part_vbuf); + draw_walls(part_vbuf); +} + +int persist_counter = 0; +// draw the graphics that appear after update_particles is called +void render_after(pixel *part_vbuf, pixel *vid_buf) +{ + render_parts(part_vbuf); //draw particles + draw_other(part_vbuf); + //if(su == WL_GRAV+100) + // draw_grav_zones(part_vbuf); + if (vid_buf && (display_mode & DISPLAY_PERS)) + { + if (!persist_counter) + { + dim_copy_pers(pers_bg, vid_buf); + } + else + { + memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE); + } + persist_counter = (persist_counter+1) % 3; + } +#ifndef OGLR + if (render_mode & FIREMODE) + render_fire(part_vbuf); +#endif + + render_signs(part_vbuf); + +#ifndef OGLR + if(vid_buf && ngrav_enable && (display_mode & DISPLAY_WARP)) + render_gravlensing(part_vbuf, vid_buf); +#endif +} + void draw_walls(pixel *vid) { - int x, y, i, j, cr, cg, cb; + int x, y, i, j, cr, cg, cb, nx, ny, t; unsigned char wt; + float lx, ly; pixel pc; pixel gc; for (y=0; y=XRES || ny<0 || ny>=YRES) + break; + addpixel(vid, nx, ny, 255, 255, 255, 64); + i = nx/CELL; + j = ny/CELL; + lx += vx[j][i]*0.125f; + ly += vy[j][i]*0.125f; + if (bmap[j][i]==WL_STREAM && i!=x && j!=y) + break; + } + drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128); + } } void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int click, int tool) diff --git a/src/interface.c b/src/interface.c index 0e31ffb56..9e8c6db86 100644 --- a/src/interface.c +++ b/src/interface.c @@ -5441,7 +5441,8 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved b = mouse_get_state(&mx, &my); memcpy(vid_buf,old_buf,(XRES+BARSIZE)*(YRES+MENUSIZE)*PIXELSIZE); - render_parts(vid_buf); + render_before(vid_buf); + render_after(vid_buf, NULL); ui_edit_process(mx, my, b, &box_R); ui_edit_process(mx, my, b, &box_G); ui_edit_process(mx, my, b, &box_B); @@ -6466,10 +6467,10 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation) int render_optionicons[] = {0xE1, 0xDF, 0x9B, 0xC4, 0xBF, 0xDB}; char * render_desc[] = {"Effects", "Glow", "Fire", "Blur", "Blob", "Basic"}; - int display_optioncount = 7; - int display_options[] = {DISPLAY_AIRC, DISPLAY_AIRP, DISPLAY_AIRV, DISPLAY_AIRH, DISPLAY_WARP, DISPLAY_PERS, DISPLAY_EFFE}; - int display_optionicons[] = {0xD4, 0x99, 0x98, 0xBE, 0xDE, 0x9A, -1}; - char * display_desc[] = {"Air: Cracker", "Air: Pressure", "Air: Velocity", "Air: Heat", "Warp effect", "Persistent", "Effects"}; + int display_optioncount = 6; + int display_options[] = {DISPLAY_AIRC, DISPLAY_AIRP, DISPLAY_AIRV, DISPLAY_AIRH, DISPLAY_WARP, DISPLAY_PERS}; + int display_optionicons[] = {0xD4, 0x99, 0x98, 0xBE, 0xDE, 0x9A}; + char * display_desc[] = {"Air: Cracker", "Air: Pressure", "Air: Velocity", "Air: Heat", "Warp effect", "Persistent"}; int colour_optioncount = 4; int colour_options[] = {COLOUR_BASC, COLOUR_LIFE, COLOUR_HEAT, COLOUR_GRAD}; @@ -6558,63 +6559,24 @@ 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); - - if(ngrav_enable && display_mode & DISPLAY_WARP) +#ifdef OGLR + part_vbuf = vid_buf; +#else + 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 + render_before(part_vbuf); + render_after(part_vbuf, vid_buf); + quickoptions_menu(vid_buf, b, bq, mx, my); + for (i=0; i1180) @@ -1067,10 +1025,19 @@ int main(int argc, char *argv[]) sandcolour_b = sandcolour_r = sandcolour_g = (int)(20.0f*sin((float)sandcolour_frame*(M_PI/180.0f))); sandcolour_frame++; sandcolour_frame%=360; - - if(ngrav_enable && drawgrav_enable) - draw_grav(vid_buf); - draw_walls(part_vbuf); + +#ifdef OGLR + part_vbuf = vid_buf; +#else + 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; + } +#endif + render_before(part_vbuf); if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) { @@ -1099,8 +1066,9 @@ int main(int argc, char *argv[]) #endif } - render_parts(part_vbuf); //draw particles - draw_other(part_vbuf); + render_after(part_vbuf, vid_buf); + if(su == WL_GRAV+100) + draw_grav_zones(part_vbuf); if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) { @@ -1118,9 +1086,6 @@ int main(int argc, char *argv[]) debug_perf_istart %= DEBUG_PERF_FRAMECOUNT; } - if(sl == WL_GRAV+100 || sr == WL_GRAV+100) - draw_grav_zones(part_vbuf); - gravity_update_async(); //Check for updated velocity maps from gravity thread if (!sys_pause||framerender) //Only update if not paused memset(gravmap, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float)); //Clear the old gravmap @@ -1130,31 +1095,6 @@ int main(int argc, char *argv[]) sys_pause = 1; } - if (display_mode & DISPLAY_PERS) - { - if (!fire_fc)//fire_fc has nothing to do with fire... it is a counter for diminishing persistent view every 3 frames - { - dim_copy_pers(pers_bg, vid_buf); - } - else - { - memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE); - } - fire_fc = (fire_fc+1) % 3; - } - -#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 - memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE);//clear menu areas clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); @@ -2822,7 +2762,6 @@ int main(int argc, char *argv[]) #endif } - //execute python step hook sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE); //Setting an element for the stick man diff --git a/src/powder.c b/src/powder.c index 798c562bc..da75ee2b2 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2730,8 +2730,7 @@ movedone: int parts_lastActiveIndex = NPART-1; void update_particles(pixel *vid)//doesn't update the particles themselves, but some other things { - int i, j, x, y, t, nx, ny, r, cr,cg,cb, l = -1; - float lx, ly; + int i, x, y, t; int lastPartUsed = 0; int lastPartUnused = -1; #ifdef MT @@ -2792,31 +2791,6 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but } update_particles_i(vid, 0, 1); - - // this should probably be elsewhere - for (y=0; y=XRES || ny<0 || ny>=YRES) - break; - addpixel(vid, nx, ny, 255, 255, 255, 64); - i = nx/CELL; - j = ny/CELL; - lx += vx[j][i]*0.125f; - ly += vy[j][i]*0.125f; - if (bmap[j][i]==WL_STREAM && i!=x && j!=y) - break; - } - drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128); - } - } void clear_area(int area_x, int area_y, int area_w, int area_h)