Description
- [ YES] I checked there is no similar issue already reported
- [ YES] I checked the documentation on the wiki
- [ YES] My code has no errors or misuse of raylib
- [ TECNICALLY YES] I tested it on latest raylib version from master branch
Issue description
I was experimenting a bit with GenMeshHeightmap
and noticed that it simply refused to work for Images with the pixelformat PIXELFORMAT_UNCOMPRESSED_R32
. Long story short, I tracked it down:
LoadImageDataNormalized
in rtextures.c
is broken for both PIXELFORMAT_UNCOMPRESSED_R32
and PIXELFORMAT_UNCOMPRESSED_R16
due to k
not being incremented for each pixel. See snippet below:
case PIXELFORMAT_UNCOMPRESSED_R32:
{
pixels[i].x = ((float *)image.data)[k];
pixels[i].y = 0.0f;
pixels[i].z = 0.0f;
pixels[i].w = 1.0f;
} break;
/* ... */
case PIXELFORMAT_UNCOMPRESSED_R16:
{
pixels[i].x = HalfToFloat(((unsigned short *)image.data)[k]);
pixels[i].y = 0.0f;
pixels[i].z = 0.0f;
pixels[i].w = 1.0f;
} break;
This should be:
case PIXELFORMAT_UNCOMPRESSED_R32:
{
pixels[i].x = ((float *)image.data)[k];
pixels[i].y = 0.0f;
pixels[i].z = 0.0f;
pixels[i].w = 1.0f;
k += 1;
} break;
/* ... */
case PIXELFORMAT_UNCOMPRESSED_R16:
{
pixels[i].x = HalfToFloat(((unsigned short *)image.data)[k]);
pixels[i].y = 0.0f;
pixels[i].z = 0.0f;
pixels[i].w = 1.0f;
k += 1;
} break;
I made these changes to the source of raylib 5.0* and tested it with my own little raylib project. It seemed to produce the result I expected. However, with the latest version of raylib (master), I was unable to get my program to run even without the changes. My program would segfault when calling DrawMesh
. I don't know what that is about. I'll leave that one for someone else to figure out.
I might make a pull request if I can make the latest version of raylib work, but if anyone else is tempted to do so before me please go ahead.
* I also had fix LoadImageColors
, which had the same problem. It seems to be fixed in the latest version (master).