2 #include <dali/internal/render/renderers/render-property-buffer.h>
3 #include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
10 using Dali::Internal::PropertyImplementationType;
12 Dali::GLenum GetPropertyImplementationGlType( Property::Type propertyType )
14 Dali::GLenum type = GL_BYTE;
16 switch( propertyType )
19 case Property::STRING:
22 case Property::RECTANGLE:
23 case Property::ROTATION:
25 // types not supported by gl
28 case Property::BOOLEAN:
33 case Property::INTEGER:
39 case Property::VECTOR2:
40 case Property::VECTOR3:
41 case Property::VECTOR4:
42 case Property::MATRIX3:
43 case Property::MATRIX:
53 size_t GetPropertyImplementationGlSize( Property::Type propertyType )
57 switch( propertyType )
60 case Property::STRING:
63 case Property::RECTANGLE:
64 case Property::ROTATION:
66 // types not supported by gl
69 case Property::BOOLEAN:
74 case Property::INTEGER:
80 case Property::VECTOR2:
81 case Property::VECTOR3:
82 case Property::VECTOR4:
83 case Property::MATRIX3:
84 case Property::MATRIX:
102 PropertyBuffer::PropertyBuffer()
111 PropertyBuffer::~PropertyBuffer()
115 void PropertyBuffer::SetFormat( PropertyBuffer::Format* format )
121 void PropertyBuffer::SetData( Dali::Vector<char>* data, size_t size )
128 bool PropertyBuffer::Update( Context& context )
130 if( !mData || !mFormat || !mSize )
135 if( !mGpuBuffer || mDataChanged )
139 mGpuBuffer = new GpuBuffer( context );
142 // Update the GpuBuffer
145 DALI_ASSERT_DEBUG( mSize && "No data in the property buffer!" );
146 mGpuBuffer->UpdateDataBuffer( GetDataSize(), &((*mData)[0]), GpuBuffer::STATIC_DRAW, GpuBuffer::ARRAY_BUFFER );
149 mDataChanged = false;
155 void PropertyBuffer::BindBuffer(GpuBuffer::Target target)
159 mGpuBuffer->Bind(target);
163 unsigned int PropertyBuffer::EnableVertexAttributes( Context& context, Vector<GLint>& vAttributeLocation, unsigned int locationBase )
166 unsigned int attributeCount = mFormat->components.size();
168 GLsizei elementSize = mFormat->size;
170 for( unsigned int i = 0; i < attributeCount; ++i )
172 GLint attributeLocation = vAttributeLocation[i+locationBase];
173 if( attributeLocation != -1 )
175 context.EnableVertexAttributeArray( attributeLocation );
177 const GLint attributeSize = mFormat->components[i].size;
178 size_t attributeOffset = mFormat->components[i].offset;
179 const Property::Type attributeType = mFormat->components[i].type;
181 context.VertexAttribPointer( attributeLocation,
182 attributeSize / GetPropertyImplementationGlSize(attributeType),
183 GetPropertyImplementationGlType(attributeType),
184 GL_FALSE, // Not normalized
186 (void*)attributeOffset );
190 return attributeCount;