1 #ifndef RENDERER_H 2 #define RENDERER_H 3 4 #include <vector> 5 #ifdef OGLR 6 #include "OpenGLHeaders.h" 7 #endif 8 9 #include "Graphics.h" 10 #include "Config.h" 11 #include "gui/interface/Point.h" 12 13 class RenderPreset; 14 class Simulation; 15 16 struct gcache_item 17 { 18 int isready; 19 int pixel_mode; 20 int cola, colr, colg, colb; 21 int firea, firer, fireg, fireb; gcache_itemgcache_item22 gcache_item() : 23 isready(0), 24 pixel_mode(0), 25 cola(0), 26 colr(0), 27 colg(0), 28 colb(0), 29 firea(0), 30 firer(0), 31 fireg(0), 32 fireb(0) 33 { 34 } 35 }; 36 typedef struct gcache_item gcache_item; 37 38 class Renderer 39 { 40 public: 41 Simulation * sim; 42 Graphics * g; 43 gcache_item *graphicscache; 44 45 std::vector<unsigned int> render_modes; 46 unsigned int render_mode; 47 unsigned int colour_mode; 48 std::vector<unsigned int> display_modes; 49 unsigned int display_mode; 50 std::vector<RenderPreset> renderModePresets; 51 // 52 unsigned char fire_r[YRES/CELL][XRES/CELL]; 53 unsigned char fire_g[YRES/CELL][XRES/CELL]; 54 unsigned char fire_b[YRES/CELL][XRES/CELL]; 55 unsigned int fire_alpha[CELL*3][CELL*3]; 56 char * flm_data; 57 char * plasma_data; 58 // 59 bool gravityZonesEnabled; 60 bool gravityFieldEnabled; 61 int decorations_enable; 62 bool blackDecorations; 63 bool debugLines; 64 pixel sampleColor; 65 int findingElement; 66 int foundElements; 67 68 //Mouse position for debug information 69 ui::Point mousePos; 70 71 //Zoom window 72 ui::Point zoomWindowPosition; 73 ui::Point zoomScopePosition; 74 int zoomScopeSize; 75 bool zoomEnabled; 76 int ZFACTOR; 77 78 //Renderers 79 void RenderBegin(); 80 void RenderEnd(); 81 82 void RenderZoom(); 83 void DrawBlob(int x, int y, unsigned char cr, unsigned char cg, unsigned char cb); 84 void DrawWalls(); 85 void DrawSigns(); 86 void render_gravlensing(pixel * source); 87 void render_fire(); 88 void prepare_alpha(int size, float intensity); 89 void render_parts(); 90 void draw_grav_zones(); 91 void draw_air(); 92 void draw_grav(); 93 void draw_other(); 94 void FinaliseParts(); 95 96 void ClearAccumulation(); 97 void clearScreen(float alpha); 98 void SetSample(int x, int y); 99 100 #ifdef OGLR 101 void checkShader(GLuint shader, const char * shname); 102 void checkProgram(GLuint program, const char * progname); 103 void loadShaders(); 104 GLuint vidBuf,textTexture; 105 GLint prevFbo; 106 #endif 107 pixel * vid; 108 pixel * persistentVid; 109 pixel * warpVid; 110 void blendpixel(int x, int y, int r, int g, int b, int a); 111 void addpixel(int x, int y, int r, int g, int b, int a); 112 113 void draw_icon(int x, int y, Icon icon); 114 115 int drawtext_outline(int x, int y, String s, int r, int g, int b, int a); 116 int drawtext(int x, int y, String s, int r, int g, int b, int a); 117 int drawchar(int x, int y, String::value_type c, int r, int g, int b, int a); 118 int addchar(int x, int y, String::value_type c, int r, int g, int b, int a); 119 120 void xor_pixel(int x, int y); 121 void xor_line(int x, int y, int x2, int y2); 122 void xor_rect(int x, int y, int width, int height); 123 void xor_bitmap(unsigned char * bitmap, int x, int y, int w, int h); 124 125 void draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a); 126 void drawrect(int x, int y, int width, int height, int r, int g, int b, int a); 127 void fillrect(int x, int y, int width, int height, int r, int g, int b, int a); 128 void drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a); 129 void fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a); 130 void clearrect(int x, int y, int width, int height); 131 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); 132 133 void draw_image(pixel *img, int x, int y, int w, int h, int a); 134 void draw_image(const VideoBuffer & vidBuf, int w, int h, int a); 135 void draw_image(VideoBuffer * vidBuf, int w, int h, int a); 136 137 VideoBuffer DumpFrame(); 138 139 void drawblob(int x, int y, unsigned char cr, unsigned char cg, unsigned char cb); 140 141 pixel GetPixel(int x, int y); 142 //... 143 //Display mode modifiers 144 void CompileDisplayMode(); 145 void CompileRenderMode(); 146 void AddRenderMode(unsigned int mode); 147 void SetRenderMode(std::vector<unsigned int> render); 148 std::vector<unsigned int> GetRenderMode(); 149 void RemoveRenderMode(unsigned int mode); 150 void AddDisplayMode(unsigned int mode); 151 void RemoveDisplayMode(unsigned int mode); 152 void SetDisplayMode(std::vector<unsigned int> display); 153 std::vector<unsigned int> GetDisplayMode(); 154 void SetColourMode(unsigned int mode); 155 unsigned int GetColourMode(); 156 157 void ResetModes(); 158 GetGridSize()159 int GetGridSize() { return gridSize; } SetGridSize(int value)160 void SetGridSize(int value) { gridSize = value; } 161 162 static VideoBuffer * WallIcon(int wallID, int width, int height); 163 164 Renderer(Graphics * g, Simulation * sim); 165 ~Renderer(); 166 167 private: 168 int gridSize; 169 #ifdef OGLR 170 GLuint zoomTex, airBuf, fireAlpha, glowAlpha, blurAlpha, partsFboTex, partsFbo, partsTFX, partsTFY, airPV, airVY, airVX; 171 GLuint fireProg, airProg_Pressure, airProg_Velocity, airProg_Cracker, lensProg; 172 GLuint fireV[(YRES*XRES)*2]; 173 GLfloat fireC[(YRES*XRES)*4]; 174 GLuint smokeV[(YRES*XRES)*2]; 175 GLfloat smokeC[(YRES*XRES)*4]; 176 GLuint blobV[(YRES*XRES)*2]; 177 GLfloat blobC[(YRES*XRES)*4]; 178 GLuint blurV[(YRES*XRES)*2]; 179 GLfloat blurC[(YRES*XRES)*4]; 180 GLuint glowV[(YRES*XRES)*2]; 181 GLfloat glowC[(YRES*XRES)*4]; 182 GLuint flatV[(YRES*XRES)*2]; 183 GLfloat flatC[(YRES*XRES)*4]; 184 GLuint addV[(YRES*XRES)*2]; 185 GLfloat addC[(YRES*XRES)*4]; 186 GLfloat lineV[(((YRES*XRES)*2)*6)]; 187 GLfloat lineC[(((YRES*XRES)*2)*6)]; 188 #endif 189 }; 190 191 #endif 192