source: git/src/gla.h @ f5627353

RELEASE/1.1RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernloglog-selectstereostereo-2025walls-datawalls-data-hanging-as-warningwarn-only-for-hanging-survey
Last change on this file since f5627353 was 4ba80e0, checked in by Olly Betts <olly@…>, 20 years ago

aven: Make blobs round like they are in Survex 1.0.

aven: If the graphics drivers don't support drawing blobs using OpenGL
point markers, fall back to drawing filled circles.

git-svn-id: file:///home/survex-svn/survex/branches/survex-1_1@2989 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 6.1 KB
Line 
1//
2//  gla.h
3//
4//  Header file for the GLA abstraction layer.
5//
6//  Copyright (C) 2002 Mark R. Shinwell.
7//  Copyright (C) 2003,2004,2005 Olly Betts
8//
9//  This program is free software; you can redistribute it and/or modify
10//  it under the terms of the GNU General Public License as published by
11//  the Free Software Foundation; either version 2 of the License, or
12//  (at your option) any later version.
13//
14//  This program is distributed in the hope that it will be useful,
15//  but WITHOUT ANY WARRANTY; without even the implied warranty of
16//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17//  GNU General Public License for more details.
18//
19//  You should have received a copy of the GNU General Public License
20//  along with this program; if not, write to the Free Software
21//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22//
23
24// Use texture mapped fonts (lots faster, at least with hardware 3d)
25#define USE_FNT
26
27#include <vector>
28
29using namespace std;
30
31#include "wx.h"
32#include "aventypes.h"
33#include "quaternion.h"
34
35#ifdef USE_FNT
36#include "fnt.h"
37#endif
38
39class GfxCore;
40
41wxString GetGLSystemDescription();
42
43#define GLA_DEBUG 1
44
45typedef Double glaCoord;
46
47class GLAPoint {
48    glaCoord xc, yc, zc;
49
50public:
51    GLAPoint(glaCoord x, glaCoord y, glaCoord z) : xc(x), yc(y), zc(z) {}
52    ~GLAPoint() {}
53
54    glaCoord GetX() { return xc; }
55    glaCoord GetY() { return yc; }
56    glaCoord GetZ() { return zc; }
57};
58
59// Colours for drawing.  Don't reorder these!
60enum gla_colour {
61    col_BLACK = 0,
62    col_GREY,
63    col_LIGHT_GREY,
64    col_LIGHT_GREY_2,
65    col_DARK_GREY,
66    col_WHITE,
67    col_TURQUOISE,
68    col_GREEN,
69    col_INDICATOR_1,
70    col_INDICATOR_2,
71    col_YELLOW,
72    col_RED,
73    col_BLUE,
74    col_LAST // must be the last entry here
75};
76
77class GLAPen {
78    friend class GLACanvas; // allow direct access to components
79
80    double components[3]; // red, green, blue
81
82public:
83    GLAPen();
84    ~GLAPen();
85
86    void SetColour(double red, double green, double blue); // arguments in range 0 to 1.0
87    void Interpolate(const GLAPen&, double how_far);
88
89    double GetRed() const;
90    double GetGreen() const;
91    double GetBlue() const;
92};
93
94class GLACanvas : public wxGLCanvas {
95#ifdef GLA_DEBUG
96    int m_Vertices;
97#endif
98
99    GLdouble modelview_matrix[16];
100    GLdouble projection_matrix[16];
101    GLint viewport[4];
102
103    // Viewing volume diameter:
104    glaCoord m_VolumeDiameter;
105
106    // Parameters for plotting data:
107    Quaternion m_Rotation;
108    Double m_Scale;
109    public: // FIXME
110    struct {
111        Double x;
112        Double y;
113        Double z;
114    } m_Translation;
115    private:
116
117#ifdef USE_FNT
118    fntTexFont m_Font;
119#else
120    static void * const m_Font;
121    static const int m_FontSize;
122#endif
123
124    GLUquadric* m_Quadric;
125
126    GLuint m_Texture;
127
128    bool m_Textured;
129    bool m_Perspective;
130    bool m_Fog;
131    bool m_AntiAlias;
132    bool glpoint_ok;
133
134    vector<GLuint> drawing_lists;
135
136public:
137    GLACanvas(wxWindow* parent, int id, const wxPoint& posn, wxSize size);
138    ~GLACanvas();
139
140    void FirstShow();
141
142    void Clear();
143    void StartDrawing();
144    void FinishDrawing();
145
146    void SetVolumeDiameter(glaCoord diameter);
147    void SetDataTransform();
148    void SetIndicatorTransform();
149
150    void DrawList(unsigned int l);
151    void InvalidateList(unsigned int l);
152    void InvalidateAllLists();
153    virtual void GenerateList(unsigned int l) = 0;
154
155    void SetBackgroundColour(float red, float green, float blue);
156    void SetColour(const GLAPen& pen, double rgb_scale);
157    void SetColour(const GLAPen& pen);
158    void SetColour(gla_colour colour);
159
160    void DrawText(glaCoord x, glaCoord y, glaCoord z, const wxString& str);
161    void DrawIndicatorText(int x, int y, const wxString& str);
162    void GetTextExtent(const wxString& str, int * x_ext, int * y_ext);
163
164    void BeginQuadrilaterals();
165    void EndQuadrilaterals();
166    void BeginLines();
167    void EndLines();
168    void BeginTriangleStrip();
169    void EndTriangleStrip();
170    void BeginTriangles();
171    void EndTriangles();
172    void BeginPolyline();
173    void EndPolyline();
174    void BeginPolygon();
175    void EndPolygon();
176    void BeginBlobs();
177    void EndBlobs();
178
179    void DrawRectangle(gla_colour edge, gla_colour fill,
180                       glaCoord x0, glaCoord y0, glaCoord w, glaCoord h);
181    void DrawShadedRectangle(const GLAPen & fill_bot, const GLAPen & fill_top,
182                             glaCoord x0, glaCoord y0, glaCoord w, glaCoord h);
183    void DrawCircle(gla_colour edge, gla_colour fill, glaCoord cx, glaCoord cy, glaCoord radius);
184    void DrawSemicircle(gla_colour edge, gla_colour fill, glaCoord cx, glaCoord cy, glaCoord radius, glaCoord start);
185    void DrawTriangle(gla_colour edge, gla_colour fill, GLAPoint* vertices);
186
187    void DrawBlob(glaCoord x, glaCoord y, glaCoord z);
188    void DrawRing(glaCoord x, glaCoord y);
189
190    void PlaceVertex(glaCoord x, glaCoord y, glaCoord z);
191    void PlaceIndicatorVertex(glaCoord x, glaCoord y);
192
193    void PlaceNormal(glaCoord x, glaCoord y, glaCoord z);
194
195    void EnableDashedLines();
196    void DisableDashedLines();
197
198    void EnableSmoothPolygons();
199    void DisableSmoothPolygons();
200
201    void SetRotation(const Quaternion&);
202    void SetScale(Double);
203    void SetTranslation(Double, Double, Double);
204    void AddTranslation(Double, Double, Double);
205    void AddTranslationScreenCoordinates(int dx, int dy);
206
207    bool Transform(Double x, Double y, Double z, Double* x_out, Double* y_out, Double* z_out);
208    void ReverseTransform(Double x, Double y, Double* x_out, Double* y_out, Double* z_out);
209
210    int GetFontSize() const { return m_Font.getFontSize(); }
211
212    Double SurveyUnitsAcrossViewport() const;
213
214    void ToggleTextured();
215    bool GetTextured() const { return m_Textured; }
216
217    void TogglePerspective() { m_Perspective = !m_Perspective; }
218    bool GetPerspective() const { return m_Perspective; }
219
220    void ToggleFog() { m_Fog = !m_Fog; }
221    bool GetFog() const { return m_Fog; }
222
223    void ToggleAntiAlias() { m_AntiAlias = !m_AntiAlias; }
224    bool GetAntiAlias() const { return m_AntiAlias; }
225
226    bool SaveScreenshot(const wxString & fnm, int type) const;
227
228    bool CanUseListForBlobs() const { return glpoint_ok; }
229};
Note: See TracBrowser for help on using the repository browser.