source: git/src/gla.h @ f4c5932

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 f4c5932 was f4c5932, checked in by Olly Betts <olly@…>, 20 years ago

Mark's shadowed bounding box.

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

  • Property mode set to 100644
File size: 5.9 KB
RevLine 
[56da40e]1//
2//  gla.h
3//
4//  Header file for the GLA abstraction layer.
5//
6//  Copyright (C) 2002 Mark R. Shinwell.
[bbaa0bd]7//  Copyright (C) 2003,2004,2005 Olly Betts
[56da40e]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
[1eeb55a]24// Use texture mapped fonts (lots faster, at least with hardware 3d)
25#define USE_FNT
26
[56da40e]27#include "wx.h"
28#include "aventypes.h"
29#include "quaternion.h"
30
[1eeb55a]31#ifdef USE_FNT
32#include "fnt.h"
33#endif
34
[56da40e]35class GfxCore;
36
[cc1a1d9]37wxString GetGLSystemDescription();
38
[1897247]39#define GLA_DEBUG 1
40
[56da40e]41typedef Double glaCoord;
42typedef GLuint glaList;
43
44class GLAPoint {
45    glaCoord xc, yc, zc;
46
47public:
48    GLAPoint(glaCoord x, glaCoord y, glaCoord z) : xc(x), yc(y), zc(z) {}
49    ~GLAPoint() {}
50
51    glaCoord GetX() { return xc; }
52    glaCoord GetY() { return yc; }
53    glaCoord GetZ() { return zc; }
54};
55
[aa048c3]56// Colours for drawing.  Don't reorder these!
57enum gla_colour {
58    col_BLACK = 0,
59    col_GREY,
60    col_LIGHT_GREY,
61    col_LIGHT_GREY_2,
62    col_DARK_GREY,
63    col_WHITE,
64    col_TURQUOISE,
65    col_GREEN,
66    col_INDICATOR_1,
67    col_INDICATOR_2,
68    col_YELLOW,
69    col_RED,
[f4c5932]70    col_BLUE,
[aa048c3]71    col_LAST // must be the last entry here
72};
73
[56da40e]74class GLAPen {
[aa048c3]75    friend class GLACanvas; // allow direct access to components
76
77    double components[3]; // red, green, blue
[9cf3688]78
[56da40e]79public:
80    GLAPen();
81    ~GLAPen();
82
83    void SetColour(double red, double green, double blue); // arguments in range 0 to 1.0
[f383708]84    void Interpolate(const GLAPen&, double how_far);
[56da40e]85
[f7ea0e1]86    double GetRed() const;
87    double GetGreen() const;
88    double GetBlue() const;
[56da40e]89};
90
91class GLACanvas : public wxGLCanvas {
[203d2a7]92#ifdef GLA_DEBUG
93    int m_Vertices;
94#endif
95
[dde4fe7]96    GLdouble modelview_matrix[16];
97    GLdouble projection_matrix[16];
98    GLint viewport[4];
99
[c5fc8eb]100    // Viewing volume diameter:
101    glaCoord m_VolumeDiameter;
[56da40e]102
103    // Parameters for plotting data:
104    Quaternion m_Rotation;
105    Double m_Scale;
[1690fa9]106    public: // FIXME
[56da40e]107    struct {
108        Double x;
109        Double y;
110        Double z;
111    } m_Translation;
[1690fa9]112    private:
[56da40e]113
[1eeb55a]114#ifdef USE_FNT
115    fntTexFont m_Font;
116#else
[a2036bb]117    static void * const m_Font;
[203d2a7]118    static const int m_FontSize;
[1eeb55a]119#endif
[d9b3270]120
[1b12b82]121    GLUquadric* m_Quadric;
[a517825]122
123    GLuint m_Texture;
124
125    bool m_Textured;
[1eeb55a]126    bool m_Perspective;
[c60062d]127    bool m_Fog;
[db452ae]128    bool m_AntiAlias;
[1eeb55a]129
[56da40e]130public:
131    GLACanvas(wxWindow* parent, int id, const wxPoint& posn, wxSize size);
132    ~GLACanvas();
[2c8b64f]133
[1b12b82]134    void FirstShow();
135
[56da40e]136    void Clear();
137    void StartDrawing();
138    void FinishDrawing();
139
[c5fc8eb]140    void SetVolumeDiameter(glaCoord diameter);
[56da40e]141    void SetDataTransform();
142    void SetIndicatorTransform();
[9cf3688]143
[56da40e]144    glaList CreateList(GfxCore*, void (GfxCore::*generator)());
145    void DeleteList(glaList l);
146    void DrawList(glaList l);
[9cf3688]147
[56da40e]148    void SetBackgroundColour(float red, float green, float blue);
[aa048c3]149    void SetColour(const GLAPen& pen, double rgb_scale);
150    void SetColour(const GLAPen& pen);
151    void SetColour(gla_colour colour);
152
[56da40e]153    void DrawText(glaCoord x, glaCoord y, glaCoord z, const wxString& str);
[1eeb55a]154    void DrawIndicatorText(int x, int y, const wxString& str);
155    void GetTextExtent(const wxString& str, int * x_ext, int * y_ext);
[9cf3688]156
[56da40e]157    void BeginQuadrilaterals();
158    void EndQuadrilaterals();
159    void BeginLines();
160    void EndLines();
[dde4fe7]161    void BeginTriangleStrip();
162    void EndTriangleStrip();
[56da40e]163    void BeginTriangles();
164    void EndTriangles();
165    void BeginPolyline();
166    void EndPolyline();
[45aa1d6]167    void BeginPolygon();
168    void EndPolygon();
[e633bb1]169    void BeginBlobs();
170    void EndBlobs();
[9cf3688]171
[aa048c3]172    void DrawRectangle(gla_colour edge, gla_colour fill,
173                       glaCoord x0, glaCoord y0, glaCoord w, glaCoord h);
174    void DrawShadedRectangle(const GLAPen & fill_bot, const GLAPen & fill_top,
175                             glaCoord x0, glaCoord y0, glaCoord w, glaCoord h);
176    void DrawCircle(gla_colour edge, gla_colour fill, glaCoord cx, glaCoord cy, glaCoord radius);
177    void DrawSemicircle(gla_colour edge, gla_colour fill, glaCoord cx, glaCoord cy, glaCoord radius, glaCoord start);
178    void DrawTriangle(gla_colour edge, gla_colour fill, GLAPoint* vertices);
[9cf3688]179
[e633bb1]180    void DrawBlob(glaCoord x, glaCoord y, glaCoord z);
181    void DrawRing(glaCoord x, glaCoord y);
[9cf3688]182
[56da40e]183    void PlaceVertex(glaCoord x, glaCoord y, glaCoord z);
184    void PlaceIndicatorVertex(glaCoord x, glaCoord y);
[203d2a7]185
186    void PlaceNormal(glaCoord x, glaCoord y, glaCoord z);
[9cf3688]187
[56da40e]188    void EnableDashedLines();
189    void DisableDashedLines();
190
[1b12b82]191    void EnableSmoothPolygons();
192    void DisableSmoothPolygons();
193
[69ea543]194    void SetRotation(const Quaternion&);
[56da40e]195    void SetScale(Double);
196    void SetTranslation(Double, Double, Double);
197    void AddTranslation(Double, Double, Double);
198    void AddTranslationScreenCoordinates(int dx, int dy);
199
[6adffadf]200    bool Transform(Double x, Double y, Double z, Double* x_out, Double* y_out, Double* z_out);
[a2b3d62]201    void ReverseTransform(Double x, Double y, Double* x_out, Double* y_out, Double* z_out);
[56da40e]202
[1eeb55a]203    int GetFontSize() const { return m_Font.getFontSize(); }
[087bc72]204
[e7f9e99]205    Double SurveyUnitsAcrossViewport() const;
[6abab84]206
[a517825]207    void ToggleTextured();
208    bool GetTextured() const { return m_Textured; }
209
[6abab84]210    void TogglePerspective() { m_Perspective = !m_Perspective; }
211    bool GetPerspective() const { return m_Perspective; }
[045e2af]212
[c60062d]213    void ToggleFog() { m_Fog = !m_Fog; }
214    bool GetFog() const { return m_Fog; }
215
[db452ae]216    void ToggleAntiAlias() { m_AntiAlias = !m_AntiAlias; }
217    bool GetAntiAlias() const { return m_AntiAlias; }
218
[045e2af]219    bool SaveScreenshot(const wxString & fnm, int type) const;
[56da40e]220};
Note: See TracBrowser for help on using the repository browser.