Mercurial > sdl-ios-xcode
annotate test/common.c @ 3096:ae4e80dbe330
Date: Tue, 17 Feb 2009 14:00:25 +0100
From: Stefan Klug
Subject: [SDL] Possible bug, paused audio playing garbage
On my WinCE device a paused audio device plays random garbage.
This might also be the issue in the thread "sound cracks with SDL_mixer
and AUDIO_S16LSB"
I don't have that much knowledge of the SDL audio part, but the attached
patch fixes it for me, and collapses two redundant ifs.
I'm not sure if this is the correct way to fix this.
Shouldn't the complete stream conversion part of the RunAudio loop be
dependent on the paused property of the device? (not only the call to
(*fill)(udata, istream, istream_len).
Anyways. Would be great if the patch or a fix could find its way to SVN ;-)
Cheers
Stefan
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 23 Mar 2009 05:21:40 +0000 |
parents | 9dde605c7540 |
children | 68d3b48a6002 |
rev | line source |
---|---|
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 /* A simple test program framework */ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 #include <stdio.h> |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 #include "common.h" |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 #define VIDEO_USAGE \ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 "[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display %d] [--fullscreen | --windows N] [--title title] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]" |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 #define AUDIO_USAGE \ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]" |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 CommonState * |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 CommonCreateState(char **argv, Uint32 flags) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 CommonState *state = SDL_calloc(1, sizeof(*state)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 if (!state) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 SDL_OutOfMemory(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 return NULL; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 /* Initialize some defaults */ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 state->argv = argv; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 state->flags = flags; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 state->window_title = argv[0]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 state->window_flags = SDL_WINDOW_SHOWN; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 state->window_x = SDL_WINDOWPOS_UNDEFINED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 state->window_y = SDL_WINDOWPOS_UNDEFINED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 state->window_w = 640; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 state->window_h = 480; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 state->num_windows = 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 state->audiospec.freq = 22050; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 state->audiospec.format = AUDIO_S16; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 state->audiospec.channels = 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 state->audiospec.samples = 2048; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 return state; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 int |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 CommonArg(CommonState * state, int index) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 char **argv = state->argv; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 if (SDL_strcasecmp(argv[index], "--video") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 state->videodriver = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 if (SDL_strcasecmp(argv[index], "--renderer") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 state->renderdriver = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 if (SDL_strcasecmp(argv[index], "--info") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 if (SDL_strcasecmp(argv[index], "all") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 state->verbose |= |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 (VERBOSE_VIDEO | VERBOSE_MODES | VERBOSE_RENDER | |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 VERBOSE_EVENT); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 if (SDL_strcasecmp(argv[index], "video") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 state->verbose |= VERBOSE_VIDEO; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 if (SDL_strcasecmp(argv[index], "modes") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 state->verbose |= VERBOSE_MODES; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 if (SDL_strcasecmp(argv[index], "render") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 state->verbose |= VERBOSE_RENDER; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 if (SDL_strcasecmp(argv[index], "event") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 state->verbose |= VERBOSE_EVENT; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 if (SDL_strcasecmp(argv[index], "--display") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 state->display = SDL_atoi(argv[index]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 state->window_flags |= SDL_WINDOW_FULLSCREEN; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 state->num_windows = 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 if (SDL_strcasecmp(argv[index], "--windows") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 ++index; |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
105 if (!argv[index] || !SDL_isdigit(*argv[index])) { |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 state->num_windows = SDL_atoi(argv[index]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 if (SDL_strcasecmp(argv[index], "--title") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 state->window_title = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 if (SDL_strcasecmp(argv[index], "--center") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 state->window_x = SDL_WINDOWPOS_CENTERED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 state->window_y = SDL_WINDOWPOS_CENTERED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 if (SDL_strcasecmp(argv[index], "--position") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 char *x, *y; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 x = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 y = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 while (*y && *y != ',') { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 ++y; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 if (!*y) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 *y++ = '\0'; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 state->window_x = SDL_atoi(x); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 state->window_y = SDL_atoi(y); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 if (SDL_strcasecmp(argv[index], "--geometry") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 char *w, *h; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 w = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 h = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 while (*h && *h != 'x') { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 ++h; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 if (!*h) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 *h++ = '\0'; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 state->window_w = SDL_atoi(w); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 state->window_h = SDL_atoi(h); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 } |
2209
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
164 if (SDL_strcasecmp(argv[index], "--depth") == 0) { |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
165 ++index; |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
166 if (!argv[index]) { |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
167 return -1; |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
168 } |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
169 state->depth = SDL_atoi(argv[index]); |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
170 return 2; |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
171 } |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 if (SDL_strcasecmp(argv[index], "--refresh") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 state->refresh_rate = SDL_atoi(argv[index]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 if (SDL_strcasecmp(argv[index], "--vsync") == 0) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
181 state->render_flags |= SDL_RENDERER_PRESENTVSYNC; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 if (SDL_strcasecmp(argv[index], "--noframe") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 state->window_flags |= SDL_WINDOW_BORDERLESS; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 if (SDL_strcasecmp(argv[index], "--resize") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 state->window_flags |= SDL_WINDOW_RESIZABLE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 if (SDL_strcasecmp(argv[index], "--minimize") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 state->window_flags |= SDL_WINDOW_MINIMIZED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 if (SDL_strcasecmp(argv[index], "--maximize") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 state->window_flags |= SDL_WINDOW_MAXIMIZED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 if (SDL_strcasecmp(argv[index], "--grab") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 state->window_flags |= SDL_WINDOW_INPUT_GRABBED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 if (SDL_strcasecmp(argv[index], "--rate") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 state->audiospec.freq = SDL_atoi(argv[index]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 if (SDL_strcasecmp(argv[index], "--format") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 if (SDL_strcasecmp(argv[index], "U8") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 state->audiospec.format = AUDIO_U8; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 if (SDL_strcasecmp(argv[index], "S8") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 state->audiospec.format = AUDIO_S8; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 if (SDL_strcasecmp(argv[index], "U16") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 state->audiospec.format = AUDIO_U16; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 if (SDL_strcasecmp(argv[index], "U16LE") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 state->audiospec.format = AUDIO_U16LSB; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 if (SDL_strcasecmp(argv[index], "U16BE") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 state->audiospec.format = AUDIO_U16MSB; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 if (SDL_strcasecmp(argv[index], "S16") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 state->audiospec.format = AUDIO_S16; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 if (SDL_strcasecmp(argv[index], "S16LE") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 state->audiospec.format = AUDIO_S16LSB; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 if (SDL_strcasecmp(argv[index], "S16BE") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 state->audiospec.format = AUDIO_S16MSB; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 if (SDL_strcasecmp(argv[index], "--channels") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 } |
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2179
diff
changeset
|
256 state->audiospec.channels = (Uint8) SDL_atoi(argv[index]); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 if (SDL_strcasecmp(argv[index], "--samples") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 ++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 } |
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2179
diff
changeset
|
264 state->audiospec.samples = (Uint16) SDL_atoi(argv[index]); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 if ((SDL_strcasecmp(argv[index], "-h") == 0) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 || (SDL_strcasecmp(argv[index], "--help") == 0)) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 /* Print the usage message */ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 return 0; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 const char * |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 CommonUsage(CommonState * state) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 case SDL_INIT_VIDEO: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 return VIDEO_USAGE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 case SDL_INIT_AUDIO: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 return AUDIO_USAGE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 case (SDL_INIT_VIDEO | SDL_INIT_AUDIO): |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 return VIDEO_USAGE " " AUDIO_USAGE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 return ""; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 PrintRendererFlag(Uint32 flag) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 switch (flag) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
294 case SDL_RENDERER_SINGLEBUFFER: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 fprintf(stderr, "SingleBuffer"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
297 case SDL_RENDERER_PRESENTCOPY: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 fprintf(stderr, "PresentCopy"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
300 case SDL_RENDERER_PRESENTFLIP2: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 fprintf(stderr, "PresentFlip2"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
303 case SDL_RENDERER_PRESENTFLIP3: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 fprintf(stderr, "PresentFlip3"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
306 case SDL_RENDERER_PRESENTDISCARD: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 fprintf(stderr, "PresentDiscard"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
309 case SDL_RENDERER_PRESENTVSYNC: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 fprintf(stderr, "PresentVSync"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
312 case SDL_RENDERER_ACCELERATED: |
1921
f3399f779a1d
Bug fixes to the OpenGL renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
313 fprintf(stderr, "Accelerated"); |
f3399f779a1d
Bug fixes to the OpenGL renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
314 break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 fprintf(stderr, "0x%8.8x", flag); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 PrintBlendMode(Uint32 flag) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 switch (flag) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2306
diff
changeset
|
325 case SDL_BLENDMODE_NONE: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 fprintf(stderr, "None"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 break; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2306
diff
changeset
|
328 case SDL_BLENDMODE_MASK: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 fprintf(stderr, "Mask"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 break; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2306
diff
changeset
|
331 case SDL_BLENDMODE_BLEND: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 fprintf(stderr, "Blend"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 break; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2306
diff
changeset
|
334 case SDL_BLENDMODE_ADD: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 fprintf(stderr, "Add"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 break; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2306
diff
changeset
|
337 case SDL_BLENDMODE_MOD: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 fprintf(stderr, "Mod"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 fprintf(stderr, "0x%8.8x", flag); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 PrintScaleMode(Uint32 flag) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 switch (flag) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
350 case SDL_TEXTURESCALEMODE_NONE: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 fprintf(stderr, "None"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
353 case SDL_TEXTURESCALEMODE_FAST: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 fprintf(stderr, "Fast"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
356 case SDL_TEXTURESCALEMODE_SLOW: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 fprintf(stderr, "Slow"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
359 case SDL_TEXTURESCALEMODE_BEST: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 fprintf(stderr, "Best"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 fprintf(stderr, "0x%8.8x", flag); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 PrintPixelFormat(Uint32 format) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
372 case SDL_PIXELFORMAT_UNKNOWN: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 fprintf(stderr, "Unknwon"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
375 case SDL_PIXELFORMAT_INDEX1LSB: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 fprintf(stderr, "Index1LSB"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
378 case SDL_PIXELFORMAT_INDEX1MSB: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 fprintf(stderr, "Index1MSB"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
381 case SDL_PIXELFORMAT_INDEX4LSB: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 fprintf(stderr, "Index4LSB"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
384 case SDL_PIXELFORMAT_INDEX4MSB: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 fprintf(stderr, "Index4MSB"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
387 case SDL_PIXELFORMAT_INDEX8: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 fprintf(stderr, "Index8"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
390 case SDL_PIXELFORMAT_RGB332: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 fprintf(stderr, "RGB332"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
393 case SDL_PIXELFORMAT_RGB444: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 fprintf(stderr, "RGB444"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
396 case SDL_PIXELFORMAT_RGB555: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 fprintf(stderr, "RGB555"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
399 case SDL_PIXELFORMAT_ARGB4444: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 fprintf(stderr, "ARGB4444"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
402 case SDL_PIXELFORMAT_ARGB1555: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 fprintf(stderr, "ARGB1555"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
405 case SDL_PIXELFORMAT_RGB565: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 fprintf(stderr, "RGB565"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
408 case SDL_PIXELFORMAT_RGB24: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 fprintf(stderr, "RGB24"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
411 case SDL_PIXELFORMAT_BGR24: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 fprintf(stderr, "BGR24"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
414 case SDL_PIXELFORMAT_RGB888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 fprintf(stderr, "RGB888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
417 case SDL_PIXELFORMAT_BGR888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 fprintf(stderr, "BGR888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
420 case SDL_PIXELFORMAT_ARGB8888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 fprintf(stderr, "ARGB8888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
423 case SDL_PIXELFORMAT_RGBA8888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 fprintf(stderr, "RGBA8888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
426 case SDL_PIXELFORMAT_ABGR8888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 fprintf(stderr, "ABGR8888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
429 case SDL_PIXELFORMAT_BGRA8888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 fprintf(stderr, "BGRA8888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
432 case SDL_PIXELFORMAT_ARGB2101010: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 fprintf(stderr, "ARGB2101010"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
435 case SDL_PIXELFORMAT_YV12: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 fprintf(stderr, "YV12"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
438 case SDL_PIXELFORMAT_IYUV: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 fprintf(stderr, "IYUV"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
441 case SDL_PIXELFORMAT_YUY2: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 fprintf(stderr, "YUY2"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
444 case SDL_PIXELFORMAT_UYVY: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 fprintf(stderr, "UYVY"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
447 case SDL_PIXELFORMAT_YVYU: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 fprintf(stderr, "YVYU"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 fprintf(stderr, "0x%8.8x", format); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 PrintRenderer(SDL_RendererInfo * info) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 int i, count; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 fprintf(stderr, " Renderer %s:\n", info->name); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 fprintf(stderr, " Flags: 0x%8.8X", info->flags); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 fprintf(stderr, " ("); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 count = 0; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 for (i = 0; i < sizeof(info->flags) * 8; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 Uint32 flag = (1 << i); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 if (info->flags & flag) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 if (count > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 fprintf(stderr, " | "); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 PrintRendererFlag(flag); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 ++count; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 fprintf(stderr, ")\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 fprintf(stderr, " Blend: 0x%8.8X", info->blend_modes); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 fprintf(stderr, " ("); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 count = 0; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 for (i = 0; i < sizeof(info->blend_modes) * 8; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 Uint32 flag = (1 << i); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 if (info->blend_modes & flag) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 if (count > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 fprintf(stderr, " | "); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 PrintBlendMode(flag); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 ++count; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 fprintf(stderr, ")\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 fprintf(stderr, " Scale: 0x%8.8X", info->scale_modes); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 fprintf(stderr, " ("); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 count = 0; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 for (i = 0; i < sizeof(info->scale_modes) * 8; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 Uint32 flag = (1 << i); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 if (info->scale_modes & flag) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 if (count > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 fprintf(stderr, " | "); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 PrintScaleMode(flag); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 ++count; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 fprintf(stderr, ")\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 fprintf(stderr, " Texture formats (%d): ", info->num_texture_formats); |
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2179
diff
changeset
|
509 for (i = 0; i < (int) info->num_texture_formats; ++i) { |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 if (i > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 fprintf(stderr, ", "); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 PrintPixelFormat(info->texture_formats[i]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 fprintf(stderr, "\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 if (info->max_texture_width || info->max_texture_height) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 fprintf(stderr, " Max Texture Size: %dx%d\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 info->max_texture_width, info->max_texture_height); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 SDL_bool |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 CommonInit(CommonState * state) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 int i, j, m, n; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 SDL_DisplayMode fullscreen_mode; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 if (state->flags & SDL_INIT_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 if (state->verbose & VERBOSE_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 n = SDL_GetNumVideoDrivers(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 if (n == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 fprintf(stderr, "No built-in video drivers\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 } else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 fprintf(stderr, "Built-in video drivers:"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 for (i = 0; i < n; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 if (i > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 fprintf(stderr, ","); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 fprintf(stderr, " %s", SDL_GetVideoDriver(i)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 fprintf(stderr, "\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 if (SDL_VideoInit(state->videodriver, 0) < 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 fprintf(stderr, "Couldn't initialize video driver: %s\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 if (state->verbose & VERBOSE_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 fprintf(stderr, "Video driver: %s\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 SDL_GetCurrentVideoDriver()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 if (state->verbose & VERBOSE_MODES) { |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
556 SDL_DisplayMode mode; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 int bpp; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 Uint32 Rmask, Gmask, Bmask, Amask; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
559 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 n = SDL_GetNumVideoDisplays(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 fprintf(stderr, "Number of displays: %d\n", n); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
562 for (i = 0; i < n; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
563 fprintf(stderr, "Display %d:\n", i); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 SDL_SelectVideoDisplay(i); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
566 SDL_GetDesktopDisplayMode(&mode); |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
567 SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
568 &Bmask, &Amask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 fprintf(stderr, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 " Current mode: %dx%d@%dHz, %d bits-per-pixel\n", |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
571 mode.w, mode.h, mode.refresh_rate, bpp); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 if (Rmask || Gmask || Bmask) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 fprintf(stderr, " Red Mask = 0x%.8x\n", Rmask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 fprintf(stderr, " Green Mask = 0x%.8x\n", Gmask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 fprintf(stderr, " Blue Mask = 0x%.8x\n", Bmask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 if (Amask) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 fprintf(stderr, " Alpha Mask = 0x%.8x\n", Amask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 /* Print available fullscreen video modes */ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 m = SDL_GetNumDisplayModes(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 if (m == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 fprintf(stderr, "No available fullscreen video modes\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 } else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 fprintf(stderr, " Fullscreen video modes:\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 for (j = 0; j < m; ++j) { |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
587 SDL_GetDisplayMode(j, &mode); |
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
588 SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 &Gmask, &Bmask, &Amask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 fprintf(stderr, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 " Mode %d: %dx%d@%dHz, %d bits-per-pixel\n", |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
592 j, mode.w, mode.h, mode.refresh_rate, bpp); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 if (Rmask || Gmask || Bmask) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 fprintf(stderr, " Red Mask = 0x%.8x\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 Rmask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 fprintf(stderr, " Green Mask = 0x%.8x\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 Gmask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 fprintf(stderr, " Blue Mask = 0x%.8x\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 Bmask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 if (Amask) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 fprintf(stderr, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 " Alpha Mask = 0x%.8x\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 Amask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 SDL_SelectVideoDisplay(state->display); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 if (state->verbose & VERBOSE_RENDER) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
612 SDL_RendererInfo info; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
614 n = SDL_GetNumRenderDrivers(); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 if (n == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 fprintf(stderr, "No built-in render drivers\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 } else { |
1923
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
618 fprintf(stderr, "Built-in render drivers:\n"); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 for (i = 0; i < n; ++i) { |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
620 SDL_GetRenderDriverInfo(i, &info); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 PrintRenderer(&info); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 switch (state->depth) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 case 8: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
628 fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 case 15: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
631 fullscreen_mode.format = SDL_PIXELFORMAT_RGB555; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
633 case 16: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
634 fullscreen_mode.format = SDL_PIXELFORMAT_RGB565; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 default: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
637 fullscreen_mode.format = SDL_PIXELFORMAT_RGB888; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 fullscreen_mode.w = state->window_w; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 fullscreen_mode.h = state->window_h; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 fullscreen_mode.refresh_rate = state->refresh_rate; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 SDL_SetFullscreenDisplayMode(&fullscreen_mode); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 state->windows = |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 (SDL_WindowID *) SDL_malloc(state->num_windows * |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 sizeof(*state->windows)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 if (!state->windows) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 fprintf(stderr, "Out of memory!\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 for (i = 0; i < state->num_windows; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 char title[1024]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 if (state->num_windows > 1) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 SDL_snprintf(title, SDL_arraysize(title), "%s %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
657 state->window_title, i + 1); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 } else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 SDL_strlcpy(title, state->window_title, SDL_arraysize(title)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
660 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
661 state->windows[i] = |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
662 SDL_CreateWindow(title, state->window_x, state->window_y, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
663 state->window_w, state->window_h, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 state->window_flags); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
665 if (!state->windows[i]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 fprintf(stderr, "Couldn't create window: %s\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
671 if (!state->skip_renderer |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
672 && (state->renderdriver |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
673 || !(state->window_flags & SDL_WINDOW_OPENGL))) { |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 m = -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 if (state->renderdriver) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
676 SDL_RendererInfo info; |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
677 n = SDL_GetNumRenderDrivers(); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
678 for (j = 0; j < n; ++j) { |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
679 SDL_GetRenderDriverInfo(j, &info); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
680 if (SDL_strcasecmp(info.name, state->renderdriver) == |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 m = j; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
683 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
684 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
685 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 if (m == n) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
687 fprintf(stderr, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
688 "Couldn't find render driver named %s", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
689 state->renderdriver); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
691 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
692 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
693 if (SDL_CreateRenderer |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
694 (state->windows[i], m, state->render_flags) < 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
695 fprintf(stderr, "Couldn't create renderer: %s\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
696 SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
697 return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
698 } |
1923
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
699 if (state->verbose & VERBOSE_RENDER) { |
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
700 SDL_RendererInfo info; |
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
701 |
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
702 fprintf(stderr, "Current renderer:\n"); |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
703 SDL_GetRendererInfo(&info); |
1923
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
704 PrintRenderer(&info); |
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
705 } |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 SDL_SelectRenderer(state->windows[0]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 if (state->flags & SDL_INIT_AUDIO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
712 if (state->verbose & VERBOSE_AUDIO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
713 n = SDL_GetNumAudioDrivers(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
714 if (n == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
715 fprintf(stderr, "No built-in audio drivers\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
716 } else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
717 fprintf(stderr, "Built-in audio drivers:"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 for (i = 0; i < n; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
719 if (i > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
720 fprintf(stderr, ","); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
721 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
722 fprintf(stderr, " %s", SDL_GetAudioDriver(i)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
723 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
724 fprintf(stderr, "\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
725 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
726 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
727 if (SDL_AudioInit(state->audiodriver) < 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
728 fprintf(stderr, "Couldn't initialize audio driver: %s\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
729 SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
730 return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
731 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
732 if (state->verbose & VERBOSE_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
733 fprintf(stderr, "Audio driver: %s\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 SDL_GetCurrentAudioDriver()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
736 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 if (SDL_OpenAudio(&state->audiospec, NULL) < 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
739 return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
740 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
741 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
743 return SDL_TRUE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
744 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
745 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
746 static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
747 PrintEvent(SDL_Event * event) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
749 fprintf(stderr, "SDL EVENT: "); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
750 switch (event->type) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
751 case SDL_WINDOWEVENT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
752 switch (event->window.event) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
753 case SDL_WINDOWEVENT_SHOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
754 fprintf(stderr, "Window %d shown", event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
755 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
756 case SDL_WINDOWEVENT_HIDDEN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
757 fprintf(stderr, "Window %d hidden", event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
758 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
759 case SDL_WINDOWEVENT_EXPOSED: |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
760 fprintf(stderr, "Window %d exposed", event->window.windowID); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
761 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
762 case SDL_WINDOWEVENT_MOVED: |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
763 fprintf(stderr, "Window %d moved to %d,%d", |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
764 event->window.windowID, event->window.data1, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
765 event->window.data2); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
766 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
767 case SDL_WINDOWEVENT_RESIZED: |
1970
db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
1969
diff
changeset
|
768 fprintf(stderr, "Window %d resized to %dx%d", |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
769 event->window.windowID, event->window.data1, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
770 event->window.data2); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
771 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
772 case SDL_WINDOWEVENT_MINIMIZED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
773 fprintf(stderr, "Window %d minimized", event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
774 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
775 case SDL_WINDOWEVENT_MAXIMIZED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
776 fprintf(stderr, "Window %d maximized", event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
777 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
778 case SDL_WINDOWEVENT_RESTORED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
779 fprintf(stderr, "Window %d restored", event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
780 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
781 case SDL_WINDOWEVENT_ENTER: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
782 fprintf(stderr, "Mouse entered window %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
783 event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
784 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
785 case SDL_WINDOWEVENT_LEAVE: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
786 fprintf(stderr, "Mouse left window %d", event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
787 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
788 case SDL_WINDOWEVENT_FOCUS_GAINED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
789 fprintf(stderr, "Window %d gained keyboard focus", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
790 event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
791 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
792 case SDL_WINDOWEVENT_FOCUS_LOST: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
793 fprintf(stderr, "Window %d lost keyboard focus", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
794 event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
795 break; |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
796 case SDL_WINDOWEVENT_CLOSE: |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
797 fprintf(stderr, "Window %d closed", event->window.windowID); |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
798 break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
799 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
800 fprintf(stderr, "Window %d got unknown event %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
801 event->window.windowID, event->window.event); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
802 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
803 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
804 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
805 case SDL_KEYDOWN: |
2268
4baee598306d
Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
2209
diff
changeset
|
806 fprintf(stderr, |
2306 | 807 "Keyboard %d: key pressed in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", |
808 event->key.which, event->key.windowID, | |
809 event->key.keysym.scancode, | |
810 SDL_GetScancodeName(event->key.keysym.scancode), | |
811 event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); | |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
812 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
813 case SDL_KEYUP: |
2268
4baee598306d
Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
2209
diff
changeset
|
814 fprintf(stderr, |
2306 | 815 "Keyboard %d: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", |
816 event->key.which, event->key.windowID, | |
817 event->key.keysym.scancode, | |
818 SDL_GetScancodeName(event->key.keysym.scancode), | |
819 event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); | |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
820 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
821 case SDL_TEXTINPUT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
822 fprintf(stderr, "Keyboard %d: text input \"%s\" in window %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
823 event->text.which, event->text.text, event->text.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
824 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
825 case SDL_MOUSEMOTION: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
826 fprintf(stderr, "Mouse %d: moved to %d,%d (%d,%d) in window %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
827 event->motion.which, event->motion.x, event->motion.y, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
828 event->motion.xrel, event->motion.yrel, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
829 event->motion.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
830 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
831 case SDL_MOUSEBUTTONDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
832 fprintf(stderr, "Mouse %d: button %d pressed at %d,%d in window %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
833 event->button.which, event->button.button, event->button.x, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
834 event->button.y, event->button.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
835 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
836 case SDL_MOUSEBUTTONUP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
837 fprintf(stderr, "Mouse %d: button %d released at %d,%d in window %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
838 event->button.which, event->button.button, event->button.x, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
839 event->button.y, event->button.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
840 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
841 case SDL_MOUSEWHEEL: |
2174 | 842 fprintf(stderr, |
843 "Mouse %d: wheel scrolled %d in x and %d in y in window %d", | |
2154
5660f48b31f5
fixed code for printing mousewheel events to match the new format of mousewheel events.
Bob Pendleton <bob@pendleton.com>
parents:
1970
diff
changeset
|
844 event->wheel.which, event->wheel.x, event->wheel.y, |
1957
c7803e4c21d3
Implemented Cocoa mouse wheel events
Sam Lantinga <slouken@libsdl.org>
parents:
1933
diff
changeset
|
845 event->wheel.windowID); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
846 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
847 case SDL_JOYBALLMOTION: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
848 fprintf(stderr, "Joystick %d: ball %d moved by %d,%d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
849 event->jball.which, event->jball.ball, event->jball.xrel, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
850 event->jball.yrel); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
851 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
852 case SDL_JOYHATMOTION: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
853 fprintf(stderr, "Joystick %d: hat %d moved to ", event->jhat.which, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
854 event->jhat.hat); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
855 switch (event->jhat.value) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
856 case SDL_HAT_CENTERED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
857 fprintf(stderr, "CENTER"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
858 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
859 case SDL_HAT_UP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
860 fprintf(stderr, "UP"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
861 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
862 case SDL_HAT_RIGHTUP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
863 fprintf(stderr, "RIGHTUP"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
864 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
865 case SDL_HAT_RIGHT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
866 fprintf(stderr, "RIGHT"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
867 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
868 case SDL_HAT_RIGHTDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
869 fprintf(stderr, "RIGHTDOWN"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
870 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
871 case SDL_HAT_DOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
872 fprintf(stderr, "DOWN"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
873 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
874 case SDL_HAT_LEFTDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
875 fprintf(stderr, "LEFTDOWN"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
876 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 case SDL_HAT_LEFT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
878 fprintf(stderr, "LEFT"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
879 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
880 case SDL_HAT_LEFTUP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
881 fprintf(stderr, "LEFTUP"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
883 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 fprintf(stderr, "UNKNOWN"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
887 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
888 case SDL_JOYBUTTONDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
889 fprintf(stderr, "Joystick %d: button %d pressed", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
890 event->jbutton.which, event->jbutton.button); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
891 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
892 case SDL_JOYBUTTONUP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
893 fprintf(stderr, "Joystick %d: button %d released", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
894 event->jbutton.which, event->jbutton.button); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
895 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
896 case SDL_QUIT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
897 fprintf(stderr, "Quit requested"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
898 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
899 case SDL_USEREVENT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
900 fprintf(stderr, "User event %d", event->user.code); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
901 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
902 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
903 fprintf(stderr, "Unknown event %d", event->type); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
904 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
905 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
906 fprintf(stderr, "\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
909 void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 CommonEvent(CommonState * state, SDL_Event * event, int *done) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
911 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 if (state->verbose & VERBOSE_EVENT) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
913 PrintEvent(event); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
914 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
915 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
916 switch (event->type) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
917 case SDL_WINDOWEVENT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
918 switch (event->window.event) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
919 case SDL_WINDOWEVENT_CLOSE: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
920 *done = 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
922 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
923 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
924 case SDL_KEYDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
925 switch (event->key.keysym.sym) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
926 /* Add hotkeys here */ |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
927 case SDLK_g: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
928 if (event->key.keysym.mod & KMOD_CTRL) { |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
929 /* Ctrl-G toggle grab */ |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
930 } |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
931 break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
932 case SDLK_ESCAPE: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
933 *done = 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
934 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
935 default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
936 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
937 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
938 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
939 case SDL_QUIT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
940 *done = 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
941 break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
942 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
943 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
944 |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
945 void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
946 CommonQuit(CommonState * state) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
947 { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
948 if (state->flags & SDL_INIT_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
949 SDL_VideoQuit(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
950 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
951 if (state->flags & SDL_INIT_AUDIO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
952 SDL_AudioQuit(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
953 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
954 if (state->windows) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
955 SDL_free(state->windows); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
956 } |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
957 SDL_free(state); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
958 } |