The-Powder-Toy/src/Renderer.h

136 lines
3.2 KiB
C
Raw Normal View History

2012-01-08 11:39:03 -06:00
#ifndef RENDERER_H
#define RENDERER_H
2012-01-27 03:38:56 -06:00
#include <vector>
2012-04-20 13:21:10 -05:00
#if defined(OGLR)
#ifdef MACOSX
2012-05-12 07:21:04 -05:00
#include <OpenGL/gl3.h>
2012-04-20 13:21:10 -05:00
#include <OpenGL/glu.h>
#elif defined(WIN32)
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#else
//#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#endif
2012-01-08 11:39:03 -06:00
#include "Config.h"
#include "client/Client.h"
#include "simulation/Simulation.h"
2012-01-08 11:39:03 -06:00
#include "Graphics.h"
2012-01-28 08:51:39 -06:00
#include "interface/Point.h"
2012-01-08 11:39:03 -06:00
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:
2012-01-27 03:38:56 -06:00
std::vector<unsigned int> render_modes;
2012-01-08 11:39:03 -06:00
unsigned int render_mode;
unsigned int colour_mode;
2012-01-27 03:38:56 -06:00
std::vector<unsigned int> display_modes;
2012-01-08 11:39:03 -06:00
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;
2012-01-27 03:38:56 -06:00
2012-01-28 08:51:39 -06:00
//Zoom window
ui::Point zoomWindowPosition;
ui::Point zoomScopePosition;
int zoomScopeSize;
bool zoomEnabled;
int ZFACTOR;
2012-01-27 03:38:56 -06:00
//Renderers
2012-01-28 08:51:39 -06:00
void RenderZoom();
2012-01-27 03:38:56 -06:00
void DrawWalls();
void DrawSigns();
2012-01-08 11:39:03 -06:00
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();
2012-04-20 13:21:10 -05:00
void FinaliseParts();
void clearScreen(float alpha);
//class SolidsRenderer;
#ifdef OGLR
void checkShader(GLuint shader, char * shname);
void checkProgram(GLuint program, char * progname);
void loadShaders();
#endif
2012-01-27 03:38:56 -06:00
void drawblob(int x, int y, unsigned char cr, unsigned char cg, unsigned char cb);
2012-01-27 03:38:56 -06:00
//...
2012-01-08 11:39:03 -06:00
void get_sign_pos(int i, int *x0, int *y0, int *w, int *h);
2012-01-27 03:38:56 -06:00
//Display mode modifiers
void CompileDisplayMode();
void CompileRenderMode();
void AddRenderMode(unsigned int mode);
void SetRenderMode(std::vector<unsigned int> render);
std::vector<unsigned int> GetRenderMode();
2012-01-27 03:38:56 -06:00
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();
2012-01-27 03:38:56 -06:00
void SetColourMode(unsigned int mode);
unsigned int GetColourMode();
2012-01-27 03:38:56 -06:00
2012-01-08 11:39:03 -06:00
Renderer(Graphics * g, Simulation * sim);
~Renderer();
2012-04-20 13:21:10 -05:00
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
2012-01-08 11:39:03 -06:00
};
#endif