LoadTexture pipeline
LoadTexture("sprite.png")
│
├─► LoadFileData() [rcore.c — fopen entire file]
│
├─► LoadImageFromMemory() [extension → stb_image / qoi / …]
│ Image { data, width, height, format, mipmaps }
│
├─► LoadTextureFromImage()
│ texture.id = rlLoadTexture(data, w, h, format, mipmaps)
│
└─► UnloadImage() [RL_FREE CPU buffer]
Image — CPU memory
typedef struct Image {
void *data;
int width, height, mipmaps, format; // PixelFormat enum
} Image;
Procedural generators: GenImageColor, GenImagePerlinNoise, etc. CPU filters: ImageResize, ImageBlurGaussian, ImageFormat conversion.
Texture2D — GPU handle
typedef struct Texture {
unsigned int id; // OpenGL texture name
int width, height, mipmaps, format;
} Texture2D;
rlLoadTexture checks GPU format support (RLGL.ExtSupported) before upload. Unsupported compressed formats log a warning and return id 0.
DrawTexturePro → batch
Builds four corners (with rotation), sets rlSetTexture(texture.id), emits quad to batch. Skips draw if texture.id == 0.
RenderTexture2D (FBO)
BeginTextureMode enables framebuffer, sets orthographic projection to texture size, updates CORE.Window.currentFbo. Drawing goes to GPU texture attachment instead of screen until EndTextureMode.
File format flags (config.h)
Enabled by default: PNG, BMP, GIF, QOI, DDS. Disabled by default: JPG, TGA, HDR, ASTC, KTX. Strip formats at compile time with -DSUPPORT_FILEFORMAT_JPG=1 or CMake CUSTOMIZE_BUILD=ON.
Override file I/O
SetLoadFileDataCallback lets embedded targets load from APK/assets or packfiles without changing rtextures code. Android CMake link flag: -Wl,--wrap=fopen.