1 #pragma once
2 
3 #ifdef USE_TILE_LOCAL
4 #ifdef USE_GL
5 
6 #include <vector>
7 
8 #include "glwrapper.h"
9 #ifdef __ANDROID__
10 #include <GLES/gl.h>
11 #endif
12 
13 using std::vector;
14 
15 class OGLStateManager : public GLStateManager
16 {
17 public:
18     OGLStateManager();
19 
20     // State Manipulation
21     virtual void set(const GLState& state) override;
22     virtual void pixelstore_unpack_alignment(unsigned int bpp) override;
23     virtual void reset_view_for_redraw() override;
24     virtual void reset_view_for_resize(const coord_def &m_windowsz,
25                                        const coord_def &m_drawablesz) override;
26     virtual void set_transform(const GLW_3VF &trans, const GLW_3VF &scale) override;
27     virtual void reset_transform() override;
28     virtual void get_transform(GLW_3VF *trans, GLW_3VF *scale) override;
29     virtual void set_scissor(int x, int y, unsigned int w, unsigned int h) override;
30     virtual void reset_scissor() override;
31 #ifdef __ANDROID__
32     virtual void fixup_gl_state() override;
33 #endif
34 
35     // Texture-specific functinos
36     virtual void delete_textures(size_t count, unsigned int *textures) override;
37     virtual void generate_textures(size_t count, unsigned int *textures) override;
38     virtual void bind_texture(unsigned int texture) override;
39     virtual void load_texture(unsigned char *pixels, unsigned int width,
40                               unsigned int height, MipMapOptions mip_opt,
41                               int xoffset=-1, int yoffset=-1) override;
42     int logical_to_device(int n) const override;
43     int device_to_logical(int n, bool round=true) const override;
44 protected:
45     GLState m_current_state;
46 #ifdef __ANDROID__
47     GLint m_last_tex;
48 #endif
49     int m_window_height;
50 
51 private:
52     bool glDebug(const char* msg) const;
53 };
54 
55 class OGLShapeBuffer : public GLShapeBuffer
56 {
57 public:
58     OGLShapeBuffer(bool texture = false, bool colour = false,
59                    drawing_modes prim = GLW_RECTANGLE);
60 
61     virtual const char *print_statistics() const override;
62     virtual unsigned int size() const override;
63 
64     virtual void add(const GLWPrim &rect) override;
65     virtual void draw(const GLState &state) override;
66     virtual void clear() override;
67 
68 protected:
69     // Helper methods for adding specific primitives.
70     void add_rect(const GLWPrim &rect);
71     void add_line(const GLWPrim &rect);
72 
73     drawing_modes m_prim_type;
74     bool m_texture_verts;
75     bool m_colour_verts;
76 
77     vector<GLW_3VF> m_position_buffer;
78     vector<GLW_2VF> m_texture_buffer;
79     vector<VColour> m_colour_buffer;
80     vector<unsigned short int> m_ind_buffer;
81 
82 private:
83     bool glDebug(const char* msg) const;
84 };
85 
86 struct HiDPIState;
87 extern HiDPIState display_density;
88 
89 #endif // USE_GL
90 #endif // USE_TILE_LOCAL
91