X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Frenderers%2Frender-geometry.cpp;h=c5b7ec690fe396a3f16e6dd7a201e3fdba1f4df5;hb=920b85054f3607e64f7c060090399c8b86c8bfd0;hp=c7b07a801e7c5331a80d688a11fa1273511d9aa9;hpb=0b7b233c4007025cca19303d3e5a64ef99a8fbc4;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/renderers/render-geometry.cpp b/dali/internal/render/renderers/render-geometry.cpp index c7b07a8..c5b7ec6 100644 --- a/dali/internal/render/renderers/render-geometry.cpp +++ b/dali/internal/render/renderers/render-geometry.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "render-geometry.h" +#include #include #include @@ -32,7 +32,8 @@ namespace SceneGraph { RenderGeometry::RenderGeometry() -: mDataNeedsUploading( true ) +: mDataNeedsUploading( true ), + mShaderChanged( true ) { } @@ -47,19 +48,6 @@ void RenderGeometry::GlContextCreated( Context& context ) void RenderGeometry::GlContextDestroyed() { - for( GpuBuffers::Iterator iter=mVertexBuffers.Begin(); iter != mVertexBuffers.End(); ++iter ) - { - GpuBuffer* gpuBuffer = *iter; - if( gpuBuffer ) - { - gpuBuffer->GlContextDestroyed(); - } - } - - if( mIndexBuffer ) - { - mIndexBuffer->GlContextDestroyed(); - } } void RenderGeometry::UploadAndDraw( @@ -69,10 +57,27 @@ void RenderGeometry::UploadAndDraw( const RenderDataProvider* dataProviders ) { UploadVertexData( context, bufferIndex, dataProviders ); - BindBuffers(); - EnableVertexAttributes( context, program ); + + for( unsigned int i = 0; i < mVertexBuffers.Count(); ++i ) + { + mVertexBuffers[i]->BindBuffer( context, program ); + mVertexBuffers[i]->EnableVertexAttributes( context, bufferIndex, program ); + } + + if( mIndexBuffer ) + { + mIndexBuffer->BindBuffer( context, program ); + } + +// BindBuffers( context, bufferIndex, program ); +// EnableVertexAttributes( context, bufferIndex, program ); Draw( context, bufferIndex, dataProviders ); - DisableVertexAttributes( context, program ); + + for( unsigned int i = 0; i < mVertexBuffers.Count(); ++i ) + { + mVertexBuffers[i]->DisableVertexAttributes( context, bufferIndex, program ); + } + //DisableVertexAttributes( context, bufferIndex, program ); } void RenderGeometry::GeometryUpdated() @@ -105,88 +110,62 @@ void RenderGeometry::DoUpload( for( unsigned int i=0; iGetDataSize( bufferIndex ); - vertexGpuBuffer->UpdateDataBuffer( dataSize, vertexBuffer->GetData( bufferIndex ) ); - vertexGpuBuffer->SetStride( vertexBuffer->GetElementSize( bufferIndex ) ); + propertyBuffer->DoUpload( context, bufferIndex ); - mVertexBuffers.PushBack( vertexGpuBuffer ); + mVertexBuffers.PushBack( propertyBuffer ); } // Index buffer - const PropertyBuffer* indexBuffer = dataProvider->GetIndexBuffer(); + const PropertyBufferDataProvider* indexBuffer = dataProvider->GetIndexBuffer(); if( indexBuffer ) { - GpuBuffer* indexGpuBuffer = new GpuBuffer( context, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW ); + mIndexBuffer = new RenderPropertyBuffer( *indexBuffer, true ); - unsigned int dataSize = indexBuffer->GetDataSize( bufferIndex ); - indexGpuBuffer->UpdateDataBuffer( dataSize, indexBuffer->GetData( bufferIndex ) ); - - mIndexBuffer.Reset(); - mIndexBuffer = indexGpuBuffer; + mIndexBuffer->DoUpload( context, bufferIndex ); } } -void RenderGeometry::BindBuffers() +void RenderGeometry::BindBuffers( Context& context, BufferIndex bufferIndex, Program& program ) { - for( GpuBuffers::Iterator iter=mVertexBuffers.Begin(); iter != mVertexBuffers.End(); ++iter ) + for( unsigned int i = 0; i < mVertexBuffers.Count(); ++i ) { - (*iter)->Bind(); + mVertexBuffers[i]->BindBuffer( context, program ); } if( mIndexBuffer ) { - mIndexBuffer->Bind(); + mIndexBuffer->BindBuffer( context, program ); } } -void RenderGeometry::EnableVertexAttributes( Context& context, Program& program ) +void RenderGeometry::EnableVertexAttributes( Context& context, BufferIndex bufferIndex, Program& program ) { - // @todo Loop thru the array of vertex buffers - // @todo Use AttributeDataProvider to get the attrs and enable them - // Need mapping from gpu buffers index to a particular attributes - Vector4 *vertex=0; - - unsigned int gpuBufferIndex = 0; - - GLint positionLoc = program.GetAttribLocation( Program::ATTRIB_POSITION ); - context.VertexAttribPointer( positionLoc, - 2, // 2D position - GL_FLOAT, - GL_FALSE, // Not normalized - mVertexBuffers[gpuBufferIndex]->GetStride(), - &vertex->x ); - - context.EnableVertexAttributeArray( positionLoc ); - - GLint textureCoordsLoc = program.GetAttribLocation( Program::ATTRIB_TEXCOORD ); - context.VertexAttribPointer( textureCoordsLoc, - 2, // Texture Coords = U, V - GL_FLOAT, - GL_FALSE, - mVertexBuffers[gpuBufferIndex]->GetStride(), - &vertex->z ); - context.EnableVertexAttributeArray( textureCoordsLoc ); + OwnerContainer< RenderPropertyBuffer* >::Iterator it = mVertexBuffers.Begin(); + OwnerContainer< RenderPropertyBuffer* >::ConstIterator end = mVertexBuffers.End(); + for( ; it != end; ++it ) + { + (*it)->EnableVertexAttributes( context, bufferIndex, program ); + } } -void RenderGeometry::DisableVertexAttributes( Context& context, Program& program ) +void RenderGeometry::DisableVertexAttributes( Context& context, BufferIndex bufferIndex, Program& program ) { - // @todo Loop thru the array of vertex buffers - // @todo Use AttributeDataProvider to get the attrs and disable them - GLint positionLoc = program.GetAttribLocation( Program::ATTRIB_POSITION ); - GLint textureCoordsLoc = program.GetAttribLocation( Program::ATTRIB_TEXCOORD ); - context.DisableVertexAttributeArray( positionLoc ); - context.DisableVertexAttributeArray( textureCoordsLoc ); + OwnerContainer< RenderPropertyBuffer* >::Iterator it = mVertexBuffers.Begin(); + OwnerContainer< RenderPropertyBuffer* >::ConstIterator end = mVertexBuffers.End(); + for( ; it != end; ++it ) + { + (*it)->DisableVertexAttributes( context, bufferIndex, program ); + } } void RenderGeometry::Draw( Context& context, BufferIndex bufferIndex, const RenderDataProvider* dataProvider ) { const GeometryDataProvider& geometry = dataProvider->GetGeometry(); - const PropertyBuffer* indexBuffer = dataProvider->GetIndexBuffer(); + const PropertyBufferDataProvider* indexBuffer = dataProvider->GetIndexBuffer(); GeometryDataProvider::GeometryType type = geometry.GetGeometryType( bufferIndex ); @@ -210,15 +189,9 @@ void RenderGeometry::Draw( Context& context, BufferIndex bufferIndex, const Rend } case Dali::Geometry::POINTS: { - GpuBuffer* firstVertexBuffer = mVertexBuffers[0]; - - unsigned int numVertices = 0; - GLuint stride = firstVertexBuffer->GetStride(); - if( stride != 0 ) - { - numVertices = firstVertexBuffer->GetBufferSize() / stride; - } + const PropertyBufferDataProvider* firstVertexBuffer = dataProvider->GetVertexBuffers()[0]; + unsigned int numVertices = firstVertexBuffer->GetElementCount( bufferIndex ); context.DrawArrays(GL_POINTS, 0, numVertices ); break; }