31 #ifndef MESH_VERTEXBUFFERSTATE_H
32 #define MESH_VERTEXBUFFERSTATE_H
45 class VertexBufferState
53 virtual bool useColors()
const {
return _useColors; }
54 virtual void setColors(
const bool colors ) { _useColors = colors; }
55 virtual bool stopRendering()
const {
return false; }
56 virtual RenderMode getRenderMode()
const {
return _renderMode; }
57 virtual void setRenderMode(
const RenderMode mode );
58 virtual bool useFrustumCulling()
const {
return _useFrustumCulling; }
59 virtual void setFrustumCulling(
const bool frustumCullingState )
60 { _useFrustumCulling = frustumCullingState; }
62 void setProjectionModelViewMatrix(
const Matrix4f& pmv )
64 const Matrix4f& getProjectionModelViewMatrix()
const
67 void setRange(
const Range& range ) {
_range = range; }
68 const Range& getRange()
const {
return _range; }
71 void updateRegion(
const BoundingBox& box );
72 virtual void declareRegion(
const Vector4f& region ) {}
75 virtual GLuint getDisplayList(
const void* key ) = 0;
76 virtual GLuint newDisplayList(
const void* key ) = 0;
77 virtual GLuint getBufferObject(
const void* key ) = 0;
78 virtual GLuint newBufferObject(
const void* key ) = 0;
79 virtual void deleteAll() = 0;
81 const GLEWContext* glewGetContext()
const {
return _glewContext; }
84 VertexBufferState(
const GLEWContext* glewContext );
85 virtual ~VertexBufferState() {}
89 const GLEWContext*
const _glewContext;
90 RenderMode _renderMode;
93 bool _useFrustumCulling;
100 class VertexBufferStateSimple :
public VertexBufferState
103 typedef std::map< const void*, GLuint > GLMap;
104 typedef GLMap::const_iterator GLMapCIter;
107 VertexBufferStateSimple(
const GLEWContext* glewContext )
108 : VertexBufferState( glewContext ) {}
110 virtual GLuint getDisplayList(
const void* key );
111 virtual GLuint newDisplayList(
const void* key );
112 virtual GLuint getBufferObject(
const void* key );
113 virtual GLuint newBufferObject(
const void* key );
114 virtual void deleteAll();
118 GLMap _bufferObjects;
130 : mesh::VertexBufferState( objectManager->glewGetContext( ))
131 , _objectManager( objectManager )
134 virtual GLuint getDisplayList(
const void* key )
135 {
return _objectManager->getList( key ); }
137 virtual GLuint newDisplayList(
const void* key )
138 {
return _objectManager->newList( key ); }
140 virtual GLuint getTexture(
const void* key )
141 {
return _objectManager->getTexture( key ); }
143 virtual GLuint newTexture(
const void* key )
144 {
return _objectManager->newTexture( key ); }
146 virtual GLuint getBufferObject(
const void* key )
147 {
return _objectManager->getBuffer( key ); }
149 virtual GLuint newBufferObject(
const void* key )
150 {
return _objectManager->newBuffer( key ); }
152 virtual GLuint getProgram(
const void* key )
153 {
return _objectManager->getProgram( key ); }
155 virtual GLuint newProgram(
const void* key )
156 {
return _objectManager->newProgram( key ); }
158 virtual GLuint getShader(
const void* key )
159 {
return _objectManager->getShader( key ); }
161 virtual GLuint newShader(
const void* key, GLenum type )
162 {
return _objectManager->newShader( key, type ); }
164 virtual void deleteAll() { _objectManager->
deleteAll(); }
165 bool isShared()
const {
return _objectManager->
isShared(); }
167 void setChannel( Channel* channel ) { _channel = channel; }
169 virtual bool stopRendering( )
const
170 {
return _channel ? _channel->stopRendering() :
false; }
172 virtual void declareRegion(
const mesh::Vector4f& region )
173 {
if( _channel ) _channel->
declareRegion( eq::Viewport( region )); }
183 #endif // MESH_VERTEXBUFFERSTATE_H
Matrix4f _pmvMatrix
projection * modelView matrix
Range _range
normalized [0,1] part of the model to draw
Vector4f _region
normalized x1 y1 x2 y2 region from cullDraw
A facility class to manage OpenGL objects across shared contexts.
void deleteAll()
Delete all managed objects and associated GL objects.
vmml::matrix< 4, 4, float > Matrix4f
A 4x4 float matrix.
virtual void declareRegion(const eq::PixelViewport ®ion)
Declare a region covered by the current draw or assemble operation.
vmml::vector< 4, float > Vector4f
A four-component float vector.