-
Notifications
You must be signed in to change notification settings - Fork 4
10. Creating a framebuffer
To create a framebuffer, renderXF needs two things: the main renderXF instance (GL) and the stride (myStride) for each pixel of the frame buffer.
GLFrameBuffer myFrameBuffer = new GLFrameBuffer(GL, myStride);
As GLFrameBuffers take the renderXF instance, the framebuffer is resized automatically whenever the viewport is resized via SetViewportSize()
.
It is also possible to get the true memory address via the GetAddress()
function.
IntPtr addr = myFrameBuffer.GetAddress();
//Please Ensure The Correct Type Is Used (float, int, char, byte)!
void* vaddr = (void*)myFrameBuffer.GetAddress();
WARNING: THIS ADDRESS CHANGES WHENEVER THE FRAMEBUFFER IS RESIZED BY Resize()
OR SetViewportSize()
. It will have to be retaken everytime the framebuffer size is changed.
To clear a GLFrameBuffer, just the the Clear()
function from the renderX instance:
GL.Clear(myFrameBuffer);
If for whatever reason, the framebuffer needs to be a different size than the viewport, the Resize()
function can change the resolution of the framebuffer. However, it cannot change the stride.
myFrameBuffer.Resize(Width, Height);
WARNING: Unless the framebuffer is first unlinked from the renderX instance, it will automatically be resized upon viewport size change.
If for whatever reason, the framebuffer needs to be independent of the main renderX instance, it can be unlinked from the main instance through the main instance's UnBindFrameBuffer()
function. It can be relinked via the BindFrameBuffer()
function.
//Unlinking The Framebuffer:
GL.UnBindFrameBuffer(myFrameBuffer);
//Linking The Framebuffer:
GL.BindFrameBuffer(myFrameBuffer);
- Initializing the renderer
- Setting the transform data
- Blitting and clearing the viewport
- Initializing a vertex buffer
- Creating a shader
- Drawing an object
- Screen space shaders
- Blitting bitmaps
- Loading a texture
- Creating a framebuffer
- Displaying a texture