00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #if !defined(AFX_RENDERPASS_H__2E3F741E_4225_473E_8516_81E4C39BCA31__INCLUDED_)
00020 #define AFX_RENDERPASS_H__2E3F741E_4225_473E_8516_81E4C39BCA31__INCLUDED_
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025
00026 #include "renderableGLI.h"
00027 #include <GL/glew.h>
00028 #include "../texture/singleTex.h"
00029 #include "../state/pbuffGlift.h"
00030 #include "../drawable/drawableGLI.h"
00031 #include <mathGutz.h>
00032 #include <vector>
00033
00034 namespace glift {
00035
00036 typedef std::vector<DrawableGLI*> VecDrawP;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 class _export_ RenderPass : public RenderableGLI
00052 {
00053 public:
00054
00055 RenderPass( DrawableGLI* prim, const gutz::vec4i& viewport=gutz::vec4i(), bool restoreView=false);
00056 RenderPass( const VecDrawP& prims, const gutz::vec4i& viewport=gutz::vec4i(), bool restoreView=false);
00057
00058
00059 RenderPass( DrawableGLI* prim, SingleTex* texDest,
00060 const gutz::vec4i& viewport=gutz::vec4i(), bool restoreView=false );
00061 RenderPass( const VecDrawP& prims, SingleTex* texDest,
00062 const gutz::vec4i& viewport=gutz::vec4i(), bool restoreView=false );
00063
00064
00065 RenderPass( DrawableGLI* prim, PBuffGlift* pbuffDest, bool restoreContext=false,
00066 const gutz::vec4i& viewport=gutz::vec4i(), bool restoreView=false );
00067 RenderPass( const VecDrawP& prims, PBuffGlift* pbuffDest, bool restoreContext=false,
00068 const gutz::vec4i& viewport=gutz::vec4i(), bool restoreView=false );
00069
00070
00071 RenderPass( DrawableGLI* prim, SingleTex* texDest, PBuffGlift* pbuffDest, bool restoreContext=false,
00072 const gutz::vec4i& viewport=gutz::vec4i(), bool restoreView=false );
00073 RenderPass( const VecDrawP& prims, SingleTex* texDest, PBuffGlift* pbuffDest, bool restoreContext=false,
00074 const gutz::vec4i& viewport=gutz::vec4i(), bool restoreView=false );
00075
00076 RenderPass( const RenderPass& rhs );
00077 RenderPass& operator=(const RenderPass& rhs);
00078 virtual ~RenderPass();
00079
00080
00081 void setViewport( const gutz::vec4i& viewport, bool restoreView=false );
00082 void setDest( PBuffGlift* pbuff ) {m_pbuffDest = pbuff;}
00083 void setDest( SingleTex* tex ) {m_texDest = tex;}
00084
00085 protected:
00086 virtual void renderDef();
00087
00088 inline void setViewport();
00089 inline void drawPrims();
00090 inline void restoreViewport();
00091
00092 private:
00093 VecDrawP m_prim;
00094 PBuffGlift* m_pbuffDest;
00095 SingleTex* m_texDest;
00096 bool m_restoreCTX;
00097 bool m_changeView;
00098 bool m_restoreView;
00099 gutz::vec4i m_saveVP;
00100 gutz::vec4i m_viewport;
00101
00102 RenderPass();
00103
00104
00105 void initMembers( const RenderPass& rhs );
00106 void initMembers( const VecDrawP& prim, SingleTex* texDest, PBuffGlift* pbuffDest,
00107 bool m_restoreCTX, bool changeView, const gutz::vec4i& viewport, bool restoreView );
00108 };
00109
00110 inline void RenderPass::setViewport()
00111 {
00112 if( m_changeView ) {
00113 if( m_restoreView ) {
00114 glGetIntegerv(GL_VIEWPORT, &m_saveVP[0]);
00115 }
00116 glViewport(m_viewport[0], m_viewport[1], m_viewport[2], m_viewport[3]);
00117 }
00118 }
00119
00120 inline void RenderPass::restoreViewport()
00121 {
00122 if( m_changeView && m_restoreView) {
00123 glViewport(m_saveVP[0], m_saveVP[1], m_saveVP[2], m_saveVP[3]);
00124 }
00125 }
00126
00127 inline void RenderPass::drawPrims()
00128 {
00129 for( uint i=0; i < m_prim.size(); i++) {
00130 m_prim[i]->draw();
00131 }
00132 }
00133
00134 }
00135
00136 #endif