The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Flickering in SDL 2.0 OpenGL when rendering full screen
Ladar


Joined: 17 Aug 2015
Posts: 1
So I've got a loop and all it does is clear the OpenGL buffer to White and that's it. If I do this fullscreen on several computers the screen will Flash Black. It looks like it's dropping frames or something. If it is Windowed it is fine, and if I define the resolution of the full screen window it's... for lack of a better word less likely to look like it's dropping frames. I think it's a syncing issue. Can anyone provide help to diagnose the issue. Code is below.




int CApp::OnExecute() {
if (OnInit() == false) {
return -1;
}

SDL_Event Event;

while (Running) {

while (SDL_PollEvent(&Event)) {
OnEvent(&Event);
}


OnLoop();
OnRender();

}

OnCleanup();

return 0;
}

Seen here

The render is simply


void CApp::OnRender() {

glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapWindow(gWindow);



}

And on loop is blank

void CApp::OnLoop() {
return;

}


I Init the window with;

bool CApp::OnInit() {

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, Cool;
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, Cool;
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, Cool;
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, Cool;


SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, Cool;


SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);



SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16);

//Use OpenGL 3.1 core
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);





//Create window

gWindow = SDL_CreateWindow("Afterlife Empire",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
0, 0,
SDL_WINDOW_FULLSCREEN_DESKTOP);

gContext = SDL_GL_CreateContext(gWindow);
if (gContext == NULL)
{
printf("OpenGL context could not be created! SDL Error: %s\n", SDL_GetError());

}
else
{
//Initialize GLEW
glewExperimental = GL_TRUE;
GLenum glewError = glewInit();
if (glewError != GLEW_OK)
{
printf("Error initializing GLEW! %s\n", glewGetErrorString(glewError));
}

//Use Vsync
if (SDL_GL_SetSwapInterval(1) < 0)
{
printf("Warning: Unable to set VSync! SDL Error: %s\n", SDL_GetError());
}


}




glEnable(GL_MULTISAMPLE);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);

}