BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›SDL

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
  • BRL.BMPLoader
  • Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • BRL.FileSystem
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • BRL.JPGLoader
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
    • TIntMap
    • TIntKey
    • TPtrMap
    • TPtrKey
    • TStringMap
  • BRL.Math
  • Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PNGLoader
  • BRL.PolledInput
  • Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI
  • BRL.RamStream
  • Random

    • Introduction
    • TRandom

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • BRL.TGALoader
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I

    Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Text

    Format

    • Introduction
    • TFormatter

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

PUB

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • Pub.xmmintrin
  • Pub.ZLib

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister
    • TNoSuchAlgorithmException

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLDisplayMode
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType
Edit

SDL.SDL

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.

SDL is a wrapper around operating-system-specific functions that a game needs to access.

It provides a common framework for accessing these functions for multiple operating systems (cross-platform). SDL provides support for 2D pixel operations, sound, file access, event handling, timing and threading. It is often used to complement OpenGL by setting up the graphical output an providing mouse and keyboard input, since OpenGL comprises only rendering.

Types

TypeDescription
TSDLStreamAn SDL-based data stream type.

Functions

Function OpenSDLStream:TSDLStream( file:String, readable:Int, writeMode:Int )

Opens an SDL stream for reading/writing.

Returns

A stream object.


Function SDLGetBasePath:String()

Get the directory where the application was run from.

This is where the application data directory is. This is not necessarily a fast call, though, so you should call this once near startup and save the string if you need it.
Mac OS X and iOS Specific Functionality: If the application is in a ".app" bundle, this function returns the Resource directory (e.g. MyApp.app/Contents/Resources/). This behaviour can be overridden by adding a property to the Info.plist file. Adding a string key with the name SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the behaviour.

Example

SuperStrict

Framework SDL.SDL
Import BRL.StandardIO

Print SDLGetBasePath()


Function SDLGetPrefPath:String(org:String, app:String)

Returns the preferences dir.

This is meant to be where the application can write personal files (Preferences and save games, etc.) that are specific to the application. This directory is unique per user and per application. The path will be Null if there is a problem (creating directory failed, etc.)
The return path will be guaranteed to end with a path separator ('' on Windows, '/' on most other platforms). You should assume the path returned by this function is the only safe place to write files (and that GetBasePath(), while it might be writable, or even the parent of the returned path, aren't where you should be writing things).
Both the org and app strings may become part of a directory name, so please follow these rules:

  • Try to use the same org string (including case-sensitivity) for all your applications that use this function.
  • Always use a unique app string for each one, and make sure it never changes for an app once you've decided on it.
  • Only use letters, numbers, and spaces. Avoid punctuation like "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.


Function SDLAndroidGetExternalStoragePath:String()

Gets the path used for external storage for this application.

This path is unique to your application, but is public and can be written to by other applications. Your external storage path is typically: /storage/sdcard0/Android/data/your.app.package/files.

Returns

The path used for external storage for this application on success or NULL on failure; call SDLGetError() for more information.


Function SDLAndroidGetExternalStorageState:Int()

Gets the current state of external storage.

The current state of external storage, a bitmask of these values: SDL_ANDROID_EXTERNAL_STORAGE_READ, SDL_ANDROID_EXTERNAL_STORAGE_WRITE. If external storage is currently unavailable, this will return 0.


Function SDLAndroidGetInternalStoragePath:String()

Gets the path used for internal storage for this application.

This path is unique to your application and cannot be written to by other applications. Your internal storage path is typically: /data/data/your.app.package/files.

Returns

The path used for internal storage or NULL on failure; call SDLGetError() for more information.


Function SDLHasClipboardText:Int()

Return a flag indicating whether the clipboard exists and contains a text string that is non-empty.


Function SDLGetClipboardText:String()

Returns the clipboard text.


Function SDLSetClipboardText:Int(Text:String)

Puts text into the clipboard.

Returns

0 on success or a negative error code on failure.


Function SDLLogAppInfo(Text:String)

Logs a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.


Function SDLLogDebug(category:Int, Text:String)

Logs a message with SDL_LOG_PRIORITY_DEBUG.


Function SDLLogError(category:Int, Text:String)

Logs a message with SDL_LOG_PRIORITY_ERROR.


Function SDLLogCritical(category:Int, Text:String)

Logs a message with SDL_LOG_PRIORITY_CRITICAL.


Function SDLLogInfo(category:Int, Text:String)

Logs a message with SDL_LOG_PRIORITY_INFO.


Function SDLLogVerbose(category:Int, Text:String)

Logs a message with SDL_LOG_PRIORITY_VERBOSE.


Function SDLLogWarn(category:Int, Text:String)

Logs a message with SDL_LOG_PRIORITY_WARN.


Function SDLLogSetAllPriority(priority:Int)

Sets the priority of all log categories.

If you are debugging SDL, you might want to call this with SDL_LOG_PRIORITY_WARN.


Function SDLGetPowerInfo:Int(seconds:Int Var, percent:Int Var)

Gets the current power supply details.

You should never take a battery status as absolute truth. Batteries (especially failing batteries) are delicate hardware, and the values reported here are best estimates based on what that hardware reports. It's not uncommon for older batteries to lose stored power much faster than it reports, or completely drain when reporting it has 20 percent left, etc. Battery status can change at any time; if you are concerned with power state, you should call this function frequently, and perhaps ignore changes until they seem to be stable for a few seconds.

Returns

One of SDL_POWERSTATE_UNKNOWN, SDL_POWERSTATE_ON_BATTERY, SDL_POWERSTATE_NO_BATTERY, SDL_POWERSTATE_CHARGING, or SDL_POWERSTATE_CHARGED.

Example

SuperStrict

Framework SDL.SDL
Import brl.standardio

Local seconds:Int
Local percent:Int

Local result:Int = SDLGetPowerInfo(seconds, percent)

Local state:String
Select result
    Case SDL_POWERSTATE_UNKNOWN
        state = "Unknown"
    Case SDL_POWERSTATE_ON_BATTERY
        state = "On Battery"
    Case SDL_POWERSTATE_NO_BATTERY
        state = "No Battery"
    Case SDL_POWERSTATE_CHARGING
        state = "Charging"
    Case SDL_POWERSTATE_CHARGED
        state = "Charged"
End Select

Print "State     : " + state
Print "Remaining : " + seconds + " seconds (" + percent + " %)"


Function SDLGetPixelFormatName:String(format:UInt)

Gets the human readable name of a pixel format

Example

SuperStrict

Framework SDL.SDL
Import brl.standardio

Print SDLGetPixelFormatName(SDL_PIXELFORMAT_INDEX8)
Print SDLGetPixelFormatName(SDL_PIXELFORMAT_RGB24)
Print SDLGetPixelFormatName(SDL_PIXELFORMAT_BGRA8888)


Function SDLGetTicks:UInt()

Gets the number of milliseconds since the SDL library initialization.

This value wraps if the program runs for more than 49 days.

Returns

A value representing the number of milliseconds since the SDL library initialized.


Function SDLGetError:String()

Retrieves a message about the last error that occurred.

Returns

A message with information about the specific error that occurred, or an empty string if there hasn't been an error message set since the last call to SDLClearError(). The message is only applicable when an SDL function has signaled an error. You must check the return values of SDL function calls to determine when to appropriately call SDLGetError().


Function SDLClearError()

Clears any previous error message.


Function SDLAudioInit:Int(name:String)

(re)Initialises the audio subsystem.


Function SDLGetCPUCount:Int()

Returns the total number of logical CPU cores.

On CPUs that include technologies such as hyperthreading, the number of logical cores may be more than the number of physical cores.


Consts

Const SDL_APP_TERMINATING:Int = $101

The application is being terminated by the OS.

Called on iOS in applicationWillTerminate(). Called on Android in onDestroy()


Const SDL_APP_LOWMEMORY:Int = $102

The application is low on memory, free memory if possible.

Called on iOS in applicationDidReceiveMemoryWarning(). Called on Android in onLowMemory()


Const SDL_APP_WILLENTERBACKGROUND:Int = $103

The application is about to enter the background.

Called on iOS in applicationWillResignActive(). Called on Android in onPause()


Const SDL_APP_DIDENTERBACKGROUND:Int = $104

The application did enter the background and may not get CPU for some time.

Called on iOS in applicationDidEnterBackground(). Called on Android in onPause()


Const SDL_APP_WILLENTERFOREGROUND:Int = $105

The application is about to enter the foreground.

Called on iOS in applicationWillEnterForeground(). Called on Android in onResume()


Const SDL_APP_DIDENTERFOREGROUND:Int = $106

The application is now interactive.

Called on iOS in applicationDidBecomeActive(). Called on Android in onResume()


Const SDL_LOG_CATEGORY_APPLICATION:Int = 0

Application log category.

Has a default log priority of SDL_LOG_PRIORITY_INFO.


Const SDL_LOG_CATEGORY_ERROR:Int = 1

Error log category.

Has a default log priority of SDL_LOG_PRIORITY_CRITICAL.


Const SDL_LOG_CATEGORY_ASSERT:Int = 2

Assertion log category.

Has a default log priority of SDL_LOG_PRIORITY_WARN.


Const SDL_LOG_CATEGORY_SYSTEM:Int = 3

System log category.

Has a default log priority of SDL_LOG_PRIORITY_CRITICAL.


Const SDL_LOG_CATEGORY_AUDIO:Int = 4

Audio log category.

Has a default log priority of SDL_LOG_PRIORITY_CRITICAL.


Const SDL_LOG_CATEGORY_VIDEO:Int = 5

Video log category.

Has a default log priority of SDL_LOG_PRIORITY_CRITICAL.


Const SDL_LOG_CATEGORY_RENDER:Int = 6

Render log category.

Has a default log priority of SDL_LOG_PRIORITY_CRITICAL.


Const SDL_LOG_CATEGORY_INPUT:Int = 7

Input log category.

Has a default log priority of SDL_LOG_PRIORITY_CRITICAL.


Const SDL_LOG_CATEGORY_TEST:Int = 8

Test log category.

Has a default log priority of SDL_LOG_PRIORITY_VERBOSE.


Const SDL_LOG_CATEGORY_CUSTOM:Int = 19

Application defined starting category.

An application can use subsequent category numbers as required, e.g. SDL_LOG_CATEGORY_CUSTOM + 1, etc.


Const SDL_LOG_PRIORITY_VERBOSE:Int = 1

Verbose log priority.


Const SDL_LOG_PRIORITY_DEBUG:Int = 2

Debug log priority.


Const SDL_LOG_PRIORITY_INFO:Int = 3

Info log priority.


Const SDL_LOG_PRIORITY_WARN:Int = 4

Warn log priority.


Const SDL_LOG_PRIORITY_ERROR:Int = 5

Error log priority.


Const SDL_LOG_PRIORITY_CRITICAL:Int = 6

Critical log priority.


Const SDL_POWERSTATE_UNKNOWN:Int = 0

Cannot determine power status


Const SDL_POWERSTATE_ON_BATTERY:Int = 1

Not plugged in, running on the battery


Const SDL_POWERSTATE_NO_BATTERY:Int = 2

Plugged in, no battery available


Const SDL_POWERSTATE_CHARGING:Int = 3

Plugged in, charging battery


Const SDL_POWERSTATE_CHARGED:Int = 4

Plugged in, battery charged


← TCryptoPasswordHashTSDLStream →
  • Types
  • Functions
    • Function OpenSDLStream:TSDLStream( file:String, readable:Int, writeMode:Int )
    • Function SDLGetBasePath:String()
    • Function SDLGetPrefPath:String(org:String, app:String)
    • Function SDLAndroidGetExternalStoragePath:String()
    • Function SDLAndroidGetExternalStorageState:Int()
    • Function SDLAndroidGetInternalStoragePath:String()
    • Function SDLHasClipboardText:Int()
    • Function SDLGetClipboardText:String()
    • Function SDLSetClipboardText:Int(Text:String)
    • Function SDLLogAppInfo(Text:String)
    • Function SDLLogDebug(category:Int, Text:String)
    • Function SDLLogError(category:Int, Text:String)
    • Function SDLLogCritical(category:Int, Text:String)
    • Function SDLLogInfo(category:Int, Text:String)
    • Function SDLLogVerbose(category:Int, Text:String)
    • Function SDLLogWarn(category:Int, Text:String)
    • Function SDLLogSetAllPriority(priority:Int)
    • Function SDLGetPowerInfo:Int(seconds:Int Var, percent:Int Var)
    • Function SDLGetPixelFormatName:String(format:UInt)
    • Function SDLGetTicks:UInt()
    • Function SDLGetError:String()
    • Function SDLClearError()
    • Function SDLAudioInit:Int(name:String)
    • Function SDLGetCPUCount:Int()
  • Consts
    • Const SDL_APP_TERMINATING:Int = $101
    • Const SDL_APP_LOWMEMORY:Int = $102
    • Const SDL_APP_WILLENTERBACKGROUND:Int = $103
    • Const SDL_APP_DIDENTERBACKGROUND:Int = $104
    • Const SDL_APP_WILLENTERFOREGROUND:Int = $105
    • Const SDL_APP_DIDENTERFOREGROUND:Int = $106
    • Const SDL_LOG_CATEGORY_APPLICATION:Int = 0
    • Const SDL_LOG_CATEGORY_ERROR:Int = 1
    • Const SDL_LOG_CATEGORY_ASSERT:Int = 2
    • Const SDL_LOG_CATEGORY_SYSTEM:Int = 3
    • Const SDL_LOG_CATEGORY_AUDIO:Int = 4
    • Const SDL_LOG_CATEGORY_VIDEO:Int = 5
    • Const SDL_LOG_CATEGORY_RENDER:Int = 6
    • Const SDL_LOG_CATEGORY_INPUT:Int = 7
    • Const SDL_LOG_CATEGORY_TEST:Int = 8
    • Const SDL_LOG_CATEGORY_CUSTOM:Int = 19
    • Const SDL_LOG_PRIORITY_VERBOSE:Int = 1
    • Const SDL_LOG_PRIORITY_DEBUG:Int = 2
    • Const SDL_LOG_PRIORITY_INFO:Int = 3
    • Const SDL_LOG_PRIORITY_WARN:Int = 4
    • Const SDL_LOG_PRIORITY_ERROR:Int = 5
    • Const SDL_LOG_PRIORITY_CRITICAL:Int = 6
    • Const SDL_POWERSTATE_UNKNOWN:Int = 0
    • Const SDL_POWERSTATE_ON_BATTERY:Int = 1
    • Const SDL_POWERSTATE_NO_BATTERY:Int = 2
    • Const SDL_POWERSTATE_CHARGING:Int = 3
    • Const SDL_POWERSTATE_CHARGED:Int = 4
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2022 Bruce A Henderson