MrOzBarry wrote:
What is your hardware and operating system?
OS: Slackware Linux 13.1
Kernel: 2.6.33.4-smp (stock Slackware kernel)
Video card: ATI Radeon HD 4670 with 1Gb ram
Video Driver: ATI Catalyst v10.8
And if it matters:
Motherboard: Gigabyte GA-MA790X-UD4P with BIOS version F10a
CPU: AMD Phenom™ 9750 Quad-Core Processor stepping 03
RAM: 4Gb
Also, I was trying to track this down last night and started with the testdraw2 program in the test directory. It works, so I kept stripping out features from it until it broke. What I found is that if I run an event loop, everything seems to be fine, but if I just do a one shot render and then pause, the render doesn’t always work.
In fact, I found that if I simply add 2 more calls to SDL_RenderPresent() before calling SDL_SetRenderDrawColor and SDL_RenderClear, then the program works about 50% of the time. Adding 4 extra SDL_RenderPresent calls makes the program seem to work all the time.
I recompiled SDL without optimization and tried debugging it. Everything seemed OK to me, but it was 4am and I really don’t know anything about X programming, so I could easily have missed something.
I’m going to try updating my video driver today, since I see there’s newer version available now. Maybe it’s just something going on in X. The intermittent nature of the problem makes me think it’s either some sort of timing issue, or perhaps uninitialized data somewhere, though.
Here’s the test program I’m using. I started with the example from http://wiki.libsdl.org/moin.cgi/SDL_RenderPresent
Code:
#include “SDL.h”
#define USEREPEAT
/* Adding a few more SDL_RenderPresent calls makes the window render correctly,
but only most of the times. Sometimes it still fails.
/
#ifdef USEREPEAT
int main(int argc, char* argv)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) return 1;
SDL_Window* window =
SDL_CreateWindow(“SDL_RenderClear”,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
512, 512,
SDL_WINDOW_SHOWN);
SDL_CreateRenderer(window, -1, 0);
/* Add a couple of SDL_RenderPresent calls and it works about half the time.
Four more calls and it seems reliable.
*/
SDL_RenderPresent();
SDL_RenderPresent();
SDL_SetRenderDrawColor(255, 0, 0, 0);
SDL_RenderClear();
SDL_RenderPresent();
SDL_Delay(2000);
SDL_Quit();
return 0;
}
#endif
/* Run in a loop and everything seems to work, although I suspect what
is happening is that the loop simply causes enough updates to be
performed that the updates which fail are no longer on screen long
enough to see.
Need to examine this more.
/
#ifdef USELOOP
int main(int argc, char* argv)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) return 1;
SDL_Window* window =
SDL_CreateWindow(“SDL_RenderClear”,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
512, 512,
SDL_WINDOW_SHOWN);
SDL_CreateRenderer(window, -1, 0);
int done = 0;
while (!done) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_CLOSE:
done = 1;
break;
}
break;
}
}
SDL_SetRenderDrawColor(255, 0, 0, 0);
SDL_RenderClear();
SDL_RenderPresent();
}
// Always be sure to clean up
SDL_Quit();
return 0;
}
#endif