annotate test/common.c @ 5249:762e40fb8e28

Be explicit about what display you're querying. The default display is 0.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 10 Feb 2011 12:14:37 -0800
parents af8ca17f6b7c
children 58265e606e4e
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 \
5239
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
9 "[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--log all|error|system|audio|video|render|input] [--display N] [--fullscreen | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]"
1914
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];
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
27 state->window_flags = 0;
1914
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;
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
30 state->window_w = DEFAULT_WINDOW_WIDTH;
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
31 state->window_h = DEFAULT_WINDOW_HEIGHT;
1914
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;
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
37
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
38 /* Set some very sane GL defaults */
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
39 state->gl_red_size = 3;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
40 state->gl_green_size = 3;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
41 state->gl_blue_size = 2;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
42 state->gl_alpha_size = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
43 state->gl_buffer_size = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
44 state->gl_depth_size = 16;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
45 state->gl_stencil_size = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
46 state->gl_double_buffer = 1;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
47 state->gl_accum_red_size = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
48 state->gl_accum_green_size = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
49 state->gl_accum_blue_size = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
50 state->gl_accum_alpha_size = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
51 state->gl_stereo = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
52 state->gl_multisamplebuffers = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
53 state->gl_multisamplesamples = 0;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
54 state->gl_retained_backing = 1;
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3514
diff changeset
55 state->gl_accelerated = -1;
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
56 state->gl_major_version = 2;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
57 state->gl_minor_version = 1;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
58
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 return state;
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
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 int
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 CommonArg(CommonState * state, int index)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 char **argv = state->argv;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 if (SDL_strcasecmp(argv[index], "--video") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 return -1;
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 state->videodriver = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 if (SDL_strcasecmp(argv[index], "--renderer") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 return -1;
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 state->renderdriver = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 if (SDL_strcasecmp(argv[index], "--info") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 return -1;
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 if (SDL_strcasecmp(argv[index], "all") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 state->verbose |=
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 (VERBOSE_VIDEO | VERBOSE_MODES | VERBOSE_RENDER |
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 VERBOSE_EVENT);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 if (SDL_strcasecmp(argv[index], "video") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 state->verbose |= VERBOSE_VIDEO;
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], "modes") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 state->verbose |= VERBOSE_MODES;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 if (SDL_strcasecmp(argv[index], "render") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 state->verbose |= VERBOSE_RENDER;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 if (SDL_strcasecmp(argv[index], "event") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 state->verbose |= VERBOSE_EVENT;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 }
5239
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
112 if (SDL_strcasecmp(argv[index], "--log") == 0) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
113 ++index;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
114 if (!argv[index]) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
115 return -1;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
116 }
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
117 if (SDL_strcasecmp(argv[index], "all") == 0) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
118 SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
119 return 2;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
120 }
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
121 if (SDL_strcasecmp(argv[index], "error") == 0) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
122 SDL_LogSetPriority(SDL_LOG_CATEGORY_ERROR, SDL_LOG_PRIORITY_VERBOSE);
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
123 return 2;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
124 }
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
125 if (SDL_strcasecmp(argv[index], "system") == 0) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
126 SDL_LogSetPriority(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE);
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
127 return 2;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
128 }
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
129 if (SDL_strcasecmp(argv[index], "audio") == 0) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
130 SDL_LogSetPriority(SDL_LOG_CATEGORY_AUDIO, SDL_LOG_PRIORITY_VERBOSE);
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
131 return 2;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
132 }
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
133 if (SDL_strcasecmp(argv[index], "video") == 0) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
134 SDL_LogSetPriority(SDL_LOG_CATEGORY_VIDEO, SDL_LOG_PRIORITY_VERBOSE);
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
135 return 2;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
136 }
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
137 if (SDL_strcasecmp(argv[index], "render") == 0) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
138 SDL_LogSetPriority(SDL_LOG_CATEGORY_RENDER, SDL_LOG_PRIORITY_VERBOSE);
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
139 return 2;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
140 }
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
141 if (SDL_strcasecmp(argv[index], "input") == 0) {
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
142 SDL_LogSetPriority(SDL_LOG_CATEGORY_INPUT, SDL_LOG_PRIORITY_VERBOSE);
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
143 return 2;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
144 }
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
145 return -1;
af8ca17f6b7c Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 5150
diff changeset
146 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 if (SDL_strcasecmp(argv[index], "--display") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 state->display = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 state->window_flags |= SDL_WINDOW_FULLSCREEN;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 state->num_windows = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 if (SDL_strcasecmp(argv[index], "--windows") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 ++index;
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
162 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
163 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 state->num_windows = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 if (SDL_strcasecmp(argv[index], "--title") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 state->window_title = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 }
4527
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
178 if (SDL_strcasecmp(argv[index], "--icon") == 0) {
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
179 ++index;
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
180 if (!argv[index]) {
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
181 return -1;
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
182 }
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
183 state->window_icon = argv[index];
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
184 return 2;
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
185 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 if (SDL_strcasecmp(argv[index], "--center") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 state->window_x = SDL_WINDOWPOS_CENTERED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 state->window_y = SDL_WINDOWPOS_CENTERED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 if (SDL_strcasecmp(argv[index], "--position") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 char *x, *y;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 x = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 y = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 while (*y && *y != ',') {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 ++y;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 if (!*y) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 *y++ = '\0';
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 state->window_x = SDL_atoi(x);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 state->window_y = SDL_atoi(y);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 if (SDL_strcasecmp(argv[index], "--geometry") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 char *w, *h;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 w = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 h = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 while (*h && *h != 'x') {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 ++h;
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 (!*h) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 *h++ = '\0';
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 state->window_w = SDL_atoi(w);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 state->window_h = SDL_atoi(h);
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 }
2209
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
229 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
230 ++index;
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
231 if (!argv[index]) {
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
232 return -1;
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
233 }
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
234 state->depth = SDL_atoi(argv[index]);
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
235 return 2;
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
236 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 if (SDL_strcasecmp(argv[index], "--refresh") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 state->refresh_rate = SDL_atoi(argv[index]);
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], "--vsync") == 0) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
246 state->render_flags |= SDL_RENDERER_PRESENTVSYNC;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 return 1;
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 if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 state->window_flags |= SDL_WINDOW_BORDERLESS;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 if (SDL_strcasecmp(argv[index], "--resize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 state->window_flags |= SDL_WINDOW_RESIZABLE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 if (SDL_strcasecmp(argv[index], "--minimize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 state->window_flags |= SDL_WINDOW_MINIMIZED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 if (SDL_strcasecmp(argv[index], "--maximize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 state->window_flags |= SDL_WINDOW_MAXIMIZED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 if (SDL_strcasecmp(argv[index], "--grab") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 state->window_flags |= SDL_WINDOW_INPUT_GRABBED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 if (SDL_strcasecmp(argv[index], "--rate") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 return -1;
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 state->audiospec.freq = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 if (SDL_strcasecmp(argv[index], "--format") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 if (SDL_strcasecmp(argv[index], "U8") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 state->audiospec.format = AUDIO_U8;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 if (SDL_strcasecmp(argv[index], "S8") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 state->audiospec.format = AUDIO_S8;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 return 2;
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 if (SDL_strcasecmp(argv[index], "U16") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 state->audiospec.format = AUDIO_U16;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 if (SDL_strcasecmp(argv[index], "U16LE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 state->audiospec.format = AUDIO_U16LSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 if (SDL_strcasecmp(argv[index], "U16BE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 state->audiospec.format = AUDIO_U16MSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 if (SDL_strcasecmp(argv[index], "S16") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 state->audiospec.format = AUDIO_S16;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 if (SDL_strcasecmp(argv[index], "S16LE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 state->audiospec.format = AUDIO_S16LSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 if (SDL_strcasecmp(argv[index], "S16BE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 state->audiospec.format = AUDIO_S16MSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 if (SDL_strcasecmp(argv[index], "--channels") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 }
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
321 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
322 return 2;
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 if (SDL_strcasecmp(argv[index], "--samples") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 }
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
329 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
330 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 if ((SDL_strcasecmp(argv[index], "-h") == 0)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 || (SDL_strcasecmp(argv[index], "--help") == 0)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 /* Print the usage message */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 return 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 const char *
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 CommonUsage(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 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
344 case SDL_INIT_VIDEO:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 return VIDEO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 case SDL_INIT_AUDIO:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 return AUDIO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 return VIDEO_USAGE " " AUDIO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 return "";
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 PrintRendererFlag(Uint32 flag)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 switch (flag) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
359 case SDL_RENDERER_PRESENTVSYNC:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 fprintf(stderr, "PresentVSync");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
362 case SDL_RENDERER_ACCELERATED:
1921
f3399f779a1d Bug fixes to the OpenGL renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
363 fprintf(stderr, "Accelerated");
f3399f779a1d Bug fixes to the OpenGL renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
364 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 fprintf(stderr, "0x%8.8x", flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 }
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 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 PrintPixelFormat(Uint32 format)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 switch (format) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
375 case SDL_PIXELFORMAT_UNKNOWN:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 fprintf(stderr, "Unknwon");
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_INDEX1LSB:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 fprintf(stderr, "Index1LSB");
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_INDEX1MSB:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 fprintf(stderr, "Index1MSB");
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_INDEX4LSB:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 fprintf(stderr, "Index4LSB");
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_INDEX4MSB:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 fprintf(stderr, "Index4MSB");
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_INDEX8:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 fprintf(stderr, "Index8");
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_RGB332:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 fprintf(stderr, "RGB332");
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_RGB444:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 fprintf(stderr, "RGB444");
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_RGB555:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 fprintf(stderr, "RGB555");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 break;
4621
12a9cf73596a Added missing pixel format
Sam Lantinga <slouken@libsdl.org>
parents: 4527
diff changeset
402 case SDL_PIXELFORMAT_BGR555:
12a9cf73596a Added missing pixel format
Sam Lantinga <slouken@libsdl.org>
parents: 4527
diff changeset
403 fprintf(stderr, "BGR555");
12a9cf73596a Added missing pixel format
Sam Lantinga <slouken@libsdl.org>
parents: 4527
diff changeset
404 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
405 case SDL_PIXELFORMAT_ARGB4444:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 fprintf(stderr, "ARGB4444");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 break;
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
408 case SDL_PIXELFORMAT_ABGR4444:
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
409 fprintf(stderr, "ABGR4444");
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
410 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
411 case SDL_PIXELFORMAT_ARGB1555:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 fprintf(stderr, "ARGB1555");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 break;
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
414 case SDL_PIXELFORMAT_ABGR1555:
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
415 fprintf(stderr, "ABGR1555");
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
416 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
417 case SDL_PIXELFORMAT_RGB565:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 fprintf(stderr, "RGB565");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 break;
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
420 case SDL_PIXELFORMAT_BGR565:
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
421 fprintf(stderr, "BGR565");
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
422 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
423 case SDL_PIXELFORMAT_RGB24:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 fprintf(stderr, "RGB24");
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_BGR24:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 fprintf(stderr, "BGR24");
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_RGB888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 fprintf(stderr, "RGB888");
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_BGR888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 fprintf(stderr, "BGR888");
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_ARGB8888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 fprintf(stderr, "ARGB8888");
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_RGBA8888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 fprintf(stderr, "RGBA8888");
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_ABGR8888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 fprintf(stderr, "ABGR8888");
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_BGRA8888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 fprintf(stderr, "BGRA8888");
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_ARGB2101010:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 fprintf(stderr, "ARGB2101010");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
450 case SDL_PIXELFORMAT_YV12:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 fprintf(stderr, "YV12");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
453 case SDL_PIXELFORMAT_IYUV:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 fprintf(stderr, "IYUV");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
456 case SDL_PIXELFORMAT_YUY2:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 fprintf(stderr, "YUY2");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
459 case SDL_PIXELFORMAT_UYVY:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 fprintf(stderr, "UYVY");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
462 case SDL_PIXELFORMAT_YVYU:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 fprintf(stderr, "YVYU");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 fprintf(stderr, "0x%8.8x", format);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 PrintRenderer(SDL_RendererInfo * info)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 int i, count;
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, " Renderer %s:\n", info->name);
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, " Flags: 0x%8.8X", info->flags);
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->flags) * 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->flags & 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 PrintRendererFlag(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, " 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
494 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
495 if (i > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 fprintf(stderr, ", ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 PrintPixelFormat(info->texture_formats[i]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 fprintf(stderr, "\n");
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 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
503 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
504 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
505 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507
4527
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
508 static SDL_Surface *
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
509 LoadIcon(const char *file)
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
510 {
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
511 SDL_Surface *icon;
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
512
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
513 /* Load the icon surface */
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
514 icon = SDL_LoadBMP(file);
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
515 if (icon == NULL) {
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
516 fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
517 return (NULL);
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
518 }
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
519
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
520 if (icon->format->palette == NULL) {
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
521 fprintf(stderr, "Icon must have a palette!\n");
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
522 SDL_FreeSurface(icon);
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
523 return (NULL);
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
524 }
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
525
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
526 /* Set the colorkey */
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
527 SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels));
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
528
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
529 return (icon);
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
530 }
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
531
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 SDL_bool
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 CommonInit(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 int i, j, m, n;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 SDL_DisplayMode fullscreen_mode;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 if (state->flags & SDL_INIT_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 n = SDL_GetNumVideoDrivers();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 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
543 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 fprintf(stderr, "Built-in video drivers:");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 if (i > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 fprintf(stderr, ",");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 fprintf(stderr, " %s", SDL_GetVideoDriver(i));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 }
5125
dc0dfdd58f27 Removed completely non-portable event thread hack.
Sam Lantinga <slouken@libsdl.org>
parents: 5115
diff changeset
554 if (SDL_VideoInit(state->videodriver) < 0) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 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
556 SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 fprintf(stderr, "Video driver: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 SDL_GetCurrentVideoDriver());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
564 /* Upload GL settings */
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
565 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, state->gl_red_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
566 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, state->gl_green_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
567 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, state->gl_blue_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
568 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, state->gl_alpha_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
569 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, state->gl_double_buffer);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
570 SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, state->gl_buffer_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
571 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, state->gl_depth_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
572 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, state->gl_stencil_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
573 SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, state->gl_accum_red_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
574 SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, state->gl_accum_green_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
575 SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, state->gl_accum_blue_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
576 SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, state->gl_accum_alpha_size);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
577 SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
578 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
579 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples);
3571
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3514
diff changeset
580 if (state->gl_accelerated >= 0) {
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3514
diff changeset
581 SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL,
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3514
diff changeset
582 state->gl_accelerated);
19691cebb866 Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents: 3514
diff changeset
583 }
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
584 SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
585 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
586 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3395
diff changeset
587
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 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
589 SDL_DisplayMode mode;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 int bpp;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 Uint32 Rmask, Gmask, Bmask, Amask;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 n = SDL_GetNumVideoDisplays();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594 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
595 for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 fprintf(stderr, "Display %d:\n", i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597
5249
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5239
diff changeset
598 SDL_GetDesktopDisplayMode(i, &mode);
1967
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
599 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
600 &Bmask, &Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 fprintf(stderr,
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
602 " Current mode: %dx%d@%dHz, %d bits-per-pixel (%s)\n",
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
603 mode.w, mode.h, mode.refresh_rate, bpp,
4982
660d3a432102 Added some missing pixel formats and SDL_GetPixelFormatName()
Sam Lantinga <slouken@libsdl.org>
parents: 4929
diff changeset
604 SDL_GetPixelFormatName(mode.format));
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605 if (Rmask || Gmask || Bmask) {
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
606 fprintf(stderr, " Red Mask = 0x%.8x\n", Rmask);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 fprintf(stderr, " Green Mask = 0x%.8x\n", Gmask);
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
608 fprintf(stderr, " Blue Mask = 0x%.8x\n", Bmask);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 if (Amask)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 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
611 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 /* Print available fullscreen video modes */
5249
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5239
diff changeset
614 m = SDL_GetNumDisplayModes(i);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 if (m == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616 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
617 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 fprintf(stderr, " Fullscreen video modes:\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619 for (j = 0; j < m; ++j) {
5249
762e40fb8e28 Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents: 5239
diff changeset
620 SDL_GetDisplayMode(i, j, &mode);
1967
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
621 SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 &Gmask, &Bmask, &Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 fprintf(stderr,
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
624 " Mode %d: %dx%d@%dHz, %d bits-per-pixel (%s)\n",
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
625 j, mode.w, mode.h, mode.refresh_rate, bpp,
4982
660d3a432102 Added some missing pixel formats and SDL_GetPixelFormatName()
Sam Lantinga <slouken@libsdl.org>
parents: 4929
diff changeset
626 SDL_GetPixelFormatName(mode.format));
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 if (Rmask || Gmask || Bmask) {
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
628 fprintf(stderr, " Red Mask = 0x%.8x\n",
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 Rmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 fprintf(stderr, " Green Mask = 0x%.8x\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
631 Gmask);
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
632 fprintf(stderr, " Blue Mask = 0x%.8x\n",
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 Bmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634 if (Amask)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 fprintf(stderr,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636 " Alpha Mask = 0x%.8x\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638 }
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 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 if (state->verbose & VERBOSE_RENDER) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 SDL_RendererInfo info;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
646
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1967
diff changeset
647 n = SDL_GetNumRenderDrivers();
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649 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
650 } else {
1923
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
651 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
652 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
653 SDL_GetRenderDriverInfo(i, &info);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
654 PrintRenderer(&info);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
655 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
659 SDL_zero(fullscreen_mode);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660 switch (state->depth) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
661 case 8:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
662 fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 case 15:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
665 fullscreen_mode.format = SDL_PIXELFORMAT_RGB555;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667 case 16:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
668 fullscreen_mode.format = SDL_PIXELFORMAT_RGB565;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
669 break;
3184
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
670 case 24:
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
671 fullscreen_mode.format = SDL_PIXELFORMAT_RGB24;
68d3b48a6002 SDL pixel format string is printed near mode number in form of SDL_PIXELFORMAT_XXXXX, when --info option is passed. It is usefull for debugging.
Mike Gorchak <lestat@i.com.ua>
parents: 2884
diff changeset
672 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
673 default:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
674 fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677 fullscreen_mode.refresh_rate = state->refresh_rate;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679 state->windows =
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3571
diff changeset
680 (SDL_Window **) SDL_malloc(state->num_windows *
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 sizeof(*state->windows));
5150
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
682 state->renderers =
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
683 (SDL_Renderer **) SDL_malloc(state->num_windows *
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
684 sizeof(*state->renderers));
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
685 if (!state->windows || !state->renderers) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686 fprintf(stderr, "Out of memory!\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 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
690 char title[1024];
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 if (state->num_windows > 1) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693 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
694 state->window_title, i + 1);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
696 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
697 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698 state->windows[i] =
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
699 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
700 state->window_w, state->window_h,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
701 state->window_flags);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
702 if (!state->windows[i]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
703 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
704 SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
705 return SDL_FALSE;
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
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
708 if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
709 fprintf(stderr, "Can't set up fullscreen display mode: %s\n",
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
710 SDL_GetError());
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
711 return SDL_FALSE;
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
712 }
4527
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
713
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
714 if (state->window_icon) {
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
715 SDL_Surface *icon = LoadIcon(state->window_icon);
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
716 if (icon) {
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
717 SDL_SetWindowIcon(state->windows[i], icon);
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
718 SDL_FreeSurface(icon);
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
719 }
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
720 }
3ce59cbecaa3 Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents: 4517
diff changeset
721
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
722 SDL_ShowWindow(state->windows[i]);
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
723
5150
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
724 state->renderers[i] = NULL;
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
725
1933
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
726 if (!state->skip_renderer
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
727 && (state->renderdriver
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
728 || !(state->window_flags & SDL_WINDOW_OPENGL))) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
729 m = -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
730 if (state->renderdriver) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
731 SDL_RendererInfo info;
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1967
diff changeset
732 n = SDL_GetNumRenderDrivers();
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
733 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
734 SDL_GetRenderDriverInfo(j, &info);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
735 if (SDL_strcasecmp(info.name, state->renderdriver) ==
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
736 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
737 m = j;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
738 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
739 }
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 if (m == n) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
742 fprintf(stderr,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
743 "Couldn't find render driver named %s",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
744 state->renderdriver);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
745 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
746 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
747 }
5150
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
748 state->renderers[i] = SDL_CreateRenderer(state->windows[i],
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
749 m, state->render_flags);
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
750 if (!state->renderers[i]) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
751 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
752 SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
753 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
754 }
1923
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
755 if (state->verbose & VERBOSE_RENDER) {
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
756 SDL_RendererInfo info;
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
757
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
758 fprintf(stderr, "Current renderer:\n");
5150
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
759 SDL_GetRendererInfo(state->renderers[i], &info);
1923
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
760 PrintRenderer(&info);
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
761 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
762 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
763 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
764 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
765
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
766 if (state->flags & SDL_INIT_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
767 if (state->verbose & VERBOSE_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
768 n = SDL_GetNumAudioDrivers();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
769 if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
770 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
771 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
772 fprintf(stderr, "Built-in audio drivers:");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
773 for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
774 if (i > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
775 fprintf(stderr, ",");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
776 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
777 fprintf(stderr, " %s", SDL_GetAudioDriver(i));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
778 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
779 fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
780 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
781 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
782 if (SDL_AudioInit(state->audiodriver) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
783 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
784 SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
785 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
786 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
787 if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
788 fprintf(stderr, "Audio driver: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
789 SDL_GetCurrentAudioDriver());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
790 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
791
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
792 if (SDL_OpenAudio(&state->audiospec, NULL) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
793 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
794 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
795 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
796 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
797
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
798 return SDL_TRUE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
799 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
800
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
801 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
802 PrintEvent(SDL_Event * event)
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 fprintf(stderr, "SDL EVENT: ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
805 switch (event->type) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
806 case SDL_WINDOWEVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
807 switch (event->window.event) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
808 case SDL_WINDOWEVENT_SHOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
809 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
810 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
811 case SDL_WINDOWEVENT_HIDDEN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
812 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
813 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
814 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
815 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
816 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
817 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
818 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
819 event->window.windowID, event->window.data1,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
820 event->window.data2);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
821 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
822 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
823 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
824 event->window.windowID, event->window.data1,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
825 event->window.data2);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
826 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
827 case SDL_WINDOWEVENT_MINIMIZED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
828 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
829 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
830 case SDL_WINDOWEVENT_MAXIMIZED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
831 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
832 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
833 case SDL_WINDOWEVENT_RESTORED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
834 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
835 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
836 case SDL_WINDOWEVENT_ENTER:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
837 fprintf(stderr, "Mouse entered window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
838 event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
839 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
840 case SDL_WINDOWEVENT_LEAVE:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
841 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
842 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843 case SDL_WINDOWEVENT_FOCUS_GAINED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
844 fprintf(stderr, "Window %d gained keyboard focus",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
845 event->window.windowID);
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_WINDOWEVENT_FOCUS_LOST:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
848 fprintf(stderr, "Window %d lost keyboard focus",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
849 event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
850 break;
1933
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
851 case SDL_WINDOWEVENT_CLOSE:
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
852 fprintf(stderr, "Window %d closed", event->window.windowID);
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
853 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
854 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
855 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
856 event->window.windowID, event->window.event);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
857 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
858 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
859 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
860 case SDL_KEYDOWN:
2268
4baee598306d Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 2209
diff changeset
861 fprintf(stderr,
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
862 "Keyboard: key pressed in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
863 event->key.windowID,
2306
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
864 event->key.keysym.scancode,
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
865 SDL_GetScancodeName(event->key.keysym.scancode),
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
866 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
867 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
868 case SDL_KEYUP:
2268
4baee598306d Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 2209
diff changeset
869 fprintf(stderr,
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
870 "Keyboard: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
871 event->key.windowID,
2306
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
872 event->key.keysym.scancode,
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
873 SDL_GetScancodeName(event->key.keysym.scancode),
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
874 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
875 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
876 case SDL_TEXTINPUT:
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
877 fprintf(stderr, "Keyboard: text input \"%s\" in window %d",
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
878 event->text.text, event->text.windowID);
1914
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_MOUSEMOTION:
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
881 fprintf(stderr, "Mouse: moved to %d,%d (%d,%d) in window %d",
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
882 event->motion.x, event->motion.y,
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
883 event->motion.xrel, event->motion.yrel,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
884 event->motion.windowID);
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 case SDL_MOUSEBUTTONDOWN:
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
887 fprintf(stderr, "Mouse: button %d pressed at %d,%d in window %d",
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
888 event->button.button, event->button.x, event->button.y,
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
889 event->button.windowID);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
890 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
891 case SDL_MOUSEBUTTONUP:
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
892 fprintf(stderr, "Mouse: button %d released at %d,%d in window %d",
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
893 event->button.button, event->button.x, event->button.y,
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
894 event->button.windowID);
1914
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_MOUSEWHEEL:
2174
Sam Lantinga <slouken@libsdl.org>
parents: 2154
diff changeset
897 fprintf(stderr,
4465
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
898 "Mouse: wheel scrolled %d in x and %d in y in window %d",
3e69e077cb95 Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
899 event->wheel.x, event->wheel.y, event->wheel.windowID);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
900 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
901 case SDL_JOYBALLMOTION:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
902 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
903 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
904 event->jball.yrel);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
905 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
906 case SDL_JOYHATMOTION:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
907 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
908 event->jhat.hat);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
909 switch (event->jhat.value) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
910 case SDL_HAT_CENTERED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
911 fprintf(stderr, "CENTER");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
912 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
913 case SDL_HAT_UP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
914 fprintf(stderr, "UP");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
915 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
916 case SDL_HAT_RIGHTUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
917 fprintf(stderr, "RIGHTUP");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
918 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
919 case SDL_HAT_RIGHT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
920 fprintf(stderr, "RIGHT");
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 case SDL_HAT_RIGHTDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
923 fprintf(stderr, "RIGHTDOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
924 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
925 case SDL_HAT_DOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
926 fprintf(stderr, "DOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
927 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
928 case SDL_HAT_LEFTDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
929 fprintf(stderr, "LEFTDOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
930 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
931 case SDL_HAT_LEFT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
932 fprintf(stderr, "LEFT");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
933 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
934 case SDL_HAT_LEFTUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
935 fprintf(stderr, "LEFTUP");
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 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
938 fprintf(stderr, "UNKNOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
939 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
940 }
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 case SDL_JOYBUTTONDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
943 fprintf(stderr, "Joystick %d: button %d pressed",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
944 event->jbutton.which, event->jbutton.button);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
945 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
946 case SDL_JOYBUTTONUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
947 fprintf(stderr, "Joystick %d: button %d released",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
948 event->jbutton.which, event->jbutton.button);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
949 break;
4503
524dfefd554c Added an event when the clipboard is updated, triggered after the window gains the keyboard focus.
Sam Lantinga <slouken@libsdl.org>
parents: 4497
diff changeset
950 case SDL_CLIPBOARDUPDATE:
524dfefd554c Added an event when the clipboard is updated, triggered after the window gains the keyboard focus.
Sam Lantinga <slouken@libsdl.org>
parents: 4497
diff changeset
951 fprintf(stderr, "Clipboard updated");
524dfefd554c Added an event when the clipboard is updated, triggered after the window gains the keyboard focus.
Sam Lantinga <slouken@libsdl.org>
parents: 4497
diff changeset
952 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
953 case SDL_QUIT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
954 fprintf(stderr, "Quit requested");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
955 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
956 case SDL_USEREVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
957 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
958 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
959 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
960 fprintf(stderr, "Unknown event %d", event->type);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
961 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
962 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
963 fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
964 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
965
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
966 void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
967 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
968 {
3514
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
969 int i;
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
970
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
971 if (state->verbose & VERBOSE_EVENT) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
972 PrintEvent(event);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
973 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
974
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
975 switch (event->type) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
976 case SDL_WINDOWEVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
977 switch (event->window.event) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
978 case SDL_WINDOWEVENT_CLOSE:
5115
686d795b1b29 When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents: 4982
diff changeset
979 {
686d795b1b29 When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents: 4982
diff changeset
980 SDL_Window *pWindow = SDL_GetWindowFromID(event->window.windowID);
686d795b1b29 When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents: 4982
diff changeset
981 if ( pWindow ) {
686d795b1b29 When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents: 4982
diff changeset
982 SDL_DestroyWindow( pWindow );
686d795b1b29 When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents: 4982
diff changeset
983 }
686d795b1b29 When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
krogoway
parents: 4982
diff changeset
984 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
985 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
986 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
987 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
988 case SDL_KEYDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
989 switch (event->key.keysym.sym) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
990 /* Add hotkeys here */
4497
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
991 case SDLK_c:
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
992 if (event->key.keysym.mod & KMOD_CTRL) {
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
993 /* Ctrl-C copy awesome text! */
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
994 SDL_SetClipboardText("SDL rocks!\nYou know it!");
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
995 printf("Copied text to clipboard\n");
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
996 }
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
997 break;
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
998 case SDLK_v:
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
999 if (event->key.keysym.mod & KMOD_CTRL) {
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1000 /* Ctrl-V paste awesome text! */
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1001 char *text = SDL_GetClipboardText();
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1002 if (*text) {
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1003 printf("Clipboard: %s\n", text);
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1004 } else {
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1005 printf("Clipboard is empty\n");
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1006 }
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1007 SDL_free(text);
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1008 }
098a8f3835f0 Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents: 4482
diff changeset
1009 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
1010 case SDLK_g:
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
1011 if (event->key.keysym.mod & KMOD_CTRL) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
1012 /* Ctrl-G toggle grab */
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
1013 }
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
1014 break;
4517
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1015 case SDLK_m:
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1016 if (event->key.keysym.mod & KMOD_CTRL) {
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1017 /* Ctrl-M maximize */
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1018 /* FIXME: Which window has focus for this keyboard? */
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1019 for (i = 0; i < state->num_windows; ++i) {
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1020 if (SDL_GetWindowFlags(state->windows[i]) & SDL_WINDOW_MAXIMIZED) {
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1021 SDL_RestoreWindow(state->windows[i]);
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1022 } else {
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1023 SDL_MaximizeWindow(state->windows[i]);
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1024 }
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1025 }
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1026 }
7b5e4396bcaa Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents: 4503
diff changeset
1027 break;
3514
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1028 case SDLK_z:
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1029 if (event->key.keysym.mod & KMOD_CTRL) {
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1030 /* Ctrl-Z minimize */
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1031 /* FIXME: Which window has focus for this keyboard? */
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1032 for (i = 0; i < state->num_windows; ++i) {
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1033 SDL_MinimizeWindow(state->windows[i]);
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1034 }
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1035 }
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1036 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1037 case SDLK_ESCAPE:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1038 *done = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1039 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1040 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1041 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1042 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1043 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1044 case SDL_QUIT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1045 *done = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1046 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1047 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1048 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1049
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1050 void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1051 CommonQuit(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1052 {
5150
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1053 int i;
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1054
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1055 if (state->windows) {
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1056 SDL_free(state->windows);
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1057 }
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1058 if (state->renderers) {
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1059 for (i = 0; i < state->num_windows; ++i) {
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1060 if (state->renderers[i]) {
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1061 SDL_DestroyRenderer(state->renderers[i]);
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1062 }
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1063 }
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1064 SDL_free(state->renderers);
ad50b3db78bd The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents: 5145
diff changeset
1065 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1066 if (state->flags & SDL_INIT_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1067 SDL_VideoQuit();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1068 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1069 if (state->flags & SDL_INIT_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1070 SDL_AudioQuit();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1071 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1072 SDL_free(state);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1073 }
3514
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1074
f0b7bc1fe12d Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
1075 /* vi: set ts=4 sw=4 expandtab: */