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  * Based on the original sources
21  * https://github.com/Croquetx/thecolony
22  * Copyright (C) 1988, David A. Smith
23  *
24  * Distributed under Apache Version 2.0 License
25  *
26  */
27 
28 #ifndef COLONY_RENDERER_H
29 #define COLONY_RENDERER_H
30 
31 #include "common/scummsys.h"
32 #include "common/rect.h"
33 #include "graphics/managed_surface.h"
34 #include "graphics/font.h"
35 
36 namespace Colony {
37 
38 class Renderer {
39 public:
40  virtual ~Renderer() {}
41 
42  // 2D drawing primitives (used for UI overlay, dashboard, etc.)
43  virtual void clear(uint32 color) = 0;
44  virtual void drawLine(int x1, int y1, int x2, int y2, uint32 color) = 0;
45  virtual void drawRect(const Common::Rect &rect, uint32 color) = 0;
46  virtual void fillRect(const Common::Rect &rect, uint32 color) = 0;
47  virtual void drawString(const Graphics::Font *font, const Common::String &str, int x, int y, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft) = 0;
48  virtual void scroll(int dx, int dy, uint32 background) = 0;
49  virtual void drawEllipse(int x, int y, int rx, int ry, uint32 color) = 0;
50  virtual void fillEllipse(int x, int y, int rx, int ry, uint32 color) = 0;
51  virtual void fillDitherRect(const Common::Rect &rect, uint32 color1, uint32 color2) = 0;
52  virtual void setPixel(int x, int y, uint32 color) = 0;
53  virtual void drawQuad(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, uint32 color) = 0;
54  virtual void drawPolygon(const int *x, const int *y, int count, uint32 color) = 0;
55 
56  virtual void setPalette(const byte *palette, uint start, uint count) = 0;
57 
58  // 3D scene rendering
59  virtual void begin3D(int camX, int camY, int camZ, int angle, int angleY, const Common::Rect &viewport) = 0;
60  virtual void draw3DWall(int x1, int y1, int x2, int y2, uint32 color) = 0;
61  virtual void draw3DQuad(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, uint32 color) = 0;
62  virtual void draw3DPolygon(const float *x, const float *y, const float *z, int count, uint32 color) = 0;
63  virtual void draw3DLine(float x1, float y1, float z1, float x2, float y2, float z2, uint32 color) = 0;
64  virtual void end3D() = 0;
65 
66  // Buffer management
67  virtual void copyToScreen() = 0;
68  virtual void setWireframe(bool enable, int64_t fillColor = -1) = 0;
69  virtual void setXorMode(bool enable) {}
70  virtual void setStippleData(const byte *data) {}
71  virtual void setMacColors(uint32 fg, uint32 bg) {}
72  virtual void setDepthState(bool testEnabled, bool writeEnabled) {}
73  virtual void setDepthRange(float nearVal, float farVal) {}
74  virtual void computeScreenViewport() = 0;
75 
76  // Overlay a RGBA software surface onto the GL framebuffer (for Mac menu bar).
77  virtual void drawSurface(const Graphics::Surface *surf, int x, int y) {}
78  virtual Graphics::Surface *getScreenshot() { return nullptr; }
79 
80  // Convenience color accessors
81  uint32 white() const { return 255; }
82  uint32 black() const { return 0; }
83 };
84 
85 // Factory function (follows Freescape pattern: picks best available renderer)
86 Renderer *createRenderer(OSystem *system, int width, int height);
87 
88 } // End of namespace Colony
89 
90 #endif
Definition: str.h:59
Definition: font.h:83
TextAlign
Definition: font.h:48
Definition: surface.h:67
Align the text to the left.
Definition: font.h:51
Definition: rect.h:524
Definition: colony.h:53
Definition: renderer.h:38
Definition: system.h:164