forked from opentibia/yatc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine.h
145 lines (117 loc) · 4.91 KB
/
engine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//////////////////////////////////////////////////////////////////////
// Yet Another Tibia Client
//////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//////////////////////////////////////////////////////////////////////
#ifndef __ENGINE_H
#define __ENGINE_H
#include <GLICT/fonts.h>
#include <GLICT/globals.h>
#ifndef __USE_GLSDL__
#include <SDL/SDL.h>
#else
#include <SDL/glSDL.h>
#endif
#include "debugprint.h"
#include "defines.h"
#include "sprite.h"
#include "spritesdl.h"
#include "font.h"
#include "fassert.h"
struct glictColor;
struct vertex
{
int x;
int y;
int alpha;
int r;
int g;
int b;
int blended;
};
class Engine
{
public:
virtual ~Engine();
virtual bool isSupported() = 0;
virtual void drawLightmap(vertex* lightmap, int type, int width, int height, float scale);
virtual void doResize(int& w, int& h);
virtual void drawRectangle(float x, float y, float width, float height, oRGBA color) = 0;
virtual void drawRectangleLines(float x, float y, float width, float height, oRGBA color, float thickness = 1.f) {}
virtual void drawText(const char* text, const char* font, int x, int y, uint8_t color=215); // 215 == TEXTCOLOR_WHITE
virtual void drawText(const char* text, const char* font, int x, int y, oRGBA color);
// NOTE (nfries88): Special text drawing functions are required for the game area; these are them!
virtual void drawTextGW(const char* text, const char* font, int x, int y, float scale, uint8_t color=215); // 215 == TEXTCOLOR_WHITE
virtual void drawTextGW(const char* text, const char* font, int x, int y, float scale, oRGBA color);
virtual float sizeText(const char* text, const char* font) { float a = glictFontSize(text, font, 10); ASSERTFRIENDLY(a<20000, "Looks like text width is enormous."); return a; }
int getWindowWidth() const {return m_width;};
int getWindowHeight() const {return m_height;};
virtual Sprite* createSprite(const std::string& filename, int index = 0) = 0;
virtual Sprite* createSprite(int w, int h, const oRGBA& c) = 0;
virtual void Flip() = 0;
void performFpsCalc();
float getFPS(){ return m_fps; }
uint32_t m_creationTimestamp; // some engines, like GL, need this in order to know when to re-create their sprite memories
virtual void resetClipping() {
}
virtual void setClipping(int left, int top, int width, int height) {
static bool printedwarning = false;
if (printedwarning) return;
printedwarning = true;
printf("warning: engine %s did not redefine %s\n", getName(), __PRETTY_FUNCTION__);
}
virtual const char* getName() const {return "Unknown";}
virtual bool hasSDL() const { return true; }
virtual bool hasGL() const { return false; }
Sprite* getUISprite() { ASSERTFRIENDLY(m_ui, "Apparently UI sprite was not loaded. Report this to developers ASAP."); return m_ui; }
virtual void reloadGlobalGfx();
SDL_Cursor *m_cursorBasic, *m_cursorUse;
protected:
Engine();
void initFont(glictFont** fnt, const char* fontname);
friend void SpriteSDL::_BlitInternal(float dx, float dy, float sx, float sy, float w, float h);
#if (GLICT_APIREV < 69)
#define GLICTCOLORCONST
#warning Please upgrade to GLICT APIREV 69+
#else
#define GLICTCOLORCONST const
#endif
static void draw_rectangle(float left, float right, float top, float bottom, GLICTCOLORCONST glictColor &col);
static void draw_rectangle_lines(float left, float right, float top, float bottom, GLICTCOLORCONST glictColor &col);
static void font_render(const char* txt, const void* font, float fontsize, float x, float y);
static float font_size(const char* txt, const void* font, float fontsize);
static void font_color(const void* font, glictColor &col);
int m_width;
int m_height;
int m_video_bpp;
float m_fps;
glictFont *m_sysfont, *m_minifont, *m_aafont, *m_gamefont;
SDL_Surface* m_screen;
int m_videoflags;
uint32_t m_lastfpsupdate;
Sprite* m_ui;
Sprite* m_light;
friend class winOptionsGraphics_t;
friend class GM_Debug;
};
extern int ptrx, ptry;
#include "enginesdl.h"
#ifdef USE_OPENGL
#include "enginegl.h"
#endif
extern Engine* g_engine;
#endif