forked from Gargaj/Bonzomatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderer.h
107 lines (92 loc) · 2.49 KB
/
Renderer.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
#include <Platform.h>
typedef enum {
RENDERER_WINDOWMODE_WINDOWED = 0,
RENDERER_WINDOWMODE_FULLSCREEN,
RENDERER_WINDOWMODE_BORDERLESS
} RENDERER_WINDOWMODE;
typedef struct
{
int nWidth;
int nHeight;
RENDERER_WINDOWMODE windowMode;
bool bVsync;
} RENDERER_SETTINGS;
namespace Renderer
{
extern char * defaultShaderFilename;
extern char defaultShader[65536];
extern int nWidth;
extern int nHeight;
bool OpenSetupDialog( RENDERER_SETTINGS * settings );
bool Open( RENDERER_SETTINGS * settings );
void StartFrame();
void EndFrame();
bool WantsToQuit();
void RenderFullscreenQuad();
bool ReloadShader( char * szShaderCode, int nShaderCodeSize, char * szErrorBuffer, int nErrorBufferSize );
void SetShaderConstant( char * szConstName, float x );
void SetShaderConstant( char * szConstName, float x, float y );
void StartTextRendering();
void SetTextRenderingViewport( Scintilla::PRectangle rect );
void EndTextRendering();
void Close();
enum TEXTURETYPE
{
TEXTURETYPE_1D = 1,
TEXTURETYPE_2D = 2,
};
struct Texture
{
int width;
int height;
TEXTURETYPE type;
};
Texture * CreateRGBA8TextureFromFile( char * szFilename );
Texture * CreateA8TextureFromData( int w, int h, unsigned char * data );
Texture * Create1DR32Texture( int w );
bool UpdateR32Texture( Texture * tex, float * data );
void SetShaderTexture( char * szTextureName, Texture * tex );
void BindTexture( Texture * tex ); // temporary function until all the quad rendering is moved to the renderer
void ReleaseTexture( Texture * tex );
struct Vertex
{
Vertex( float _x, float _y, unsigned int _c = 0xFFFFFFFF, float _u = 0.0, float _v = 0.0) :
x(_x), y(_y), c(_c), u(_u), v(_v) {}
float x, y;
float u, v;
unsigned int c;
};
void RenderQuad( const Vertex & a, const Vertex & b, const Vertex & c, const Vertex & d );
void RenderLine( const Vertex & a, const Vertex & b );
struct KeyEvent
{
int character;
int scanCode;
bool ctrl;
bool shift;
bool alt;
};
extern KeyEvent keyEventBuffer[512];
extern int keyEventBufferCount;
enum MOUSEEVENTTYPE
{
MOUSEEVENTTYPE_DOWN = 0,
MOUSEEVENTTYPE_MOVE,
MOUSEEVENTTYPE_UP,
};
enum MOUSEBUTTON
{
MOUSEBUTTON_LEFT = 0,
MOUSEBUTTON_RIGHT,
MOUSEBUTTON_MIDDLE,
};
struct MouseEvent
{
MOUSEEVENTTYPE eventType;
int x;
int y;
MOUSEBUTTON button;
};
extern MouseEvent mouseEventBuffer[512];
extern int mouseEventBufferCount;
}