doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ZClip.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code 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 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code 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 Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "qe3.h"
33 #include "Radiant.h"
34 
35 #include "zclip.h"
36 
37 
39 {
40  LONG
41  lSize = sizeof(m_bEnabled);
42  if (!LoadRegistryInfo("radiant_ZClipEnabled", &m_bEnabled, &lSize))
43  m_bEnabled = false;
44 
45  lSize = sizeof(m_iZClipTop);
46  if (!LoadRegistryInfo("radiant_ZClipTop", &m_iZClipTop, &lSize))
47  m_iZClipTop = 64;
48 
49  lSize = sizeof(m_iZClipBottom);
50  if (!LoadRegistryInfo("radiant_ZClipBottom", &m_iZClipBottom, &lSize))
51  m_iZClipBottom = -64;
52 
53  Legalise();
54 }
55 
57 {
58  // TODO: registry save
59 
60  SaveRegistryInfo("radiant_ZClipEnabled", &m_bEnabled, sizeof(m_bEnabled));
61  SaveRegistryInfo("radiant_ZClipTop", &m_iZClipTop, sizeof(m_iZClipTop));
62  SaveRegistryInfo("radiant_ZClipBottom", &m_iZClipBottom, sizeof(m_iZClipBottom));
63 }
64 
65 void CZClip::Reset(void)
66 {
67  m_iZClipTop = 64; // arb. starting values, but must be at least 64 apart
68  m_iZClipBottom = -64;
69  m_bEnabled = false;
70 
71  Legalise();
72 }
73 
74 
75 int CZClip::GetTop(void)
76 {
77  return m_iZClipTop;
78 }
79 
81 {
82  return m_iZClipBottom;
83 }
84 
85 void CZClip::Legalise(void)
86 {
87  // need swapping?
88  //
90  {
91  int iTemp = m_iZClipTop;
93  m_iZClipBottom = iTemp;
94  }
95 
96  // too close together?
97  //
98 #define ZCLIP_MIN_SPACING 64
99 
102 }
103 
104 
105 void CZClip::SetTop(int iNewZ)
106 {
107  m_iZClipTop = iNewZ;
108 
109  Legalise();
110 }
111 
112 void CZClip::SetBottom(int iNewZ)
113 {
114  m_iZClipBottom = iNewZ;
115 
116  Legalise();
117 }
118 
120 {
121  return m_bEnabled;
122 }
123 
124 
125 bool CZClip::Enable(bool bOnOff)
126 {
128  return IsEnabled();
129 }
130 
131 #define ZCLIP_BAR_THICKNESS 8
132 #define ZCLIP_ARROWHEIGHT (ZCLIP_BAR_THICKNESS*8)
133 
134 void CZClip::Paint(void)
135 {
136  float x, y;
137  int xCam = z.width/4; // hmmm, a rather unpleasant and obscure global name, but it was already called that so...
138 
139  qglColor3f (ZCLIP_COLOUR);//1.0, 0.0, 1.0);
140 
141  // draw TOP marker...
142  //
143  x = 0;
144  y = m_iZClipTop;
145 
146  if (m_bEnabled)
147  qglBegin(GL_QUADS);
148  else
149  qglBegin(GL_LINE_LOOP);
150 
151  qglVertex3f (x-xCam,y,0);
152  qglVertex3f (x-xCam,y+ZCLIP_BAR_THICKNESS,0);
153  qglVertex3f (x+xCam,y+ZCLIP_BAR_THICKNESS,0);
154  qglVertex3f (x+xCam,y,0);
155  qglEnd ();
156 
157  qglColor3f (ZCLIP_COLOUR_DIM);//0.8, 0.0, 0.8);
158 
159  if (m_bEnabled)
160  qglBegin(GL_TRIANGLES);
161  else
162  qglBegin(GL_LINE_LOOP);
166  qglEnd ();
167 
168  // draw bottom marker...
169  //
170  qglColor3f (ZCLIP_COLOUR);//1.0, 0.0, 1.0);
171  x = 0;
172  y = m_iZClipBottom;
173 
174  if (m_bEnabled)
175  qglBegin(GL_QUADS);
176  else
177  qglBegin(GL_LINE_LOOP);
178  qglVertex3f (x-xCam,y,0);
179  qglVertex3f (x-xCam,y-ZCLIP_BAR_THICKNESS,0);
180  qglVertex3f (x+xCam,y-ZCLIP_BAR_THICKNESS,0);
181  qglVertex3f (x+xCam,y,0);
182  qglEnd ();
183 
184  qglColor3f (ZCLIP_COLOUR_DIM);//0.8, 0.0, 0.8);
185 
186  if (m_bEnabled)
187  qglBegin(GL_TRIANGLES);
188  else
189  qglBegin(GL_LINE_LOOP);
193  qglEnd ();
194 }
195 
196 
198 
199 
bool m_bEnabled
Definition: ZClip.h:57
GLenum GLint GLint y
Definition: glext.h:2849
#define qglBegin
Definition: qgl_linked.h:33
#define ZCLIP_MIN_SPACING
bool LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize)
Definition: Radiant.cpp:405
GLenum GLint x
Definition: glext.h:2849
void Paint(void)
Definition: ZClip.cpp:134
CZClip()
Definition: ZClip.cpp:38
#define ZCLIP_COLOUR
Definition: ZClip.h:35
void SetBottom(int iNewZ)
Definition: ZClip.cpp:112
#define qglEnd
Definition: qgl_linked.h:103
#define qglColor3f
Definition: qgl_linked.h:50
#define ZCLIP_COLOUR_DIM
Definition: ZClip.h:36
bool SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize)
Definition: Radiant.cpp:398
int m_iZClipTop
Definition: ZClip.h:58
long LONG
bool IsEnabled(void)
Definition: ZClip.cpp:119
~CZClip()
Definition: ZClip.cpp:56
int m_iZClipBottom
Definition: ZClip.h:59
void Reset(void)
Definition: ZClip.cpp:65
int GetBottom(void)
Definition: ZClip.cpp:80
int GetTop(void)
Definition: ZClip.cpp:75
void Legalise(void)
Definition: ZClip.cpp:85
#define qglVertex3f
Definition: qgl_linked.h:349
bool Enable(bool bOnOff)
Definition: ZClip.cpp:125
GLdouble GLdouble z
Definition: glext.h:3067
#define ZCLIP_ARROWHEIGHT
Definition: ZClip.cpp:132
#define ZCLIP_BAR_THICKNESS
Definition: ZClip.cpp:131
void SetTop(int iNewZ)
Definition: ZClip.cpp:105