The scene flickers if i rotate the camera with the mouse, sometimes if I release the mouse it keeps black until i rotate the camera again. If i release the mouse in a moment where the scene renders correctly, then the next frames are also rendered correctly.
void Graphics_Engine::render(Hex_Board::hex_tile const * const * const tiles_list, uint16_t tiles_count)
{
double x, y, x_i, y_i;
double angle;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
camera->update();
glColor3f( 0.0f, 1.0f, 0.0f);
for (uint16_t i = 0; i < tiles_count; i++)
{
glBegin(GL_LINE_LOOP);
x = sqrt(3.) * (tiles_list[i]->q + tiles_list[i]->r/2.);
y = 3./2. * tiles_list[i]->r;
for (uint8_t i = 0; i < 6; i++)
{
angle = 2. * M_PI / 6. * (i + 0.5);
x_i = x + cos(angle);
y_i = y + sin(angle);
glVertex3f(x_i, y_i, 0);
}
glEnd();
}
SDL_RenderPresent(renderer);
glClear(GL_COLOR_BUFFER_BIT);
}
void Camera::update()
{
gluLookAt(pos[0], pos[1], pos[2],
tar[0], tar[1], tar[2],
up[0], up[1], up[2]);
}