1 #include <Platform.h>
2 
3 typedef enum {
4   RENDERER_WINDOWMODE_WINDOWED = 0,
5   RENDERER_WINDOWMODE_FULLSCREEN,
6   RENDERER_WINDOWMODE_BORDERLESS
7 } RENDERER_WINDOWMODE;
8 
9 typedef struct
10 {
11   int nWidth;
12   int nHeight;
13   RENDERER_WINDOWMODE windowMode;
14   bool bVsync;
15 } RENDERER_SETTINGS;
16 
17 namespace Renderer
18 {
19   extern const char * defaultShaderFilename;
20   extern const char defaultShader[65536];
21 
22   extern int nWidth;
23   extern int nHeight;
24 
25   bool OpenSetupDialog( RENDERER_SETTINGS * settings );
26   bool Open( RENDERER_SETTINGS * settings );
27 
28   void StartFrame();
29   void EndFrame();
30   bool WantsToQuit();
31 
32   void RenderFullscreenQuad();
33 
34   bool ReloadShader( const char * szShaderCode, int nShaderCodeSize, char * szErrorBuffer, int nErrorBufferSize );
35   void SetShaderConstant( const char * szConstName, float x );
36   void SetShaderConstant( const char * szConstName, float x, float y );
37 
38   void StartTextRendering();
39   void SetTextRenderingViewport( Scintilla::PRectangle rect );
40   void EndTextRendering();
41 
42   bool GrabFrame( void * pPixelBuffer ); // input buffer must be able to hold w * h * 4 bytes of 0xAABBGGRR data
43 
44   void Close();
45 
46   enum TEXTURETYPE
47   {
48     TEXTURETYPE_1D = 1,
49     TEXTURETYPE_2D = 2,
50   };
51 
52   struct Texture
53   {
54     int width;
55     int height;
56     TEXTURETYPE type;
57   };
58 
59   Texture * CreateRGBA8Texture();
60   Texture * CreateRGBA8TextureFromFile( const char * szFilename );
61   Texture * CreateA8TextureFromData( int w, int h, const unsigned char * data );
62   Texture * Create1DR32Texture( int w );
63   bool UpdateR32Texture( Texture * tex, float * data );
64   void SetShaderTexture( const char * szTextureName, Texture * tex );
65   void BindTexture( Texture * tex ); // temporary function until all the quad rendering is moved to the renderer
66   void ReleaseTexture( Texture * tex );
67 
68   void CopyBackbufferToTexture( Texture * tex );
69 
70   struct Vertex
71   {
72     Vertex( float _x, float _y, unsigned int _c = 0xFFFFFFFF, float _u = 0.0, float _v = 0.0) :
xVertex73       x(_x), y(_y), c(_c), u(_u), v(_v) {}
74     float x, y;
75     unsigned int c;
76     float u, v;
77   };
78   void RenderQuad( const Vertex & a, const Vertex & b, const Vertex & c, const Vertex & d );
79   void RenderLine( const Vertex & a, const Vertex & b );
80 
81   struct KeyEvent
82   {
83     int character;
84     int scanCode;
85     bool ctrl;
86     bool shift;
87     bool alt;
88   };
89   extern KeyEvent keyEventBuffer[512];
90   extern int keyEventBufferCount;
91 
92   enum MOUSEEVENTTYPE
93   {
94     MOUSEEVENTTYPE_DOWN = 0,
95     MOUSEEVENTTYPE_MOVE,
96     MOUSEEVENTTYPE_UP,
97     MOUSEEVENTTYPE_SCROLL
98   };
99   enum MOUSEBUTTON
100   {
101     MOUSEBUTTON_LEFT = 0,
102     MOUSEBUTTON_RIGHT,
103     MOUSEBUTTON_MIDDLE,
104   };
105   struct MouseEvent
106   {
107     MOUSEEVENTTYPE eventType;
108     float x;
109     float y;
110     MOUSEBUTTON button;
111   };
112   extern MouseEvent mouseEventBuffer[512];
113   extern int mouseEventBufferCount;
114 }
115