annotate test/common.c @ 3335:b8d313de8a65

Adam Strzelecki to SDL Since current DirectFB implementation is incomplete for YUV surfaces (actually causes segmentation faults when trying Lock and use YUV planar textures) I decided to fix it a bit. Here's a patch that should make DirectFB properly support YUV both packed and planar (3 planes). (1) Removed SDL_BYTESPERPIXEL at all in favor of DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(fmt)) which does return always proper BPP for YUVs too, coz SDL_BYTESPERPIXEL returns incorrect values for FOURCCs (2) Fixed data->pixels allocation for planar YUVs in CreateTexture, it should allocate 150% more space (3) Copy other planes for planar YUVs in UpdateTexture (4) Moved checking if format is supported at all with DirectFB on CreateTexture at the beginning of the code Waiting for comments, -- Adam Strzelecki | nanoant.com
author Sam Lantinga <slouken@libsdl.org>
date Sun, 04 Oct 2009 04:03:37 +0000
parents c18c03927a77
children 3e0f51e60fa2
rev   line source
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 /* A simple test program framework */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 #include <stdio.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 #include "common.h"
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 #define VIDEO_USAGE \
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 "[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display %d] [--fullscreen | --windows N] [--title title] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]"
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 #define AUDIO_USAGE \
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
14 struct pformat {
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
15 Uint32 id;
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
16 const char* idstr;
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
17 } pixel_format[]={
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
18 {SDL_PIXELFORMAT_INDEX1LSB, "SDL_PIXELFORMAT_INDEX1LSB"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
19 {SDL_PIXELFORMAT_INDEX1MSB, "SDL_PIXELFORMAT_INDEX1MSB"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
20 {SDL_PIXELFORMAT_INDEX4LSB, "SDL_PIXELFORMAT_INDEX4LSB"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
21 {SDL_PIXELFORMAT_INDEX4MSB, "SDL_PIXELFORMAT_INDEX4MSB"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
22 {SDL_PIXELFORMAT_INDEX8, "SDL_PIXELFORMAT_INDEX8"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
23 {SDL_PIXELFORMAT_RGB332, "SDL_PIXELFORMAT_RGB332"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
24 {SDL_PIXELFORMAT_RGB444, "SDL_PIXELFORMAT_RGB444"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
25 {SDL_PIXELFORMAT_RGB555, "SDL_PIXELFORMAT_RGB555"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
26 {SDL_PIXELFORMAT_BGR555, "SDL_PIXELFORMAT_BGR555"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
27 {SDL_PIXELFORMAT_ARGB4444, "SDL_PIXELFORMAT_ARGB4444"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
28 {SDL_PIXELFORMAT_ABGR4444, "SDL_PIXELFORMAT_ABGR4444"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
29 {SDL_PIXELFORMAT_ARGB1555, "SDL_PIXELFORMAT_ARGB1555"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
30 {SDL_PIXELFORMAT_ABGR1555, "SDL_PIXELFORMAT_ABGR1555"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
31 {SDL_PIXELFORMAT_RGB565, "SDL_PIXELFORMAT_RGB565"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
32 {SDL_PIXELFORMAT_BGR565, "SDL_PIXELFORMAT_BGR565"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
33 {SDL_PIXELFORMAT_RGB24, "SDL_PIXELFORMAT_RGB24"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
34 {SDL_PIXELFORMAT_BGR24, "SDL_PIXELFORMAT_BGR24"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
35 {SDL_PIXELFORMAT_RGB888, "SDL_PIXELFORMAT_RGB888"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
36 {SDL_PIXELFORMAT_BGR888, "SDL_PIXELFORMAT_BGR888"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
37 {SDL_PIXELFORMAT_ARGB8888, "SDL_PIXELFORMAT_ARGB8888"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
38 {SDL_PIXELFORMAT_RGBA8888, "SDL_PIXELFORMAT_RGBA8888"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
39 {SDL_PIXELFORMAT_ABGR8888, "SDL_PIXELFORMAT_ABGR8888"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
40 {SDL_PIXELFORMAT_BGRA8888, "SDL_PIXELFORMAT_BGRA8888"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
41 {SDL_PIXELFORMAT_ARGB2101010, "SDL_PIXELFORMAT_ARGB2101010"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
42 {SDL_PIXELFORMAT_YV12, "SDL_PIXELFORMAT_YV12"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
43 {SDL_PIXELFORMAT_IYUV, "SDL_PIXELFORMAT_IYUV"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
44 {SDL_PIXELFORMAT_YUY2, "SDL_PIXELFORMAT_YUY2"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
45 {SDL_PIXELFORMAT_UYVY, "SDL_PIXELFORMAT_UYVY"},
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
46 {SDL_PIXELFORMAT_YVYU, "SDL_PIXELFORMAT_YVYU"}
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
47 };
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
48
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
49 const char* PixelFormatToString(Uint32 pformat)
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
50 {
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
51 Uint32 it=0;
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
52
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
53 do {
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
54 if (pixel_format[it].idstr == NULL) {
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
55 break;
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
56 }
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
57 if (pixel_format[it].id == pformat) {
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
58 return pixel_format[it].idstr;
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
59 }
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
60 it++;
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
61 } while(1);
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
62
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
63 return "SDL_PIXELFORMAT_UNKNOWN";
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
64 }
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
65
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 CommonState *
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 CommonCreateState(char **argv, Uint32 flags)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 CommonState *state = SDL_calloc(1, sizeof(*state));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 if (!state) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 SDL_OutOfMemory();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 return NULL;
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 /* Initialize some defaults */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 state->argv = argv;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 state->flags = flags;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 state->window_title = argv[0];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 state->window_flags = SDL_WINDOW_SHOWN;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 state->window_x = SDL_WINDOWPOS_UNDEFINED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 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
82 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
83 state->window_h = DEFAULT_WINDOW_HEIGHT;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 state->num_windows = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 state->audiospec.freq = 22050;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 state->audiospec.format = AUDIO_S16;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 state->audiospec.channels = 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 state->audiospec.samples = 2048;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 return state;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 }
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 int
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 CommonArg(CommonState * state, int index)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 char **argv = state->argv;
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 if (SDL_strcasecmp(argv[index], "--video") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 state->videodriver = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 return 2;
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], "--renderer") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 state->renderdriver = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 if (SDL_strcasecmp(argv[index], "--info") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 if (SDL_strcasecmp(argv[index], "all") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 state->verbose |=
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 (VERBOSE_VIDEO | VERBOSE_MODES | VERBOSE_RENDER |
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 VERBOSE_EVENT);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 if (SDL_strcasecmp(argv[index], "video") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 state->verbose |= VERBOSE_VIDEO;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 if (SDL_strcasecmp(argv[index], "modes") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 state->verbose |= VERBOSE_MODES;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 if (SDL_strcasecmp(argv[index], "render") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 state->verbose |= VERBOSE_RENDER;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 if (SDL_strcasecmp(argv[index], "event") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 state->verbose |= VERBOSE_EVENT;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 if (SDL_strcasecmp(argv[index], "--display") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 state->display = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 state->window_flags |= SDL_WINDOW_FULLSCREEN;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 state->num_windows = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 if (SDL_strcasecmp(argv[index], "--windows") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 ++index;
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
157 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
158 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 state->num_windows = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 if (SDL_strcasecmp(argv[index], "--title") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 state->window_title = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 if (SDL_strcasecmp(argv[index], "--center") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 state->window_x = SDL_WINDOWPOS_CENTERED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 state->window_y = SDL_WINDOWPOS_CENTERED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 if (SDL_strcasecmp(argv[index], "--position") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 char *x, *y;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 x = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 y = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 while (*y && *y != ',') {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 ++y;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 if (!*y) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 *y++ = '\0';
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 state->window_x = SDL_atoi(x);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 state->window_y = SDL_atoi(y);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 if (SDL_strcasecmp(argv[index], "--geometry") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 char *w, *h;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 w = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 h = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 while (*h && *h != 'x') {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 ++h;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 if (!*h) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 *h++ = '\0';
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 state->window_w = SDL_atoi(w);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 state->window_h = SDL_atoi(h);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 }
2209
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
216 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
217 ++index;
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
218 if (!argv[index]) {
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
219 return -1;
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
220 }
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
221 state->depth = SDL_atoi(argv[index]);
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
222 return 2;
b292fa4941c6 Added support for the --depth command line option
Sam Lantinga <slouken@libsdl.org>
parents: 2185
diff changeset
223 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 if (SDL_strcasecmp(argv[index], "--refresh") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 state->refresh_rate = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 if (SDL_strcasecmp(argv[index], "--vsync") == 0) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
233 state->render_flags |= SDL_RENDERER_PRESENTVSYNC;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 state->window_flags |= SDL_WINDOW_BORDERLESS;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 if (SDL_strcasecmp(argv[index], "--resize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 state->window_flags |= SDL_WINDOW_RESIZABLE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 if (SDL_strcasecmp(argv[index], "--minimize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 state->window_flags |= SDL_WINDOW_MINIMIZED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 if (SDL_strcasecmp(argv[index], "--maximize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 state->window_flags |= SDL_WINDOW_MAXIMIZED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 if (SDL_strcasecmp(argv[index], "--grab") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 state->window_flags |= SDL_WINDOW_INPUT_GRABBED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 if (SDL_strcasecmp(argv[index], "--rate") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 state->audiospec.freq = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264 if (SDL_strcasecmp(argv[index], "--format") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 if (SDL_strcasecmp(argv[index], "U8") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 state->audiospec.format = AUDIO_U8;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 if (SDL_strcasecmp(argv[index], "S8") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 state->audiospec.format = AUDIO_S8;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 if (SDL_strcasecmp(argv[index], "U16") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 state->audiospec.format = AUDIO_U16;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 if (SDL_strcasecmp(argv[index], "U16LE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 state->audiospec.format = AUDIO_U16LSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 if (SDL_strcasecmp(argv[index], "U16BE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 state->audiospec.format = AUDIO_U16MSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 if (SDL_strcasecmp(argv[index], "S16") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 state->audiospec.format = AUDIO_S16;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 if (SDL_strcasecmp(argv[index], "S16LE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 state->audiospec.format = AUDIO_S16LSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 if (SDL_strcasecmp(argv[index], "S16BE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 state->audiospec.format = AUDIO_S16MSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 if (SDL_strcasecmp(argv[index], "--channels") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 }
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
308 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
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], "--samples") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 }
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
316 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
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], "-h") == 0)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 || (SDL_strcasecmp(argv[index], "--help") == 0)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 /* Print the usage message */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 return 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 }
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 const char *
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 CommonUsage(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 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
331 case SDL_INIT_VIDEO:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 return VIDEO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 case SDL_INIT_AUDIO:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 return AUDIO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 return VIDEO_USAGE " " AUDIO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 return "";
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 PrintRendererFlag(Uint32 flag)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 switch (flag) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
346 case SDL_RENDERER_SINGLEBUFFER:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 fprintf(stderr, "SingleBuffer");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
349 case SDL_RENDERER_PRESENTCOPY:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 fprintf(stderr, "PresentCopy");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
352 case SDL_RENDERER_PRESENTFLIP2:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 fprintf(stderr, "PresentFlip2");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
355 case SDL_RENDERER_PRESENTFLIP3:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 fprintf(stderr, "PresentFlip3");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
358 case SDL_RENDERER_PRESENTDISCARD:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 fprintf(stderr, "PresentDiscard");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
361 case SDL_RENDERER_PRESENTVSYNC:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 fprintf(stderr, "PresentVSync");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
364 case SDL_RENDERER_ACCELERATED:
1921
f3399f779a1d Bug fixes to the OpenGL renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
365 fprintf(stderr, "Accelerated");
f3399f779a1d Bug fixes to the OpenGL renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1916
diff changeset
366 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 fprintf(stderr, "0x%8.8x", flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 PrintBlendMode(Uint32 flag)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 switch (flag) {
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
377 case SDL_BLENDMODE_NONE:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 fprintf(stderr, "None");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 break;
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
380 case SDL_BLENDMODE_MASK:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 fprintf(stderr, "Mask");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 break;
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
383 case SDL_BLENDMODE_BLEND:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 fprintf(stderr, "Blend");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 break;
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
386 case SDL_BLENDMODE_ADD:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 fprintf(stderr, "Add");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 break;
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2306
diff changeset
389 case SDL_BLENDMODE_MOD:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 fprintf(stderr, "Mod");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 fprintf(stderr, "0x%8.8x", flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 }
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 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 PrintScaleMode(Uint32 flag)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 switch (flag) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
402 case SDL_TEXTURESCALEMODE_NONE:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 fprintf(stderr, "None");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
405 case SDL_TEXTURESCALEMODE_FAST:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 fprintf(stderr, "Fast");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
408 case SDL_TEXTURESCALEMODE_SLOW:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 fprintf(stderr, "Slow");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
411 case SDL_TEXTURESCALEMODE_BEST:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 fprintf(stderr, "Best");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 fprintf(stderr, "0x%8.8x", flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 PrintPixelFormat(Uint32 format)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 switch (format) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
424 case SDL_PIXELFORMAT_UNKNOWN:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 fprintf(stderr, "Unknwon");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
427 case SDL_PIXELFORMAT_INDEX1LSB:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 fprintf(stderr, "Index1LSB");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
430 case SDL_PIXELFORMAT_INDEX1MSB:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 fprintf(stderr, "Index1MSB");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
433 case SDL_PIXELFORMAT_INDEX4LSB:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 fprintf(stderr, "Index4LSB");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
436 case SDL_PIXELFORMAT_INDEX4MSB:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 fprintf(stderr, "Index4MSB");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
439 case SDL_PIXELFORMAT_INDEX8:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 fprintf(stderr, "Index8");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
442 case SDL_PIXELFORMAT_RGB332:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 fprintf(stderr, "RGB332");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
445 case SDL_PIXELFORMAT_RGB444:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 fprintf(stderr, "RGB444");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
448 case SDL_PIXELFORMAT_RGB555:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 fprintf(stderr, "RGB555");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
451 case SDL_PIXELFORMAT_ARGB4444:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 fprintf(stderr, "ARGB4444");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 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
454 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
455 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
456 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
457 case SDL_PIXELFORMAT_ARGB1555:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 fprintf(stderr, "ARGB1555");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 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
460 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
461 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
462 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
463 case SDL_PIXELFORMAT_RGB565:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 fprintf(stderr, "RGB565");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 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
466 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
467 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
468 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
469 case SDL_PIXELFORMAT_RGB24:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 fprintf(stderr, "RGB24");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
472 case SDL_PIXELFORMAT_BGR24:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 fprintf(stderr, "BGR24");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
475 case SDL_PIXELFORMAT_RGB888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 fprintf(stderr, "RGB888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
478 case SDL_PIXELFORMAT_BGR888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 fprintf(stderr, "BGR888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
481 case SDL_PIXELFORMAT_ARGB8888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 fprintf(stderr, "ARGB8888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
484 case SDL_PIXELFORMAT_RGBA8888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 fprintf(stderr, "RGBA8888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
487 case SDL_PIXELFORMAT_ABGR8888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 fprintf(stderr, "ABGR8888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
490 case SDL_PIXELFORMAT_BGRA8888:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 fprintf(stderr, "BGRA8888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
493 case SDL_PIXELFORMAT_ARGB2101010:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 fprintf(stderr, "ARGB2101010");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
496 case SDL_PIXELFORMAT_YV12:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 fprintf(stderr, "YV12");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
499 case SDL_PIXELFORMAT_IYUV:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 fprintf(stderr, "IYUV");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
502 case SDL_PIXELFORMAT_YUY2:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 fprintf(stderr, "YUY2");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
505 case SDL_PIXELFORMAT_UYVY:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 fprintf(stderr, "UYVY");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 break;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
508 case SDL_PIXELFORMAT_YVYU:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 fprintf(stderr, "YVYU");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
510 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 fprintf(stderr, "0x%8.8x", format);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 PrintRenderer(SDL_RendererInfo * info)
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 int i, count;
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, " Renderer %s:\n", info->name);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 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
525 fprintf(stderr, " (");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 count = 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527 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
528 Uint32 flag = (1 << i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 if (info->flags & flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 if (count > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 fprintf(stderr, " | ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 PrintRendererFlag(flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534 ++count;
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 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537 fprintf(stderr, ")\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 fprintf(stderr, " Blend: 0x%8.8X", info->blend_modes);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 fprintf(stderr, " (");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 count = 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542 for (i = 0; i < sizeof(info->blend_modes) * 8; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 Uint32 flag = (1 << i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 if (info->blend_modes & flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 if (count > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 fprintf(stderr, " | ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 PrintBlendMode(flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 ++count;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 fprintf(stderr, ")\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 fprintf(stderr, " Scale: 0x%8.8X", info->scale_modes);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 fprintf(stderr, " (");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 count = 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 for (i = 0; i < sizeof(info->scale_modes) * 8; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 Uint32 flag = (1 << i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 if (info->scale_modes & flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 if (count > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 fprintf(stderr, " | ");
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 PrintScaleMode(flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 ++count;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567 fprintf(stderr, ")\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 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
570 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
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 PrintPixelFormat(info->texture_formats[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 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
579 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
580 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
581 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 }
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 SDL_bool
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 CommonInit(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587 int i, j, m, n;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 SDL_DisplayMode fullscreen_mode;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 if (state->flags & SDL_INIT_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 n = SDL_GetNumVideoDrivers();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594 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
595 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 fprintf(stderr, "Built-in video drivers:");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597 for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598 if (i > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
599 fprintf(stderr, ",");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 fprintf(stderr, " %s", SDL_GetVideoDriver(i));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603 fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 if (SDL_VideoInit(state->videodriver, 0) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 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
608 SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 fprintf(stderr, "Video driver: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 SDL_GetCurrentVideoDriver());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616 if (state->verbose & VERBOSE_MODES) {
1967
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
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 SDL_SelectVideoDisplay(i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626
1967
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
627 SDL_GetDesktopDisplayMode(&mode);
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
628 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
629 &Bmask, &Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
630 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
631 " 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
632 mode.w, mode.h, mode.refresh_rate, bpp,
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
633 PixelFormatToString(mode.format));
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
634 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
635 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
636 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
637 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
638 if (Amask)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639 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
640 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
642 /* Print available fullscreen video modes */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
643 m = SDL_GetNumDisplayModes();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 if (m == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
645 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
646 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
647 fprintf(stderr, " Fullscreen video modes:\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
648 for (j = 0; j < m; ++j) {
1967
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
649 SDL_GetDisplayMode(j, &mode);
01e29c3e9a29 In general, fill in pointers to structures, rather than return them.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
650 SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
651 &Gmask, &Bmask, &Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
652 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
653 " 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
654 j, mode.w, mode.h, mode.refresh_rate, bpp,
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
655 PixelFormatToString(mode.format));
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
656 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
657 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
658 Rmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
659 fprintf(stderr, " Green Mask = 0x%.8x\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
660 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
661 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
662 Bmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 if (Amask)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 fprintf(stderr,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665 " Alpha Mask = 0x%.8x\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666 Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
669 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
670 }
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 SDL_SelectVideoDisplay(state->display);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
674 if (state->verbose & VERBOSE_RENDER) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
675 SDL_RendererInfo info;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1967
diff changeset
677 n = SDL_GetNumRenderDrivers();
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
679 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
680 } else {
1923
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
681 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
682 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
683 SDL_GetRenderDriverInfo(i, &info);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 PrintRenderer(&info);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686 }
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 switch (state->depth) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
690 case 8:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
691 fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
692 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
693 case 15:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
694 fullscreen_mode.format = SDL_PIXELFORMAT_RGB555;
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 16:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
697 fullscreen_mode.format = SDL_PIXELFORMAT_RGB565;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
698 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
699 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
700 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
701 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
702 default:
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
703 fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
704 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
705 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
706 fullscreen_mode.w = state->window_w;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
707 fullscreen_mode.h = state->window_h;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
708 fullscreen_mode.refresh_rate = state->refresh_rate;
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
709 if (SDL_SetFullscreenDisplayMode(&fullscreen_mode)<0) {
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
710 fprintf(stderr, "Can't switch to fullscreen display mode: %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
711 SDL_GetError());
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
712 return SDL_FALSE;
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
713 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
714
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
715 state->windows =
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
716 (SDL_WindowID *) SDL_malloc(state->num_windows *
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
717 sizeof(*state->windows));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
718 if (!state->windows) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
719 fprintf(stderr, "Out of memory!\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
720 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
721 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
722 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
723 char title[1024];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
724
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
725 if (state->num_windows > 1) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
726 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
727 state->window_title, i + 1);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
728 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
729 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
730 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
731 state->windows[i] =
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
732 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
733 state->window_w, state->window_h,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
734 state->window_flags);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
735 if (!state->windows[i]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
736 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
737 SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
738 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
739 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
740
1933
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
741 if (!state->skip_renderer
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
742 && (state->renderdriver
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
743 || !(state->window_flags & SDL_WINDOW_OPENGL))) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
744 m = -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
745 if (state->renderdriver) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
746 SDL_RendererInfo info;
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1967
diff changeset
747 n = SDL_GetNumRenderDrivers();
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
748 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
749 SDL_GetRenderDriverInfo(j, &info);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
750 if (SDL_strcasecmp(info.name, state->renderdriver) ==
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
751 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
752 m = j;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
753 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
754 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
755 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
756 if (m == n) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
757 fprintf(stderr,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
758 "Couldn't find render driver named %s",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
759 state->renderdriver);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
760 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
761 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
762 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
763 if (SDL_CreateRenderer
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
764 (state->windows[i], m, state->render_flags) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
765 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
766 SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
767 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
768 }
1923
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
769 if (state->verbose & VERBOSE_RENDER) {
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
770 SDL_RendererInfo info;
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
771
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
772 fprintf(stderr, "Current renderer:\n");
1969
5d3724f64f2b Clarified the difference between render drivers and render contexts
Sam Lantinga <slouken@libsdl.org>
parents: 1967
diff changeset
773 SDL_GetRendererInfo(&info);
1923
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
774 PrintRenderer(&info);
d4572b97b08f Switch OpenGL contexts when switching render contexts.
Sam Lantinga <slouken@libsdl.org>
parents: 1921
diff changeset
775 }
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
776 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
777 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
778 SDL_SelectRenderer(state->windows[0]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
779 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
780
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
781 if (state->flags & SDL_INIT_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
782 if (state->verbose & VERBOSE_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
783 n = SDL_GetNumAudioDrivers();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784 if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
785 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
786 } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
787 fprintf(stderr, "Built-in audio drivers:");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
788 for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
789 if (i > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
790 fprintf(stderr, ",");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
791 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
792 fprintf(stderr, " %s", SDL_GetAudioDriver(i));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
793 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
794 fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
795 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
796 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
797 if (SDL_AudioInit(state->audiodriver) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
798 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
799 SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
800 return SDL_FALSE;
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 if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
803 fprintf(stderr, "Audio driver: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
804 SDL_GetCurrentAudioDriver());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
805 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
806
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
807 if (SDL_OpenAudio(&state->audiospec, NULL) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
808 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
809 return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
810 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
811 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
812
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
813 return SDL_TRUE;
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
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
816 static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
817 PrintEvent(SDL_Event * event)
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 fprintf(stderr, "SDL EVENT: ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
820 switch (event->type) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
821 case SDL_WINDOWEVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
822 switch (event->window.event) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
823 case SDL_WINDOWEVENT_SHOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
824 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
825 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
826 case SDL_WINDOWEVENT_HIDDEN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
827 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
828 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
829 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
830 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
831 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
832 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
833 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
834 event->window.windowID, event->window.data1,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
835 event->window.data2);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
836 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
837 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
838 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
839 event->window.windowID, event->window.data1,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
840 event->window.data2);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
841 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
842 case SDL_WINDOWEVENT_MINIMIZED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843 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
844 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
845 case SDL_WINDOWEVENT_MAXIMIZED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
846 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
847 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
848 case SDL_WINDOWEVENT_RESTORED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
849 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
850 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
851 case SDL_WINDOWEVENT_ENTER:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
852 fprintf(stderr, "Mouse entered window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
853 event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
854 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
855 case SDL_WINDOWEVENT_LEAVE:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
856 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
857 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
858 case SDL_WINDOWEVENT_FOCUS_GAINED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
859 fprintf(stderr, "Window %d gained keyboard focus",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
860 event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
861 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
862 case SDL_WINDOWEVENT_FOCUS_LOST:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
863 fprintf(stderr, "Window %d lost keyboard focus",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
864 event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
865 break;
1933
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
866 case SDL_WINDOWEVENT_CLOSE:
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
867 fprintf(stderr, "Window %d closed", event->window.windowID);
7ee5297340f7 Implemented Cocoa window support
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
868 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
869 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
870 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
871 event->window.windowID, event->window.event);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
872 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
873 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
874 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
875 case SDL_KEYDOWN:
2268
4baee598306d Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 2209
diff changeset
876 fprintf(stderr,
2306
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
877 "Keyboard %d: key pressed in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
878 event->key.which, event->key.windowID,
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
879 event->key.keysym.scancode,
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
880 SDL_GetScancodeName(event->key.keysym.scancode),
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
881 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
882 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
883 case SDL_KEYUP:
2268
4baee598306d Date: Thu, 05 Jul 2007 14:02:33 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 2209
diff changeset
884 fprintf(stderr,
2306
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
885 "Keyboard %d: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
886 event->key.which, event->key.windowID,
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
887 event->key.keysym.scancode,
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
888 SDL_GetScancodeName(event->key.keysym.scancode),
1a8bab15a45d Fixed compile errors
Sam Lantinga <slouken@libsdl.org>
parents: 2268
diff changeset
889 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
890 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
891 case SDL_TEXTINPUT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
892 fprintf(stderr, "Keyboard %d: text input \"%s\" in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
893 event->text.which, event->text.text, event->text.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
894 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
895 case SDL_MOUSEMOTION:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
896 fprintf(stderr, "Mouse %d: moved to %d,%d (%d,%d) in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
897 event->motion.which, event->motion.x, event->motion.y,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
898 event->motion.xrel, event->motion.yrel,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
899 event->motion.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
900 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
901 case SDL_MOUSEBUTTONDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
902 fprintf(stderr, "Mouse %d: button %d pressed at %d,%d in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
903 event->button.which, event->button.button, event->button.x,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
904 event->button.y, event->button.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
905 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
906 case SDL_MOUSEBUTTONUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
907 fprintf(stderr, "Mouse %d: button %d released at %d,%d in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
908 event->button.which, event->button.button, event->button.x,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
909 event->button.y, event->button.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
910 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
911 case SDL_MOUSEWHEEL:
2174
Sam Lantinga <slouken@libsdl.org>
parents: 2154
diff changeset
912 fprintf(stderr,
Sam Lantinga <slouken@libsdl.org>
parents: 2154
diff changeset
913 "Mouse %d: wheel scrolled %d in x and %d in y in window %d",
2154
5660f48b31f5 fixed code for printing mousewheel events to match the new format of mousewheel events.
Bob Pendleton <bob@pendleton.com>
parents: 1970
diff changeset
914 event->wheel.which, event->wheel.x, event->wheel.y,
1957
c7803e4c21d3 Implemented Cocoa mouse wheel events
Sam Lantinga <slouken@libsdl.org>
parents: 1933
diff changeset
915 event->wheel.windowID);
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
916 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
917 case SDL_JOYBALLMOTION:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
918 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
919 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
920 event->jball.yrel);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
921 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
922 case SDL_JOYHATMOTION:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
923 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
924 event->jhat.hat);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
925 switch (event->jhat.value) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
926 case SDL_HAT_CENTERED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
927 fprintf(stderr, "CENTER");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
928 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
929 case SDL_HAT_UP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
930 fprintf(stderr, "UP");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
931 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
932 case SDL_HAT_RIGHTUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
933 fprintf(stderr, "RIGHTUP");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
934 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
935 case SDL_HAT_RIGHT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
936 fprintf(stderr, "RIGHT");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
937 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
938 case SDL_HAT_RIGHTDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
939 fprintf(stderr, "RIGHTDOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
940 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
941 case SDL_HAT_DOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
942 fprintf(stderr, "DOWN");
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_HAT_LEFTDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
945 fprintf(stderr, "LEFTDOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
946 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
947 case SDL_HAT_LEFT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
948 fprintf(stderr, "LEFT");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
949 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
950 case SDL_HAT_LEFTUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
951 fprintf(stderr, "LEFTUP");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
952 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
953 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
954 fprintf(stderr, "UNKNOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
955 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
956 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
957 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
958 case SDL_JOYBUTTONDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
959 fprintf(stderr, "Joystick %d: button %d pressed",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
960 event->jbutton.which, event->jbutton.button);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
961 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
962 case SDL_JOYBUTTONUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
963 fprintf(stderr, "Joystick %d: button %d released",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
964 event->jbutton.which, event->jbutton.button);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
965 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
966 case SDL_QUIT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
967 fprintf(stderr, "Quit requested");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
968 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
969 case SDL_USEREVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
970 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
971 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
972 default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
973 fprintf(stderr, "Unknown event %d", event->type);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
974 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
975 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
976 fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
977 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
978
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
979 void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
980 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
981 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
982 if (state->verbose & VERBOSE_EVENT) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
983 PrintEvent(event);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
984 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
985
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
986 switch (event->type) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
987 case SDL_WINDOWEVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
988 switch (event->window.event) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
989 case SDL_WINDOWEVENT_CLOSE:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
990 *done = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
991 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
992 }
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_KEYDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
995 switch (event->key.keysym.sym) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
996 /* Add hotkeys here */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
997 case SDLK_g:
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
998 if (event->key.keysym.mod & KMOD_CTRL) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
999 /* Ctrl-G toggle grab */
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
1000 }
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1957
diff changeset
1001 break;
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1002 case SDLK_ESCAPE:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1003 *done = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1004 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1005 default:
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 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1008 break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1009 case SDL_QUIT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1010 *done = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1011 break;
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 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1014
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1015 void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1016 CommonQuit(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1017 {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1018 if (state->flags & SDL_INIT_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1019 SDL_VideoQuit();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1020 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1021 if (state->flags & SDL_INIT_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1022 SDL_AudioQuit();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1023 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1024 if (state->windows) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1025 SDL_free(state->windows);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1026 }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1027 SDL_free(state);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1028 }