docs/html/guidebasicsinit.html
changeset 3352 6dc250ebdd80
parent 3351 8e0182c236d8
child 3353 6b14223dd5c7
     1.1 --- a/docs/html/guidebasicsinit.html	Wed Oct 07 06:11:53 2009 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,240 +0,0 @@
     1.4 -<HTML
     1.5 -><HEAD
     1.6 -><TITLE
     1.7 ->Initializing SDL</TITLE
     1.8 -><META
     1.9 -NAME="GENERATOR"
    1.10 -CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
    1.11 -"><LINK
    1.12 -REL="HOME"
    1.13 -TITLE="SDL Library Documentation"
    1.14 -HREF="index.html"><LINK
    1.15 -REL="UP"
    1.16 -TITLE="The Basics"
    1.17 -HREF="guidethebasics.html"><LINK
    1.18 -REL="PREVIOUS"
    1.19 -TITLE="The Basics"
    1.20 -HREF="guidethebasics.html"><LINK
    1.21 -REL="NEXT"
    1.22 -TITLE="Graphics and Video"
    1.23 -HREF="guidevideo.html"></HEAD
    1.24 -><BODY
    1.25 -CLASS="SECT1"
    1.26 -BGCOLOR="#FFF8DC"
    1.27 -TEXT="#000000"
    1.28 -LINK="#0000ee"
    1.29 -VLINK="#551a8b"
    1.30 -ALINK="#ff0000"
    1.31 -><DIV
    1.32 -CLASS="NAVHEADER"
    1.33 -><TABLE
    1.34 -SUMMARY="Header navigation table"
    1.35 -WIDTH="100%"
    1.36 -BORDER="0"
    1.37 -CELLPADDING="0"
    1.38 -CELLSPACING="0"
    1.39 -><TR
    1.40 -><TH
    1.41 -COLSPAN="3"
    1.42 -ALIGN="center"
    1.43 ->SDL Library Documentation</TH
    1.44 -></TR
    1.45 -><TR
    1.46 -><TD
    1.47 -WIDTH="10%"
    1.48 -ALIGN="left"
    1.49 -VALIGN="bottom"
    1.50 -><A
    1.51 -HREF="guidethebasics.html"
    1.52 -ACCESSKEY="P"
    1.53 ->Prev</A
    1.54 -></TD
    1.55 -><TD
    1.56 -WIDTH="80%"
    1.57 -ALIGN="center"
    1.58 -VALIGN="bottom"
    1.59 ->Chapter 1. The Basics</TD
    1.60 -><TD
    1.61 -WIDTH="10%"
    1.62 -ALIGN="right"
    1.63 -VALIGN="bottom"
    1.64 -><A
    1.65 -HREF="guidevideo.html"
    1.66 -ACCESSKEY="N"
    1.67 ->Next</A
    1.68 -></TD
    1.69 -></TR
    1.70 -></TABLE
    1.71 -><HR
    1.72 -ALIGN="LEFT"
    1.73 -WIDTH="100%"></DIV
    1.74 -><DIV
    1.75 -CLASS="SECT1"
    1.76 -><H1
    1.77 -CLASS="SECT1"
    1.78 -><A
    1.79 -NAME="GUIDEBASICSINIT"
    1.80 -></A
    1.81 ->Initializing SDL</H1
    1.82 -><P
    1.83 ->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
    1.84 -HREF="sdlinit.html"
    1.85 -><TT
    1.86 -CLASS="FUNCTION"
    1.87 ->SDL_Init</TT
    1.88 -></A
    1.89 -> (or <A
    1.90 -HREF="sdlinitsubsystem.html"
    1.91 -><TT
    1.92 -CLASS="FUNCTION"
    1.93 ->SDL_InitSubSystem</TT
    1.94 -></A
    1.95 ->). <TT
    1.96 -CLASS="FUNCTION"
    1.97 ->SDL_Init</TT
    1.98 -> 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:
    1.99 -<PRE
   1.100 -CLASS="PROGRAMLISTING"
   1.101 ->    SDL_Init ( SDL_INIT_VIDEO );</PRE
   1.102 ->
   1.103 -To initialize the default subsystems, the Video subsystem and the Timers subsystem you would call:
   1.104 -<PRE
   1.105 -CLASS="PROGRAMLISTING"
   1.106 ->    SDL_Init ( SDL_INIT_VIDEO | SDL_INIT_TIMER );</PRE
   1.107 -></P
   1.108 -><P
   1.109 -><TT
   1.110 -CLASS="FUNCTION"
   1.111 ->SDL_Init</TT
   1.112 -> is complemented by <A
   1.113 -HREF="sdlquit.html"
   1.114 -><TT
   1.115 -CLASS="FUNCTION"
   1.116 ->SDL_Quit</TT
   1.117 -></A
   1.118 -> (and <A
   1.119 -HREF="sdlquitsubsystem.html"
   1.120 -><TT
   1.121 -CLASS="FUNCTION"
   1.122 ->SDL_QuitSubSystem</TT
   1.123 -></A
   1.124 ->). <TT
   1.125 -CLASS="FUNCTION"
   1.126 ->SDL_Quit</TT
   1.127 -> shuts down all subsystems, including the default ones. It should always be called before a SDL application exits.</P
   1.128 -><P
   1.129 ->With <TT
   1.130 -CLASS="FUNCTION"
   1.131 ->SDL_Init</TT
   1.132 -> and <TT
   1.133 -CLASS="FUNCTION"
   1.134 ->SDL_Quit</TT
   1.135 -> 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
   1.136 -CLASS="FUNCTION"
   1.137 ->SDL_Init</TT
   1.138 ->, 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
   1.139 -CLASS="FUNCTION"
   1.140 ->SDL_GetError</TT
   1.141 ->. Use this often, you can never know too much about an error.</P
   1.142 -><DIV
   1.143 -CLASS="EXAMPLE"
   1.144 -><A
   1.145 -NAME="AEN60"
   1.146 -></A
   1.147 -><P
   1.148 -><B
   1.149 ->Example 1-1. Initializing SDL</B
   1.150 -></P
   1.151 -><PRE
   1.152 -CLASS="PROGRAMLISTING"
   1.153 ->#include "SDL.h"   /* All SDL App's need this */
   1.154 -#include &#60;stdio.h&#62;
   1.155 -
   1.156 -int main(int argc, char *argv[]) {
   1.157 -    
   1.158 -    printf("Initializing SDL.\n");
   1.159 -    
   1.160 -    /* Initialize defaults, Video and Audio */
   1.161 -    if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) { 
   1.162 -        printf("Could not initialize SDL: %s.\n", SDL_GetError());
   1.163 -        exit(-1);
   1.164 -    }
   1.165 -
   1.166 -    printf("SDL initialized.\n");
   1.167 -
   1.168 -    printf("Quiting SDL.\n");
   1.169 -    
   1.170 -    /* Shutdown all subsystems */
   1.171 -    SDL_Quit();
   1.172 -    
   1.173 -    printf("Quiting....\n");
   1.174 -
   1.175 -    exit(0);
   1.176 -}&#13;</PRE
   1.177 -></DIV
   1.178 -></DIV
   1.179 -><DIV
   1.180 -CLASS="NAVFOOTER"
   1.181 -><HR
   1.182 -ALIGN="LEFT"
   1.183 -WIDTH="100%"><TABLE
   1.184 -SUMMARY="Footer navigation table"
   1.185 -WIDTH="100%"
   1.186 -BORDER="0"
   1.187 -CELLPADDING="0"
   1.188 -CELLSPACING="0"
   1.189 -><TR
   1.190 -><TD
   1.191 -WIDTH="33%"
   1.192 -ALIGN="left"
   1.193 -VALIGN="top"
   1.194 -><A
   1.195 -HREF="guidethebasics.html"
   1.196 -ACCESSKEY="P"
   1.197 ->Prev</A
   1.198 -></TD
   1.199 -><TD
   1.200 -WIDTH="34%"
   1.201 -ALIGN="center"
   1.202 -VALIGN="top"
   1.203 -><A
   1.204 -HREF="index.html"
   1.205 -ACCESSKEY="H"
   1.206 ->Home</A
   1.207 -></TD
   1.208 -><TD
   1.209 -WIDTH="33%"
   1.210 -ALIGN="right"
   1.211 -VALIGN="top"
   1.212 -><A
   1.213 -HREF="guidevideo.html"
   1.214 -ACCESSKEY="N"
   1.215 ->Next</A
   1.216 -></TD
   1.217 -></TR
   1.218 -><TR
   1.219 -><TD
   1.220 -WIDTH="33%"
   1.221 -ALIGN="left"
   1.222 -VALIGN="top"
   1.223 ->The Basics</TD
   1.224 -><TD
   1.225 -WIDTH="34%"
   1.226 -ALIGN="center"
   1.227 -VALIGN="top"
   1.228 -><A
   1.229 -HREF="guidethebasics.html"
   1.230 -ACCESSKEY="U"
   1.231 ->Up</A
   1.232 -></TD
   1.233 -><TD
   1.234 -WIDTH="33%"
   1.235 -ALIGN="right"
   1.236 -VALIGN="top"
   1.237 ->Graphics and Video</TD
   1.238 -></TR
   1.239 -></TABLE
   1.240 -></DIV
   1.241 -></BODY
   1.242 -></HTML
   1.243 ->
   1.244 \ No newline at end of file