ScummVM API documentation
renderer.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 #ifndef WATCHMAKER_RENDERER_H
23 #define WATCHMAKER_RENDERER_H
24 
25 #include "math/matrix4.h"
26 #include "watchmaker/2d_stuff.h"
27 #include "watchmaker/rect.h"
28 #include "watchmaker/sdl_wrapper.h"
29 #include "watchmaker/struct.h"
30 #include "watchmaker/types.h"
31 #include "watchmaker/utils.h"
32 #include "watchmaker/work_dirs.h"
33 
34 namespace Watchmaker {
35 
36 class sdl_wrapper;
37 struct gMaterial;
38 
39 struct WindowInfo {
40  unsigned int width;
41  unsigned int height;
42 };
43 
44 class Fonts;
45 class Renderer {
46  WorkDirs *_workDirs;
47  WGame *_game;
48 public:
49  TwoDeeStuff _2dStuff;
50 
51  Fonts *_fonts = nullptr;
52  Common::Rect _viewport;
53  Renderer(WGame *game, sdl_wrapper *wrapper);
54  bool addMaterial(gMaterial &material, const Common::String &name, int NumFaces, unsigned int LoaderFlags);
55 
56  void initGL();
57 
58  void showFrame();
59 
60  void setVirtualScreen(unsigned int dimX, unsigned int dimY);
61  void getScreenInfos(unsigned int &width, unsigned int &height) const;
62  WindowInfo getScreenInfos() const;
63  bool createScreenBuffer();
64  void initBlitterViewPort();
65 
66  void setCurCameraViewport(t3dF32 fov, uint8 sup);
67 
68  void renderBitmap(SDDBitmap &bitmap);
69  void printText(const char *s, unsigned int dst, FontKind font, FontColor color, uint16 x, uint16 y);
70 
71  int rFitX(int x);
72  int rFitY(int y);
73  int rInvFitX(int x);
74  int rInvFitY(int y);
75 
76  static const int MAX_BITMAP_LIST = 1024;
77  struct BitmapList {
78  unsigned int _numBitmaps = 0;
79  gTexture bitmaps[MAX_BITMAP_LIST];
80 
81  unsigned int acquirePosition();
82  };
83  BitmapList _bitmapList;
84  void clearBitmap(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b);
85  void blitScreenBuffer();
86  unsigned int getBitmapDimX(int32 id) const;
87  unsigned int getBitmapDimY(int32 id) const;
88  unsigned int getBitmapRealDimX(int32 id) const;
89  unsigned int getBitmapRealDimY(int32 id) const;
90 
91  bool setProjectionMatrix(float width, float height, float fAspect, float fNearPlane, float fFarPlane);
92  Math::Vector3d screenSpaceToCameraSpace(float x, float y);
93 
94  void add2DStuff();
95 private:
96  sdl_wrapper *sdl;
97  // aspect correction
98  float gAspectX = 1, gAspectY = 1;
99  float gInvAspectX = 1, gInvAspectY = 1;
100  float _nearPlane = 0.0f;
101  Math::Matrix4 _projectionMatrix;
102 };
103 
104 
105 } // End of namespace Watchmaker
106 
107 #endif // WATCHMAKER_RENDERER_H
Definition: renderer.h:77
Definition: 2d_stuff.h:30
Definition: str.h:59
Definition: sdl_wrapper.h:32
Definition: rect.h:144
Definition: renderer.h:39
Definition: work_dirs.h:30
Definition: fonts.h:37
Definition: struct.h:442
Definition: texture.h:36
Definition: 2d_stuff.h:34
Definition: game.h:55
Definition: renderer.h:45
Definition: material.h:39