3 Commit

Autore SHA1 Messaggio Data
  Ray 43bc00379c removed trailing spaces 1 mese fa
  Ray ba798e9155
Merge pull request #5079 from zet23t/fixing-obj-loader-crash 1 mese fa
  Eike Decker 121c996c6e fixing OBJ loading crash when there are no normals present 1 mese fa
2 ha cambiato i file con 15 aggiunte e 7 eliminazioni
  1. +5
    -5
      src/external/rl_gputex.h
  2. +10
    -2
      src/rmodels.c

+ 5
- 5
src/external/rl_gputex.h Vedi File

@ -585,7 +585,7 @@ int rl_save_ktx(const char *file_name, void *data, int width, int height, int fo
// KTX 2.0: UInt32 supercompressionScheme - 0 (None), 1 (Crunch CRN), 2 (Zlib DEFLATE)...
// KTX 2.0 defines additional header elements...
} ktx_header;
Byte[12] identifier
UInt32 vkFormat
UInt32 typeSize
@ -632,10 +632,10 @@ int rl_save_ktx(const char *file_name, void *data, int width, int height, int fo
header.faces = 1;
header.mipmap_levels = mipmaps; // If it was 0, it means mipmaps should be generated on loading (not for compressed formats)
header.key_value_data_size = 0; // No extra data after the header
// TODO: WARNING: Function dependant on rlgl library!
rlGetGlTextureFormats(format, &header.gl_internal_format, &header.gl_format, &header.gl_type); // rlgl module function
header.gl_base_internal_format = header.gl_format; // TODO: WARNING: KTX 1.1 only
// NOTE: We can save into a .ktx all PixelFormats supported by raylib, including compressed formats like DXT, ETC or ASTC
@ -947,7 +947,7 @@ void get_gl_texture_formats(int format, unsigned int *gl_internal_format, unsign
{
// KTX 1.1 uses OpenGL formats on header info but KTX 2.0 uses Vulkan texture formats,
// if this library is being improved to support KTX 2.0, it requires those formats to be provided -> View list at the end!
/*
*gl_internal_format = 0;
*gl_format = 0;
@ -1023,7 +1023,7 @@ void get_gl_texture_formats(int format, unsigned int *gl_internal_format, unsign
/*
// OpenGL texture data formats
// NOTE: Those values can be useful for KTX 1.1 saving,
// NOTE: Those values can be useful for KTX 1.1 saving,
// probably only the latest OpenGL ones, not the extensions ones
// So, there is no need to include full OpenGL headers
#define GL_UNSIGNED_BYTE 0x1401

+ 10
- 2
src/rmodels.c Vedi File

@ -4473,9 +4473,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 < 3; i++) model.meshes[meshIndex].normals[localMeshVertexCount*3 + i] = objAttributes.normals[normalIndex*3 + i];
for (int i = 0; i < 2; i++) model.meshes[meshIndex].texcoords[localMeshVertexCount*2 + i] = objAttributes.texcoords[texcordIndex*2 + i];
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];
}
else
{
model.meshes[meshIndex].normals[localMeshVertexCount*3 + 0] = 0.0f;
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];

Caricamento…
Annulla
Salva