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;
89 kStereoEyeFlatAnaglyph = 2
91 virtual void setStereoEye(
StereoEye eye) { _stereoEye = eye; }
92 void setStereoParameters(
float separation,
float convergence);
94 virtual void useColor(uint8 r, uint8 g, uint8 b) = 0;
95 virtual void enableCulling(
bool enabled) {};
96 virtual void polygonOffset(
bool enabled) = 0;
101 virtual void freeTexture(
Texture *texture) = 0;
104 virtual void renderSensorShoot(byte color,
const Math::Vector3d sensor,
const Math::Vector3d player,
const Common::Rect &viewPort) = 0;
105 virtual void renderPlayerShootBall(byte color,
const Common::Point &position,
int frame,
const Common::Rect &viewPort) = 0;
108 virtual void renderCrossair(
const Common::Point &crossairPosition) = 0;
116 void setColorRemaps(ColorReMap *colorRemaps);
117 virtual void clear(uint8 r, uint8 g, uint8 b,
bool ignoreViewport =
false) = 0;
118 virtual void clearDepthBuffer(
bool ignoreViewport =
false) {}
119 virtual void drawFloor(uint8 color) = 0;
120 virtual void drawBackground(uint8 color);
122 void drawEclipse(uint8 color1, uint8 color2,
float difference);
123 virtual void drawSkybox(
Texture *texture, Math::Vector3d camera) {};
124 virtual void drawThunder(
Texture *texture, Math::Vector3d camera,
float size) {};
125 virtual void drawCelestialBody(Math::Vector3d position,
float radius, uint8 color) {};
131 void readFromPalette(uint8 index, uint8 &r, uint8 &g, uint8 &b);
132 void setPaletteValue(uint8 index, uint8 r, uint8 g, uint8 b);
133 uint8 indexFromColor(uint8 r, uint8 g, uint8 b);
134 uint8 mapEGAColor(uint8 index);
136 bool getRGBAt(uint8 index, uint8 ecolor, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
137 bool getRGBAtC64(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
138 bool getRGBAtCGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
139 bool getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
140 bool getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2);
141 bool getRGBAtZX(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
142 bool getRGBAtHercules(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
143 void extractCPCIndexes(uint8 cm1, uint8 cm2, uint8 &i1, uint8 &i2);
144 void extractC64Indexes(uint8 cm1, uint8 cm2, uint8 &i1, uint8 &i2);
146 void selectColorFromFourColorPalette(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1);
149 virtual void setStippleData(byte *data) {};
150 virtual void useStipple(
bool enabled) {};
151 void scaleStipplePattern(byte originalPattern[128], byte newPattern[128]);
153 byte _defaultStippleArray[128] = {
154 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
155 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
156 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
157 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
158 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
159 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
160 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
161 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
162 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
163 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
164 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
165 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
166 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
167 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
168 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
169 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
172 byte *_variableStippleArray;
174 float _skyNormals[16][3] = {
193 float _skyUvs1008[16][2] = {
215 float _skyUvs672[16][2] = {
237 float _skyUvs128[16][2] = {
259 float _skyVertices[16][3] = {
260 { -81280.0, 8128.0, 81280.0 },
261 { -81280.0, -8128.0, 81280.0 },
262 { 81280.0, -8128.0, 81280.0 },
263 { 81280.0, 8128.0, 81280.0 },
265 { 81280.0f, -8128.0f, -81280.0f },
266 { -81280.0f, -8128.0f, -81280.0f },
267 { -81280.0f, 8128.0f, -81280.0f },
268 { 81280.0f, 8128.0f, -81280.0f },
270 { -81280.0f, 8128.0f, 81280.0f },
271 { -81280.0f, 8128.0f, -81280.0f },
272 { -81280.0f, -8128.0f, -81280.0f },
273 { -81280.0f, -8128.0f, 81280.0f },
275 { 81280.0f, 8128.0f, -81280.0f },
276 { 81280.0f, 8128.0f, 81280.0f },
277 { 81280.0f, -8128.0f, 81280.0f },
278 { 81280.0f, -8128.0f, -81280.0f },
281 unsigned int _skyIndices[24] = {
296 void setColorMap(ColorMap *colorMap_);
298 ColorReMap *_colorRemaps;
299 void clearColorPairArray();
300 void fillColorPairArray();
305 int _underFireBackgroundColor;
307 byte _stipples[16][128];
313 int _colorCyclingIndex;
314 int _colorCyclingTimer;
315 int _colorCyclingPaletteIndex;
316 int _colorCyclingSpeed;
317 void updateColorCycling();
322 bool _debugRenderBoundingBoxes;
323 bool _debugRenderOcclusionBoxes;
324 bool _debugRenderWireframe;
325 bool _debugRenderNormals;
329 virtual void drawAABB(
const Math::AABB &aabb, uint8 r, uint8 g, uint8 b) {}
337 virtual void positionCamera(
const Math::Vector3d &pos,
const Math::Vector3d &interest,
float rollAngle = 0.0f) = 0;
338 virtual void updateProjectionMatrix(
float fov,
float aspectRatio,
float nearClipPlane,
float farClipPlane) = 0;
340 Math::Matrix4 getMvpMatrix()
const {
return _mvpMatrix; }
348 bool computeScreenViewport();
355 Math::Matrix4 _projectionMatrix;
356 Math::Matrix4 _modelViewMatrix;
357 Math::Matrix4 _mvpMatrix;
359 Math::Frustum _frustum;
361 Math::Matrix4 makeProjectionMatrix(
float fov,
float nearClipPlane,
float farClipPlane)
const;
362 void applyStereoTint(uint8 &r, uint8 &g, uint8 &b)
const;
363 void getStereoCamera(
const Math::Vector3d &pos,
const Math::Vector3d &interest, Math::Vector3d &eyePos, Math::Vector3d &eyeInterest)
const;
364 float getStereoFrustumOffset(
float nearClipPlane,
bool mirroredProjection)
const;
367 float _stereoSeparation;
368 float _stereoConvergence;
379 #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
StereoEye
Definition: gfx.h:85