Mercurial > sdl-ios-xcode
annotate docs/html/guidebasicsinit.html @ 610:95433459fbd2
Date: Mon, 14 Apr 2003 22:08:27 +0100
From: Patrice Mandin
Subject: [SDL][PATCH] 2 patches for sdl
Here are 2 patches for SDL:
- One is to put the dummy video drivers at the end of the
video drivers list. It gave me problems, when
SDL_VIDEODRIVER is not set, and the dummy driver is used
instead of the platform's driver, just because it is
always available. So the dummy driver must always be at
the end of the list. I suppose picogui and dc video
drivers also don't work.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 15 Apr 2003 15:46:56 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >Initializing SDL</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="The Basics" | |
14 HREF="guidethebasics.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="The Basics" | |
17 HREF="guidethebasics.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="Graphics and Video" | |
20 HREF="guidevideo.html"></HEAD | |
21 ><BODY | |
22 CLASS="SECT1" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 WIDTH="100%" | |
32 BORDER="0" | |
33 CELLPADDING="0" | |
34 CELLSPACING="0" | |
35 ><TR | |
36 ><TH | |
37 COLSPAN="3" | |
38 ALIGN="center" | |
39 >SDL Library Documentation</TH | |
40 ></TR | |
41 ><TR | |
42 ><TD | |
43 WIDTH="10%" | |
44 ALIGN="left" | |
45 VALIGN="bottom" | |
46 ><A | |
47 HREF="guidethebasics.html" | |
48 >Prev</A | |
49 ></TD | |
50 ><TD | |
51 WIDTH="80%" | |
52 ALIGN="center" | |
53 VALIGN="bottom" | |
54 >Chapter 1. The Basics</TD | |
55 ><TD | |
56 WIDTH="10%" | |
57 ALIGN="right" | |
58 VALIGN="bottom" | |
59 ><A | |
60 HREF="guidevideo.html" | |
61 >Next</A | |
62 ></TD | |
63 ></TR | |
64 ></TABLE | |
65 ><HR | |
66 ALIGN="LEFT" | |
67 WIDTH="100%"></DIV | |
68 ><DIV | |
69 CLASS="SECT1" | |
70 ><H1 | |
71 CLASS="SECT1" | |
72 ><A | |
73 NAME="GUIDEBASICSINIT" | |
74 >Initializing SDL</A | |
75 ></H1 | |
76 ><P | |
77 >SDL is composed of eight subsystems - Audio, CDROM, Event Handling, File I/O, Joystick Handling, Threading, Timers and Video. Before you can use any of these subsystems they must be initialized by calling <A | |
78 HREF="sdlinit.html" | |
79 ><TT | |
80 CLASS="FUNCTION" | |
81 >SDL_Init</TT | |
82 ></A | |
83 > (or <A | |
84 HREF="sdlinitsubsystem.html" | |
85 ><TT | |
86 CLASS="FUNCTION" | |
87 >SDL_InitSubSystem</TT | |
88 ></A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
89 >). <TT |
0 | 90 CLASS="FUNCTION" |
91 >SDL_Init</TT | |
92 > must be called before any other SDL function. It automatically initializes the Event Handling, File I/O and Threading subsystems and it takes a parameter specifying which other subsystems to initialize. So, to initialize the default subsystems and the Video subsystems you would call: | |
93 <PRE | |
94 CLASS="PROGRAMLISTING" | |
95 > SDL_Init ( SDL_INIT_VIDEO );</PRE | |
96 > | |
97 To initialize the default subsystems, the Video subsystem and the Timers subsystem you would call: | |
98 <PRE | |
99 CLASS="PROGRAMLISTING" | |
100 > SDL_Init ( SDL_INIT_VIDEO | SDL_INIT_TIMER );</PRE | |
101 ></P | |
102 ><P | |
103 ><TT | |
104 CLASS="FUNCTION" | |
105 >SDL_Init</TT | |
106 > is complemented by <A | |
107 HREF="sdlquit.html" | |
108 ><TT | |
109 CLASS="FUNCTION" | |
110 >SDL_Quit</TT | |
111 ></A | |
112 > (and <A | |
113 HREF="sdlquitsubsystem.html" | |
114 ><TT | |
115 CLASS="FUNCTION" | |
116 >SDL_QuitSubSystem</TT | |
117 ></A | |
118 >). <TT | |
119 CLASS="FUNCTION" | |
120 >SDL_Quit</TT | |
121 > shuts down all subsystems, including the default ones. It should always be called before a SDL application exits.</P | |
122 ><P | |
123 >With <TT | |
124 CLASS="FUNCTION" | |
125 >SDL_Init</TT | |
126 > and <TT | |
127 CLASS="FUNCTION" | |
128 >SDL_Quit</TT | |
129 > firmly embedded in your programmers toolkit you can write your first and most basic SDL application. However, we must be prepare to handle errors. Many SDL functions return a value and indicates whether the function has succeeded or failed, <TT | |
130 CLASS="FUNCTION" | |
131 >SDL_Init</TT | |
132 >, for instance, returns -1 if it could not initialize a subsystem. SDL provides a useful facility that allows you to determine exactly what the problem was, every time an error occurs within SDL an error message is stored which can be retrieved using <TT | |
133 CLASS="FUNCTION" | |
134 >SDL_GetError</TT | |
135 >. Use this often, you can never know too much about an error.</P | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
136 ><DIV |
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
137 CLASS="EXAMPLE" |
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
138 ><A |
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
139 NAME="AEN60" |
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
140 ></A |
0 | 141 ><P |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
142 ><B |
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
143 >Example 1-1. Initializing SDL</B |
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
144 ></P |
0 | 145 ><PRE |
146 CLASS="PROGRAMLISTING" | |
147 >#include "SDL.h" /* All SDL App's need this */ | |
148 #include <stdio.h> | |
149 | |
150 int main() { | |
151 | |
152 printf("Initializing SDL.\n"); | |
153 | |
154 /* Initialize defaults, Video and Audio */ | |
155 if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) { | |
156 printf("Could not initialize SDL: %s.\n", SDL_GetError()); | |
157 exit(-1); | |
158 } | |
159 | |
160 printf("SDL initialized.\n"); | |
161 | |
162 printf("Quiting SDL.\n"); | |
163 | |
164 /* Shutdown all subsystems */ | |
165 SDL_Quit(); | |
166 | |
167 printf("Quiting....\n"); | |
168 | |
169 exit(0); | |
170 } </PRE | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
171 ></DIV |
0 | 172 ></DIV |
173 ><DIV | |
174 CLASS="NAVFOOTER" | |
175 ><HR | |
176 ALIGN="LEFT" | |
177 WIDTH="100%"><TABLE | |
178 WIDTH="100%" | |
179 BORDER="0" | |
180 CELLPADDING="0" | |
181 CELLSPACING="0" | |
182 ><TR | |
183 ><TD | |
184 WIDTH="33%" | |
185 ALIGN="left" | |
186 VALIGN="top" | |
187 ><A | |
188 HREF="guidethebasics.html" | |
189 >Prev</A | |
190 ></TD | |
191 ><TD | |
192 WIDTH="34%" | |
193 ALIGN="center" | |
194 VALIGN="top" | |
195 ><A | |
196 HREF="index.html" | |
197 >Home</A | |
198 ></TD | |
199 ><TD | |
200 WIDTH="33%" | |
201 ALIGN="right" | |
202 VALIGN="top" | |
203 ><A | |
204 HREF="guidevideo.html" | |
205 >Next</A | |
206 ></TD | |
207 ></TR | |
208 ><TR | |
209 ><TD | |
210 WIDTH="33%" | |
211 ALIGN="left" | |
212 VALIGN="top" | |
213 >The Basics</TD | |
214 ><TD | |
215 WIDTH="34%" | |
216 ALIGN="center" | |
217 VALIGN="top" | |
218 ><A | |
219 HREF="guidethebasics.html" | |
220 >Up</A | |
221 ></TD | |
222 ><TD | |
223 WIDTH="33%" | |
224 ALIGN="right" | |
225 VALIGN="top" | |
226 >Graphics and Video</TD | |
227 ></TR | |
228 ></TABLE | |
229 ></DIV | |
230 ></BODY | |
231 ></HTML | |
232 > |