22#ifndef WINTERMUTE_BASE_RENDER_TINYGL_H
23#define WINTERMUTE_BASE_RENDER_TINYGL_H
25#include "engines/wintermute/base/gfx/base_renderer3d.h"
26#include "engines/wintermute/dctypes.h"
28#include "graphics/transform_struct.h"
29#include "graphics/tinygl/tinygl.h"
31#if defined(USE_TINYGL)
35class BaseSurfaceTinyGL;
37class BaseRenderTinyGL :
public BaseRenderer3D {
38 friend class BaseSurfaceTinyGL;
39 friend class Mesh3DSTinyGL;
40 friend class XMeshTinyGL;
41 friend class ShadowVolumeTinyGL;
55 struct RectangleVertex {
61 struct SimpleShadowVertex {
73 BaseRenderTinyGL(BaseGame *inGame =
nullptr);
74 ~BaseRenderTinyGL()
override;
76 bool invalidateTexture(BaseSurface *texture)
override;
78 bool invalidateDeviceObjects()
override;
79 bool restoreDeviceObjects()
override;
81 bool resetDevice()
override;
83 void setSpriteBlendMode(Graphics::TSpriteBlendMode blendMode,
bool forceChange =
false)
override;
85 void setAmbientLightRenderState()
override;
87 int getMaxActiveLights()
override;
88 void lightEnable(
int index,
bool enable)
override;
89 void setLightParameters(
int index,
const DXVector3 &position,
const DXVector3 &direction,
const DXVector4 &diffuse,
bool spotlight)
override;
91 void enableCulling()
override;
92 void disableCulling()
override;
94 bool enableShadows()
override;
95 bool disableShadows()
override;
96 bool shadowVolumeSupported()
override;
98 BaseImage *takeScreenshot(
int newWidth = 0,
int newHeight = 0)
override;
99 bool fadeToColor(
byte r,
byte g,
byte b,
byte a)
override;
101 bool flip()
override;
102 bool clear()
override;
104 bool setViewport(
int left,
int top,
int right,
int bottom)
override;
105 bool drawLine(
int x1,
int y1,
int x2,
int y2, uint32 color)
override;
106 bool fillRect(
int x,
int y,
int w,
int h, uint32 color)
override;
108 DXMatrix *buildMatrix(DXMatrix* out,
const DXVector2 *centre,
const DXVector2 *scaling,
float angle);
109 void transformVertices(
struct SpriteVertex *vertices,
const DXVector2 *centre,
const DXVector2 *scaling,
float angle);
111 bool setProjection()
override;
112 bool setProjection2D();
113 bool setWorldTransform(
const DXMatrix &transform)
override;
114 bool setViewTransform(
const DXMatrix &transform)
override;
115 bool setProjectionTransform(
const DXMatrix &transform)
override;
117 bool initRenderer(
int width,
int height,
bool windowed)
override;
118 bool setup2D(
bool force =
false)
override;
119 bool setup3D(Camera3D *camera,
bool force =
false)
override;
122 return "TinyGL software renderer";
124 bool displayDebugInfo()
override {
125 return STATUS_FAILED;
127 bool drawShaderQuad()
override {
128 return STATUS_FAILED;
131 float getScaleRatioX()
const override {
134 float getScaleRatioY()
const override {
138 BaseSurface *createSurface()
override;
140 bool startSpriteBatch()
override;
141 bool endSpriteBatch()
override;
142 bool commitSpriteBatch()
override;
144 bool drawSpriteEx(BaseSurface *texture,
const Common::Rect32 &rect,
const DXVector2 &pos,
const DXVector2 &rot,
const DXVector2 &scale,
145 float angle, uint32 color,
bool alphaDisable, Graphics::TSpriteBlendMode blendMode,
bool mirrorX,
bool mirrorY)
override;
147 void renderSceneGeometry(
const BaseArray<AdWalkplane *> &planes,
const BaseArray<AdBlock *> &blocks,
148 const BaseArray<AdGeneric *> &generics,
const BaseArray<Light3D *> &lights, Camera3D *camera)
override;
149 void renderShadowGeometry(
const BaseArray<AdWalkplane *> &planes,
const BaseArray<AdBlock *> &blocks,
const BaseArray<AdGeneric *> &generics, Camera3D *camera)
override;
151 Mesh3DS *createMesh3DS()
override;
152 XMesh *createXMesh()
override;
153 ShadowVolume *createShadowVolume()
override;
155 bool setViewport3D(DXViewport *viewport)
override;
157 void postfilter()
override;
158 void setPostfilter(PostFilter postFilter)
override { _postFilterMode = postFilter; };
162 void displaySimpleShadow(BaseObject *
object)
override;
164 Graphics::TSpriteBlendMode _blendMode;
165 SimpleShadowVertex _simpleShadow[4];
169 bool _shadowVolumesSupported;