22 #ifndef FREESCAPE_GFX_H 23 #define FREESCAPE_GFX_H 25 #include "common/hashmap.h" 26 #include "common/rendermode.h" 27 #include "common/rect.h" 29 #include "graphics/pixelformat.h" 30 #include "graphics/managed_surface.h" 31 #include "graphics/renderer.h" 32 #include "math/frustum.h" 33 #include "math/vector3d.h" 37 #define kVertexArraySize 128 38 #define kCoordsArraySize 4 46 byte getCPCPixelMode1(byte cpc_byte,
int index);
47 byte getCPCPixelMode0(byte cpc_byte,
int index);
48 byte getCPCPixel(byte cpc_byte,
int index,
bool mode1);
52 Texture(){ _width = 0; _height = 0; };
70 bool _authenticGraphics;
72 virtual void init() = 0;
79 virtual void useColor(uint8 r, uint8 g, uint8 b) = 0;
80 virtual void enableCulling(
bool enabled) {};
81 virtual void polygonOffset(
bool enabled) = 0;
86 virtual void freeTexture(
Texture *texture) = 0;
89 virtual void renderSensorShoot(byte color,
const Math::Vector3d sensor,
const Math::Vector3d player,
const Common::Rect &viewPort) = 0;
90 virtual void renderPlayerShootBall(byte color,
const Common::Point &position,
int frame,
const Common::Rect &viewPort) = 0;
93 virtual void renderCrossair(
const Common::Point &crossairPosition) = 0;
101 void setColorRemaps(ColorReMap *colorRemaps);
102 virtual void clear(uint8 r, uint8 g, uint8 b,
bool ignoreViewport =
false) = 0;
103 virtual void drawFloor(uint8 color) = 0;
104 virtual void drawBackground(uint8 color);
106 void drawEclipse(uint8 color1, uint8 color2,
float difference);
107 virtual void drawSkybox(
Texture *texture, Math::Vector3d camera) {};
108 virtual void drawThunder(
Texture *texture, Math::Vector3d camera,
float size) {};
109 virtual void drawCelestialBody(Math::Vector3d position,
float radius, uint8 color) {};
115 void readFromPalette(uint8 index, uint8 &r, uint8 &g, uint8 &b);
116 void setPaletteValue(uint8 index, uint8 r, uint8 g, uint8 b);
117 uint8 indexFromColor(uint8 r, uint8 g, uint8 b);
118 uint8 mapEGAColor(uint8 index);
120 bool getRGBAt(uint8 index, uint8 ecolor, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
121 bool getRGBAtC64(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
122 bool getRGBAtCGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
123 bool getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
124 bool getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2);
125 bool getRGBAtZX(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
126 bool getRGBAtHercules(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
127 void extractCPCIndexes(uint8 cm1, uint8 cm2, uint8 &i1, uint8 &i2);
128 void extractC64Indexes(uint8 cm1, uint8 cm2, uint8 &i1, uint8 &i2);
130 void selectColorFromFourColorPalette(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1);
133 virtual void setStippleData(byte *data) {};
134 virtual void useStipple(
bool enabled) {};
135 void scaleStipplePattern(byte originalPattern[128], byte newPattern[128]);
137 byte _defaultStippleArray[128] = {
138 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
139 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
140 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
141 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
142 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
143 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
144 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
145 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
146 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
147 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
148 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
149 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
150 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
151 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
152 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
153 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
156 byte *_variableStippleArray;
158 float _skyNormals[16][3] = {
177 float _skyUvs1008[16][2] = {
199 float _skyUvs672[16][2] = {
221 float _skyUvs128[16][2] = {
243 float _skyVertices[16][3] = {
244 { -81280.0, 8128.0, 81280.0 },
245 { -81280.0, -8128.0, 81280.0 },
246 { 81280.0, -8128.0, 81280.0 },
247 { 81280.0, 8128.0, 81280.0 },
249 { 81280.0f, -8128.0f, -81280.0f },
250 { -81280.0f, -8128.0f, -81280.0f },
251 { -81280.0f, 8128.0f, -81280.0f },
252 { 81280.0f, 8128.0f, -81280.0f },
254 { -81280.0f, 8128.0f, 81280.0f },
255 { -81280.0f, 8128.0f, -81280.0f },
256 { -81280.0f, -8128.0f, -81280.0f },
257 { -81280.0f, -8128.0f, 81280.0f },
259 { 81280.0f, 8128.0f, -81280.0f },
260 { 81280.0f, 8128.0f, 81280.0f },
261 { 81280.0f, -8128.0f, 81280.0f },
262 { 81280.0f, -8128.0f, -81280.0f },
265 unsigned int _skyIndices[24] = {
280 void setColorMap(ColorMap *colorMap_);
282 ColorReMap *_colorRemaps;
283 void clearColorPairArray();
284 void fillColorPairArray();
289 int _underFireBackgroundColor;
291 byte _stipples[16][128];
296 bool _debugRenderBoundingBoxes;
297 bool _debugRenderOcclusionBoxes;
298 bool _debugRenderWireframe;
299 bool _debugRenderNormals;
303 virtual void drawAABB(
const Math::AABB &aabb, uint8 r, uint8 g, uint8 b) {}
311 virtual void positionCamera(
const Math::Vector3d &pos,
const Math::Vector3d &interest,
float rollAngle = 0.0f) = 0;
312 virtual void updateProjectionMatrix(
float fov,
float aspectRatio,
float nearClipPlane,
float farClipPlane) = 0;
314 Math::Matrix4 getMvpMatrix()
const {
return _mvpMatrix; }
322 bool computeScreenViewport();
329 Math::Matrix4 _projectionMatrix;
330 Math::Matrix4 _modelViewMatrix;
331 Math::Matrix4 _mvpMatrix;
333 Math::Frustum _frustum;
335 Math::Matrix4 makeProjectionMatrix(
float fov,
float nearClipPlane,
float farClipPlane)
const;
346 #endif // FREESCAPE_GFX_H Definition: managed_surface.h:51
virtual void flipBuffer()
Definition: gfx.h:78
RendererType
Definition: renderer.h:45
RenderMode
Definition: rendermode.h:48