ScummVM API documentation
Renderer2D.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * Copyright (C) 2006-2010 - Frictional Games
24 *
25 * This file is part of HPL1 Engine.
26 */
27
28#ifndef HPL_RENDERER2D_H
29#define HPL_RENDERER2D_H
30
31#include "common/list.h"
32#include "hpl1/engine/graphics/GraphicsTypes.h"
33#include "hpl1/engine/graphics/Material.h"
34#include "hpl1/engine/graphics/Mesh2d.h"
35#include "hpl1/engine/math/MathTypes.h"
36#include "hpl1/engine/scene/Light2D.h"
37#include "hpl1/std/multiset.h"
38#include "hpl1/std/set.h"
39
40namespace hpl {
41
42#define MAX_SHADOW_POINTS (100)
43#define MAX_ONSCREEN_SHADOWCASTERS (100)
44
45class cScene;
46class cResources;
47class iLowLevelGraphics;
48class LowLevelResources;
49class cRenderObject2D;
50class cGraphicsDrawer;
51class cCamera2D;
52class cGridMap2D;
53class iTexture;
54
55// For Normal obejcts:
57public:
58 bool operator()(const cRenderObject2D &aObjectA, const cRenderObject2D &aObjectB) const;
59};
60
61// For transparent objects
63public:
64 bool operator()(const cRenderObject2D &aObjectA, const cRenderObject2D &aObjectB) const;
65};
66
68typedef tRenderObjectSet::iterator tRenderObjectSetIt;
69
71typedef tRenderTransObjectSet::iterator tRenderTransObjectSetIt;
72
75
76class cResources;
77class cWorld2D;
78
80public:
81 cRenderer2D(iLowLevelGraphics *apLowLevelGraphics, cResources *apResources, cGraphicsDrawer *apGraphicsDrawer);
83
84 void RenderObjects(cCamera2D *apCamera, cGridMap2D *apMapLights, cWorld2D *apWorld);
85 void AddObject(cRenderObject2D &aObject);
86
87 void SetShadowZ(float afZ) { mfShadowZ = afZ; }
88 float GetShadowZ() { return mfShadowZ; }
89
90 void SetAmbientLight(cColor aCol) { mAmbientLight = aCol; }
91 cColor GetAmbientLight() { return mAmbientLight; }
92
93 iTexture *GetLightMap(int alNum) {
94 if (alNum < 0 || alNum > 1)
95 return NULL;
96 return mpLightMap[alNum];
97 }
98
99private:
100 iLowLevelGraphics *mpLowLevelGraphics;
101 LowLevelResources *mpLowLevelResources;
102 cResources *mpResources;
103 cGraphicsDrawer *mpGraphicsDrawer;
104
105 tRenderObjectSet m_mapObject;
106 tRenderTransObjectSet m_mapTransObject;
107
109 iTexture *mpLightMap[2];
110
111 cColor mAmbientLight;
112
113 cRect2f mPrevLightRect;
114
115 int mvShadowPoints[MAX_SHADOW_POINTS][2];
116 int mlShadowPointSize;
117
118 float mfShadowZ;
119
120 tLightList mlstLights;
121 tLightList mlstFastLights;
122
124 void ClearShadows();
125 bool RenderShadows(cCamera2D *apCamera, iLight2D *pLight, cWorld2D *apWorld);
126
127 inline void RenderObject(const cRenderObject2D &aObject, unsigned int &aIdxAdd, iMaterial *pMat,
128 iLight2D *pLight, eMaterialRenderType aRenderType, cCamera2D *apCam);
129
131
132 inline cVector2f CalcLineEnd(cVector3f avLight, cVector3f avPoint, float afRadius,
133 cVector2f &avSide, cVector2f avClipPos);
134
135 inline void FindShadowPoints(tMesh2DEdgeVec *apEdgeVec, cVector2f avLightPos, cVector2f avTilePos);
136
137 inline int CreateVertexes(cVector2f vLightPos, cRect2f LightRect, float fRadius, bool bNonFit,
138 cVector2f vTilePos, tVertexVec *apVtxVec, cColor ShadowColor, int lFirstIndex, float fSourceSize);
139
140 inline bool ClipPoints(cVector3f *avPoint, cRect2f aRect, cVector2f avPos, float afSize);
141};
142
143} // namespace hpl
144
145#endif // HPL_RENDERER2D_H
Definition: list.h:44
Definition: low_level_resources.h:40
Definition: Camera2D.h:38
Definition: Color.h:37
Definition: GraphicsDrawer.h:77
Definition: GridMap2D.h:147
Definition: Renderer2D.h:56
Definition: RenderObject2D.h:44
Definition: Renderer2D.h:62
Definition: Renderer2D.h:79
Definition: Resources.h:160
Definition: World2D.h:64
Definition: Light2D.h:40
Definition: LowLevelGraphics.h:200
Definition: Material.h:203
Definition: Texture.h:88
Definition: list_intern.h:54