MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _initVerticesFormat

Method _initVerticesFormat

Engine/source/gfx/gl/gfxGLVertexDecl.cpp:96–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void GFXGLVertexDecl::_initVerticesFormat(U32 stream)
97{
98 U32 buffer = 0;
99 U32 vertexSize = 0;
100
101 for ( U32 i=0; i < mFormat->getElementCount(); i++ )
102 {
103 const GFXVertexElement &element = mFormat->getElement( i );
104
105 if(element.getStreamIndex() != stream)
106 continue;
107
108 AssertFatal(!mFormat->hasBlendIndices() || !element.isSemantic(GFXSemantic::TEXCOORD) || (mFormat->hasBlendIndices() && element.isSemantic(GFXSemantic::TEXCOORD) && element.getSemanticIndex() < 2), "skinning with more than 2 used texcoords!");
109
110 vertexSize += element.getSizeInBytes();
111 }
112
113 // Loop thru the vertex format elements adding the array state...
114 U32 texCoordIndex = 0;
115 for ( U32 i=0; i < mFormat->getElementCount(); i++ )
116 {
117 const GFXVertexElement &element = mFormat->getElement( i );
118
119 if(element.getStreamIndex() != stream)
120 continue;
121
122 glVerticesFormat.increment();
123 glVertexAttribData &glElement = glVerticesFormat.last();
124 glElement.stream = element.getStreamIndex();
125
126 if ( element.isSemantic( GFXSemantic::POSITION ) )
127 {
128 glElement.attrIndex = Torque::GL_VertexAttrib_Position;
129 glElement.elementCount = element.getSizeInBytes() / 4;
130 glElement.normalized = false;
131 glElement.type = GL_FLOAT;
132 glElement.stride = vertexSize;
133 glElement.pointerFirst = (void*)(uintptr_t)buffer;
134
135 buffer += element.getSizeInBytes();
136 }
137 else if ( element.isSemantic( GFXSemantic::NORMAL ) )
138 {
139 glElement.attrIndex = Torque::GL_VertexAttrib_Normal;
140 glElement.elementCount = 3;
141 glElement.normalized = false;
142 glElement.type = GL_FLOAT;
143 glElement.stride = vertexSize;
144 glElement.pointerFirst = (void*)(uintptr_t)buffer;
145
146 buffer += element.getSizeInBytes();
147 }
148 else if ( element.isSemantic( GFXSemantic::TANGENT ) )
149 {
150 glElement.attrIndex = Torque::GL_VertexAttrib_Tangent;
151 glElement.elementCount = 3;
152 glElement.normalized = false;
153 glElement.type = GL_FLOAT;

Callers

nothing calls this directly

Calls 11

getMaxFunction · 0.85
getStreamIndexMethod · 0.80
hasBlendIndicesMethod · 0.80
isSemanticMethod · 0.80
getSemanticIndexMethod · 0.80
incrementMethod · 0.80
getElementCountMethod · 0.45
getElementMethod · 0.45
getSizeInBytesMethod · 0.45
lastMethod · 0.45
getSemanticMethod · 0.45

Tested by

no test coverage detected