LoadRenderTextureEx
This commit is contained in:
parent
ef5be632fe
commit
19fc92a1d9
|
|
@ -1275,7 +1275,8 @@ RLAPI void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 posi
|
|||
RLAPI Texture2D LoadTexture(const char *fileName); // Load texture from file into GPU memory (VRAM)
|
||||
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 LoadRenderTexture(int width, int height); // Load texture for rendering (framebuffer) with RGBA pixel format and depthbuffer
|
||||
RLAPI RenderTexture2D LoadRenderTextureEx(int width, int height, int format, int useDepth); // Load texture for rendering (framebuffer) with custom pixel format and optional framebuffer
|
||||
RLAPI void UnloadTexture(Texture2D texture); // Unload texture from GPU memory (VRAM)
|
||||
RLAPI void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory (VRAM)
|
||||
RLAPI void UpdateTexture(Texture2D texture, const void *pixels); // Update GPU texture with new data
|
||||
|
|
|
|||
|
|
@ -2967,6 +2967,12 @@ TextureCubemap LoadTextureCubemap(Image image, int layout)
|
|||
// Load texture for rendering (framebuffer)
|
||||
// NOTE: Render texture is loaded by default with RGBA color attachment and depth RenderBuffer
|
||||
RenderTexture2D LoadRenderTexture(int width, int height)
|
||||
{
|
||||
return LoadRenderTextureEx(width, height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
|
||||
}
|
||||
|
||||
// Load texture for rendering (framebuffer)
|
||||
RenderTexture2D LoadRenderTextureEx(int width, int height, int format, int useDepth)
|
||||
{
|
||||
RenderTexture2D target = { 0 };
|
||||
|
||||
|
|
@ -2977,22 +2983,27 @@ 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
|
||||
target.depth.id = rlLoadTextureDepth(width, height, true);
|
||||
target.depth.width = width;
|
||||
target.depth.height = height;
|
||||
target.depth.format = 19; //DEPTH_COMPONENT_24BIT?
|
||||
target.depth.mipmaps = 1;
|
||||
if(useDepth)
|
||||
{
|
||||
target.depth.id = rlLoadTextureDepth(width, height, true);
|
||||
target.depth.width = width;
|
||||
target.depth.height = height;
|
||||
target.depth.format = 19; //DEPTH_COMPONENT_24BIT?
|
||||
target.depth.mipmaps = 1;
|
||||
|
||||
// Attach depth renderbuffer/texture to FBO
|
||||
rlFramebufferAttach(target.id, target.depth.id, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
||||
}
|
||||
|
||||
// Attach color texture and depth renderbuffer/texture to FBO
|
||||
// Attach color texture to FBO
|
||||
rlFramebufferAttach(target.id, target.texture.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||
rlFramebufferAttach(target.id, target.depth.id, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
||||
|
||||
// Check if fbo is complete with attachments (valid)
|
||||
if (rlFramebufferComplete(target.id)) TRACELOG(LOG_INFO, "FBO: [ID %i] Framebuffer object created successfully", target.id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user