]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/prtview/portals.h
reformat code! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / contrib / prtview / portals.h
1 /*
2    PrtView plugin for GtkRadiant
3    Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef _PORTALS_H_
21 #define _PORTALS_H_
22
23 #include <glib.h>
24 #include "irender.h"
25 #include "renderable.h"
26 #include "math/vector.h"
27
28
29 class CBspPoint {
30 public:
31     float p[3];
32 };
33
34 class CBspPortal {
35 public:
36     CBspPortal();
37
38     ~CBspPortal();
39
40 protected:
41
42 public:
43     CBspPoint center;
44     unsigned point_count;
45     CBspPoint *point;
46     CBspPoint *inner_point;
47     float fp_color_random[4];
48     float min[3];
49     float max[3];
50     float dist;
51     bool hint;
52
53     bool Build(char *def);
54 };
55
56 #ifdef PATH_MAX
57 const int PRTVIEW_PATH_MAX = PATH_MAX;
58 #else
59 const int PRTVIEW_PATH_MAX = 260;
60 #endif
61 typedef guint32 PackedColour;
62 #define RGB(r, g, b) ( (guint32)( ( (guint8) ( r ) | ( (guint16) ( g ) << 8 ) ) | ( ( (guint32) (guint8) ( b ) ) << 16 ) ) )
63 #define GetRValue(rgb)      ( (guint8)( rgb ) )
64 #define GetGValue(rgb)      ( (guint8)( ( (guint16)( rgb ) ) >> 8 ) )
65 #define GetBValue(rgb)      ( (guint8)( ( rgb ) >> 16 ) )
66
67
68 class CPortals {
69 public:
70
71     CPortals();
72
73     ~CPortals();
74
75 protected:
76
77
78 public:
79
80     void Load();     // use filename in fn
81     void Purge();
82
83     void FixColors();
84
85     char fn[PRTVIEW_PATH_MAX];
86
87     int zbuffer;
88     int polygons;
89     int lines;
90     bool show_3d;
91     bool aa_3d;
92     bool fog;
93     PackedColour color_3d;
94     float width_3d;      // in 8'ths
95     float fp_color_3d[4];
96     PackedColour color_fog;
97     float fp_color_fog[4];
98     float trans_3d;
99     float clip_range;
100     bool clip;
101
102     bool show_2d;
103     bool aa_2d;
104     PackedColour color_2d;
105     float width_2d;      // in 8'ths
106     float fp_color_2d[4];
107
108     CBspPortal *portal;
109     int *portal_sort;
110     bool hint_flags;
111 //      CBspNode *node;
112
113     unsigned int node_count;
114     unsigned int portal_count;
115 };
116
117 class CubicClipVolume {
118 public:
119     Vector3 cam, min, max;
120 };
121
122 class CPortalsDrawSolid : public OpenGLRenderable {
123 public:
124     mutable CubicClipVolume clip;
125
126     void render(RenderStateFlags state) const;
127 };
128
129 class CPortalsDrawSolidOutline : public OpenGLRenderable {
130 public:
131     mutable CubicClipVolume clip;
132
133     void render(RenderStateFlags state) const;
134 };
135
136 class CPortalsDrawWireframe : public OpenGLRenderable {
137 public:
138     void render(RenderStateFlags state) const;
139 };
140
141 class CPortalsRender : public Renderable {
142 public:
143     CPortalsDrawSolid m_drawSolid;
144     CPortalsDrawSolidOutline m_drawSolidOutline;
145     CPortalsDrawWireframe m_drawWireframe;
146
147     void renderSolid(Renderer &renderer, const VolumeTest &volume) const;
148
149     void renderWireframe(Renderer &renderer, const VolumeTest &volume) const;
150 };
151
152 extern CPortals portals;
153 extern CPortalsRender render;
154
155 void Portals_constructShaders();
156
157 void Portals_destroyShaders();
158
159 void Portals_shadersChanged();
160
161
162 #endif // _PORTALS_H_