[rTextures] Add LoadRenderTextureEx with user defined format (#6114)

* Add LoadRenderTextureEx that defines the FBO pixel format

* rlparser: update raylib_api.* by CI

* requested review

* rlparser: update raylib_api.* by CI

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Jeffery Myers
2026-09-02 00:42:56 -07:00
committed by GitHub
parent 237c1f85dd
commit 5a433a51a3
7 changed files with 298 additions and 236 deletions

View File

@@ -1461,6 +1461,7 @@ RLAPI Texture2D LoadTexture(const char *fileName);
RLAPI Texture2D LoadTextureFromImage(Image image); // Load texture from image data
RLAPI TextureCubemap LoadTextureCubemap(Image image, int layout); // Load cubemap from image, multiple image cubemap layouts supported
RLAPI RenderTexture2D LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer)
RLAPI RenderTexture2D LoadRenderTextureEx(int width, int height, int format); // Load texture for rendering (framebuffer), with specific format
RLAPI bool IsTextureValid(Texture2D texture); // Check if texture is valid (loaded in GPU)
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
RLAPI bool IsRenderTextureValid(RenderTexture2D target); // Check if render texture is valid (loaded in GPU)

View File

@@ -4388,12 +4388,24 @@ TextureCubemap LoadTextureCubemap(Image image, int layout)
return cubemap;
}
// Load texture for rendering (framebuffer)
// NOTE: Render texture is loaded by default with RGBA color attachment and depth RenderBuffer
// Load RGBA texture for rendering (framebuffer)
RenderTexture2D LoadRenderTexture(int width, int height)
{
return LoadRenderTextureEx(width, height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
}
// Load texture for rendering (framebuffer), with specific format
// NOTE: Render texture is loaded by default with RGBA color attachment and depth RenderBuffer
RLAPI RenderTexture2D LoadRenderTextureEx(int width, int height, int format)
{
RenderTexture2D target = { 0 };
if (format >= PIXELFORMAT_COMPRESSED_DXT1_RGB)
{
TRACELOG(LOG_WARNING, "FBO: Render texture format not supported");
return target;
}
target.id = rlLoadFramebuffer(); // Load an empty framebuffer
if (target.id > 0)
@@ -4401,10 +4413,10 @@ RenderTexture2D LoadRenderTexture(int width, int height)
rlEnableFramebuffer(target.id);
// Create color texture (default to RGBA)
target.texture.id = rlLoadTexture(NULL, width, height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
target.texture.id = rlLoadTexture(NULL, width, height, format, 1);
target.texture.width = width;
target.texture.height = height;
target.texture.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
target.texture.format = format;
target.texture.mipmaps = 1;
// Create depth renderbuffer/texture

View File

@@ -9125,6 +9125,25 @@
}
]
},
{
"name": "LoadRenderTextureEx",
"description": "Load texture for rendering (framebuffer), with specific format",
"returnType": "RenderTexture2D",
"params": [
{
"type": "int",
"name": "width"
},
{
"type": "int",
"name": "height"
},
{
"type": "int",
"name": "format"
}
]
},
{
"name": "IsTextureValid",
"description": "Check if texture is valid (loaded in GPU)",

View File

@@ -6536,6 +6536,16 @@ return {
{type = "int", name = "height"}
}
},
{
name = "LoadRenderTextureEx",
description = "Load texture for rendering (framebuffer), with specific format",
returnType = "RenderTexture2D",
params = {
{type = "int", name = "width"},
{type = "int", name = "height"},
{type = "int", name = "format"}
}
},
{
name = "IsTextureValid",
description = "Check if texture is valid (loaded in GPU)",

View File

@@ -4930,6 +4930,14 @@
((type "int") (name "width"))
((type "int") (name "height"))))
((name "LoadRenderTextureEx")
(description "Load texture for rendering (framebuffer), with specific format")
(return-type "RenderTexture2D")
(params
((type "int") (name "width"))
((type "int") (name "height"))
((type "int") (name "format"))))
((name "IsTextureValid")
(description "Check if texture is valid (loaded in GPU)")
(return-type "bool")

File diff suppressed because it is too large Load Diff

View File

@@ -681,7 +681,7 @@
<Param type="unsigned int" name="frames" desc="" />
</Callback>
</Callbacks>
<Functions count="617">
<Functions count="618">
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
<Param type="int" name="width" desc="" />
<Param type="int" name="height" desc="" />
@@ -2306,6 +2306,11 @@
<Param type="int" name="width" desc="" />
<Param type="int" name="height" desc="" />
</Function>
<Function name="LoadRenderTextureEx" retType="RenderTexture2D" paramCount="3" desc="Load texture for rendering (framebuffer), with specific format">
<Param type="int" name="width" desc="" />
<Param type="int" name="height" desc="" />
<Param type="int" name="format" desc="" />
</Function>
<Function name="IsTextureValid" retType="bool" paramCount="1" desc="Check if texture is valid (loaded in GPU)">
<Param type="Texture2D" name="texture" desc="" />
</Function>