|
Size: 11506
Comment: edits w/ Sam
|
Size: 10132
Comment: edits w/ Sam
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 11: | Line 11: |
| == Functions by Type == === Basics === Introduction to the Basics |
== Basics == |
| Line 22: | Line 19: |
| === Video === Introduction to Video |
== Video == |
| Line 33: | Line 29: |
| === Input Events === Introduction to Input Events |
== Input Events == |
| Line 43: | Line 38: |
| === Force Feedback === Introduction to Force Feedback |
== Force Feedback == |
| Line 50: | Line 44: |
| === Audio === Introduction to Audio |
== Audio == |
| Line 57: | Line 50: |
| === File I/O Abstraction === Introduction to File I/O Abstraction |
== File I/O Abstraction == |
| Line 64: | Line 56: |
| === Shared Object Support === Introduction to Shared Object Support |
== Shared Object Support == |
| Line 71: | Line 62: |
| === Threads === Introduction to Threads |
== Threads == |
| Line 80: | Line 70: |
| === Timers === Introduction to Timers |
== Timers == |
| Line 87: | Line 76: |
| === Platform and CPU Information === Introduction to Platform and CPU Information |
== Platform and CPU Information == |
| Line 96: | Line 84: |
| === Power Management === Introduction to Power Management |
== Power Management == |
| Line 104: | Line 91: |
== Introductory Information by Category == |
---- ---- <<Color2(green,Temp Section to be moved)>> Introductory Information by Category |
| Line 222: | Line 212: |
---- <<Color2(green,This section is junk I don't want to lose yet but will most likely delete. Ignore it.)>> -OR - In each section: * For more detailed information on each Category, including how to get started, answers to common questions and errors, and more, click the '''Introduction to...''' link in each section * For a list of functions found in each header click the link under '''Related Functions''' * You will find links to detailed pages about each function on those pages * For the header file itself click the link under '''Header''' in each section -OR- Each section below includes * a link to introductory information about each function type including, where relevant: * <<Color2(green,Add a list here of the common sections found on each introductory page as the list develops.)>> * a link to one or more pages containing a complete list of functions belonging to each header in that category * listed functions link to detailed information on each * a link to the header page |
DRAFT |
SDL 1.3 API by Category
Contents
Basics
View information and functions related to... |
View the header |
Video
View information and functions related to... |
View the header |
Input Events
View information and functions related to... |
View the header |
Force Feedback
View information and functions related to... |
View the header |
Audio
View information and functions related to... |
View the header |
File I/O Abstraction
View information and functions related to... |
View the header |
Shared Object Support
View information and functions related to... |
View the header |
Threads
View information and functions related to... |
View the header |
Timers
View information and functions related to... |
View the header |
Platform and CPU Information
View information and functions related to... |
View the header |
Power Management
View information and functions related to... |
View the header |
green
Introductory Information by Category
green
Introduction to Initialization
General
Functions in this category are used to set up SDL 1.3 for use and generally have global effects in your program.
Initialization
To begin using SDL in your program SDL_Init() must be called to initialize subsystems and enable use of other SDL funcions.
The Event Handling, File I/O, and Threading subsystems are initialized by default. To initialize other subsystems you must specifically call them. Multiple subsystems may be or'd together.
Example: SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
Shut Down
SDL_Quit() should be called before an SDL application exits to shut down all subsystems, including the default ones.
It is not necessary to specify individual subsystems when using SDL_Quit(). It will automatically shut down all active subsystems.
Version
These functions are used to collect or display information about the version of SDL that is currently being used by the program.
- The version number consists of three segments (X.Y.Z)
- X = Major Version, which increments with massive changes, additions, and enhancements
- Y = Minor Version, which increments with backwards-compatible changes to the major revision
Z = Patchlevel, which increments with fixes to the minor revision
Example: 1.3.0
There are four (4) macros green
that apply to this header.
This macro gathers information from SDL_MAJOR_VERSION, SDL_MINOR_VERSION, AND SDL_PATCHLEVEL (#defines) and fills the structure SDL_version with that information.
- A minor macro that converts version numbers into a numeric value.
- A minor macro that produces the current SDL version number (major.minor.patchlevel)
- A minor macro that confirms whether a program was compiled with a version no older than the specified version.
Introduction to Video
Introduction to Input
Introduction to Force Feedback
The SDL Haptic subsystem allows you to control haptic (force feedback) devices.
The basic usage is as follows:
- Initialize the Subsystem (SDL_INIT_HAPTIC)
- Open a Haptic Device
SDL_HapticOpen() to open from index
SDL_HapticOpenFromJoystick() to open from an existing joystick
Create an effect (SDL_HapticEffect) <<Color2: execution failed [No argument named ""] (see also the log)>>
Upload the effect with SDL_HapticNewEffect()
Run the effect with SDL_HapticRunEffect()
(optional) Free the effect with SDL_HapticDestroyEffect()
Close the haptic device with SDL_HapticClose()
Code Example:
int test_haptic( SDL_Joystick * joystick ) {
SDL_Haptic *haptic;
SDL_HapticEffect effect;
int effect_id;
// Open the device
haptic = SDL_HapticOpenFromJoystick( joystick );
if (haptic == NULL) return -1; // Most likely joystick isn't haptic
// See if it can do sine waves
if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) {
SDL_HapticClose(haptic); // No sine effect
return -1;
}
// Create the effect
memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default
effect.type = SDL_HAPTIC_SINE;
effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates
effect.periodic.direction.dir[0] = 18000; // Force comes from south
effect.periodic.period = 1000; // 1000 ms
effect.periodic.magnitude = 20000; // 20000/32767 strength
effect.periodic.length = 5000; // 5 seconds long
effect.periodic.attack_length = 1000; // Takes 1 second to get max strength
effect.periodic.fade_length = 1000; // Takes 1 second to fade away
// Upload the effect
effect_id = SDL_HapticNewEffect( haptic, &effect );
// Test the effect
SDL_HapticRunEffect( haptic, effect_id, 1 );
SDL_Delay( 5000); // Wait for the effect to finish
// We destroy the effect, although closing the device also does this
SDL_HapticDestroyEffect( haptic, effect_id );
// Close the device
SDL_HapticClose(haptic);
return 0; // Success
}
Introduction to Audio
Introduction to File I/O Abstraction
Introduction to Shared Object Support
Introduction to Threads
Introduction to Timers
Introduction to CPU Feature Detection
Introduction to Power Management
Introduction to Endian Independence (Byte Order and Byte Swapping)
