source: git/src/gla.h @ a7aa27d9

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 a7aa27d9 was 9cf3688, checked in by Olly Betts <olly@…>, 21 years ago

More whitespace changes

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