annotate test/testsprite2.c @ 1943:7d642361ef0f

The old windows video drivers are superceded by the unified win32 driver.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 26 Jul 2006 03:15:41 +0000
parents 3f54b3ec5a07
children a788656ca29a
rev   line source
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /* Simple program: Move N sprites around on the screen as fast as possible */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 #include <stdlib.h>
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1904
diff changeset
4 #include <stdio.h>
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 #include <time.h>
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
7 #include "common.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 #define NUM_SPRITES 100
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 #define MAX_SPEED 1
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
11 #define BACKGROUND 0x00A0A0A0
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
13 static CommonState *state;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 static int num_sprites;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 static SDL_TextureID *sprites;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 static SDL_Rect *positions;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 static SDL_Rect *velocities;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 static int sprite_w, sprite_h;
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
19 static SDL_TextureBlendMode blendMode = SDL_TextureBlendMode_Mask;
1917
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
20 static SDL_TextureScaleMode scaleMode = SDL_TextureScaleMode_None;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 quit(int rc)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 if (sprites) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 SDL_free(sprites);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 if (positions) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 SDL_free(positions);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 if (velocities) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 SDL_free(velocities);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
35 CommonQuit(state);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 exit(rc);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 LoadSprite(char *file)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 int i;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 SDL_Surface *temp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 /* Load the sprite image */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 temp = SDL_LoadBMP(file);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 if (temp == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 return (-1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 sprite_w = temp->w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 sprite_h = temp->h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 /* Set transparent pixel as the pixel at (0,0) */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 if (temp->format->palette) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint8 *) temp->pixels);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 /* Create textures from the image */
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
60 for (i = 0; i < state->num_windows; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
61 SDL_SelectRenderer(state->windows[i]);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 sprites[i] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 SDL_CreateTextureFromSurface(0, SDL_TextureAccess_Remote, temp);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 if (!sprites[i]) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 SDL_FreeSurface(temp);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 return (-1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 SDL_FreeSurface(temp);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 /* We're ready to roll. :) */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 return (0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 int i, n;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 int window_w, window_h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 SDL_Rect area, *position, *velocity;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 SDL_SelectRenderer(window);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 /* Query the sizes */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 SDL_GetWindowSize(window, &window_w, &window_h);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 /* Move the sprite, bounce at the wall, and draw */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 n = 0;
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
90 SDL_RenderFill(NULL, BACKGROUND);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 for (i = 0; i < num_sprites; ++i) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 position = &positions[i];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 velocity = &velocities[i];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 position->x += velocity->x;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 if ((position->x < 0) || (position->x >= (window_w - sprite_w))) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 velocity->x = -velocity->x;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 position->x += velocity->x;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 position->y += velocity->y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 if ((position->y < 0) || (position->y >= (window_h - sprite_w))) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 velocity->y = -velocity->y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 position->y += velocity->y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 /* Blit the sprite onto the screen */
1917
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
106 SDL_RenderCopy(sprite, NULL, position, blendMode, scaleMode);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 /* Update the screen! */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 SDL_RenderPresent();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 main(int argc, char *argv[])
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 int i, done;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 SDL_Event event;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 Uint32 then, now, frames;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
120 /* Initialize parameters */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 num_sprites = NUM_SPRITES;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
122
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
123 /* Initialize test framework */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
124 state = CommonCreateState(argv, SDL_INIT_VIDEO);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
125 if (!state) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
126 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
127 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
128 for (i = 1; i < argc;) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
129 int consumed;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
130
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
131 consumed = CommonArg(state, i);
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
132 if (consumed == 0) {
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
133 consumed = -1;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
134 if (SDL_strcasecmp(argv[i], "--blend") == 0) {
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
135 if (argv[i + 1]) {
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
136 if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
137 blendMode = SDL_TextureBlendMode_None;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
138 consumed = 2;
1917
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
139 } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
140 blendMode = SDL_TextureBlendMode_Mask;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
141 consumed = 2;
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
142 } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
143 blendMode = SDL_TextureBlendMode_Blend;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
144 consumed = 2;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
145 } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
146 blendMode = SDL_TextureBlendMode_Add;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
147 consumed = 2;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
148 } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
149 blendMode = SDL_TextureBlendMode_Mod;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
150 consumed = 2;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
151 }
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
152 }
1917
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
153 } else if (SDL_strcasecmp(argv[i], "--scale") == 0) {
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
154 if (argv[i + 1]) {
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
155 if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
156 scaleMode = SDL_TextureScaleMode_None;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
157 consumed = 2;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
158 } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) {
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
159 scaleMode = SDL_TextureScaleMode_Fast;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
160 consumed = 2;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
161 } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) {
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
162 scaleMode = SDL_TextureScaleMode_Slow;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
163 consumed = 2;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
164 } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) {
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
165 scaleMode = SDL_TextureScaleMode_Best;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
166 consumed = 2;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
167 }
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
168 }
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
169 } else if (SDL_isdigit(*argv[i])) {
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
170 num_sprites = SDL_atoi(argv[i]);
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
171 consumed = 1;
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
172 }
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
173 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
174 if (consumed < 0) {
1917
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
175 fprintf(stderr,
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
176 "Usage: %s %s [--blend none|mask|blend|add|mod] [--scale none|fast|slow|best]",
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1915
diff changeset
177 argv[0], CommonUsage(state));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 quit(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
180 i += consumed;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
182 if (!CommonInit(state)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
183 quit(2);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 /* Create the windows, initialize the renderers, and load the textures */
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
187 sprites =
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
188 (SDL_TextureID *) SDL_malloc(state->num_windows * sizeof(*sprites));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
189 if (!sprites) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 fprintf(stderr, "Out of memory!\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 quit(2);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
193 for (i = 0; i < state->num_windows; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
194 SDL_SelectRenderer(state->windows[i]);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 SDL_RenderFill(NULL, BACKGROUND);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 if (LoadSprite("icon.bmp") < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 quit(2);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 /* Allocate memory for the sprite info */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 if (!positions || !velocities) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 fprintf(stderr, "Out of memory!\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 quit(2);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 srand(time(NULL));
1917
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
209 if (scaleMode != SDL_TextureScaleMode_None) {
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
210 sprite_w += sprite_w / 2;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
211 sprite_h += sprite_h / 2;
3f54b3ec5a07 Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
212 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 for (i = 0; i < num_sprites; ++i) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
214 positions[i].x = rand() % (state->window_w - sprite_w);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
215 positions[i].y = rand() % (state->window_h - sprite_h);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 positions[i].w = sprite_w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 positions[i].h = sprite_h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 velocities[i].x = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 velocities[i].y = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 while (!velocities[i].x && !velocities[i].y) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225
1915
a228436a2404 Implemented multi-window OpenGL program with test framework.
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
226 /* Main render loop */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 frames = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 then = SDL_GetTicks();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 done = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 while (!done) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 /* Check for events */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 ++frames;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 while (SDL_PollEvent(&event)) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
234 CommonEvent(state, &event, &done);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 switch (event.type) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 case SDL_WINDOWEVENT:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 switch (event.window.event) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 case SDL_WINDOWEVENT_EXPOSED:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 SDL_SelectRenderer(event.window.windowID);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 SDL_RenderFill(NULL, BACKGROUND);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 default:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
248 for (i = 0; i < state->num_windows; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
249 MoveSprites(state->windows[i], sprites[i]);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 /* Print out some timing information */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 now = SDL_GetTicks();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 if (now > then) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 printf("%2.2f frames per second\n",
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 ((double) frames * 1000) / (now - then));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 quit(0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 /* vi: set ts=4 sw=4 expandtab: */