Hi there,
i got problems with my fps using SDL_Flip. Thats the important code
lines:
screen = SDL_SetVideoMode(1024, 768, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
for (; {
if ( gettimeofday(&tv, NULL) < 0 )
log_Error(âCould not get the time of the dayâ, strerror(errno));
if (starttime == 0) starttime = tv.tv_sec;
curtime = (tv.tv_sec - starttime)*1000 + tv.tv_usec/1000;
if (oldtime == 0) oldtime = curtime;
if (oldtime+1000 <= curtime) {
cl_fps = fps;
fps = 0;
oldtime = curtime;
printf(fps: %i\n", cl_fps);
}
SDL_Split();
fps++;
}
With that code, i only get 14 fps on my system, removing SDL_Split(); i
get up to 600000 fps. I really donât get why SDL_Split is so slow, itâs
a hardware surface and it only needs to change the buffers, or do i miss
the point?
mIc
Michael Sauer wrote:
Hi there,
i got problems with my fps using SDL_Flip. Thats the important code
lines:
screen = SDL_SetVideoMode(1024, 768, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
for (; {
if ( gettimeofday(&tv, NULL) < 0 )
log_Error(âCould not get the time of the dayâ, strerror(errno));
if (starttime == 0) starttime = tv.tv_sec;
curtime = (tv.tv_sec - starttime)*1000 + tv.tv_usec/1000;
if (oldtime == 0) oldtime = curtime;
if (oldtime+1000 <= curtime) {
cl_fps = fps;
fps = 0;
oldtime = curtime;
printf(fps: %i\n", cl_fps);
}
SDL_Split();
Do you mean SDL_Flip ?
fps++;
}
With that code, i only get 14 fps on my system, removing SDL_Split(); i
get up to 600000 fps. I really donât get why SDL_Split is so slow, itâs
a hardware surface and it only needs to change the buffers, or do i miss
the point?
Youâre probably running on an unaccelerated platform (X11 maybe ?), so
SDL emulates doublebuffering by copying a shadow surface to the screen
every time you do a SDL_Flip().
Specifying the SDL_HWSURFACE flag wonât get you a hardware surface on
all platforms, only on platforms that support it.
Stephane
â Stephane Marchesin <stephane.marchesin at wanadoo.fr> wrote:
Youâre probably running on an unaccelerated platform (X11 maybe ?),
so SDL emulates doublebuffering by copying a shadow surface to the
screen every time you do a SDL_Flip().
Specifying the SDL_HWSURFACE flag wonât get you a hardware surface
on all platforms, only on platforms that support it.
My code, after calling SDL_SetVideoMode, checks the flags returned
from that call and echos data about the video surface into stdout.
Makes for quick data about the environment if I need to debug.
Itâs my understanding from the list here that most 2d game
applications (for those of us attempting to recapture he glory days
of 8 and 16 bit game consoles ) should be using software
surfaces. Itâs possible to implement the system to use hardware
surfaces, but that greatly limits the target systems and is not
entirely necessary to achieve solid framerates for simpleÂŽ 2d
games. I donât have a lot of practical experience trying to
optomize such things, though (yet), so there is probably someone
here that could tell you more.
NBarnes__________________________________
Do you Yahoo!?
Yahoo! Domains ? Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer
[âŚ]
My code, after calling SDL_SetVideoMode, checks the flags returned
from that call and echos data about the video surface into stdout.
Makes for quick data about the environment if I need to debug.
Itâs my understanding from the list here that most 2d game
applications (for those of us attempting to recapture he glory days
of 8 and 16 bit game consoles ) should be using software
surfaces. Itâs possible to implement the system to use hardware
surfaces, but that greatly limits the target systems and is not
entirely necessary to achieve solid framerates for simpleÂŽ 2d
games. I donât have a lot of practical experience trying to
optomize such things, though (yet), so there is probably someone
here that could tell you more.
NBarnes
jup. even on win32 software surfaces are sometimes faster than hardware
surfaces.