From 986b25b50838996800263b9ee18cf1397d9558a7 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 11 Aug 2014 21:56:40 -0400 Subject: [PATCH] redo spark graphics, add spark render setting --- src/graphics/Renderer.cpp | 21 +++++++++++++++++++++ src/gui/render/RenderView.cpp | 16 ++++++++++++---- src/simulation/ElementGraphics.h | 4 +++- src/simulation/elements/SPRK.cpp | 10 +++++----- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index bd8238c5f..520cc04c8 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -1956,6 +1956,23 @@ void Renderer::render_parts() fire_r[ny/CELL][nx/CELL] = firer; fire_g[ny/CELL][nx/CELL] = fireg; fire_b[ny/CELL][nx/CELL] = fireb; +#endif + } + if(firea && (pixel_mode & FIRE_SPARK)) + { +#ifdef OGLR + smokeV[csmokeV++] = nx; + smokeV[csmokeV++] = ny; + smokeC[csmokeC++] = ((float)firer)/255.0f; + smokeC[csmokeC++] = ((float)fireg)/255.0f; + smokeC[csmokeC++] = ((float)fireb)/255.0f; + smokeC[csmokeC++] = ((float)firea)/255.0f; + csmoke++; +#else + firea /= 4; + fire_r[ny/CELL][nx/CELL] = (firea*firer + (255-firea)*fire_r[ny/CELL][nx/CELL]) >> 8; + fire_g[ny/CELL][nx/CELL] = (firea*fireg + (255-firea)*fire_g[ny/CELL][nx/CELL]) >> 8; + fire_b[ny/CELL][nx/CELL] = (firea*fireb + (255-firea)*fire_b[ny/CELL][nx/CELL]) >> 8; #endif } } @@ -2441,6 +2458,7 @@ Renderer::Renderer(Graphics * g, Simulation * sim): SetColourMode(COLOUR_DEFAULT); AddRenderMode(RENDER_BASC); AddRenderMode(RENDER_FIRE); + AddRenderMode(RENDER_SPRK); //Render mode presets. Possibly load from config in future? renderModePresets = new RenderPreset[11]; @@ -2467,11 +2485,13 @@ Renderer::Renderer(Graphics * g, Simulation * sim): renderModePresets[4].Name = "Fire Display"; renderModePresets[4].RenderModes.push_back(RENDER_FIRE); + renderModePresets[4].RenderModes.push_back(RENDER_SPRK); renderModePresets[4].RenderModes.push_back(RENDER_EFFE); renderModePresets[4].RenderModes.push_back(RENDER_BASC); renderModePresets[5].Name = "Blob Display"; renderModePresets[5].RenderModes.push_back(RENDER_FIRE); + renderModePresets[5].RenderModes.push_back(RENDER_SPRK); renderModePresets[5].RenderModes.push_back(RENDER_EFFE); renderModePresets[5].RenderModes.push_back(RENDER_BLOB); @@ -2482,6 +2502,7 @@ Renderer::Renderer(Graphics * g, Simulation * sim): renderModePresets[7].Name = "Fancy Display"; renderModePresets[7].RenderModes.push_back(RENDER_FIRE); + renderModePresets[7].RenderModes.push_back(RENDER_SPRK); renderModePresets[7].RenderModes.push_back(RENDER_GLOW); renderModePresets[7].RenderModes.push_back(RENDER_BLUR); renderModePresets[7].RenderModes.push_back(RENDER_EFFE); diff --git a/src/gui/render/RenderView.cpp b/src/gui/render/RenderView.cpp index f4a84d1ca..1f7b7c795 100644 --- a/src/gui/render/RenderView.cpp +++ b/src/gui/render/RenderView.cpp @@ -186,6 +186,14 @@ RenderView::RenderView(): tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_BASC)); AddComponent(tCheckbox); + checkboxOffset += cSpace; + + tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Spark", "Glow effect on sparks"); + renderModes.push_back(tCheckbox); + tCheckbox->SetIcon(IconEffect); + tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_SPRK)); + AddComponent(tCheckbox); + checkboxOffset += sSpace; line1 = checkboxOffset-5; @@ -231,9 +239,9 @@ RenderView::RenderView(): AddComponent(tCheckbox); #ifdef OGLR - tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "I don't know what this does..."); //I would remove the whole checkbox, but then there's a large empty space + tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "Some type of OpenGL effect ... maybe"); //I would remove the whole checkbox, but then there's a large empty space #else - tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "Does nothing"); + tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "Enables moving solids, stickmen guns, and premium(tm) graphics"); #endif displayModes.push_back(tCheckbox); tCheckbox->SetIcon(IconEffect); @@ -379,9 +387,9 @@ void RenderView::OnTick(float dt) isToolTipFadingIn = false; if(toolTipPresence < 120) { - toolTipPresence += int(dt*2)>0?int(dt*2):1; + toolTipPresence += int(dt*2)>1?int(dt*2):2; if(toolTipPresence > 120) - toolTipPresence = 0; + toolTipPresence = 120; } } if(toolTipPresence>0) diff --git a/src/simulation/ElementGraphics.h b/src/simulation/ElementGraphics.h index d1c816739..1069d8d1d 100644 --- a/src/simulation/ElementGraphics.h +++ b/src/simulation/ElementGraphics.h @@ -21,6 +21,7 @@ #define FIREMODE 0x00FF0000 #define FIRE_ADD 0x00010000 #define FIRE_BLEND 0x00020000 +#define FIRE_SPARK 0x00040000 #define EFFECT 0xFF000000 #define EFFECT_GRAVIN 0x01000000 @@ -29,7 +30,8 @@ #define EFFECT_DBGLINES 0x08000000 #define RENDER_EFFE OPTIONS | PSPEC_STICKMAN | EFFECT | PMODE_SPARK | PMODE_FLARE | PMODE_LFLARE -#define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_ADD | PMODE_BLEND | FIREMODE +#define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_ADD | PMODE_BLEND | FIRE_ADD | FIRE_BLEND +#define RENDER_SPRK OPTIONS | PSPEC_STICKMAN | PMODE_ADD | PMODE_BLEND | FIRE_SPARK #define RENDER_GLOW OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_GLOW | PMODE_ADD | PMODE_BLEND #define RENDER_BLUR OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_BLUR | PMODE_ADD | PMODE_BLEND #define RENDER_BLOB OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_BLOB | PMODE_ADD | PMODE_BLEND diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp index 423c05c68..35a384215 100644 --- a/src/simulation/elements/SPRK.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -355,11 +355,11 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) int Element_SPRK::graphics(GRAPHICS_FUNC_ARGS) { - *firea = 80; - *firer = 170; - *fireg = 200; - *fireb = 220; - *pixel_mode |= FIRE_ADD; + *firea = 60; + *firer = *colr/2; + *fireg = *colg/2; + *fireb = *colb/2; + *pixel_mode |= FIRE_SPARK; return 1; }