Mercurial > sdl-ios-xcode
annotate test/testtimer.c @ 1032:c1c2efca4548
Date: Mon, 24 Jan 2005 21:37:56 +0800
From: Chris Taylor
Subject: Patch to put back dynamic OpenGL loading for MPW
I sent a patch a while ago that removes dynamic OpenGL loading for
Macintosh Programmer's Workshop. Dynamic loading DOES actually work
when an SDL program is built with MPW, it just has to be set up for it.
(Whoops!!) This is the ideal way to get OpenGL extensions to work,
which D2X uses quite a few of.
This patch puts dynamic loading back in SDL for Mac OS 9. It applies to
current CVS. I noticed that two members need to be set when
DrawSprocket is used.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 25 Jan 2005 16:57:11 +0000 |
parents | ed57c876700d |
children | be9c9c8f6d53 |
rev | line source |
---|---|
0 | 1 |
2 /* Test program to check the resolution of the SDL timer on the current | |
3 platform | |
4 */ | |
5 | |
6 #include <stdlib.h> | |
7 #include <stdio.h> | |
8 | |
9 #include "SDL.h" | |
10 | |
11 #define DEFAULT_RESOLUTION 1 | |
12 | |
13 static int ticks = 0; | |
14 | |
15 static Uint32 ticktock(Uint32 interval) | |
16 { | |
17 ++ticks; | |
18 return(interval); | |
19 } | |
20 | |
21 static Uint32 callback(Uint32 interval, void *param) | |
22 { | |
23 printf("Timer %d : param = %d\n", interval, (int) param); | |
24 return interval; | |
25 } | |
26 | |
27 int main(int argc, char *argv[]) | |
28 { | |
29 int desired; | |
30 SDL_TimerID t1, t2, t3; | |
31 | |
32 if ( SDL_Init(SDL_INIT_TIMER) < 0 ) { | |
33 fprintf(stderr, "Couldn't load SDL: %s\n", SDL_GetError()); | |
34 exit(1); | |
35 } | |
36 atexit(SDL_Quit); | |
37 | |
38 /* Start the timer */ | |
39 desired = 0; | |
40 if ( argv[1] ) { | |
41 desired = atoi(argv[1]); | |
42 } | |
43 if ( desired == 0 ) { | |
44 desired = DEFAULT_RESOLUTION; | |
45 } | |
46 SDL_SetTimer(desired, ticktock); | |
47 | |
48 /* Wait 10 seconds */ | |
49 printf("Waiting 10 seconds\n"); | |
50 SDL_Delay(10*1000); | |
51 | |
52 /* Stop the timer */ | |
53 SDL_SetTimer(0, NULL); | |
54 | |
55 /* Print the results */ | |
56 if ( ticks ) { | |
57 fprintf(stderr, | |
58 "Timer resolution: desired = %d ms, actual = %f ms\n", | |
59 desired, (double)(10*1000)/ticks); | |
60 } | |
61 | |
62 /* Test multiple timers */ | |
63 printf("Testing multiple timers...\n"); | |
64 t1 = SDL_AddTimer(100, callback, (void*)1); | |
65 if(!t1) | |
766
ed57c876700d
Date: Wed, 26 Nov 2003 01:52:02 +0800
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
66 fprintf(stderr,"Could not create timer 1: %s\n", SDL_GetError()); |
0 | 67 t2 = SDL_AddTimer(50, callback, (void*)2); |
68 if(!t2) | |
766
ed57c876700d
Date: Wed, 26 Nov 2003 01:52:02 +0800
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
69 fprintf(stderr,"Could not create timer 2: %s\n", SDL_GetError()); |
0 | 70 t3 = SDL_AddTimer(233, callback, (void*)3); |
71 if(!t3) | |
766
ed57c876700d
Date: Wed, 26 Nov 2003 01:52:02 +0800
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
72 fprintf(stderr,"Could not create timer 3: %s\n", SDL_GetError()); |
0 | 73 |
74 /* Wait 10 seconds */ | |
75 printf("Waiting 10 seconds\n"); | |
76 SDL_Delay(10*1000); | |
77 | |
78 printf("Removing timer 1 and waiting 5 more seconds\n"); | |
79 SDL_RemoveTimer(t1); | |
80 | |
81 SDL_Delay(5*1000); | |
82 | |
83 SDL_RemoveTimer(t2); | |
84 SDL_RemoveTimer(t3); | |
85 | |
86 return(0); | |
87 } |