@ -1293,10 +1293,19 @@ void UploadMesh(Mesh *mesh, bool dynamic)
rlEnableVertexAttribute ( RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION ) ;
/ / Enable vertex attributes : texcoords ( shader - location = 1 )
mesh - > vboId [ RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD ] = rlLoadVertexBuffer ( mesh - > texcoords , mesh - > vertexCount * 2 * sizeof ( float ) , dynamic ) ;
rlSetVertexAttribute ( RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD , 2 , RL_FLOAT , 0 , 0 , 0 ) ;
rlEnableVertexAttribute ( RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD ) ;
if ( mesh - > texcoords ! = NULL )
{
mesh - > vboId [ RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD ] = rlLoadVertexBuffer ( mesh - > texcoords , mesh - > vertexCount * 2 * sizeof ( float ) , dynamic ) ;
rlSetVertexAttribute ( RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD , 2 , RL_FLOAT , 0 , 0 , 0 ) ;
rlEnableVertexAttribute ( RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD ) ;
}
else
{
float value [ 2 ] = { 0.0f , 0.0f } ;
rlSetVertexAttributeDefault ( RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD , value , SHADER_ATTRIB_VEC2 , 2 ) ;
rlDisableVertexAttribute ( RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD ) ;
}
/ / WARNING : When setting default vertex attribute values , the values for each generic vertex attribute
/ / is part of current state , and it is maintained even if a different program object is used
@ -1431,12 +1440,12 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
if ( mesh . animVertices ) rlEnableStatePointer ( GL_VERTEX_ARRAY , mesh . animVertices ) ;
else rlEnableStatePointer ( GL_VERTEX_ARRAY , mesh . vertices ) ;
rlEnableStatePointer ( GL_TEXTURE_COORD_ARRAY , mesh . texcoords ) ;
k">if ( mesh . texcoords ) rlEnableStatePointer ( GL_TEXTURE_COORD_ARRAY , mesh . texcoords ) ;
if ( mesh . animNormals ) rlEnableStatePointer ( GL_NORMAL_ARRAY , mesh . animNormals ) ;
else rlEnableStatePointer ( GL_NORMAL_ARRAY , mesh . normals ) ;
else if ( mesh . normals ) rlEnableStatePointer( GL_NORMAL_ARRAY , mesh . normals ) ;
rlEnableStatePointer ( GL_COLOR_ARRAY , mesh . colors ) ;
k">if ( mesh . colors ) rlEnableStatePointer ( GL_COLOR_ARRAY , mesh . colors ) ;
rlPushMatrix ( ) ;
rlMultMatrixf ( MatrixToFloat ( transform ) ) ;
@ -3836,6 +3845,7 @@ void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float
/ / Draw a model points
/ / WARNING : OpenGL ES 2.0 does not support point mode drawing
/ / TODO : gate these properly for non es 2.0 versions only
void DrawModelPoints ( Model model , Vector3 position , float scale , Color tint )
{
rlEnablePointMode ( ) ;
@ -4420,7 +4430,11 @@ static Model LoadOBJ(const char *fileName)
model . meshes [ i ] . vertices = ( float * ) MemAlloc ( sizeof ( float ) * vertexCount * 3 ) ;
model . meshes [ i ] . normals = ( float * ) MemAlloc ( sizeof ( float ) * vertexCount * 3 ) ;
model . meshes [ i ] . texcoords = ( float * ) MemAlloc ( sizeof ( float ) * vertexCount * 2 ) ;
# if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
model . meshes [ i ] . colors = ( unsigned char * ) MemAlloc ( sizeof ( unsigned char ) * vertexCount * 4 ) ;
# else
model . meshes [ i ] . colors = NULL ;
# endif
}
MemFree ( localMeshVertexCounts ) ;
@ -4474,7 +4488,17 @@ static Model LoadOBJ(const char *fileName)
for ( int i = 0 ; i < 3 ; i + + ) model . meshes [ meshIndex ] . vertices [ localMeshVertexCount * 3 + i ] = objAttributes . vertices [ vertIndex * 3 + i ] ;
for ( int i = 0 ; i < 2 ; i + + ) model . meshes [ meshIndex ] . texcoords [ localMeshVertexCount * 2 + i ] = objAttributes . texcoords [ texcordIndex * 2 + i ] ;
if ( objAttributes . texcoords ! = NULL & & texcordIndex ! = TINYOBJ_INVALID_INDEX & & texcordIndex > = 0 )
{
for ( int i = 0 ; i < 2 ; i + + ) model . meshes [ meshIndex ] . texcoords [ localMeshVertexCount * 2 + i ] = objAttributes . texcoords [ texcordIndex * 2 + i ] ;
model . meshes [ meshIndex ] . texcoords [ localMeshVertexCount * 2 + 1 ] = 1.0f - model . meshes [ meshIndex ] . texcoords [ localMeshVertexCount * 2 + 1 ] ;
}
else
{
model . meshes [ meshIndex ] . texcoords [ localMeshVertexCount * 2 + 0 ] = 0.0f ;
model . meshes [ meshIndex ] . texcoords [ localMeshVertexCount * 2 + 1 ] = 0.0f ;
}
if ( objAttributes . normals ! = NULL & & normalIndex ! = TINYOBJ_INVALID_INDEX & & normalIndex > = 0 )
{
for ( int i = 0 ; i < 3 ; i + + ) model . meshes [ meshIndex ] . normals [ localMeshVertexCount * 3 + i ] = objAttributes . normals [ normalIndex * 3 + i ] ;
@ -4485,11 +4509,9 @@ static Model LoadOBJ(const char *fileName)
model . meshes [ meshIndex ] . normals [ localMeshVertexCount * 3 + 1 ] = 1.0f ;
model . meshes [ meshIndex ] . normals [ localMeshVertexCount * 3 + 2 ] = 0.0f ;
}
model . meshes [ meshIndex ] . texcoords [ localMeshVertexCount * 2 + 1 ] = 1.0f - model . meshes [ meshIndex ] . texcoords [ localMeshVertexCount * 2 + 1 ] ;
# if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
for ( int i = 0 ; i < 4 ; i + + ) model . meshes [ meshIndex ] . colors [ localMeshVertexCount * 4 + i ] = 255 ;
# endif
faceVertIndex + + ;
localMeshVertexCount + + ;
}