OpenGL Windowed Garbage (XP SP3)

Hi everyone!

OpenGL in windowed mode interleaves garbage from the screen in the drawing,
so there is a flicker effect where sections of other programs are
momentarily drawn in the OpenGL window. It’s like whatever is in the
current backbuffer is just splashed in screen momentarily. This only
happens in windowed mode. Double buffering is enabled.

Following is the full source code of the init routine:

int init()
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
{
cerr << “Could not initialize SDL.” << endl;
return 1;
}
cout << "Using Audio Driver: " << SDL_GetCurrentAudioDriver() << endl;
cout << "Using Video Driver: " << SDL_GetCurrentVideoDriver() << endl;
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_Rect rect;
rect.x = 0;
rect.h = 0;
rect.w = SCREEN_WIDTH;
rect.h = SCREEN_HEIGHT;
SDL_GetDisplayBounds(0, &rect);
window = SDL_CreateWindow(“Title”,
(rect.w-SCREEN_WIDTH)/2,
(rect.h-SCREEN_HEIGHT)/2,
SCREEN_WIDTH,
SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN );
if(!window)
{
cerr << "Could not initialize Window: " << SDL_GetError() << endl;
return 1;
}
SDL_RendererInfo info;
cout << “Available Render Drivers:\n”;
for(int i = 0; i != SDL_GetNumRenderDrivers(); ++i)
{
if(SDL_GetRenderDriverInfo(i, &info) == 0)
cout << ‘\t’ << i << ") " << info.name << endl;
else
cout << ‘\t’ << i << ") INVALID DRIVER : " << SDL_GetError() << endl;
}
// Try and force an OpenGL driver.
if(!SDL_SetHint(SDL_HINT_RENDER_DRIVER, “opengl”))
cerr << “Couldn’t force OpenGL driver.” << endl;
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1,
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (!renderer)
{
cerr << "Could not create renderer: " << SDL_GetError() << endl;
return 1;
}
// Print out information about the renderer.
RENDERER = renderer;
memset((void*)&info, 0, sizeof(SDL_RendererInfo));
SDL_GetRendererInfo(RENDERER, &info);
cout << "Rendering using " << info.name << endl;
return 0;
}

And the render function is straightforward with only SDL calls (no OpenGL
calls):

void render(SDL_Renderer *renderer)
{
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
// SDL_RenderClear always works here.
//if(
SDL_RenderClear(renderer);
// != 0) cerr << “Failed to clear render target.” << endl;
// Full of SDL calls.
RunRender();
SDL_RenderPresent(renderer);
}

I’ve tried every permutation I could imagine, most just end up in the
renderer just not working. The exact same code runs fine in OSX 10.6, but
on the same machine (macbook pro) running WinXP SP3 it has the ugly
artifacts in windowed mode. I updated the Nvidia drivers, even tried
tweaking some driver settings (triple buffering) but to no avail.

Thanks for your attention. Any thoughts?

Hi everyone!

OpenGL in windowed mode interleaves garbage from the screen in the
drawing, so there is a flicker effect where sections of other programs are
momentarily drawn in the OpenGL window. It’s like whatever is in the
current backbuffer is just splashed in screen momentarily. This only
happens in windowed mode. Double buffering is enabled.

Following is the full source code of the init routine:

int init()
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
{
cerr << “Could not initialize SDL.” << endl;
return 1;
}
cout << "Using Audio Driver: " << SDL_GetCurrentAudioDriver() << endl;
cout << "Using Video Driver: " << SDL_GetCurrentVideoDriver() << endl;
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_Rect rect;
rect.x = 0;
rect.h = 0;
rect.w = SCREEN_WIDTH;
rect.h = SCREEN_HEIGHT;
SDL_GetDisplayBounds(0, &rect);
window = SDL_CreateWindow(“Title”,
(rect.w-SCREEN_WIDTH)/2,
(rect.h-SCREEN_HEIGHT)/2,
SCREEN_WIDTH,
SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN );
if(!window)
{
cerr << "Could not initialize Window: " << SDL_GetError() << endl;
return 1;
}
SDL_RendererInfo info;
cout << “Available Render Drivers:\n”;
for(int i = 0; i != SDL_GetNumRenderDrivers(); ++i)
{
if(SDL_GetRenderDriverInfo(i, &info) == 0)
cout << ‘\t’ << i << ") " << info.name << endl;
else
cout << ‘\t’ << i << ") INVALID DRIVER : " << SDL_GetError() << endl;
}
// Try and force an OpenGL driver.
if(!SDL_SetHint(SDL_HINT_RENDER_DRIVER, “opengl”))
cerr << “Couldn’t force OpenGL driver.” << endl;
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1,
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (!renderer)
{
cerr << "Could not create renderer: " << SDL_GetError() << endl;
return 1;
}
// Print out information about the renderer.
RENDERER = renderer;
memset((void*)&info, 0, sizeof(SDL_RendererInfo));
SDL_GetRendererInfo(RENDERER, &info);
cout << "Rendering using " << info.name << endl;
return 0;
}

And the render function is straightforward with only SDL calls (no OpenGL
calls):

void render(SDL_Renderer *renderer)
{
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
// SDL_RenderClear always works here.
//if(
SDL_RenderClear(renderer);
// != 0) cerr << “Failed to clear render target.” << endl;
// Full of SDL calls.
RunRender();
SDL_RenderPresent(renderer);
}

I’ve tried every permutation I could imagine, most just end up in the
renderer just not working. The exact same code runs fine in OSX 10.6, but
on the same machine (macbook pro) running WinXP SP3 it has the ugly
artifacts in windowed mode. I updated the Nvidia drivers, even tried
tweaking some driver settings (triple buffering) but to no avail.

Running XP SP3 on a macbook pro? Are you using any kind of emulation? If
so, I’d sooner guess that this was an issue with the virtualized graphics
card driver.On Thu, Nov 24, 2011 at 8:18 AM, Jeremy Jurksztowicz <jurksztowicz at gmail.com wrote:

Thanks for your attention. Any thoughts?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org