File: glwrapper-ogl.h

package info (click to toggle)
crawl 2%3A0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 100,188 kB
  • sloc: cpp: 363,709; ansic: 27,765; javascript: 9,516; python: 8,463; perl: 3,293; java: 3,132; xml: 2,380; makefile: 1,835; sh: 611; objc: 250; cs: 15; sed: 9; lisp: 3
file content (86 lines) | stat: -rw-r--r-- 2,830 bytes parent folder | download | duplicates (3)
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
#pragma once

#ifdef USE_TILE_LOCAL
#ifdef USE_GL

#include <vector>

#include "glwrapper.h"

using std::vector;

class OGLStateManager : public GLStateManager
{
public:
    OGLStateManager();

    // State Manipulation
    virtual void set(const GLState& state) override;
    virtual void pixelstore_unpack_alignment(unsigned int bpp) override;
    virtual void reset_view_for_redraw() override;
    virtual void reset_view_for_resize(const coord_def &m_windowsz,
                                       const coord_def &m_drawablesz) override;
    virtual void set_transform(const GLW_3VF &trans, const GLW_3VF &scale) override;
    virtual void reset_transform() override;
    virtual void get_transform(GLW_3VF *trans, GLW_3VF *scale) override;
    virtual void set_scissor(int x, int y, unsigned int w, unsigned int h) override;
    virtual void reset_scissor() override;

    // Texture-specific functinos
    virtual void delete_textures(size_t count, unsigned int *textures) override;
    virtual void generate_textures(size_t count, unsigned int *textures) override;
    virtual void bind_texture(unsigned int texture) override;
    virtual void load_texture(unsigned char *pixels, unsigned int width,
                              unsigned int height, MipMapOptions mip_opt,
                              int xoffset=-1, int yoffset=-1) override;
    int logical_to_device(int n) const override;
    int device_to_logical(int n, bool round=true) const override;
protected:
    GLState m_current_state;
    int m_window_height;
    // optional, possibly nullptr function pointer to OpenGL 3+ function
    // The function pointer type is often ifdef'd in annoying headers
    // So we save the cast for the point where we use it, rather than
    // cluttering this header.
    void* m_mipmapFn = nullptr;

private:
    bool glDebug(const char* msg) const;
};

class OGLShapeBuffer : public GLShapeBuffer
{
public:
    OGLShapeBuffer(bool texture = false, bool colour = false,
                   drawing_modes prim = GLW_RECTANGLE);

    virtual const char *print_statistics() const override;
    virtual unsigned int size() const override;

    virtual void add(const GLWPrim &rect) override;
    virtual void draw(const GLState &state) override;
    virtual void clear() override;

protected:
    // Helper methods for adding specific primitives.
    void add_rect(const GLWPrim &rect);
    void add_line(const GLWPrim &rect);

    drawing_modes m_prim_type;
    bool m_texture_verts;
    bool m_colour_verts;

    vector<GLW_3VF> m_position_buffer;
    vector<GLW_2VF> m_texture_buffer;
    vector<VColour> m_colour_buffer;
    vector<unsigned short int> m_ind_buffer;

private:
    bool glDebug(const char* msg) const;
};

struct HiDPIState;
extern HiDPIState display_density;

#endif // USE_GL
#endif // USE_TILE_LOCAL