SDLu, was time stamped events, was Detecting Double Clicks

Actually, after further thought, SDL_GetTicksSince() is rather trivial and
people are going to argue that because of that, it shouldn’t be in the SDL.

Uint32 SDL_GetTicksSince(Uint32 timestamp)
{
/* ha to all you C Programmers your ‘{’ should be on a new line…
READABILITY FIRST */
Uint32 currentTime = SDL_GetTicks();
if (currentTime > timestamp)
return currentTime - timestamp;
return (0xFFFFFFFF - timestamp) + currentTime;
}

This way, you could decide to reset your base time (timestamp) on your own.
I understand that you don’t want to bulk the library with such basic
functions, but sometimes it’s just nice to be kind to newbies ;)… or
perhaps make libSDLu (the SDL utility library). OpenGL has one of these
that contains functions that could totally be accomplished using just
OpenGL, but they are more ‘user-friendly’.

Sam, could I get the rights to produce a library called SDLu? LGPLed (of
course). I know you typically don’t want people using the SDL name for a
3rd party library. It would contain such functions. I wouldn’t even start
the functions with names like ‘SDL_’… they’d be ‘SDLu_’

If I get the rights (even if I don’t, I’ll call it something else), what
other functions should I create?

Actually, I suppose there should be a SDLu_ and SDLGLu_. The SDLGLu_ would
of course only include things that were to be included in a program that
also uses OpenGL

My recommendations are:
create OpenGL texture from SDL_Surface.

I don’t know what else right now, but I have to run.> ----- Original Message -----

From: shane16@xmission.com (Shane Fausett)
To:
Sent: Thursday, January 17, 2002 1:02 PM
Subject: Re: time stamped events, was [SDL] Detecting Double Clicks

At 06:59 PM 1/17/2002 +0100, you wrote:

If you wanted to use SDL to write a portable game server you would
need

something like SDL_GetTicks() that didn’t roll over after 49 days.

What about introducing a new SDL_GetTicks in SDL 1.3 which returns the
number

of ticks since the last time SDL_GetTicks was called ?


Trick


What ??? are you that lazy ??? First it would kill backward compatability
with existing code, and second it is VERY trivial to implement on your own

UInt32 ticks,lapse;

ticks = SDL_GetTicks();

… other stuff

lapse = SDL_GetTicks - ticks;

Shane


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

“Fro Joe” wrote in message
news:mailman.1011300185.20047.sdl at libsdl.org

Actually, after further thought, SDL_GetTicksSince() is rather
trivial and
people are going to argue that because of that, it shouldn’t be in
the SDL.

Uint32 SDL_GetTicksSince(Uint32 timestamp)
{
/* ha to all you C Programmers your ‘{’ should be on a new line…
READABILITY FIRST */
Uint32 currentTime = SDL_GetTicks();
if (currentTime > timestamp)
return currentTime - timestamp;
return (0xFFFFFFFF - timestamp) + currentTime;
}

It’s more trivial than that:

Uint32 SDL_GetTicksSince(Uint32 timestamp)
{
return SDL_GetTicks() - timestamp;
}

The above works reliably across the wraparound at 0xffffffff. Really.

The relatively complicated and incorrect (off by 1 across wraparound
boundary) code you posted above is the strongest argument for
’SDL_GetTicksSince’ in SDL yet.–
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

oops. You’re right… I missed a +1 on mine.

I see what you’re getting at now. Rolling over would give you a negative
number, but it would be interpreted as a positive, so flip the bits and add
one.

I suppose one could safely assume 2’s complement? (I suppose there’s little
chance of SDL on some crazy embedded system)

My argument I think is still valid. There should be a SDLu and SDLGLu
(perhaps even just public domain headers) to do things like this. People
are not going to want such trivial things in their program wasting space
(cut the bloat or go MS). Therefore, I think I just made a stronger case
for the added libraries/headers =)> ----- Original Message -----

From: root@rainerdeyke.com (Rainer Deyke)
Newsgroups: loki.open-source.sdl
To:
Sent: Thursday, January 17, 2002 3:30 PM
Subject: Re: [SDL] Re: SDLu, was time stamped events, was [SDL] Detecting
Double Clicks

“Fro Joe” wrote in message
news:mailman.1011300185.20047.sdl at libsdl.org

Actually, after further thought, SDL_GetTicksSince() is rather
trivial and
people are going to argue that because of that, it shouldn’t be in
the SDL.

Uint32 SDL_GetTicksSince(Uint32 timestamp)
{
/* ha to all you C Programmers your ‘{’ should be on a new line…
READABILITY FIRST */
Uint32 currentTime = SDL_GetTicks();
if (currentTime > timestamp)
return currentTime - timestamp;
return (0xFFFFFFFF - timestamp) + currentTime;
}

It’s more trivial than that:

Uint32 SDL_GetTicksSince(Uint32 timestamp)
{
return SDL_GetTicks() - timestamp;
}

The above works reliably across the wraparound at 0xffffffff. Really.

The relatively complicated and incorrect (off by 1 across wraparound
boundary) code you posted above is the strongest argument for
’SDL_GetTicksSince’ in SDL yet.


Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

This way, you could decide to reset your base time (timestamp) on your own.
I understand that you don’t want to bulk the library with such basic
functions, but sometimes it’s just nice to be kind to newbies ;)… or
perhaps make libSDLu (the SDL utility library). OpenGL has one of these
that contains functions that could totally be accomplished using just
OpenGL, but they are more ‘user-friendly’.

It would be way better to make ppl do this correctly than hiding it away in
yet another depended library. SDLu is unneccessary. Learn to code in stead.–
Trick


Linux User #229006 * http://counter.li.org

“There is no magic” - Nakor, magic user

Hiya,

FJ> I suppose one could safely assume 2’s complement? (I suppose there’s little
FJ> chance of SDL on some crazy embedded system)

One’s compliment. There is no 2 in binary. :wink:

Neil.

Hiya,

FJ> I suppose one could safely assume 2’s complement? (I suppose there’s little
FJ> chance of SDL on some crazy embedded system)

One’s compliment. There is no 2 in binary. :wink:

Off-off topic. Please drop the thread.

Thanks,
-Sam Lantinga, Software Engineer, Blizzard Entertainment