GLWidget.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code 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
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #if !defined(AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_)
  21. #define AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_
  22. #if _MSC_VER > 1000
  23. #pragma once
  24. #endif // _MSC_VER > 1000
  25. /////////////////////////////////////////////////////////////////////////////
  26. // idGLWidget window
  27. class idGLDrawable {
  28. public:
  29. idGLDrawable();
  30. ~idGLDrawable() {};
  31. virtual void draw(int x, int y, int w, int h);
  32. virtual void setMedia(const char *name){}
  33. virtual void buttonDown(int button, float x, float y);
  34. virtual void buttonUp(int button, float x, float y);
  35. virtual void mouseMove(float x, float y);
  36. virtual int getRealTime() {return realTime;};
  37. virtual bool ScreenCoords() {
  38. return true;
  39. }
  40. void SetRealTime(int i) {
  41. realTime = i;
  42. }
  43. virtual void Update() {};
  44. float getScale() {
  45. return scale;
  46. }
  47. void setScale(float f) {
  48. scale = f;
  49. }
  50. protected:
  51. float scale;
  52. float xOffset;
  53. float yOffset;
  54. float zOffset;
  55. float pressX;
  56. float pressY;
  57. bool handleMove;
  58. int button;
  59. int realTime;
  60. };
  61. class idGLDrawableWorld : public idGLDrawable {
  62. public:
  63. idGLDrawableWorld();
  64. ~idGLDrawableWorld();
  65. void AddTris(srfTriangles_t *tris, const idMaterial *mat);
  66. virtual void draw(int x, int y, int w, int h);
  67. void InitWorld();
  68. protected:
  69. idRenderWorld *world;
  70. idRenderModel *worldModel;
  71. qhandle_t worldModelDef;
  72. qhandle_t lightDef;
  73. qhandle_t modelDef;
  74. };
  75. class idGLDrawableMaterial : public idGLDrawableWorld {
  76. public:
  77. idGLDrawableMaterial(const idMaterial *mat) {
  78. material = mat;
  79. scale = 1.0;
  80. light = 1.0;
  81. worldDirty = true;
  82. }
  83. idGLDrawableMaterial() {
  84. material = NULL;
  85. light = 1.0;
  86. worldDirty = true;
  87. realTime = 50;
  88. }
  89. ~idGLDrawableMaterial() {
  90. }
  91. virtual void setMedia(const char *name);
  92. virtual void draw(int x, int y, int w, int h);
  93. virtual void buttonUp(int button){}
  94. virtual void buttonDown(int button, float x, float y);
  95. virtual void mouseMove(float x, float y);
  96. virtual void Update() { worldDirty = true ;};
  97. protected:
  98. const idMaterial *material;
  99. bool worldDirty;
  100. float light;
  101. };
  102. class idGLDrawableModel : public idGLDrawableWorld {
  103. public:
  104. idGLDrawableModel(const char *name);
  105. idGLDrawableModel();
  106. ~idGLDrawableModel() {}
  107. virtual void setMedia(const char *name);
  108. virtual void buttonDown(int button, float x, float y);
  109. virtual void mouseMove(float x, float y);
  110. virtual void draw(int x, int y, int w, int h);
  111. virtual void Update() { worldDirty = true ;};
  112. virtual bool ScreenCoords() {
  113. return false;
  114. }
  115. void SetSkin( const char *skin );
  116. protected:
  117. bool worldDirty;
  118. float light;
  119. idStr skinStr;
  120. idQuat rotation;
  121. idVec3 lastPress;
  122. float radius;
  123. idVec4 rect;
  124. };
  125. class idGLDrawableConsole : public idGLDrawable {
  126. public:
  127. idGLDrawableConsole () {
  128. }
  129. ~idGLDrawableConsole() {
  130. }
  131. virtual void setMedia(const char *name) {
  132. }
  133. virtual void draw(int x, int y, int w, int h);
  134. virtual int getRealTime() {return 0;};
  135. protected:
  136. };
  137. class idGLWidget : public CWnd
  138. {
  139. // Construction
  140. public:
  141. idGLWidget();
  142. void setDrawable(idGLDrawable *d);
  143. // Attributes
  144. public:
  145. // Operations
  146. public:
  147. // Overrides
  148. // ClassWizard generated virtual function overrides
  149. //{{AFX_VIRTUAL(idGLWidget)
  150. public:
  151. virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
  152. protected:
  153. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  154. //}}AFX_VIRTUAL
  155. // Implementation
  156. public:
  157. virtual ~idGLWidget();
  158. // Generated message map functions
  159. protected:
  160. idGLDrawable *drawable;
  161. bool initialized;
  162. //{{AFX_MSG(idGLWidget)
  163. afx_msg void OnPaint();
  164. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  165. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  166. afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  167. afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
  168. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  169. afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
  170. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  171. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  172. afx_msg void OnTimer(UINT nIDEvent);
  173. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  174. //}}AFX_MSG
  175. DECLARE_MESSAGE_MAP()
  176. };
  177. class idGLConsoleWidget : public idGLWidget {
  178. idGLDrawableConsole console;
  179. public:
  180. idGLConsoleWidget() {
  181. };
  182. ~idGLConsoleWidget() {
  183. }
  184. void init();
  185. protected:
  186. //{{AFX_MSG(idGLConsoleWidget)
  187. afx_msg void OnPaint();
  188. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  189. afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  190. afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  191. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  192. //}}AFX_MSG
  193. DECLARE_MESSAGE_MAP()
  194. };
  195. /////////////////////////////////////////////////////////////////////////////
  196. //{{AFX_INSERT_LOCATION}}
  197. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  198. #endif // !defined(AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_)