User Tools

Site Tools


notes:sysprog

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
notes:sysprog [2019/02/05 23:27]
bmeehan1 [URLs]
notes:sysprog [2019/02/06 22:59] (current)
wprice2 [Course Notes Wiki]
Line 56: Line 56:
 If you'd like to play a sound through SDL, it's best to use the extension library SDL_mixer. There are two basic types of sound in the SDL_mixer: Mix_Music for songs and music, and Mix_Chunk for sound effects such as footsteps or voice lines. As for actually playing said audio, you should use the function "​Mix_OpenAudio"​ to first initialize the mixer'​s functions. This function has 4 arguments. The frequency, format, number of channels, and sample size of the clip being played. Now that SDL_mixer is initialized,​ You can use "​Mix_LoadMUS"​ and "​Mix_LoadWAV"​ to music and sound effects respectfully. After the audio has run its course, don't forget to free the music man! If you'd like to play a sound through SDL, it's best to use the extension library SDL_mixer. There are two basic types of sound in the SDL_mixer: Mix_Music for songs and music, and Mix_Chunk for sound effects such as footsteps or voice lines. As for actually playing said audio, you should use the function "​Mix_OpenAudio"​ to first initialize the mixer'​s functions. This function has 4 arguments. The frequency, format, number of channels, and sample size of the clip being played. Now that SDL_mixer is initialized,​ You can use "​Mix_LoadMUS"​ and "​Mix_LoadWAV"​ to music and sound effects respectfully. After the audio has run its course, don't forget to free the music man!
  
 +==SDL important functions==
 +
 +-The SDL_GetMouseState(int *x int *y) function allows the user to receive any information on both the buttons being pressed and the location of the mouse with the SDL_BUTTON() macros and the x and y integers respectfully.
 +
 +-The SDL_GetKeyState(int *numkeys) points the numkeys pointer at an array indexed with SDLK_* symbols. Each pointer in the array corresponds with a button on the keyboard. If the value is 1, the key is pressed and the opposite for if the value is 0. It is important to note that the returned pointer should not be freed by the caller as it is a pointer to an internal SDL array.
 =====DokuWiki wrap plugin===== =====DokuWiki wrap plugin=====
 http://​www.dokuwiki.org/​_media/​plugin:​wrap_plugin_example2.png http://​www.dokuwiki.org/​_media/​plugin:​wrap_plugin_example2.png
notes/sysprog.txt · Last modified: 2019/02/06 22:59 by wprice2