впервые задаю вопрос здесь, но некоторое время смотрел ответы других. Мой собственный вопрос касается повышения производительности моей программы.
В настоящее время я вытираю viewFrameBuffer при каждом проходе через мою программу, а затем сначала отрисовываю фоновое изображение, а затем остальную часть моей сцены. Мне было интересно, как мне сделать рендеринг фонового изображения один раз, и только стирать оставшуюся часть сцены для обновления / повторного рендеринга.
Я пытался использовать отдельный буфер, но я не уверен, как представить этот новый буфер в буфер рендеринга.
// 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];
Надеюсь, что, решив это, я также смогу реализовать еще один буфер для рендеринга частиц, так как я могу настроить их на использование черного фона в качестве альфа-источника. Любая помощь с благодарностью