summaryrefslogtreecommitdiff
path: root/src/graphics/Renderer.h
diff options
context:
space:
mode:
authorSimon 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)
commitadc9cc08167946927fa21f86d70ce0a0b9630baa (patch)
tree009ec84f4398cac18d89283bc6d80193085b39af /src/graphics/Renderer.h
parent94c9603d0ce7597cfe987bf211610ca7d325ddaa (diff)
downloadpowder-adc9cc08167946927fa21f86d70ce0a0b9630baa.zip
powder-adc9cc08167946927fa21f86d70ce0a0b9630baa.tar.gz
Move graphics into seperate folder
Diffstat (limited to 'src/graphics/Renderer.h')
-rw-r--r--src/graphics/Renderer.h146
1 files changed, 146 insertions, 0 deletions
diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h
new file mode 100644
index 0000000..b414fe4
--- /dev/null
+++ b/src/graphics/Renderer.h
@@ -0,0 +1,146 @@
+#ifndef RENDERER_H
+#define RENDERER_H
+
+#include <vector>
+#ifdef OGLR
+#include "OpenGLHeaders.h"
+#endif
+
+#include "Config.h"
+#include "client/Client.h"
+#include "simulation/Simulation.h"
+#include "Graphics.h"
+#include "interface/Point.h"
+
+class Simulation;
+
+class Graphics;
+
+struct gcache_item
+{
+ int isready;
+ int pixel_mode;
+ int cola, colr, colg, colb;
+ int firea, firer, fireg, fireb;
+};
+typedef struct gcache_item gcache_item;
+
+class Renderer
+{
+public:
+ std::vector<unsigned int> render_modes;
+ unsigned int render_mode;
+ unsigned int colour_mode;
+ std::vector<unsigned int> display_modes;
+ unsigned int display_mode;
+ //
+ unsigned char fire_r[YRES/CELL][XRES/CELL];
+ unsigned char fire_g[YRES/CELL][XRES/CELL];
+ unsigned char fire_b[YRES/CELL][XRES/CELL];
+ unsigned int fire_alpha[CELL*3][CELL*3];
+ char * flm_data;
+ char * plasma_data;
+ int emp_decor;
+ //
+ int decorations_enable;
+ Simulation * sim;
+ Graphics * g;
+ gcache_item *graphicscache;
+
+ //Zoom window
+ ui::Point zoomWindowPosition;
+ ui::Point zoomScopePosition;
+ int zoomScopeSize;
+ bool zoomEnabled;
+ int ZFACTOR;
+
+ //Renderers
+ void RenderZoom();
+ void DrawWalls();
+ void DrawSigns();
+ void render_gravlensing();
+ void render_fire();
+ void prepare_alpha(int size, float intensity);
+ void render_parts();
+ void draw_grav_zones();
+ void draw_air();
+ void draw_grav();
+ void draw_other();
+ void FinaliseParts();
+ void clearScreen(float alpha);
+
+ //class SolidsRenderer;
+
+#ifdef OGLR
+ void checkShader(GLuint shader, char * shname);
+ void checkProgram(GLuint program, char * progname);
+ void loadShaders();
+#else
+ pixel * vid;
+ void blendpixel(int x, int y, int r, int g, int b, int a);
+ void addpixel(int x, int y, int r, int g, int b, int a);
+
+ void draw_icon(int x, int y, Icon icon);
+
+ int drawtext(int x, int y, const char *s, int r, int g, int b, int a);
+ int drawtext(int x, int y, std::string s, int r, int g, int b, int a);
+ int drawchar(int x, int y, int c, int r, int g, int b, int a);
+ int addchar(int x, int y, int c, int r, int g, int b, int a);
+
+ void xor_pixel(int x, int y);
+ void xor_line(int x, int y, int x2, int y2);
+ void xor_rect(int x, int y, int width, int height);
+ void xor_bitmap(unsigned char * bitmap, int x, int y, int w, int h);
+
+ void draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a);
+ void drawrect(int x, int y, int width, int height, int r, int g, int b, int a);
+ void fillrect(int x, int y, int width, int height, int r, int g, int b, int a);
+ void clearrect(int x, int y, int width, int height);
+ void gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2);
+
+ void draw_image(pixel *img, int x, int y, int w, int h, int a);
+#endif
+
+ void drawblob(int x, int y, unsigned char cr, unsigned char cg, unsigned char cb);
+ //...
+ //Display mode modifiers
+ void CompileDisplayMode();
+ void CompileRenderMode();
+ void AddRenderMode(unsigned int mode);
+ void SetRenderMode(std::vector<unsigned int> render);
+ std::vector<unsigned int> GetRenderMode();
+ void RemoveRenderMode(unsigned int mode);
+ void AddDisplayMode(unsigned int mode);
+ void RemoveDisplayMode(unsigned int mode);
+ void SetDisplayMode(std::vector<unsigned int> display);
+ std::vector<unsigned int> GetDisplayMode();
+ void SetColourMode(unsigned int mode);
+ unsigned int GetColourMode();
+
+ Renderer(Graphics * g, Simulation * sim);
+ ~Renderer();
+
+private:
+#ifdef OGLR
+ GLuint zoomTex, airBuf, fireAlpha, glowAlpha, blurAlpha, partsFboTex, partsFbo, partsTFX, partsTFY, airPV, airVY, airVX;
+ GLuint fireProg, airProg_Pressure, airProg_Velocity, airProg_Cracker, lensProg;
+ GLuint fireV[(YRES*XRES)*2];
+ GLfloat fireC[(YRES*XRES)*4];
+ GLuint smokeV[(YRES*XRES)*2];
+ GLfloat smokeC[(YRES*XRES)*4];
+ GLuint blobV[(YRES*XRES)*2];
+ GLfloat blobC[(YRES*XRES)*4];
+ GLuint blurV[(YRES*XRES)*2];
+ GLfloat blurC[(YRES*XRES)*4];
+ GLuint glowV[(YRES*XRES)*2];
+ GLfloat glowC[(YRES*XRES)*4];
+ GLuint flatV[(YRES*XRES)*2];
+ GLfloat flatC[(YRES*XRES)*4];
+ GLuint addV[(YRES*XRES)*2];
+ GLfloat addC[(YRES*XRES)*4];
+ GLfloat lineV[(((YRES*XRES)*2)*6)];
+ GLfloat lineC[(((YRES*XRES)*2)*6)];
+#endif
+};
+
+#endif