root/trunk/docs/sdl.html

Revision 255, 3.0 kB (checked in by aldacron, 2 years ago)

[Docs]
* corrected several spelling mistakes
* tweaked the wording of a few passages to make for clarity or to just make them more proper
* fixed a couple of glaring bugs that caused some bits of text to be invisible
* deleted a some things that were no longer relevant

  • Property svn:mime-type set to text/html
  • Property svn:mim-type set to text/html
Line 
1 <html lang="en">
2 <head>
3     <title>DerelictSDL</title>
4     <link rel="stylesheet" type="text/css" href="styles.css">
5 </head>
6 <body>
7 <hr>
8 <hr>
9 <h2 align="center">DerelictSDL</h2>
10 <hr>
11 <hr>
12 <h3>Introduction</h3>
13 DerelictSDL is a D binding to Sam Lantinga's <a href="http://www.libsdl.org/">Simple
14 DirectMedia Layer</a>, a cross-platform multimedia library designed to provide
15 low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
16 and 2D video framebuffer. Although SDL is available on a large number of platforms,
17 DerelictSDL is currently only available on Windows and Linux.
18
19 <div class="important">The current version of DerelictSDL requires SDL 1.2.10 or later.</div>
20
21 <div class="note">SDL_VideoInfo is defined differently
22 in DerelictSDL than it is in SDL. This is because the C version makes use of
23 bitfields, which D does not support. Currently, DerelictSDL replaces all bitfields
24 in the structure definition with a single <tt>uint</tt> field called  <tt>flags</tt>. It is
25 still possible to access the individual bitfield flags by using bit manipulation
26 operators, but unless you know what you are doing it is recommended that you not
27 do so. Instances of SDL_VideoInfo are created on the C side, not in D. There is
28 nothing in the C standard which specifies the order of the bits in the bitfield
29 (i.e. the first field encountered might become the low order or high order bit),
30 so what may work with one SDL shared library on one platform may not work with an
31 SDL shared library on another platform (or even on the same platform if compiled
32 with a different compiler!). So please keep in mind that manipulating the <tt>flags</tt>
33 field of DerelictSDL's SDL_VideoInfo could result in unexpected consequences. You
34 have been warned!</div>   
35
36 <h3>Using</h3>
37 <ol>
38 <li>Always make sure the DerelictSDL source modules are available on your import
39 path.</li>
40 <li>In modules that make use of DerelictSDL, you will need to import the
41 derelict.sdl.sdl module.</li>
42 <li>Before calling any SDL functions, you need to make a call to <tt>DerelictSDL.load()</tt>.
43 This will load the shared library.</li>
44 </ol>
45
46 <p>
47 The following is a complete program that loads DerelictSDL:
48 </p>
49
50 <pre>
51 import derelict.sdl.sdl;
52
53 void main()
54 {
55     DerelictSDL.load();
56    
57     // now you can call SDL functions
58 }
59 </pre>
60 <p>
61 As with other Derelict packages, DerelictSDL will throw an exception if an error
62 occurs while loading the shared library. For more information on Derelict
63 exceptions, see the documentation for
64 <a href="loading.html">Loading/Unloading Shared Libraries</a>.
65 </p><p>
66 Finally, the method <tt>DerelictSDL.unload()</tt> is provided for convenience. In normal
67 practice you do not need to call this function, as Derelict will unload the library
68 automatically when the app exits. You generally should only use this function if
69 you need to unload DerelictSDL while the application is running.
70 </p>
71
72 <h3>Dependencies</h3>
73 <a href="util.html">DerelictUtil</a>
74
75 </body>
76 </html>
Note: See TracBrowser for help on using the browser.