Hello, first time asking a question here but been watching others answers for a while. My own question is one for improving the performance of my program.
Currently I'm wiping the viewFrameBuffer on each pass through my program and then rendering the background image first followed by the rest of my scene. I was wondering how I go about rendering the background image once, and only wiping the rest of the scene for updating/re-rendering.
I tried using a seperate buffer but I'm not sure how to present this new buffer to the render buffer.
// Set the current EAGLContext and bind to the framebuffer. This will direct all OGL commands to the
// framebuffer and the associated renderbuffer attachment which is where our scene will be rendered
[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
// Define the viewport. Changing the settings for the viewport can allow you to scale the viewport
// as well as the dimensions etc and so I'm setting it for each frame in case we want to change i
glViewport(0, 0, screenBounds.size.width , screenBounds.size.height);
// Clear the screen. If we are going to draw a background image then this clear is not necessary
// as drawing the background image will destroy the previous image
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Setup how the images are to be blended when rendered. This could be changed at different points during your
// render process if you wanted to apply different effects
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
switch (currentViewInt) {
case 1:
{
[background render:CGPointMake(240, 0) fromTopLeftBottomRightCenter:@"Bottom"];
// Other Rendering Code
}}
// Bind to the renderbuffer and then present this image to the current context
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
Hopefully by solving this I'll also be able to implement another buffer just for rendering particles as I can set them to always use a black background as their alpha source. Any help is greatly appreciated