DeferredRenderer 1.0
|
00001 #ifndef __GL_WINDOW_H__ 00002 #define __GL_WINDOW_H__ 00003 00004 #include "Effect.h" 00005 #include "PostProcessor.h" 00006 #include "ngl/Camera.h" 00007 #include "ngl/TransformStack.h" 00008 #include "ngl/Obj.h" 00009 #include "ScreenQuad.h" 00010 #include "FrameBufferObject.h" 00011 #include "Frustum.h" 00012 #include "TextureManager.h" 00013 #include "LightingManager.h" 00014 #include "GameObject.h" 00015 #include "ngl/VertexArrayObject.h" 00016 00017 // must be included after our stuff becuase GLEW needs to be first 00018 #include <QtOpenGL> 00019 00027 class GLWindow : public QGLWidget 00028 { 00029 Q_OBJECT 00030 public : 00031 00034 GLWindow( 00035 QWidget *_parent 00036 ); 00037 00040 void processKeyPress(QKeyEvent *_event); 00041 00042 public slots: 00043 00046 inline void toggleWireframe(bool _mode) 00047 { 00048 m_wireframe = _mode; 00049 updateGL(); 00050 } 00051 00054 inline void toggleShadowMap(bool _mode) 00055 { 00056 m_showShadowMap = _mode; 00057 updateGL(); 00058 } 00059 00062 inline void toggleDebug(bool _mode) 00063 { 00064 m_debug = _mode; 00065 updateGL(); 00066 } 00067 00068 00071 inline void setKa(double _value) 00072 { 00073 m_Ka = (float)_value; 00074 updateGL(); 00075 } 00076 00079 inline void setKd(double _value) 00080 { 00081 m_Kd = (float)_value; 00082 updateGL(); 00083 } 00084 00087 inline void setDVecX(double _value) 00088 { 00089 m_directionalVec.m_x = _value; 00090 updateGL(); 00091 } 00092 00095 inline void setDVecY(double _value) 00096 { 00097 m_directionalVec.m_y = _value; 00098 updateGL(); 00099 } 00100 00103 inline void setDVecZ(double _value) 00104 { 00105 m_directionalVec.m_z = _value; 00106 updateGL(); 00107 } 00108 00111 inline void setAmbientColourR(double _value) 00112 { 00113 m_ambientColour.m_x = _value; 00114 updateGL(); 00115 } 00116 00119 inline void setAmbientColourG(double _value) 00120 { 00121 m_ambientColour.m_y = _value; 00122 updateGL(); 00123 } 00124 00127 inline void setAmbientColourB(double _value) 00128 { 00129 m_ambientColour.m_z = _value; 00130 updateGL(); 00131 } 00132 00135 inline void setDColourR(double _value) 00136 { 00137 m_directionalColour.m_x = _value; 00138 updateGL(); 00139 } 00140 00143 inline void setDColourG(double _value) 00144 { 00145 m_directionalColour.m_y = _value; 00146 updateGL(); 00147 } 00148 00151 inline void setDColourB(double _value) 00152 { 00153 m_directionalColour.m_z = _value; 00154 updateGL(); 00155 } 00156 00159 inline void changeNormWeight(double _value) 00160 { 00161 m_AAweightNorm = (float)_value; 00162 updateGL(); 00163 } 00164 00167 inline void changeDepthWeight(double _value) 00168 { 00169 m_AAweightDepth = (float)_value; 00170 updateGL(); 00171 } 00172 00175 inline void changeNormBarrier(double _value) 00176 { 00177 m_AAbarrierNorm = (float)_value; 00178 updateGL(); 00179 } 00180 00183 inline void changeDepthBarrier(double _value) 00184 { 00185 m_AAbarrierDepth = (float)_value; 00186 updateGL(); 00187 } 00188 00191 inline void changeKernel(double _value) 00192 { 00193 m_AAkernel = (float)_value; 00194 updateGL(); 00195 } 00196 00199 void setMainDisplay(int _displayMode); 00200 00201 protected: 00202 00204 float m_AAbarrierNorm, m_AAbarrierDepth, m_AAweightNorm,m_AAweightDepth, m_AAkernel; 00205 00211 void genShader(const std::string &_name, const std::string &_VSname, const std::string &_FSname, const std::vector<std::string> &_attributes); 00212 00214 int m_currentDisplay; 00215 00217 int m_spinXFace; 00218 00220 int m_spinYFace; 00221 00223 bool m_rotate; 00224 00226 int m_origX; 00227 00229 int m_origY; 00230 00232 void initializeGL(); 00233 00235 void resizeGL(const int _w,const int _h){m_windoWidth = _w; m_windowHeight = _h;} 00236 00238 void paintGL(); 00239 00242 void timerEvent(QTimerEvent *_event); 00243 00245 void createScreenQuad(); 00246 00248 ngl::TransformStack m_transformStack; 00249 00250 private: 00253 void mouseMoveEvent ( 00254 QMouseEvent * _event 00255 ); 00258 void mousePressEvent ( 00259 QMouseEvent *_event 00260 ); 00263 void mouseReleaseEvent ( 00264 QMouseEvent *_event 00265 ); 00266 00268 void setupShaders(); 00269 00271 void setupTextures(); 00272 00274 void lightAccumulation(); 00276 void shadowPass(); 00278 void geometryPass(); 00280 void debugPass(); 00281 00283 void postProcess(); 00284 00286 void postProcessUniforms(); 00287 00289 void postProcessSetup(); 00290 00292 void addStandardEffect(const std::string &_effectName, 00293 const std::string &_outputName, 00294 const std::string &_shaderName, 00295 const std::string &_sourceName); 00296 00298 TextureManager m_textureManager; 00299 00301 LightingManager m_lightingManager; 00302 00304 int m_updatetimer; 00305 00307 float m_time; 00309 float m_timeStep; 00311 float m_Ka; 00313 float m_Kd; 00315 bool m_wireframe; 00317 bool m_debug; 00319 ScreenQuad m_viewportQuad; 00321 Frustum m_frustum; 00323 FrameBufferObject m_fbo; 00325 FrameBufferObject m_shadowBuffer; 00326 00328 ngl::Camera m_cam; 00329 00331 unsigned int m_pointLightVAO; 00333 std::string m_spotLightName; 00335 unsigned int m_screenQuadVAO; 00336 00338 ScreenQuad m_debugQuad1; 00340 ScreenQuad m_debugQuad2; 00342 ScreenQuad m_debugQuad3; 00344 ScreenQuad m_debugQuad4; 00346 ScreenQuad m_debugQuad5; 00348 ScreenQuad m_debugQuad6; 00349 00351 ngl::Vector m_directionalVec; 00352 00354 ngl::Vector m_ambientColour; 00355 00357 ngl::Vector m_directionalColour; 00358 00360 bool m_showShadowMap; 00361 00363 PostProcessor m_postProcessor; 00364 00366 ngl::Obj *obj; 00367 00368 int m_windoWidth, m_windowHeight; 00369 }; 00370 00371 #endif