Wiki Page Content

Differences between revisions 23 and 24
Revision 23 as of 2010-04-29 04:32:53
Size: 9908
Editor: SheenaSmith
Comment: edits w/ Sam
Revision 24 as of 2010-05-06 23:09:07
Size: 4812
Editor: SheenaSmith
Comment: move introductory info to category pages
Deletions are marked like this. Additions are marked like this.
Line 88: Line 88:


----
----
----
<<Color2(green,Temp Section to be moved)>>

<<Anchor(InitI)>>'''Introduction to Initialization'''

__General__<<BR>> Functions in this category are used to set up SDL 1.3 for use and generally have global effects in your program.

__Initialization__<<BR>>
To begin using SDL in your program [[SDL_Init]]() must be called to initialize subsystems and enable use of other SDL funcions.
 * The [[#Timers|Event Handling]], [[#File I/O Abstraction|File I/O]], and [[#Threads|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);}}}
  . Initializes the 3 default subsystems and the [[#Video|Video]] and [[#Audio|Audio]] subsystems.

__Shut Down__<<BR>>
[[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__<<BR>>
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<<BR>>
 ''Example:'' 1.3.0

There are four (4) macros <<Color2(green,Create a link to a resource that describes macros)>> that apply to this header.

 * [[SDL_VERSION]]
  * This macro gathers information from SDL_MAJOR_VERSION, SDL_MINOR_VERSION, AND SDL_PATCHLEVEL (#defines) and fills the structure [[SDL_version]] with that information.
 * [[SDL_version#Related_Minor_Macros|SDL_VERSIONNUM]]
  * A minor macro that converts version numbers into a numeric value.
 * [[SDL_version#Related_Minor_Macros|SDL_COMPILEDVERSION]]
  * A minor macro that produces the current SDL version number (major.minor.patchlevel)
 * [[SDL_version#Related_Minor_Macros|SDL_VERSION_ATLEAST]]
  * A minor macro that confirms whether a program was compiled with a version no older than the specified version.

<<Anchor(VideoI)>>'''Introduction to Video'''

<<Anchor(InputI)>>'''Introduction to Input'''

<<Anchor(FFI)>>'''Introduction to Force Feedback'''

The SDL Haptic subsystem allows you to control haptic (force feedback) devices.

The basic usage is as follows:

 1. Initialize the Subsystem (SDL_INIT_HAPTIC)
 1. Open a Haptic Device
  a. [[SDL_HapticOpen]]() to open from index
  a. [[SDL_HapticOpenFromJoystick]]() to open from an existing joystick
 1. Create an effect ([[SDL_HapticEffect]]) <<Color2(green,= typedef union - page? no link?)>>
 1. Upload the effect with [[SDL_HapticNewEffect]]()
 1. Run the effect with [[SDL_HapticRunEffect]]()
 1. (optional) Free the effect with [[SDL_HapticDestroyEffect]]()
 1. Close the haptic device with [[SDL_HapticClose]]()

Code Example:

{{{#!highlight cpp
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
}
}}}
<<Anchor(AudioI)>>'''Introduction to Audio'''

<<Anchor(I/OI)>>'''Introduction to File I/O Abstraction'''

<<Anchor(SOSI)>>'''Introduction to Shared Object Support'''

<<Anchor(ThreadsI)>>'''Introduction to Threads'''

<<Anchor(TimersI)>>'''Introduction to Timers'''

<<Anchor(CPUI)>>'''Introduction to CPU Feature Detection'''

<<Anchor(PowerI)>>'''Introduction to Power Management'''

<<Anchor(EndianI)>>'''Introduction to Endian Independence (Byte Order and Byte Swapping)'''

DRAFT

SDL 1.3 API by Category

Basics

View information and functions related to...

View the header

Initialization & Shutdown

SDL.h

Error Handling

SDL_error.h

Querying SDL Version

SDL_version.h

Video

View information and functions related to...

View the header

Display Management, Window Management and Rendering

SDL_video.h

Pixel Formats and Conversion Routines

SDL_pixels.h

Rectangle Functions

SDL_rect.h

Surface Creation and Simple Drawing

SDL_surface.h

Platform-specific Window Management

SDL_syswm.h

Input Events

View information and functions related to...

View the header

Event Handling

SDL_events.h

Keyboard Support

SDL_keyboard.h

Mouse Support

SDL_mouse.h

Joystick Support

SDL_joystick.h

Force Feedback

View information and functions related to...

View the header

Force Feedback Support

SDL_haptic.h

Audio

View information and functions related to...

View the header

Audio Device Management, Playing and Recording

SDL_audio.h

File I/O Abstraction

View information and functions related to...

View the header

File I/O Abstraction

SDL_rwops.h

Shared Object Support

View information and functions related to...

View the header

Shared Object Loading and Function Lookup

SDL_loadso.h

Threads

View information and functions related to...

View the header

Thread Management

SDL_thread.h

Thread Synchronization Primitives

SDL_mutex.h

Atomic Operations for 32 and 64 Bit Values

SDL_atomic.h

Timers

View information and functions related to...

View the header

Timer Support

SDL_timer.h

Platform and CPU Information

View information and functions related to...

View the header

Platform Detection

SDL_platform.h

CPU Feature Detection

SDL_cpuinfo.h

Byte Order and Byte Swapping

SDL_endian.h

Power Management

View information and functions related to...

View the header

Power Management Status

SDL_power.h

None: APIByCategory (last edited 2020-01-13 13:44:18 by markand)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit