1 // 2 // Copyright 2014 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // Implementation of the state class for mananging GLES 3 Vertex Array Objects. 7 // 8 9 #include "libGLESv2/VertexAttribute.h" 10 11 namespace gl 12 { 13 14 VertexAttribute::VertexAttribute() 15 : enabled(false), 16 type(GL_FLOAT), 17 size(4), 18 normalized(false), 19 pureInteger(false), 20 stride(0), 21 pointer(NULL), 22 divisor(0) 23 { 24 } 25 26 size_t ComputeVertexAttributeTypeSize(const VertexAttribute& attrib) 27 { 28 GLuint size = attrib.size; 29 switch (attrib.type) 30 { 31 case GL_BYTE: return size * sizeof(GLbyte); 32 case GL_UNSIGNED_BYTE: return size * sizeof(GLubyte); 33 case GL_SHORT: return size * sizeof(GLshort); 34 case GL_UNSIGNED_SHORT: return size * sizeof(GLushort); 35 case GL_INT: return size * sizeof(GLint); 36 case GL_UNSIGNED_INT: return size * sizeof(GLuint); 37 case GL_INT_2_10_10_10_REV: return 4; 38 case GL_UNSIGNED_INT_2_10_10_10_REV: return 4; 39 case GL_FIXED: return size * sizeof(GLfixed); 40 case GL_HALF_FLOAT: return size * sizeof(GLhalf); 41 case GL_FLOAT: return size * sizeof(GLfloat); 42 default: UNREACHABLE(); return size * sizeof(GLfloat); 43 } 44 } 45 46 size_t ComputeVertexAttributeStride(const VertexAttribute& attrib) 47 { 48 if (!attrib.enabled) 49 { 50 return 16; 51 } 52 return attrib.stride ? attrib.stride : ComputeVertexAttributeTypeSize(attrib); 53 } 54 55 }