2010-06-18 2 views
0

Première fois en posant une question ici mais en regardant d'autres réponses pendant un moment. Ma propre question en est une pour améliorer les performances de mon programme.OpenGLES - Rendre une image d'arrière-plan une seule fois et ne pas l'effacer

Actuellement, j'efface le viewFrameBuffer à chaque passage dans mon programme, puis je rends l'image d'arrière-plan suivie du reste de ma scène. Je me demandais comment je faisais pour rendre l'image d'arrière-plan une fois, et seulement essuyer le reste de la scène pour la mise à jour/re-rendu.

J'ai essayé d'utiliser un tampon séparé mais je ne suis pas sûr comment présenter ce nouveau tampon au tampon de rendu.

// 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]; 

Espérons que la résolution de ce que je vais aussi être en mesure de mettre en œuvre un autre tampon juste pour le rendu des particules que je peux les mettre à toujours utiliser un fond noir comme source alpha. Toute aide est grandement appréciée

+0

Quel problème de performances tentez-vous de résoudre? Si votre arrière-plan n'est pas particulièrement coûteux à dessiner (c'est-à-dire qu'il n'est pas construit à partir de tout un ensemble de pièces composées ensemble), vous ne verrez pas de gains de performance en faisant cela. – Pivot

Répondre

0

Si vous voulez dessiner un tampon dans un autre, cela signifie que le premier tampon doit être une texture, de sorte que vous pouvez dessiner un quadmap mappé de texture dans l'autre tampon. Si vous avez l'arrière-plan en tant que texture (le plus probable), alors ayez cette texture, et une autre texture (dessinée avec un FBO) avec le contenu (particules, etc.) et dessinez-les ensemble pour composer la scène finale en l'écran.

Questions connexes