]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/tools/radiant/GLWidget.h
Various Mac OS X tweaks to get this to build. Probably breaking things.
[icculus/iodoom3.git] / neo / tools / radiant / GLWidget.h
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 #if !defined(AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_)
29 #define AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_
30
31 #if _MSC_VER > 1000
32 #pragma once
33 #endif // _MSC_VER > 1000
34
35 /////////////////////////////////////////////////////////////////////////////
36 // idGLWidget window
37
38 class idGLDrawable {
39 public:
40         idGLDrawable();
41         ~idGLDrawable() {};
42         virtual void draw(int x, int y, int w, int h);
43         virtual void setMedia(const char *name){}
44         virtual void buttonDown(int button, float x, float y);
45         virtual void buttonUp(int button, float x, float y);
46         virtual void mouseMove(float x, float y);
47         virtual int getRealTime() {return realTime;};
48         virtual bool ScreenCoords() { 
49                 return true;
50         }
51         void SetRealTime(int i) {
52                 realTime = i;
53         }
54         virtual void Update() {};
55         float getScale() {
56                 return scale;
57         }
58         void setScale(float f) {
59                 scale = f;
60         }
61 protected:
62         float scale;
63         float xOffset;
64         float yOffset;
65         float zOffset;
66         float pressX;
67         float pressY;
68         bool  handleMove;
69         int button;
70         int realTime;
71 };
72
73 class idGLDrawableWorld : public idGLDrawable {
74 public:
75         idGLDrawableWorld();
76         ~idGLDrawableWorld();
77         void AddTris(srfTriangles_t *tris, const idMaterial *mat);
78         virtual void draw(int x, int y, int w, int h);
79         void InitWorld();
80 protected:
81         idRenderWorld *world;
82         idRenderModel *worldModel;
83         qhandle_t       worldModelDef;
84         qhandle_t       lightDef;
85         qhandle_t   modelDef;
86 };
87
88 class idGLDrawableMaterial : public idGLDrawableWorld {
89 public:
90
91         idGLDrawableMaterial(const idMaterial *mat) {
92                 material = mat;
93                 scale = 1.0;
94                 light = 1.0;
95                 worldDirty = true;
96         }
97
98         idGLDrawableMaterial() {
99                 material = NULL;
100                 light = 1.0;
101                 worldDirty = true;
102                 realTime = 50;
103         }
104
105         ~idGLDrawableMaterial() {
106         }
107
108         virtual void setMedia(const char *name);
109         virtual void draw(int x, int y, int w, int h);
110         virtual void buttonUp(int button){}
111         virtual void buttonDown(int button, float x, float y);
112         virtual void mouseMove(float x, float y);
113         virtual void Update() { worldDirty = true ;};
114
115 protected:
116         const idMaterial *material;
117         bool worldDirty;
118         float light;
119 };
120
121 class idGLDrawableModel : public idGLDrawableWorld {
122 public:
123
124         idGLDrawableModel(const char *name);
125
126         idGLDrawableModel();
127
128         ~idGLDrawableModel() {}
129
130         virtual void setMedia(const char *name);
131
132         virtual void buttonDown(int button, float x, float y);
133         virtual void mouseMove(float x, float y);
134         virtual void draw(int x, int y, int w, int h);
135         virtual void Update() { worldDirty = true ;};
136         virtual bool ScreenCoords() { 
137                 return false;
138         }
139         void SetSkin( const char *skin );
140
141 protected:
142         bool worldDirty;
143         float light;
144         idStr skinStr;
145         idQuat rotation;
146         idVec3 lastPress;
147         float radius;
148         idVec4 rect;
149
150 };
151
152 class idGLDrawableConsole : public idGLDrawable {
153 public:
154
155         idGLDrawableConsole () {
156         }
157
158         ~idGLDrawableConsole() {
159         }
160
161         virtual void setMedia(const char *name) {
162         }
163
164
165         virtual void draw(int x, int y, int w, int h);
166
167         virtual int getRealTime() {return 0;};
168
169 protected:
170
171 };
172
173
174
175 class idGLWidget : public CWnd
176 {
177 // Construction
178 public:
179         idGLWidget();
180         void setDrawable(idGLDrawable *d);
181
182 // Attributes
183 public:
184
185 // Operations
186 public:
187
188 // Overrides
189         // ClassWizard generated virtual function overrides
190         //{{AFX_VIRTUAL(idGLWidget)
191         public:
192         virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
193         protected:
194         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
195         //}}AFX_VIRTUAL
196
197 // Implementation
198 public:
199         virtual ~idGLWidget();
200
201         // Generated message map functions
202 protected:
203         idGLDrawable *drawable;
204         bool initialized;
205         //{{AFX_MSG(idGLWidget)
206         afx_msg void OnPaint();
207         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
208         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
209         afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
210         afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
211         afx_msg void OnMouseMove(UINT nFlags, CPoint point);
212         afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
213         afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
214         afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
215         afx_msg void OnTimer(UINT nIDEvent);
216         afx_msg BOOL OnEraseBkgnd(CDC* pDC);
217         //}}AFX_MSG
218
219         DECLARE_MESSAGE_MAP()
220 };
221
222 class idGLConsoleWidget : public idGLWidget {
223         idGLDrawableConsole console;
224 public:
225         idGLConsoleWidget() {
226         };
227         ~idGLConsoleWidget() {
228         }
229         void init();
230 protected:
231         //{{AFX_MSG(idGLConsoleWidget)
232         afx_msg void OnPaint();
233         afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
234         afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
235         afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
236         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
237         //}}AFX_MSG
238         DECLARE_MESSAGE_MAP()
239
240 };
241
242 /////////////////////////////////////////////////////////////////////////////
243
244 //{{AFX_INSERT_LOCATION}}
245 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
246
247 #endif // !defined(AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_)