author | Sam Lantinga <slouken@libsdl.org> |
Sat, 29 Sep 2012 01:12:40 -0700 | |
changeset 6513 | c781fb99ce39 |
parent 6509 | e94d5a5376c1 |
child 6543 | 44a83e1a48f9 |
permissions | -rw-r--r-- |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
1 |
/* |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
2 |
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org> |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
3 |
|
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
4 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
5 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
6 |
arising from the use of this software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
7 |
|
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
8 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
9 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
10 |
freely. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5522
diff
changeset
|
11 |
*/ |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 |
/* A simple test program framework */ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 |
#include <stdio.h> |
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 |
#include "common.h" |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 |
#define VIDEO_USAGE \ |
5234
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
20 |
"[--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
|
21 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
#define AUDIO_USAGE \ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
"[--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
|
24 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
CommonState * |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
CommonCreateState(char **argv, Uint32 flags) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
{ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
CommonState *state = SDL_calloc(1, sizeof(*state)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
if (!state) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
SDL_OutOfMemory(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
return NULL; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
/* Initialize some defaults */ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
state->argv = argv; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
state->flags = flags; |
5517 | 37 |
#ifdef __NDS__ |
38 |
state->window_title = ""; |
|
39 |
#else |
|
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
state->window_title = argv[0]; |
5517 | 41 |
#endif |
3500
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3408
diff
changeset
|
42 |
state->window_flags = 0; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
state->window_x = SDL_WINDOWPOS_UNDEFINED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
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
|
45 |
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
|
46 |
state->window_h = DEFAULT_WINDOW_HEIGHT; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
state->num_windows = 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
state->audiospec.freq = 22050; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
state->audiospec.format = AUDIO_S16; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
state->audiospec.channels = 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 |
state->audiospec.samples = 2048; |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
52 |
|
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
53 |
/* 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
|
54 |
state->gl_red_size = 3; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
55 |
state->gl_green_size = 3; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
56 |
state->gl_blue_size = 2; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
57 |
state->gl_alpha_size = 0; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
58 |
state->gl_buffer_size = 0; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
59 |
state->gl_depth_size = 16; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
60 |
state->gl_stencil_size = 0; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
61 |
state->gl_double_buffer = 1; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
62 |
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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
state->gl_stereo = 0; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
67 |
state->gl_multisamplebuffers = 0; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
68 |
state->gl_multisamplesamples = 0; |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
69 |
state->gl_retained_backing = 1; |
3571
19691cebb866
Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents:
3514
diff
changeset
|
70 |
state->gl_accelerated = -1; |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
71 |
|
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
return state; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
} |
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 |
int |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
CommonArg(CommonState * state, int index) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
{ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
char **argv = state->argv; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
|
5517 | 80 |
#ifdef __NDS__ |
81 |
return 0; |
|
82 |
#endif |
|
83 |
||
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
if (SDL_strcasecmp(argv[index], "--video") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
state->videodriver = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
if (SDL_strcasecmp(argv[index], "--renderer") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
state->renderdriver = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
if (SDL_strcasecmp(argv[index], "--info") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
if (SDL_strcasecmp(argv[index], "all") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
state->verbose |= |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
(VERBOSE_VIDEO | VERBOSE_MODES | VERBOSE_RENDER | |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
VERBOSE_EVENT); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
if (SDL_strcasecmp(argv[index], "video") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
state->verbose |= VERBOSE_VIDEO; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
if (SDL_strcasecmp(argv[index], "modes") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
state->verbose |= VERBOSE_MODES; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 |
if (SDL_strcasecmp(argv[index], "render") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 |
state->verbose |= VERBOSE_RENDER; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
if (SDL_strcasecmp(argv[index], "event") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
state->verbose |= VERBOSE_EVENT; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
} |
5234
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
129 |
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:
5147
diff
changeset
|
130 |
++index; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
131 |
if (!argv[index]) { |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
132 |
return -1; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
133 |
} |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
134 |
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:
5147
diff
changeset
|
135 |
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:
5147
diff
changeset
|
136 |
return 2; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
137 |
} |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
138 |
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:
5147
diff
changeset
|
139 |
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:
5147
diff
changeset
|
140 |
return 2; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
141 |
} |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
142 |
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:
5147
diff
changeset
|
143 |
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:
5147
diff
changeset
|
144 |
return 2; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
145 |
} |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
146 |
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:
5147
diff
changeset
|
147 |
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:
5147
diff
changeset
|
148 |
return 2; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
149 |
} |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
150 |
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:
5147
diff
changeset
|
151 |
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:
5147
diff
changeset
|
152 |
return 2; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
153 |
} |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
154 |
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:
5147
diff
changeset
|
155 |
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:
5147
diff
changeset
|
156 |
return 2; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
157 |
} |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
158 |
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:
5147
diff
changeset
|
159 |
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:
5147
diff
changeset
|
160 |
return 2; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
161 |
} |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
162 |
return -1; |
af8ca17f6b7c
Added the ability to turn on logging output to the test programs
Sam Lantinga <slouken@libsdl.org>
parents:
5147
diff
changeset
|
163 |
} |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
if (SDL_strcasecmp(argv[index], "--display") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 |
state->display = SDL_atoi(argv[index]); |
5247
d844537c42fd
Allow windows to be created on non-primary displays.
Sam Lantinga <slouken@libsdl.org>
parents:
5246
diff
changeset
|
170 |
if (SDL_WINDOWPOS_ISUNDEFINED(state->window_x)) { |
d844537c42fd
Allow windows to be created on non-primary displays.
Sam Lantinga <slouken@libsdl.org>
parents:
5246
diff
changeset
|
171 |
state->window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->display); |
d844537c42fd
Allow windows to be created on non-primary displays.
Sam Lantinga <slouken@libsdl.org>
parents:
5246
diff
changeset
|
172 |
state->window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->display); |
d844537c42fd
Allow windows to be created on non-primary displays.
Sam Lantinga <slouken@libsdl.org>
parents:
5246
diff
changeset
|
173 |
} |
5304
59e6e16351e6
Allow centering on a different display
Sam Lantinga <slouken@libsdl.org>
parents:
5247
diff
changeset
|
174 |
if (SDL_WINDOWPOS_ISCENTERED(state->window_x)) { |
59e6e16351e6
Allow centering on a different display
Sam Lantinga <slouken@libsdl.org>
parents:
5247
diff
changeset
|
175 |
state->window_x = SDL_WINDOWPOS_CENTERED_DISPLAY(state->display); |
59e6e16351e6
Allow centering on a different display
Sam Lantinga <slouken@libsdl.org>
parents:
5247
diff
changeset
|
176 |
state->window_y = SDL_WINDOWPOS_CENTERED_DISPLAY(state->display); |
59e6e16351e6
Allow centering on a different display
Sam Lantinga <slouken@libsdl.org>
parents:
5247
diff
changeset
|
177 |
} |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 |
if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
state->window_flags |= SDL_WINDOW_FULLSCREEN; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 |
state->num_windows = 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 |
return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
if (SDL_strcasecmp(argv[index], "--windows") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 |
++index; |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1914
diff
changeset
|
187 |
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
|
188 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 |
if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
state->num_windows = SDL_atoi(argv[index]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
if (SDL_strcasecmp(argv[index], "--title") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 |
state->window_title = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
} |
4527
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
203 |
if (SDL_strcasecmp(argv[index], "--icon") == 0) { |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
204 |
++index; |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
205 |
if (!argv[index]) { |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
206 |
return -1; |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
207 |
} |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
208 |
state->window_icon = argv[index]; |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
209 |
return 2; |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
210 |
} |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
if (SDL_strcasecmp(argv[index], "--center") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 |
state->window_x = SDL_WINDOWPOS_CENTERED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 |
state->window_y = SDL_WINDOWPOS_CENTERED; |
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 |
if (SDL_strcasecmp(argv[index], "--position") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 |
char *x, *y; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 |
x = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
y = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 |
while (*y && *y != ',') { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 |
++y; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 |
if (!*y) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 |
*y++ = '\0'; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
state->window_x = SDL_atoi(x); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 |
state->window_y = SDL_atoi(y); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 |
if (SDL_strcasecmp(argv[index], "--geometry") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
char *w, *h; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
w = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
h = argv[index]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
while (*h && *h != 'x') { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
++h; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 |
if (!*h) { |
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 |
*h++ = '\0'; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 |
state->window_w = SDL_atoi(w); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
state->window_h = SDL_atoi(h); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
} |
2209
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
254 |
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
|
255 |
++index; |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
256 |
if (!argv[index]) { |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
257 |
return -1; |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
258 |
} |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
259 |
state->depth = SDL_atoi(argv[index]); |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
260 |
return 2; |
b292fa4941c6
Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
261 |
} |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 |
if (SDL_strcasecmp(argv[index], "--refresh") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 |
state->refresh_rate = SDL_atoi(argv[index]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 |
if (SDL_strcasecmp(argv[index], "--vsync") == 0) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
271 |
state->render_flags |= SDL_RENDERER_PRESENTVSYNC; |
1914
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 |
if (SDL_strcasecmp(argv[index], "--noframe") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 |
state->window_flags |= SDL_WINDOW_BORDERLESS; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 |
return 1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 |
if (SDL_strcasecmp(argv[index], "--resize") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 |
state->window_flags |= SDL_WINDOW_RESIZABLE; |
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], "--minimize") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 |
state->window_flags |= SDL_WINDOW_MINIMIZED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 |
return 1; |
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], "--maximize") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 |
state->window_flags |= SDL_WINDOW_MAXIMIZED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 |
return 1; |
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], "--grab") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 |
state->window_flags |= SDL_WINDOW_INPUT_GRABBED; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 |
return 1; |
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], "--rate") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 |
state->audiospec.freq = SDL_atoi(argv[index]); |
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], "--format") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 |
if (SDL_strcasecmp(argv[index], "U8") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 |
state->audiospec.format = AUDIO_U8; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 |
if (SDL_strcasecmp(argv[index], "S8") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 |
state->audiospec.format = AUDIO_S8; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 |
if (SDL_strcasecmp(argv[index], "U16") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 |
state->audiospec.format = AUDIO_U16; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
if (SDL_strcasecmp(argv[index], "U16LE") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 |
state->audiospec.format = AUDIO_U16LSB; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 |
if (SDL_strcasecmp(argv[index], "U16BE") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 |
state->audiospec.format = AUDIO_U16MSB; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 |
if (SDL_strcasecmp(argv[index], "S16") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 |
state->audiospec.format = AUDIO_S16; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 |
if (SDL_strcasecmp(argv[index], "S16LE") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
state->audiospec.format = AUDIO_S16LSB; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 |
if (SDL_strcasecmp(argv[index], "S16BE") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 |
state->audiospec.format = AUDIO_S16MSB; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
return 2; |
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 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 |
if (SDL_strcasecmp(argv[index], "--channels") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
} |
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
|
346 |
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
|
347 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 |
if (SDL_strcasecmp(argv[index], "--samples") == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 |
++index; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 |
if (!argv[index]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 |
} |
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
|
354 |
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
|
355 |
return 2; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 |
if ((SDL_strcasecmp(argv[index], "-h") == 0) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 |
|| (SDL_strcasecmp(argv[index], "--help") == 0)) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 |
/* Print the usage message */ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 |
return -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 |
} |
6175
42c40787f382
Added testnative to the Makefile and fixed building on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
362 |
if (SDL_strcmp(argv[index], "-NSDocumentRevisionsDebugMode") == 0) { |
42c40787f382
Added testnative to the Makefile and fixed building on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
363 |
/* Debug flag sent by Xcode */ |
42c40787f382
Added testnative to the Makefile and fixed building on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
364 |
return 2; |
42c40787f382
Added testnative to the Makefile and fixed building on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
365 |
} |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 |
return 0; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 |
const char * |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 |
CommonUsage(CommonState * state) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 |
{ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 |
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
|
373 |
case SDL_INIT_VIDEO: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 |
return VIDEO_USAGE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 |
case SDL_INIT_AUDIO: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 |
return AUDIO_USAGE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 |
case (SDL_INIT_VIDEO | SDL_INIT_AUDIO): |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 |
return VIDEO_USAGE " " AUDIO_USAGE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 |
default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 |
return ""; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 |
static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 |
PrintRendererFlag(Uint32 flag) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 |
{ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 |
switch (flag) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
388 |
case SDL_RENDERER_PRESENTVSYNC: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 |
fprintf(stderr, "PresentVSync"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
391 |
case SDL_RENDERER_ACCELERATED: |
1921
f3399f779a1d
Bug fixes to the OpenGL renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
392 |
fprintf(stderr, "Accelerated"); |
f3399f779a1d
Bug fixes to the OpenGL renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
393 |
break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 |
default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 |
fprintf(stderr, "0x%8.8x", flag); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 |
static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 |
PrintPixelFormat(Uint32 format) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 |
{ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 |
switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
404 |
case SDL_PIXELFORMAT_UNKNOWN: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 |
fprintf(stderr, "Unknwon"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
407 |
case SDL_PIXELFORMAT_INDEX1LSB: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 |
fprintf(stderr, "Index1LSB"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
410 |
case SDL_PIXELFORMAT_INDEX1MSB: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 |
fprintf(stderr, "Index1MSB"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
413 |
case SDL_PIXELFORMAT_INDEX4LSB: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 |
fprintf(stderr, "Index4LSB"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
416 |
case SDL_PIXELFORMAT_INDEX4MSB: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 |
fprintf(stderr, "Index4MSB"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
419 |
case SDL_PIXELFORMAT_INDEX8: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 |
fprintf(stderr, "Index8"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
422 |
case SDL_PIXELFORMAT_RGB332: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 |
fprintf(stderr, "RGB332"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
425 |
case SDL_PIXELFORMAT_RGB444: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 |
fprintf(stderr, "RGB444"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
428 |
case SDL_PIXELFORMAT_RGB555: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 |
fprintf(stderr, "RGB555"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 |
break; |
4621
12a9cf73596a
Added missing pixel format
Sam Lantinga <slouken@libsdl.org>
parents:
4527
diff
changeset
|
431 |
case SDL_PIXELFORMAT_BGR555: |
12a9cf73596a
Added missing pixel format
Sam Lantinga <slouken@libsdl.org>
parents:
4527
diff
changeset
|
432 |
fprintf(stderr, "BGR555"); |
12a9cf73596a
Added missing pixel format
Sam Lantinga <slouken@libsdl.org>
parents:
4527
diff
changeset
|
433 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
434 |
case SDL_PIXELFORMAT_ARGB4444: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 |
fprintf(stderr, "ARGB4444"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 |
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
|
437 |
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
|
438 |
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
|
439 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
440 |
case SDL_PIXELFORMAT_ARGB1555: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 |
fprintf(stderr, "ARGB1555"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 |
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
|
443 |
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
|
444 |
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
|
445 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
446 |
case SDL_PIXELFORMAT_RGB565: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 |
fprintf(stderr, "RGB565"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
452 |
case SDL_PIXELFORMAT_RGB24: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 |
fprintf(stderr, "RGB24"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
455 |
case SDL_PIXELFORMAT_BGR24: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 |
fprintf(stderr, "BGR24"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
458 |
case SDL_PIXELFORMAT_RGB888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 |
fprintf(stderr, "RGB888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
461 |
case SDL_PIXELFORMAT_BGR888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 |
fprintf(stderr, "BGR888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
464 |
case SDL_PIXELFORMAT_ARGB8888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 |
fprintf(stderr, "ARGB8888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
467 |
case SDL_PIXELFORMAT_RGBA8888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 |
fprintf(stderr, "RGBA8888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
470 |
case SDL_PIXELFORMAT_ABGR8888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 |
fprintf(stderr, "ABGR8888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
473 |
case SDL_PIXELFORMAT_BGRA8888: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 |
fprintf(stderr, "BGRA8888"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
476 |
case SDL_PIXELFORMAT_ARGB2101010: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 |
fprintf(stderr, "ARGB2101010"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
479 |
case SDL_PIXELFORMAT_YV12: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 |
fprintf(stderr, "YV12"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
482 |
case SDL_PIXELFORMAT_IYUV: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 |
fprintf(stderr, "IYUV"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
485 |
case SDL_PIXELFORMAT_YUY2: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 |
fprintf(stderr, "YUY2"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
488 |
case SDL_PIXELFORMAT_UYVY: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 |
fprintf(stderr, "UYVY"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
491 |
case SDL_PIXELFORMAT_YVYU: |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 |
fprintf(stderr, "YVYU"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 |
default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 |
fprintf(stderr, "0x%8.8x", format); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 |
break; |
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 |
} |
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 |
static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 |
PrintRenderer(SDL_RendererInfo * info) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 |
{ |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 |
int i, count; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 |
fprintf(stderr, " Renderer %s:\n", info->name); |
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 |
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
|
508 |
fprintf(stderr, " ("); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 |
count = 0; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 |
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
|
511 |
Uint32 flag = (1 << i); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 |
if (info->flags & flag) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 |
if (count > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 |
fprintf(stderr, " | "); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 |
PrintRendererFlag(flag); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 |
++count; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 |
fprintf(stderr, ")\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 |
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
|
523 |
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
|
524 |
if (i > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 |
fprintf(stderr, ", "); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 |
PrintPixelFormat(info->texture_formats[i]); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 |
fprintf(stderr, "\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 |
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
|
532 |
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
|
533 |
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
|
534 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 |
|
4527
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
537 |
static SDL_Surface * |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
538 |
LoadIcon(const char *file) |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
539 |
{ |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
540 |
SDL_Surface *icon; |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
541 |
|
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
542 |
/* Load the icon surface */ |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
543 |
icon = SDL_LoadBMP(file); |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
544 |
if (icon == NULL) { |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
545 |
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
|
546 |
return (NULL); |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
547 |
} |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
548 |
|
6509
e94d5a5376c1
SDL 2.0 supports 32-bit icons with alpha. :)
Sam Lantinga <slouken@libsdl.org>
parents:
6508
diff
changeset
|
549 |
if (icon->format->palette) { |
e94d5a5376c1
SDL 2.0 supports 32-bit icons with alpha. :)
Sam Lantinga <slouken@libsdl.org>
parents:
6508
diff
changeset
|
550 |
/* Set the colorkey */ |
e94d5a5376c1
SDL 2.0 supports 32-bit icons with alpha. :)
Sam Lantinga <slouken@libsdl.org>
parents:
6508
diff
changeset
|
551 |
SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels)); |
4527
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
552 |
} |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
553 |
|
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
554 |
return (icon); |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
555 |
} |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
556 |
|
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 |
SDL_bool |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 |
CommonInit(CommonState * state) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
559 |
{ |
6471
5f6990aaf357
Print a message if the window size was changed from the requested size.
Sam Lantinga <slouken@libsdl.org>
parents:
6422
diff
changeset
|
560 |
int i, j, m, n, w, h; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 |
SDL_DisplayMode fullscreen_mode; |
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 |
if (state->flags & SDL_INIT_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 |
if (state->verbose & VERBOSE_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 |
n = SDL_GetNumVideoDrivers(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
566 |
if (n == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
567 |
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
|
568 |
} else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 |
fprintf(stderr, "Built-in video drivers:"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 |
for (i = 0; i < n; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 |
if (i > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 |
fprintf(stderr, ","); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 |
fprintf(stderr, " %s", SDL_GetVideoDriver(i)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 |
fprintf(stderr, "\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 |
} |
5123
dc0dfdd58f27
Removed completely non-portable event thread hack.
Sam Lantinga <slouken@libsdl.org>
parents:
5113
diff
changeset
|
579 |
if (SDL_VideoInit(state->videodriver) < 0) { |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 |
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
|
581 |
SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 |
return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 |
if (state->verbose & VERBOSE_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 |
fprintf(stderr, "Video driver: %s\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 |
SDL_GetCurrentVideoDriver()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 |
|
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
589 |
/* Upload GL settings */ |
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
590 |
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
|
591 |
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
|
592 |
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
|
593 |
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
|
594 |
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
|
595 |
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
|
596 |
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
|
597 |
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
|
598 |
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
|
599 |
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
|
600 |
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
|
601 |
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
|
602 |
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
|
603 |
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
|
604 |
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
|
605 |
if (state->gl_accelerated >= 0) { |
19691cebb866
Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents:
3514
diff
changeset
|
606 |
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, |
19691cebb866
Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents:
3514
diff
changeset
|
607 |
state->gl_accelerated); |
19691cebb866
Default to allow either accelerated or not
Sam Lantinga <slouken@libsdl.org>
parents:
3514
diff
changeset
|
608 |
} |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
609 |
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing); |
5363
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
5349
diff
changeset
|
610 |
if (state->gl_major_version) { |
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
5349
diff
changeset
|
611 |
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version); |
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
5349
diff
changeset
|
612 |
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version); |
96799a165806
Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents:
5349
diff
changeset
|
613 |
} |
3408
55541ddf13e3
Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3395
diff
changeset
|
614 |
|
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 |
if (state->verbose & VERBOSE_MODES) { |
6505
ce7abf273d8c
Print the bounds of each display when showing mode information
Sam Lantinga <slouken@libsdl.org>
parents:
6503
diff
changeset
|
616 |
SDL_Rect bounds; |
1967
01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
617 |
SDL_DisplayMode mode; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 |
int bpp; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 |
Uint32 Rmask, Gmask, Bmask, Amask; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 |
n = SDL_GetNumVideoDisplays(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 |
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
|
623 |
for (i = 0; i < n; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 |
fprintf(stderr, "Display %d:\n", i); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 |
|
6505
ce7abf273d8c
Print the bounds of each display when showing mode information
Sam Lantinga <slouken@libsdl.org>
parents:
6503
diff
changeset
|
626 |
SDL_zero(bounds); |
ce7abf273d8c
Print the bounds of each display when showing mode information
Sam Lantinga <slouken@libsdl.org>
parents:
6503
diff
changeset
|
627 |
SDL_GetDisplayBounds(i, &bounds); |
ce7abf273d8c
Print the bounds of each display when showing mode information
Sam Lantinga <slouken@libsdl.org>
parents:
6503
diff
changeset
|
628 |
fprintf(stderr, "Bounds: %dx%d at %d,%d\n", bounds.w, bounds.h, bounds.x, bounds.y); |
ce7abf273d8c
Print the bounds of each display when showing mode information
Sam Lantinga <slouken@libsdl.org>
parents:
6503
diff
changeset
|
629 |
|
5244
762e40fb8e28
Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents:
5234
diff
changeset
|
630 |
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
|
631 |
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
|
632 |
&Bmask, &Amask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
633 |
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
|
634 |
" 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
|
635 |
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
|
636 |
SDL_GetPixelFormatName(mode.format)); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
637 |
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
|
638 |
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
|
639 |
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
|
640 |
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
|
641 |
if (Amask) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 |
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
|
643 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 |
/* Print available fullscreen video modes */ |
5244
762e40fb8e28
Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents:
5234
diff
changeset
|
646 |
m = SDL_GetNumDisplayModes(i); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 |
if (m == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 |
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
|
649 |
} else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 |
fprintf(stderr, " Fullscreen video modes:\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 |
for (j = 0; j < m; ++j) { |
5244
762e40fb8e28
Be explicit about what display you're querying. The default display is 0.
Sam Lantinga <slouken@libsdl.org>
parents:
5234
diff
changeset
|
652 |
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
|
653 |
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 |
&Gmask, &Bmask, &Amask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 |
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
|
656 |
" 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
|
657 |
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
|
658 |
SDL_GetPixelFormatName(mode.format)); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 |
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
|
660 |
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
|
661 |
Rmask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
662 |
fprintf(stderr, " Green Mask = 0x%.8x\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
663 |
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
|
664 |
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
|
665 |
Bmask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 |
if (Amask) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 |
fprintf(stderr, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 |
" Alpha Mask = 0x%.8x\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 |
Amask); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
676 |
if (state->verbose & VERBOSE_RENDER) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
677 |
SDL_RendererInfo info; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
678 |
|
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
679 |
n = SDL_GetNumRenderDrivers(); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
680 |
if (n == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 |
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
|
682 |
} else { |
1923
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
683 |
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
|
684 |
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
|
685 |
SDL_GetRenderDriverInfo(i, &info); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 |
PrintRenderer(&info); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
687 |
} |
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 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 |
|
3500
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3408
diff
changeset
|
691 |
SDL_zero(fullscreen_mode); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
692 |
switch (state->depth) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
693 |
case 8: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
694 |
fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
695 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
696 |
case 15: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
697 |
fullscreen_mode.format = SDL_PIXELFORMAT_RGB555; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
698 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
699 |
case 16: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
700 |
fullscreen_mode.format = SDL_PIXELFORMAT_RGB565; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 |
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
|
702 |
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
|
703 |
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
|
704 |
break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 |
default: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
706 |
fullscreen_mode.format = SDL_PIXELFORMAT_RGB888; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 |
fullscreen_mode.refresh_rate = state->refresh_rate; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 |
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
|
712 |
(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
|
713 |
sizeof(*state->windows)); |
5147
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:
5142
diff
changeset
|
714 |
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:
5142
diff
changeset
|
715 |
(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:
5142
diff
changeset
|
716 |
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:
5142
diff
changeset
|
717 |
if (!state->windows || !state->renderers) { |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 |
fprintf(stderr, "Out of memory!\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
719 |
return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
720 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
721 |
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
|
722 |
char title[1024]; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
723 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
724 |
if (state->num_windows > 1) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
725 |
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
|
726 |
state->window_title, i + 1); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
727 |
} else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
728 |
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
|
729 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
730 |
state->windows[i] = |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
731 |
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
|
732 |
state->window_w, state->window_h, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
733 |
state->window_flags); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 |
if (!state->windows[i]) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 |
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
|
736 |
SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 |
return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 |
} |
6471
5f6990aaf357
Print a message if the window size was changed from the requested size.
Sam Lantinga <slouken@libsdl.org>
parents:
6422
diff
changeset
|
739 |
SDL_GetWindowSize(state->windows[i], &w, &h); |
6503
8ff31baded38
Don't warn about the window size changing if the window is resizable
Sam Lantinga <slouken@libsdl.org>
parents:
6471
diff
changeset
|
740 |
if (!(state->window_flags & SDL_WINDOW_RESIZABLE) && |
8ff31baded38
Don't warn about the window size changing if the window is resizable
Sam Lantinga <slouken@libsdl.org>
parents:
6471
diff
changeset
|
741 |
(w != state->window_w || h != state->window_h)) { |
6471
5f6990aaf357
Print a message if the window size was changed from the requested size.
Sam Lantinga <slouken@libsdl.org>
parents:
6422
diff
changeset
|
742 |
printf("Window requested size %dx%d, got %dx%d\n", state->window_w, state->window_h, w, h); |
5f6990aaf357
Print a message if the window size was changed from the requested size.
Sam Lantinga <slouken@libsdl.org>
parents:
6422
diff
changeset
|
743 |
state->window_w = w; |
5f6990aaf357
Print a message if the window size was changed from the requested size.
Sam Lantinga <slouken@libsdl.org>
parents:
6422
diff
changeset
|
744 |
state->window_h = h; |
5f6990aaf357
Print a message if the window size was changed from the requested size.
Sam Lantinga <slouken@libsdl.org>
parents:
6422
diff
changeset
|
745 |
} |
3500
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3408
diff
changeset
|
746 |
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
|
747 |
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
|
748 |
SDL_GetError()); |
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3408
diff
changeset
|
749 |
return SDL_FALSE; |
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3408
diff
changeset
|
750 |
} |
4527
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
751 |
|
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
752 |
if (state->window_icon) { |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
753 |
SDL_Surface *icon = LoadIcon(state->window_icon); |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
754 |
if (icon) { |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
755 |
SDL_SetWindowIcon(state->windows[i], icon); |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
756 |
SDL_FreeSurface(icon); |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
757 |
} |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
758 |
} |
3ce59cbecaa3
Added support for testing window manager icons
Sam Lantinga <slouken@libsdl.org>
parents:
4517
diff
changeset
|
759 |
|
3500
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3408
diff
changeset
|
760 |
SDL_ShowWindow(state->windows[i]); |
4b594623401b
Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents:
3408
diff
changeset
|
761 |
|
5147
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:
5142
diff
changeset
|
762 |
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:
5142
diff
changeset
|
763 |
|
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
764 |
if (!state->skip_renderer |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
765 |
&& (state->renderdriver |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
766 |
|| !(state->window_flags & SDL_WINDOW_OPENGL))) { |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
767 |
m = -1; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
768 |
if (state->renderdriver) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
769 |
SDL_RendererInfo info; |
1969
5d3724f64f2b
Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents:
1967
diff
changeset
|
770 |
n = SDL_GetNumRenderDrivers(); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
771 |
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
|
772 |
SDL_GetRenderDriverInfo(j, &info); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
773 |
if (SDL_strcasecmp(info.name, state->renderdriver) == |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
774 |
0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
775 |
m = j; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
776 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
777 |
} |
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 |
if (m == n) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
780 |
fprintf(stderr, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
781 |
"Couldn't find render driver named %s", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
782 |
state->renderdriver); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
783 |
return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
784 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
785 |
} |
5147
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:
5142
diff
changeset
|
786 |
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:
5142
diff
changeset
|
787 |
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:
5142
diff
changeset
|
788 |
if (!state->renderers[i]) { |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
789 |
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
|
790 |
SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
791 |
return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
792 |
} |
1923
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
793 |
if (state->verbose & VERBOSE_RENDER) { |
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
794 |
SDL_RendererInfo info; |
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
795 |
|
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
796 |
fprintf(stderr, "Current renderer:\n"); |
5147
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:
5142
diff
changeset
|
797 |
SDL_GetRendererInfo(state->renderers[i], &info); |
1923
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
798 |
PrintRenderer(&info); |
d4572b97b08f
Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents:
1921
diff
changeset
|
799 |
} |
1914
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 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
802 |
} |
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 |
if (state->flags & SDL_INIT_AUDIO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
805 |
if (state->verbose & VERBOSE_AUDIO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
806 |
n = SDL_GetNumAudioDrivers(); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
807 |
if (n == 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
808 |
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
|
809 |
} else { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
810 |
fprintf(stderr, "Built-in audio drivers:"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
811 |
for (i = 0; i < n; ++i) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
812 |
if (i > 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
813 |
fprintf(stderr, ","); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
814 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
815 |
fprintf(stderr, " %s", SDL_GetAudioDriver(i)); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
816 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
817 |
fprintf(stderr, "\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
818 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
819 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
820 |
if (SDL_AudioInit(state->audiodriver) < 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
821 |
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
|
822 |
SDL_GetError()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
823 |
return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
824 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
825 |
if (state->verbose & VERBOSE_VIDEO) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
826 |
fprintf(stderr, "Audio driver: %s\n", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
827 |
SDL_GetCurrentAudioDriver()); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
828 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
829 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
830 |
if (SDL_OpenAudio(&state->audiospec, NULL) < 0) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
831 |
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
|
832 |
return SDL_FALSE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
833 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
834 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
835 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
836 |
return SDL_TRUE; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
837 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
838 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
839 |
static void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
840 |
PrintEvent(SDL_Event * event) |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
841 |
{ |
5404
6717e01acbe0
Fixed minimizing fullscreen windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5363
diff
changeset
|
842 |
if (event->type == SDL_MOUSEMOTION) { |
6717e01acbe0
Fixed minimizing fullscreen windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5363
diff
changeset
|
843 |
/* Mouse motion is really spammy */ |
5406
1517da4ab6b1
Implemented mouse relative mode on Mac OS X.
Sam Lantinga <slouken@libsdl.org>
parents:
5404
diff
changeset
|
844 |
//return; |
5404
6717e01acbe0
Fixed minimizing fullscreen windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5363
diff
changeset
|
845 |
} |
6717e01acbe0
Fixed minimizing fullscreen windows.
Sam Lantinga <slouken@libsdl.org>
parents:
5363
diff
changeset
|
846 |
|
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
847 |
fprintf(stderr, "SDL EVENT: "); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
848 |
switch (event->type) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
849 |
case SDL_WINDOWEVENT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
850 |
switch (event->window.event) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
851 |
case SDL_WINDOWEVENT_SHOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
852 |
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
|
853 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
854 |
case SDL_WINDOWEVENT_HIDDEN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
855 |
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
|
856 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
857 |
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
|
858 |
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
|
859 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
860 |
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
|
861 |
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
|
862 |
event->window.windowID, event->window.data1, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
863 |
event->window.data2); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
864 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
865 |
case SDL_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
|
866 |
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
|
867 |
event->window.windowID, event->window.data1, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
868 |
event->window.data2); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
869 |
break; |
6508
81a3d541d9a2
Show the size changed window message
Sam Lantinga <slouken@libsdl.org>
parents:
6505
diff
changeset
|
870 |
case SDL_WINDOWEVENT_SIZE_CHANGED: |
81a3d541d9a2
Show the size changed window message
Sam Lantinga <slouken@libsdl.org>
parents:
6505
diff
changeset
|
871 |
fprintf(stderr, "Window %d changed size to %dx%d", |
81a3d541d9a2
Show the size changed window message
Sam Lantinga <slouken@libsdl.org>
parents:
6505
diff
changeset
|
872 |
event->window.windowID, event->window.data1, |
81a3d541d9a2
Show the size changed window message
Sam Lantinga <slouken@libsdl.org>
parents:
6505
diff
changeset
|
873 |
event->window.data2); |
81a3d541d9a2
Show the size changed window message
Sam Lantinga <slouken@libsdl.org>
parents:
6505
diff
changeset
|
874 |
break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
875 |
case SDL_WINDOWEVENT_MINIMIZED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
876 |
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
|
877 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
878 |
case SDL_WINDOWEVENT_MAXIMIZED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
879 |
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
|
880 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
881 |
case SDL_WINDOWEVENT_RESTORED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 |
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
|
883 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 |
case SDL_WINDOWEVENT_ENTER: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 |
fprintf(stderr, "Mouse entered window %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 |
event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
887 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
888 |
case SDL_WINDOWEVENT_LEAVE: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
889 |
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
|
890 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
891 |
case SDL_WINDOWEVENT_FOCUS_GAINED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
892 |
fprintf(stderr, "Window %d gained keyboard focus", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
893 |
event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
894 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
895 |
case SDL_WINDOWEVENT_FOCUS_LOST: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
896 |
fprintf(stderr, "Window %d lost keyboard focus", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
897 |
event->window.windowID); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
898 |
break; |
1933
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
899 |
case SDL_WINDOWEVENT_CLOSE: |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
900 |
fprintf(stderr, "Window %d closed", event->window.windowID); |
7ee5297340f7
Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
901 |
break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
902 |
default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
903 |
fprintf(stderr, "Window %d got unknown event %d", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
904 |
event->window.windowID, event->window.event); |
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 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 |
case SDL_KEYDOWN: |
2268
4baee598306d
Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
2209
diff
changeset
|
909 |
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
|
910 |
"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
|
911 |
event->key.windowID, |
2306 | 912 |
event->key.keysym.scancode, |
913 |
SDL_GetScancodeName(event->key.keysym.scancode), |
|
914 |
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
|
915 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
916 |
case SDL_KEYUP: |
2268
4baee598306d
Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
2209
diff
changeset
|
917 |
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
|
918 |
"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
|
919 |
event->key.windowID, |
2306 | 920 |
event->key.keysym.scancode, |
921 |
SDL_GetScancodeName(event->key.keysym.scancode), |
|
922 |
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
|
923 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
924 |
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
|
925 |
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
|
926 |
event->text.text, event->text.windowID); |
1914
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_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
|
929 |
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
|
930 |
event->motion.x, event->motion.y, |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
931 |
event->motion.xrel, event->motion.yrel, |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
932 |
event->motion.windowID); |
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_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
|
935 |
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
|
936 |
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
|
937 |
event->button.windowID); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
938 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
939 |
case SDL_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
|
940 |
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
|
941 |
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
|
942 |
event->button.windowID); |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
943 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
944 |
case SDL_MOUSEWHEEL: |
2174 | 945 |
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
|
946 |
"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
|
947 |
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
|
948 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
949 |
case SDL_JOYBALLMOTION: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
950 |
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
|
951 |
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
|
952 |
event->jball.yrel); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
953 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
954 |
case SDL_JOYHATMOTION: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
955 |
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
|
956 |
event->jhat.hat); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
957 |
switch (event->jhat.value) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
958 |
case SDL_HAT_CENTERED: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
959 |
fprintf(stderr, "CENTER"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
960 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
961 |
case SDL_HAT_UP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
962 |
fprintf(stderr, "UP"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
963 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
964 |
case SDL_HAT_RIGHTUP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
965 |
fprintf(stderr, "RIGHTUP"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
966 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
967 |
case SDL_HAT_RIGHT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
968 |
fprintf(stderr, "RIGHT"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
969 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
970 |
case SDL_HAT_RIGHTDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
971 |
fprintf(stderr, "RIGHTDOWN"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
972 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
973 |
case SDL_HAT_DOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
974 |
fprintf(stderr, "DOWN"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
975 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
976 |
case SDL_HAT_LEFTDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
977 |
fprintf(stderr, "LEFTDOWN"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
978 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
979 |
case SDL_HAT_LEFT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
980 |
fprintf(stderr, "LEFT"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
981 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
982 |
case SDL_HAT_LEFTUP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
983 |
fprintf(stderr, "LEFTUP"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
984 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
985 |
default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
986 |
fprintf(stderr, "UNKNOWN"); |
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 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
989 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
990 |
case SDL_JOYBUTTONDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
991 |
fprintf(stderr, "Joystick %d: button %d pressed", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
992 |
event->jbutton.which, event->jbutton.button); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
993 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
994 |
case SDL_JOYBUTTONUP: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
995 |
fprintf(stderr, "Joystick %d: button %d released", |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
996 |
event->jbutton.which, event->jbutton.button); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
997 |
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
|
998 |
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
|
999 |
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
|
1000 |
break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1001 |
case SDL_QUIT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1002 |
fprintf(stderr, "Quit requested"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1003 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1004 |
case SDL_USEREVENT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1005 |
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
|
1006 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1007 |
default: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1008 |
fprintf(stderr, "Unknown event %d", event->type); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1009 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1010 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1011 |
fprintf(stderr, "\n"); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1012 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1013 |
|
5463
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1014 |
static void |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1015 |
ScreenShot(SDL_Renderer *renderer) |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1016 |
{ |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1017 |
SDL_Rect viewport; |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1018 |
SDL_Surface *surface; |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1019 |
|
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1020 |
if (!renderer) { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1021 |
return; |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1022 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1023 |
|
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1024 |
SDL_RenderGetViewport(renderer, &viewport); |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1025 |
surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1026 |
#if SDL_BYTEORDER == SDL_LIL_ENDIAN |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1027 |
0x00FF0000, 0x0000FF00, 0x000000FF, |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1028 |
#else |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1029 |
0x000000FF, 0x0000FF00, 0x00FF0000, |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1030 |
#endif |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1031 |
0x00000000); |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1032 |
if (!surface) { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1033 |
fprintf(stderr, "Couldn't create surface: %s\n", SDL_GetError()); |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1034 |
return; |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1035 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1036 |
|
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1037 |
if (SDL_RenderReadPixels(renderer, NULL, surface->format->format, |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1038 |
surface->pixels, surface->pitch) < 0) { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1039 |
fprintf(stderr, "Couldn't read screen: %s\n", SDL_GetError()); |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1040 |
return; |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1041 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1042 |
|
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1043 |
if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1044 |
fprintf(stderr, "Couldn't save screenshot.bmp: %s\n", SDL_GetError()); |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1045 |
return; |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1046 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1047 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1048 |
|
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1049 |
void |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1050 |
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
|
1051 |
{ |
3514
f0b7bc1fe12d
Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents:
3500
diff
changeset
|
1052 |
int i; |
f0b7bc1fe12d
Added Ctrl-Z common key binding
Sam Lantinga <slouken@libsdl.org>
parents:
3500
diff
changeset
|
1053 |
|
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1054 |
if (state->verbose & VERBOSE_EVENT) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1055 |
PrintEvent(event); |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1056 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1057 |
|
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1058 |
switch (event->type) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1059 |
case SDL_WINDOWEVENT: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1060 |
switch (event->window.event) { |
6513
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1061 |
case SDL_WINDOWEVENT_SIZE_CHANGED: |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1062 |
{ |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1063 |
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1064 |
if (window) { |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1065 |
for (i = 0; i < state->num_windows; ++i) { |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1066 |
if (window == state->windows[i] && |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1067 |
(state->window_flags & SDL_WINDOW_RESIZABLE)) { |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1068 |
SDL_Rect viewport; |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1069 |
|
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1070 |
viewport.x = 0; |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1071 |
viewport.y = 0; |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1072 |
SDL_GetWindowSize(window, &viewport.w, &viewport.h); |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1073 |
SDL_RenderSetViewport(state->renderers[i], &viewport); |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1074 |
} |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1075 |
} |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1076 |
} |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1077 |
} |
c781fb99ce39
If the window is resizable, reset the viewport by default if the window size changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6509
diff
changeset
|
1078 |
break; |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1079 |
case SDL_WINDOWEVENT_CLOSE: |
5113
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
|
1080 |
{ |
5463
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1081 |
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1082 |
if (window) { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1083 |
SDL_DestroyWindow(window); |
5113
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
|
1084 |
} |
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
|
1085 |
} |
1914
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1086 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1087 |
} |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1088 |
break; |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1089 |
case SDL_KEYDOWN: |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1090 |
switch (event->key.keysym.sym) { |
051df511279c
Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1091 |
/* Add hotkeys here */ |
5463
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1092 |
case SDLK_PRINTSCREEN: { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1093 |
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1094 |
if (window) { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1095 |
for (i = 0; i < state->num_windows; ++i) { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1096 |
if (window == state->windows[i]) { |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1097 |
ScreenShot(state->renderers[i]); |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1098 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1099 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1100 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1101 |
} |
9cdb6f1d791a
Added screenshot support for tests using the common framework.
Sam Lantinga <slouken@libsdl.org>
parents:
5406
diff
changeset
|
1102 |
break; |
4497
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1103 |
case SDLK_c: |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1104 |
if (event->key.keysym.mod & KMOD_CTRL) { |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1105 |
/* Ctrl-C copy awesome text! */ |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1106 |
SDL_SetClipboardText("SDL rocks!\nYou know it!"); |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1107 |
printf("Copied text to clipboard\n"); |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1108 |
} |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1109 |
break; |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1110 |
case SDLK_v: |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1111 |
if (event->key.keysym.mod & KMOD_CTRL) { |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1112 |
/* Ctrl-V paste awesome text! */ |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1113 |
char *text = SDL_GetClipboardText(); |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1114 |
if (*text) { |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1115 |
printf("Clipboard: %s\n", text); |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1116 |
} else { |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1117 |
printf("Clipboard is empty\n"); |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1118 |
} |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1119 |
SDL_free(text); |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1120 |
} |
098a8f3835f0
Added simple clipboard test
Sam Lantinga <slouken@libsdl.org>
parents:
4482
diff
changeset
|
1121 |
break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
1122 |
case SDLK_g: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
1123 |
if (event->key.keysym.mod & KMOD_CTRL) { |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
1124 |
/* Ctrl-G toggle grab */ |
5349
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1125 |
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1126 |
if (window) { |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1127 |
SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window)); |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1128 |
} |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
1129 |
} |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1957
diff
changeset
|
1130 |
break; |
4517
7b5e4396bcaa
Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents:
4503
diff
changeset
|
1131 |
case SDLK_m: |
7b5e4396bcaa
Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents:
4503
diff
changeset
|
1132 |
if (event->key.keysym.mod & KMOD_CTRL) { |
7b5e4396bcaa
Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents:
4503
diff
changeset
|
1133 |
/* Ctrl-M maximize */ |
5349
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1134 |
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1135 |
if (window) { |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1136 |
Uint32 flags = SDL_GetWindowFlags(window); |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1137 |
if (flags & SDL_WINDOW_MAXIMIZED) { |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1138 |
SDL_RestoreWindow(window); |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1139 |
} else { |
02770b3c43f8
We have the correct window, we don't have to search for it, duh. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5304
diff
changeset
|
1140 |
SDL_MaximizeWindow(window); |
4517
7b5e4396bcaa
Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents:
4503
diff
changeset
|
1141 |
} |
7b5e4396bcaa
Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents:
4503
diff
changeset
|
1142 |
} |
7b5e4396bcaa
Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents:
4503
diff
changeset
|
1143 |
} |
7b5e4396bcaa
Added test case for maximize code
Sam Lantinga <slouken@libsdl.org>
parents:
4503
diff
changeset
|
1144 |
break; |
5406
1517da4ab6b1
Implemented mouse relative mode on Mac OS X.
Sam |