Currently I am porting a bit of openGL code to the raspberry.
To reduce the number of redraws, it won't redraw parts that haven't changed.
Here I have trouble with the raspberry somehow. It seems it is clearing the back buffer with every frame. So stuff I draw one frame is thrown away the next. When I let the openGL code draw everything every frame, all is fine (expect the performance
I created a small code snipplet to demonstrate this:
Code: Select all
#include "lib_instrument.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
int i;
int w = 1920;
int h = 1080;
int x = SDL_WINDOWPOS_CENTERED;
int y = SDL_WINDOWPOS_CENTERED;
SDL_Window* window = NULL;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
log_error("Main", "Unable to initialize SDL Video: %s", SDL_GetError());
return 1;
}
window = SDL_CreateWindow("Air Panel", x, y, w, h, SDL_WINDOW_OPENGL);
SDL_GL_CreateContext(window);
printf("Drawing red\n");
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Screen will indeed become red, all is still fine
for(int i=0; i < 10; i++) {
printf("Swap\n");
SDL_GL_SwapWindow(window);
// Here the screen is black
// I expect it to be black->red->black->red->black etc. here
}
return 0;
}
Kind regards,
Corjan