Fix property buffers data types passed in to GL. 63/39563/3
authorFrancisco Santos <f1.santos@samsung.com>
Mon, 18 May 2015 18:24:50 +0000 (19:24 +0100)
committerFrancisco Santos <f1.santos@samsung.com>
Thu, 21 May 2015 13:12:05 +0000 (14:12 +0100)
Change-Id: I869f7d3a50cab9670c1005c948389991f30a3776

dali/internal/render/renderers/render-renderer-property-buffer.cpp

index 3dfd6e5..c1418db 100644 (file)
@@ -29,7 +29,7 @@ using namespace Dali;
 using Dali::Property;
 using Dali::Internal::PropertyImplementationType;
 
-Dali::GLenum GetPropertyImplementationSize( Property::Type& propertyType )
+Dali::GLenum GetPropertyImplementationGlType( Property::Type& propertyType )
 {
   Dali::GLenum type = GL_BYTE;
 
@@ -40,69 +40,79 @@ Dali::GLenum GetPropertyImplementationSize( Property::Type& propertyType )
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
+    case Property::RECTANGLE:
+    case Property::ROTATION:
     {
-      DALI_ASSERT_ALWAYS( "No type for properties with no type, or dynamic sizes" );
+      // types not supported by gl
       break;
     }
     case Property::BOOLEAN:
     {
-      DALI_ASSERT_ALWAYS( "" );
       type = GL_BYTE;
       break;
     }
     case Property::INTEGER:
-    {
-      type = GL_SHORT;
-      break;
-    }
     case Property::UNSIGNED_INTEGER:
     {
-      type = sizeof( PropertyImplementationType< Property::UNSIGNED_INTEGER >::Type );
+      type = GL_SHORT;
       break;
     }
     case Property::FLOAT:
-    {
-      type = sizeof( PropertyImplementationType< Property::FLOAT >::Type );
-      break;
-    }
     case Property::VECTOR2:
-    {
-      type = sizeof( PropertyImplementationType< Property::VECTOR2 >::Type );
-      break;
-    }
     case Property::VECTOR3:
-    {
-      type = sizeof( PropertyImplementationType< Property::VECTOR3 >::Type );
-      break;
-    }
     case Property::VECTOR4:
+    case Property::MATRIX3:
+    case Property::MATRIX:
     {
-      type = sizeof( PropertyImplementationType< Property::VECTOR4 >::Type );
+      type = GL_FLOAT;
       break;
     }
-    case Property::MATRIX3:
+  }
+
+  return type;
+}
+
+size_t GetPropertyImplementationGlSize( Property::Type& propertyType )
+{
+  size_t size = 1u;
+
+  switch( propertyType )
+  {
+    case Property::NONE:
+    case Property::TYPE_COUNT:
+    case Property::STRING:
+    case Property::ARRAY:
+    case Property::MAP:
+    case Property::RECTANGLE:
+    case Property::ROTATION:
     {
-      type = sizeof( PropertyImplementationType< Property::MATRIX3 >::Type );
+      // types not supported by gl
       break;
     }
-    case Property::MATRIX:
+    case Property::BOOLEAN:
     {
-      type = sizeof( PropertyImplementationType< Property::MATRIX >::Type );
+      size = 1u;
       break;
     }
-    case Property::RECTANGLE:
+    case Property::INTEGER:
+    case Property::UNSIGNED_INTEGER:
     {
-      type = sizeof( PropertyImplementationType< Property::RECTANGLE >::Type );
+      size = 2u;
       break;
     }
-    case Property::ROTATION:
+    case Property::FLOAT:
+    case Property::VECTOR2:
+    case Property::VECTOR3:
+    case Property::VECTOR4:
+    case Property::MATRIX3:
+    case Property::MATRIX:
     {
-      type = sizeof( PropertyImplementationType< Property::ROTATION >::Type );
+      size = 4u;
       break;
     }
   }
 
-  return type;
+  return size;
 }
 
 void UploadAttribute( Dali::Internal::Context& context,
@@ -114,8 +124,8 @@ void UploadAttribute( Dali::Internal::Context& context,
 {
   // TODO: MESH_REWORK  Matrices need multiple calls to this function
   context.VertexAttribPointer( attributeLocation,
-                               attributeSize  / sizeof(Dali::Internal::GetPropertyImplementationSize(attributeType)),
-                               GL_FLOAT, // TODO: MESH_REWORK get the correct type
+                               attributeSize  / GetPropertyImplementationGlSize(attributeType),
+                               GetPropertyImplementationGlType(attributeType),
                                GL_FALSE,  // Not normalized
                                elementSize,
                                (void*)attributeOffset );