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);
121 virtual void fillViewportStippled(uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2, byte *stipple) {}
123 void drawEclipse(uint8 color1, uint8 color2,
float difference);
124 virtual void drawSkybox(
Texture *texture, Math::Vector3d camera) {};
125 virtual void drawThunder(
Texture *texture, Math::Vector3d camera,
float size) {};
126 virtual void drawCelestialBody(Math::Vector3d position,
float radius, uint8 color) {};
132 void readFromPalette(uint8 index, uint8 &r, uint8 &g, uint8 &b);
133 void setPaletteValue(uint8 index, uint8 r, uint8 g, uint8 b);
134 uint8 indexFromColor(uint8 r, uint8 g, uint8 b);
135 uint8 mapEGAColor(uint8 index);
137 bool getRGBAt(uint8 index, uint8 ecolor, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
138 bool getRGBAtC64(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
139 bool getRGBAtCGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
140 bool getRGBAtCPC(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
141 bool getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2);
142 bool getRGBAtZX(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
143 bool getRGBAtHercules(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple);
144 void extractCPCIndexes(uint8 cm1, uint8 cm2, uint8 &i1, uint8 &i2);
145 void extractC64Indexes(uint8 cm1, uint8 cm2, uint8 &i1, uint8 &i2);
147 void selectColorFromFourColorPalette(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1);
150 virtual void setStippleData(byte *data) {};
151 virtual void useStipple(
bool enabled) {};
152 void scaleStipplePattern(byte originalPattern[128], byte newPattern[128]);
154 byte _defaultStippleArray[128] = {
155 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
156 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
157 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
158 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
159 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
160 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
161 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
162 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
163 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
164 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
165 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
166 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
167 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
168 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
169 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC,
170 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
173 byte *_variableStippleArray;
175 float _skyNormals[16][3] = {
194 float _skyUvs1008[16][2] = {
216 float _skyUvs672[16][2] = {
238 float _skyUvs128[16][2] = {
260 float _skyVertices[16][3] = {
261 { -81280.0, 8128.0, 81280.0 },
262 { -81280.0, -8128.0, 81280.0 },
263 { 81280.0, -8128.0, 81280.0 },
264 { 81280.0, 8128.0, 81280.0 },
266 { 81280.0f, -8128.0f, -81280.0f },
267 { -81280.0f, -8128.0f, -81280.0f },
268 { -81280.0f, 8128.0f, -81280.0f },
269 { 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 },
274 { -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 },
279 { 81280.0f, -8128.0f, -81280.0f },
282 unsigned int _skyIndices[24] = {
297 void setColorMap(ColorMap *colorMap_);
299 ColorReMap *_colorRemaps;
300 void clearColorPairArray();
301 void fillColorPairArray();
306 int _underFireBackgroundColor;
307 int _fourColorBackground;
309 byte _stipples[16][128];
315 int _colorCyclingIndex;
316 int _colorCyclingTimer;
317 int _colorCyclingPaletteIndex;
318 int _colorCyclingSpeed;
319 void updateColorCycling();
324 bool _debugRenderBoundingBoxes;
325 bool _debugRenderOcclusionBoxes;
326 bool _debugRenderWireframe;
327 bool _debugRenderNormals;
331 virtual void drawAABB(
const Math::AABB &aabb, uint8 r, uint8 g, uint8 b) {}
339 virtual void positionCamera(
const Math::Vector3d &pos,
const Math::Vector3d &interest,
float rollAngle = 0.0f) = 0;
340 virtual void updateProjectionMatrix(
float fov,
float aspectRatio,
float nearClipPlane,
float farClipPlane) = 0;
342 Math::Matrix4 getMvpMatrix()
const {
return _mvpMatrix; }
350 bool computeScreenViewport();
357 Math::Matrix4 _projectionMatrix;
358 Math::Matrix4 _modelViewMatrix;
359 Math::Matrix4 _mvpMatrix;
361 Math::Frustum _frustum;
363 Math::Matrix4 makeProjectionMatrix(
float fov,
float nearClipPlane,
float farClipPlane)
const;
364 void applyStereoTint(uint8 &r, uint8 &g, uint8 &b)
const;
365 void getStereoCamera(
const Math::Vector3d &pos,
const Math::Vector3d &interest, Math::Vector3d &eyePos, Math::Vector3d &eyeInterest)
const;
366 float getStereoFrustumOffset(
float nearClipPlane,
bool mirroredProjection)
const;
369 float _stereoSeparation;
370 float _stereoConvergence;
381 #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