external c-sources updated
This commit is contained in:
parent
2ad5a4babf
commit
a0882a5b81
13 changed files with 7674 additions and 4241 deletions
17
raylib/external/rl_gputex.h
vendored
17
raylib/external/rl_gputex.h
vendored
|
@ -171,6 +171,10 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
|
||||
*width = header->width;
|
||||
*height = header->height;
|
||||
|
||||
if (*width % 4 != 0) LOG("WARNING: IMAGE: DDS file width must be multiple of 4. Image will not display correctly");
|
||||
if (*height % 4 != 0) LOG("WARNING: IMAGE: DDS file height must be multiple of 4. Image will not display correctly");
|
||||
|
||||
image_pixel_size = header->width*header->height;
|
||||
|
||||
if (header->mipmap_count == 0) *mips = 1; // Parameter not used
|
||||
|
@ -181,6 +185,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
if (header->ddspf.flags == 0x40) // No alpha channel
|
||||
{
|
||||
int data_size = image_pixel_size*sizeof(unsigned short);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
@ -192,6 +197,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
if (header->ddspf.a_bit_mask == 0x8000) // 1bit alpha
|
||||
{
|
||||
int data_size = image_pixel_size*sizeof(unsigned short);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
@ -211,6 +217,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
else if (header->ddspf.a_bit_mask == 0xf000) // 4bit alpha
|
||||
{
|
||||
int data_size = image_pixel_size*sizeof(unsigned short);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
@ -232,6 +239,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
else if ((header->ddspf.flags == 0x40) && (header->ddspf.rgb_bit_count == 24)) // DDS_RGB, no compressed
|
||||
{
|
||||
int data_size = image_pixel_size*3*sizeof(unsigned char);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
@ -241,6 +249,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
else if ((header->ddspf.flags == 0x41) && (header->ddspf.rgb_bit_count == 32)) // DDS_RGBA, no compressed
|
||||
{
|
||||
int data_size = image_pixel_size*4*sizeof(unsigned char);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
@ -261,9 +270,11 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
}
|
||||
else if (((header->ddspf.flags == 0x04) || (header->ddspf.flags == 0x05)) && (header->ddspf.fourcc > 0)) // Compressed
|
||||
{
|
||||
// NOTE: This forces only 1 mipmap to be loaded which is not really correct but it works
|
||||
int data_size = (header->pitch_or_linear_size < file_size - 0x80) ? header->pitch_or_linear_size : file_size - 0x80;
|
||||
*mips = 1;
|
||||
int data_size = 0;
|
||||
|
||||
// Calculate data size, including all mipmaps
|
||||
if (header->mipmap_count > 1) data_size = header->pitch_or_linear_size + header->pitch_or_linear_size / 3;
|
||||
else data_size = header->pitch_or_linear_size;
|
||||
|
||||
image_data = RL_MALLOC(data_size*sizeof(unsigned char));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue