Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ CORE = \
core/core_3d_camera_mode \
core/core_3d_camera_split_screen \
core/core_3d_picking \
core/core_3d_fixed_function_didactic \
core/core_3d_camera_view_opengl11 \
core/core_3d_camera_view_opengl33 \
core/core_automation_events \
core/core_basic_screen_manager \
core/core_basic_window \
Expand Down
382 changes: 382 additions & 0 deletions examples/core/core_3d_camera_view_opengl11.c

Large diffs are not rendered by default.

Binary file added examples/core/core_3d_camera_view_opengl11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
407 changes: 407 additions & 0 deletions examples/core/core_3d_camera_view_opengl33.c

Large diffs are not rendered by default.

Binary file added examples/core/core_3d_camera_view_opengl33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
852 changes: 852 additions & 0 deletions examples/core/core_3d_fixed_function_didactic.c

Large diffs are not rendered by default.

Binary file added examples/core/core_3d_fixed_function_didactic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions examples/core/resources/models/unit_cube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
o unit_cube
v -0.5 -0.5 -0.5
v 0.5 -0.5 -0.5
v 0.5 0.5 -0.5
v -0.5 0.5 -0.5
v -0.5 -0.5 0.5
v 0.5 -0.5 0.5
v 0.5 0.5 0.5
v -0.5 0.5 0.5
#comment these out to compare opengl11 planar auto fill with just using this and opengl33
vt 0.0 0.0
vt 1.0 0.0
vt 1.0 1.0
vt 0.0 1.0
s off
f 1/1 4/4 3/3
f 1/1 3/3 2/2
f 5/1 6/2 7/3
f 5/1 7/3 8/4
f 1/1 5/1 8/4
f 1/1 8/4 4/4
f 2/2 3/3 7/3
f 2/2 7/3 6/2
f 4/4 8/4 7/3
f 4/4 7/3 3/3
f 1/1 2/2 6/2
f 1/1 6/2 5/1
172 changes: 172 additions & 0 deletions examples/core/resources/models/unit_sphere.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
o unit_sphere
v 0.0000 0.5000 0.0000
v 0.1913 0.4619 0.0000
v 0.1353 0.4619 0.1353
v 0.0000 0.4619 0.1913
v -0.1353 0.4619 0.1353
v -0.1913 0.4619 0.0000
v -0.1353 0.4619 -0.1353
v -0.0000 0.4619 -0.1913
v 0.1353 0.4619 -0.1353
v 0.3536 0.3536 0.0000
v 0.2500 0.3536 0.2500
v 0.0000 0.3536 0.3536
v -0.2500 0.3536 0.2500
v -0.3536 0.3536 0.0000
v -0.2500 0.3536 -0.2500
v -0.0000 0.3536 -0.3536
v 0.2500 0.3536 -0.2500
v 0.4619 0.1913 0.0000
v 0.3266 0.1913 0.3266
v 0.0000 0.1913 0.4619
v -0.3266 0.1913 0.3266
v -0.4619 0.1913 0.0000
v -0.3266 0.1913 -0.3266
v -0.0000 0.1913 -0.4619
v 0.3266 0.1913 -0.3266
v 0.5000 0.0000 0.0000
v 0.3536 0.0000 0.3536
v 0.0000 0.0000 0.5000
v -0.3536 0.0000 0.3536
v -0.5000 0.0000 0.0000
v -0.3536 0.0000 -0.3536
v -0.0000 0.0000 -0.5000
v 0.3536 0.0000 -0.3536
v 0.4619 -0.1913 0.0000
v 0.3266 -0.1913 0.3266
v 0.0000 -0.1913 0.4619
v -0.3266 -0.1913 0.3266
v -0.4619 -0.1913 0.0000
v -0.3266 -0.1913 -0.3266
v -0.0000 -0.1913 -0.4619
v 0.3266 -0.1913 -0.3266
v 0.3536 -0.3536 0.0000
v 0.2500 -0.3536 0.2500
v 0.0000 -0.3536 0.3536
v -0.2500 -0.3536 0.2500
v -0.3536 -0.3536 0.0000
v -0.2500 -0.3536 -0.2500
v -0.0000 -0.3536 -0.3536
v 0.2500 -0.3536 -0.2500
v 0.1913 -0.4619 0.0000
v 0.1353 -0.4619 0.1353
v 0.0000 -0.4619 0.1913
v -0.1353 -0.4619 0.1353
v -0.1913 -0.4619 0.0000
v -0.1353 -0.4619 -0.1353
v -0.0000 -0.4619 -0.1913
v 0.1353 -0.4619 -0.1353
v 0.0000 -0.5000 0.0000
s off
f 1 3 2
f 1 4 3
f 1 5 4
f 1 6 5
f 1 7 6
f 1 8 7
f 1 9 8
f 1 2 9
f 2 3 10
f 3 11 10
f 3 4 11
f 4 12 11
f 4 5 12
f 5 13 12
f 5 6 13
f 6 14 13
f 6 7 14
f 7 15 14
f 7 8 15
f 8 16 15
f 8 9 16
f 9 17 16
f 9 2 17
f 2 10 17
f 10 11 18
f 11 19 18
f 11 12 19
f 12 20 19
f 12 13 20
f 13 21 20
f 13 14 21
f 14 22 21
f 14 15 22
f 15 23 22
f 15 16 23
f 16 24 23
f 16 17 24
f 17 25 24
f 17 10 25
f 10 18 25
f 18 19 26
f 19 27 26
f 19 20 27
f 20 28 27
f 20 21 28
f 21 29 28
f 21 22 29
f 22 30 29
f 22 23 30
f 23 31 30
f 23 24 31
f 24 32 31
f 24 25 32
f 25 33 32
f 25 18 33
f 18 26 33
f 26 27 34
f 27 35 34
f 27 28 35
f 28 36 35
f 28 29 36
f 29 37 36
f 29 30 37
f 30 38 37
f 30 31 38
f 31 39 38
f 31 32 39
f 32 40 39
f 32 33 40
f 33 41 40
f 33 26 41
f 26 34 41
f 34 35 42
f 35 43 42
f 35 36 43
f 36 44 43
f 36 37 44
f 37 45 44
f 37 38 45
f 38 46 45
f 38 39 46
f 39 47 46
f 39 40 47
f 40 48 47
f 40 41 48
f 41 49 48
f 41 34 49
f 34 42 49
f 42 43 50
f 43 51 50
f 43 44 51
f 44 52 51
f 44 45 52
f 45 53 52
f 45 46 53
f 46 54 53
f 46 47 54
f 47 55 54
f 47 48 55
f 48 56 55
f 48 49 56
f 49 57 56
f 49 42 57
f 42 50 57
f 58 50 51
f 58 51 52
f 58 52 53
f 58 53 54
f 58 54 55
f 58 55 56
f 58 56 57
f 58 57 50
13 changes: 5 additions & 8 deletions src/rmodels.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
#define GL_COLOR_ARRAY 0x8076
#define GL_TEXTURE_COORD_ARRAY 0x8078

rlEnableTexture(material.maps[MATERIAL_MAP_DIFFUSE].texture.id);
if (mesh.texcoords && material.maps[MATERIAL_MAP_DIFFUSE].texture.id > 0) rlEnableTexture(material.maps[MATERIAL_MAP_DIFFUSE].texture.id);

if (mesh.animVertices) rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.animVertices);
else rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.vertices);
Expand Down Expand Up @@ -4434,10 +4434,12 @@ 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].texcoords = (float *)MemAlloc(sizeof(float)*vertexCount*2);
model.meshes[i].colors = (unsigned char *)MemAlloc(sizeof(unsigned char)*vertexCount*4);
#else
if (objAttributes.texcoords != NULL && objAttributes.num_texcoords > 0) model.meshes[i].texcoords = (float *)MemAlloc(sizeof(float)*vertexCount*2);
else model.meshes[i].texcoords = NULL;
model.meshes[i].colors = NULL;
#endif
}
Expand Down Expand Up @@ -4493,16 +4495,11 @@ 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];

if ((objAttributes.texcoords != NULL) && (texcordIndex != TINYOBJ_INVALID_INDEX) && (texcordIndex >= 0))
if ((objAttributes.texcoords != NULL) && (texcordIndex != TINYOBJ_INVALID_INDEX) && (texcordIndex >= 0) && (model.meshes[meshIndex].texcoords))
{
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))
{
Expand Down
Loading