diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-06 15:06:26 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-06 15:06:26 (GMT) |
| commit | adc9cc08167946927fa21f86d70ce0a0b9630baa (patch) | |
| tree | 009ec84f4398cac18d89283bc6d80193085b39af /src | |
| parent | 94c9603d0ce7597cfe987bf211610ca7d325ddaa (diff) | |
| download | powder-adc9cc08167946927fa21f86d70ce0a0b9630baa.zip powder-adc9cc08167946927fa21f86d70ce0a0b9630baa.tar.gz | |
Move graphics into seperate folder
Diffstat (limited to 'src')
33 files changed, 114 insertions, 100 deletions
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 616575a..a43bd01 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -9,7 +9,7 @@ #include <sstream> #include <string> #include "Config.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #if defined(LIN32) || defined(LIN64) #include "icon.h" #endif diff --git a/src/client/Client.cpp b/src/client/Client.cpp index d0a7bee..3a46e23 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -18,7 +18,7 @@ #include "Config.h" #include "Client.h" #include "MD5.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "Misc.h" #include "interface/Point.h" diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index eb01615..668b755 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -3,7 +3,7 @@ #include "GameView.h" #include "simulation/Simulation.h" #include "simulation/Air.h" -#include "Renderer.h" +#include "graphics/Renderer.h" #include "interface/Point.h" #include "Brush.h" #include "EllipseBrush.h" diff --git a/src/game/GameModel.h b/src/game/GameModel.h index 48364a7..5f656c1 100644 --- a/src/game/GameModel.h +++ b/src/game/GameModel.h @@ -6,7 +6,7 @@ #include "client/SaveInfo.h" #include "simulation/Simulation.h" #include "interface/Colour.h" -#include "Renderer.h" +#include "graphics/Renderer.h" #include "GameView.h" #include "Brush.h" #include "client/User.h" diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 085433f..dd03987 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -4,7 +4,7 @@ #include "Config.h" #include "Style.h" #include "GameView.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "interface/Window.h" #include "interface/Button.h" #include "interface/Colour.h" diff --git a/src/PixelMethodsDef.inc b/src/graphics/DrawMethodsDef.inc index 4aee0c9..4aee0c9 100644 --- a/src/PixelMethodsDef.inc +++ b/src/graphics/DrawMethodsDef.inc diff --git a/src/Graphics.cpp b/src/graphics/Graphics.cpp index 5f84088..5f84088 100644 --- a/src/Graphics.cpp +++ b/src/graphics/Graphics.cpp diff --git a/src/Graphics.h b/src/graphics/Graphics.h index 1209b86..1209b86 100644 --- a/src/Graphics.h +++ b/src/graphics/Graphics.h diff --git a/src/OpenGLGraphics.cpp b/src/graphics/OpenGLDrawMethods.inc index b6f8f2a..cd1a350 100644 --- a/src/OpenGLGraphics.cpp +++ b/src/graphics/OpenGLDrawMethods.inc @@ -1,71 +1,3 @@ -#include "Graphics.h" -#include "font.h" - -#ifdef OGLI - -Graphics::Graphics(): -sdl_scale(1) -{ - Reset(); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - //Texture for main UI - glEnable(GL_TEXTURE_2D); - - glGenTextures(1, &vidBuf); - glBindTexture(GL_TEXTURE_2D, vidBuf); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, XRES+BARSIZE, YRES+MENUSIZE, 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); - - glBindTexture(GL_TEXTURE_2D, 0); - - glGenTextures(1, &textTexture); - glBindTexture(GL_TEXTURE_2D, textTexture); - 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_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glBindTexture(GL_TEXTURE_2D, 0); - - glDisable(GL_TEXTURE_2D); -} - -Graphics::~Graphics() -{ -} - -void Graphics::Reset() -{ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - //glOrtho(0, (XRES+BARSIZE)*sdl_scale, 0, (YRES+MENUSIZE)*sdl_scale, -1, 1); - glOrtho(0, (XRES+BARSIZE)*sdl_scale, (YRES+MENUSIZE)*sdl_scale, 0, -1, 1); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - //glRasterPos2i(0, (YRES+MENUSIZE)); - glRasterPos2i(0, 0); - glPixelZoom(1, 1); -} - -void Graphics::Clear() -{ - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); -} - -void Graphics::Finalise() -{ - glFlush(); -} - int Graphics::drawtext(int x, int y, const char *s, int r, int g, int b, int a) { if(!strlen(s)) @@ -103,7 +35,7 @@ int Graphics::drawtext(int x, int y, const char *s, int r, int g, int b, int a) switch (s[1]) { case 'w': - r = g = b = 255; + r = g = b = 255; break; case 'g': r = g = b = 192; @@ -396,6 +328,4 @@ void Graphics::draw_image(pixel *img, int x, int y, int w, int h, int a) glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); -} - -#endif +}
\ No newline at end of file diff --git a/src/graphics/OpenGLGraphics.cpp b/src/graphics/OpenGLGraphics.cpp new file mode 100644 index 0000000..baef250 --- /dev/null +++ b/src/graphics/OpenGLGraphics.cpp @@ -0,0 +1,78 @@ +#include "Graphics.h" +#include "font.h" + +#ifdef OGLI + +Graphics::Graphics(): +sdl_scale(1) +{ + Reset(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + //Texture for main UI + glEnable(GL_TEXTURE_2D); + + glGenTextures(1, &vidBuf); + glBindTexture(GL_TEXTURE_2D, vidBuf); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, XRES+BARSIZE, YRES+MENUSIZE, 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); + + glBindTexture(GL_TEXTURE_2D, 0); + + glGenTextures(1, &textTexture); + glBindTexture(GL_TEXTURE_2D, textTexture); + 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_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glBindTexture(GL_TEXTURE_2D, 0); + + glDisable(GL_TEXTURE_2D); +} + +Graphics::~Graphics() +{ +} + +void Graphics::Reset() +{ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + //glOrtho(0, (XRES+BARSIZE)*sdl_scale, 0, (YRES+MENUSIZE)*sdl_scale, -1, 1); + glOrtho(0, (XRES+BARSIZE)*sdl_scale, (YRES+MENUSIZE)*sdl_scale, 0, -1, 1); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + //glRasterPos2i(0, (YRES+MENUSIZE)); + glRasterPos2i(0, 0); + glPixelZoom(1, 1); +} + +void Graphics::Clear() +{ + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); +} + +void Graphics::Finalise() +{ + glFlush(); +} + +#define VIDXRES XRES+BARSIZE +#define VIDYRES YRES+MENUSIZE +#define PIXELMETHODS_CLASS Graphics +#include "OpenGLDrawMethods.inc" +#undef VIDYRES +#undef VIDXRES +#undef PIXELMETHODS_CLASS + + +#endif diff --git a/src/OpenGLHeaders.h b/src/graphics/OpenGLHeaders.h index 8a83472..8a83472 100644 --- a/src/OpenGLHeaders.h +++ b/src/graphics/OpenGLHeaders.h diff --git a/src/PixelMethods.inc b/src/graphics/RasterDrawMethods.inc index 4d85f60..4d85f60 100644 --- a/src/PixelMethods.inc +++ b/src/graphics/RasterDrawMethods.inc diff --git a/src/RasterGraphics.cpp b/src/graphics/RasterGraphics.cpp index a33f771..7567b9d 100644 --- a/src/RasterGraphics.cpp +++ b/src/graphics/RasterGraphics.cpp @@ -27,7 +27,7 @@ void Graphics::Finalise() #define VIDXRES XRES+BARSIZE #define VIDYRES YRES+MENUSIZE #define PIXELMETHODS_CLASS Graphics -#include "PixelMethods.inc" +#include "RasterDrawMethods.inc" #undef VIDYRES #undef VIDXRES #undef PIXELMETHODS_CLASS diff --git a/src/Renderer.cpp b/src/graphics/Renderer.cpp index a83e41e..ef3b8aa 100644 --- a/src/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -2197,6 +2197,12 @@ Renderer::~Renderer() } #define PIXELMETHODS_CLASS Renderer -#include "PixelMethods.inc" + +#ifdef OGLR +#include "OpenGLDrawMethods.inc" +#else +#include "RasterDrawMethods.inc" +#endif + #undef PIXELMETHODS_CLASS diff --git a/src/Renderer.h b/src/graphics/Renderer.h index b414fe4..b414fe4 100644 --- a/src/Renderer.h +++ b/src/graphics/Renderer.h diff --git a/src/interface/Appearance.h b/src/interface/Appearance.h index 6c9b24f..1749731 100644 --- a/src/interface/Appearance.h +++ b/src/interface/Appearance.h @@ -10,7 +10,7 @@ #include "Border.h" #include "Colour.h" -#include "Graphics.h" +#include "graphics/Graphics.h" namespace ui { diff --git a/src/interface/Button.cpp b/src/interface/Button.cpp index 43e5980..ac1f87e 100644 --- a/src/interface/Button.cpp +++ b/src/interface/Button.cpp @@ -7,7 +7,7 @@ #include <iostream> #include "interface/Button.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "Engine.h" #include "Misc.h" diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp index 2526efb..5f237a9 100644 --- a/src/interface/Engine.cpp +++ b/src/interface/Engine.cpp @@ -6,7 +6,7 @@ #include "interface/Window.h" #include "interface/Platform.h" #include "interface/Engine.h" -#include "Graphics.h" +#include "graphics/Graphics.h" using namespace ui; using namespace std; diff --git a/src/interface/Engine.h b/src/interface/Engine.h index ceabeb5..9acba62 100644 --- a/src/interface/Engine.h +++ b/src/interface/Engine.h @@ -3,7 +3,7 @@ #include <stack> #include "Singleton.h" #include "Platform.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "Window.h" namespace ui diff --git a/src/interface/SaveButton.cpp b/src/interface/SaveButton.cpp index e1aeac5..ee57e81 100644 --- a/src/interface/SaveButton.cpp +++ b/src/interface/SaveButton.cpp @@ -2,7 +2,7 @@ #include "SaveButton.h" #include "client/SaveInfo.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "Engine.h" #include "client/Client.h" #include "simulation/SaveRenderer.h" diff --git a/src/interface/SaveButton.h b/src/interface/SaveButton.h index 2220f1c..02795fb 100644 --- a/src/interface/SaveButton.h +++ b/src/interface/SaveButton.h @@ -6,7 +6,7 @@ #include "Component.h" #include "client/SaveFile.h" #include "client/SaveInfo.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "search/Thumbnail.h" #include "interface/Colour.h" diff --git a/src/powdertoyjava/PowderToyJava.cpp b/src/powdertoyjava/PowderToyJava.cpp index bcc9344..835fdc4 100644 --- a/src/powdertoyjava/PowderToyJava.cpp +++ b/src/powdertoyjava/PowderToyJava.cpp @@ -7,7 +7,7 @@ #include "Config.h" #include "PowderToyJava.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "game/GameController.h" diff --git a/src/render/RenderController.h b/src/render/RenderController.h index 81e29c2..37592ac 100644 --- a/src/render/RenderController.h +++ b/src/render/RenderController.h @@ -10,7 +10,7 @@ #include "RenderView.h" #include "RenderModel.h" -#include "Renderer.h" +#include "graphics/Renderer.h" #include "Controller.h" class RenderView; diff --git a/src/render/RenderModel.h b/src/render/RenderModel.h index 6bdf36e..7d25f50 100644 --- a/src/render/RenderModel.h +++ b/src/render/RenderModel.h @@ -10,7 +10,7 @@ #include <vector> #include "RenderView.h" -#include "Renderer.h" +#include "graphics/Renderer.h" using namespace std; diff --git a/src/render/RenderView.cpp b/src/render/RenderView.cpp index f0868a3..7bf5bf2 100644 --- a/src/render/RenderView.cpp +++ b/src/render/RenderView.cpp @@ -6,8 +6,8 @@ */ #include "simulation/ElementGraphics.h" -#include "Graphics.h" -#include "Renderer.h" +#include "graphics/Graphics.h" +#include "graphics/Renderer.h" #include "RenderView.h" class RenderView::RenderModeAction: public ui::CheckboxAction diff --git a/src/render/RenderView.h b/src/render/RenderView.h index 487a53e..c084916 100644 --- a/src/render/RenderView.h +++ b/src/render/RenderView.h @@ -13,7 +13,7 @@ #include "interface/Window.h" #include "RenderController.h" #include "RenderModel.h" -#include "Renderer.h" +#include "graphics/Renderer.h" #include "interface/Checkbox.h" class RenderController; diff --git a/src/search/Thumbnail.h b/src/search/Thumbnail.h index 25c0985..d951a96 100644 --- a/src/search/Thumbnail.h +++ b/src/search/Thumbnail.h @@ -2,7 +2,7 @@ #define THUMBNAIL_H #include <iostream> -#include "Graphics.h" +#include "graphics/Graphics.h" #include "interface/Point.h" class Thumbnail diff --git a/src/simulation/Element.h b/src/simulation/Element.h index 7cd379e..3c28e2f 100644 --- a/src/simulation/Element.h +++ b/src/simulation/Element.h @@ -4,7 +4,7 @@ #include <cmath> #include "Simulation.h" -#include "Renderer.h" +#include "graphics/Renderer.h" #include "Gravity.h" #include "Misc.h" #include "ElementGraphics.h" diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp index 2a79e79..73b486e 100644 --- a/src/simulation/SaveRenderer.cpp +++ b/src/simulation/SaveRenderer.cpp @@ -6,9 +6,9 @@ */ #include "SaveRenderer.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "Simulation.h" -#include "Renderer.h" +#include "graphics/Renderer.h" SaveRenderer::SaveRenderer(){ diff --git a/src/simulation/Sign.cpp b/src/simulation/Sign.cpp index 1ce471f..01d388f 100644 --- a/src/simulation/Sign.cpp +++ b/src/simulation/Sign.cpp @@ -6,7 +6,7 @@ */ #include "Sign.h" -#include "Graphics.h" +#include "graphics/Graphics.h" #include "Misc.h" sign::sign(std::string text_, int x_, int y_, Justification justification_): diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index b9cc6bb..e4e4120 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -10,8 +10,8 @@ #include <cstring> #include <cstddef> #include "Config.h" -#include "Renderer.h" -#include "Graphics.h" +#include "graphics/Renderer.h" +#include "graphics/Graphics.h" //#include "Elements.h" #include "Tools.h" #include "Misc.h" diff --git a/src/simulation/elements/Element.h b/src/simulation/elements/Element.h index b584506..29c7fa0 100644 --- a/src/simulation/elements/Element.h +++ b/src/simulation/elements/Element.h @@ -2,7 +2,7 @@ #define ELEMENTCLASS_H #include "simulation/Simulation.h" -#include "Renderer.h" +#include "graphics/Renderer.h" #include "simulation/Elements.h" class Simulation; diff --git a/src/simulation/tools/SimTool.h b/src/simulation/tools/SimTool.h index 0fbcba4..ed4cbcd 100644 --- a/src/simulation/tools/SimTool.h +++ b/src/simulation/tools/SimTool.h @@ -2,7 +2,7 @@ #define SIMTOOL_H #include "simulation/Simulation.h" -#include "Renderer.h" +#include "graphics/Renderer.h" #include "simulation/Elements.h" class Simulation; |
