2
0
Эх сурвалжийг харах

Renamed core functions with SDL prefix.
Documentation enhancements.

woollybah 6 жил өмнө
parent
commit
d3d59fe87a

+ 1 - 0
.gitignore

@@ -21,3 +21,4 @@
 *.armv7.i
 *.ios.dev.a
 *.i2
+commands.html

+ 2 - 1
sdl.mod/common.bmx

@@ -47,7 +47,8 @@ Extern
 	Function SDL_WasInit:Int(flags:Int)
 	Function SDL_Quit()
 
-	Function SDL_GetError:String()="bmx_SDL_GetError"
+	Function bmx_SDL_GetError:String()
+	Function SDL_ClearError()
 
 	Function bmx_SDL_AllocRW_stream:Byte Ptr(stream:TStream)
 	

+ 9 - 0
sdl.mod/doc/intro.bbdoc

@@ -0,0 +1,9 @@
+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.
+

+ 59 - 32
sdl.mod/sdl.bmx

@@ -111,7 +111,11 @@ Import "common.bmx"
 
 Import "glue.c"
 
-
+Rem
+bbdoc: An SDL-based data stream type.
+about: #TSDLStream extends #TStream to provide methods for reading and writing various types of values
+to and from an SDL-based Read/Write stream.
+End Rem
 Type TSDLStream Extends TStream
 
 	Field filePtr:Byte Ptr
@@ -172,7 +176,11 @@ Type TSDLStream Extends TStream
 
 End Type
 
-Function CreateSDLStream:TSDLStream( file:String, readable:Int, writeable:Int )
+Rem
+bbdoc: Opens an SDL stream for reading/writing.
+returns: A stream object.
+End Rem
+Function OpenSDLStream:TSDLStream( file:String, readable:Int, writeable:Int )
 	Return TSDLStream.Create( file, readable, writeable )
 End Function
 
@@ -193,7 +201,7 @@ Function _sdl_rwops_seek:Int(stream:TStream, pos:Long, whence:Int)
 End Function
 
 Function _sdl_rwops_read:Long(stream:TStream, buf:Byte Ptr, count:Long)
-	Return stream.read(buf, count)
+	Return stream.Read(buf, count)
 End Function
 
 Function _sdl_rwops_write:Long(stream:TStream, buf:Byte Ptr, count:Long)
@@ -210,9 +218,9 @@ about: 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.<br/>
 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.
+the name #SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the behaviour.
 End Rem
-Function GetBasePath:String()
+Function SDLGetBasePath:String()
 	Return bmx_SDL_GetBasePath()
 End Function
 
@@ -228,50 +236,50 @@ Both the org and app strings may become part of a directory name, so please foll
 * Always use a unique app string for each one, and make sure it never changes for an app once you've decided on it.<br/>
 * Only use letters, numbers, and spaces. Avoid punctuation like "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
 End Rem
-Function GetPrefPath:String(org:String, app:String)
+Function SDLGetPrefPath:String(org:String, app:String)
 	Return bmx_SDL_GetPrefPath(org, app)
 End Function
 ?android
 Rem
 bbdoc: Gets the path used for external storage for this application.
-returns: The path used for external storage for this application on success or NULL on failure; call SDL_GetError() for more information.
+returns: The path used for external storage for this application on success or NULL on failure; call #SDLGetError() for more information.
 about: 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.
 End Rem
-Function AndroidGetExternalStoragePath:String()
+Function SDLAndroidGetExternalStoragePath:String()
 	Return String.FromUTF8String(SDL_AndroidGetExternalStoragePath())
 End Function
 
 Rem
 bbdoc: Gets the current state of external storage.
-about: The current state of external storage, a bitmask of these values: SDL_ANDROID_EXTERNAL_STORAGE_READ, SDL_ANDROID_EXTERNAL_STORAGE_WRITE.
+about: 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.
 End Rem
-Function AndroidGetExternalStorageState:Int()
+Function SDLAndroidGetExternalStorageState:Int()
 	Return SDL_AndroidGetExternalStorageState()
 End Function
 
 Rem
 bbdoc: Gets the path used for internal storage for this application.
-returns: The path used for internal storage or NULL on failure; call SDL_GetError() for more information.
+returns: The path used for internal storage or NULL on failure; call #SDLGetError() for more information.
 about: 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.
 End Rem
-Function AndroidGetInternalStoragePath:String()
+Function SDLAndroidGetInternalStoragePath:String()
 	Return String.FromUTF8String(SDL_AndroidGetInternalStoragePath())
 End Function
 ?
 Rem
 bbdoc: Return a flag indicating whether the clipboard exists and contains a text string that is non-empty.
 End Rem
-Function HasClipboardText:Int()
+Function SDLHasClipboardText:Int()
 	Return SDL_HasClipboardText()
 End Function
 
 Rem
 bbdoc: Returns the clipboard text.
 End Rem
-Function GetClipboardText:String()
+Function SDLGetClipboardText:String()
 	Return bmx_SDL_GetClipboardText()
 End Function
 
@@ -279,68 +287,68 @@ Rem
 bbdoc: Puts text into the clipboard.
 returns: 0 on success or a negative error code on failure.
 End Rem
-Function SetClipboardText:Int(Text:String)
+Function SDLSetClipboardText:Int(Text:String)
 	Return SDL_SetClipboardText(Text.ToUTF8String())
 End Function
 
 Rem
-bbdoc: Logs a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
+bbdoc: Logs a message with #SDL_LOG_CATEGORY_APPLICATION and #SDL_LOG_PRIORITY_INFO.
 End Rem
-Function LogAppInfo(Text:String)
+Function SDLLogAppInfo(Text:String)
 	Local s:Byte Ptr = Text.ToUTF8String()
 	SDL_Log(s)
 	MemFree s
 End Function
 
 Rem
-bbdoc: Logs a message with SDL_LOG_PRIORITY_DEBUG.
+bbdoc: Logs a message with #SDL_LOG_PRIORITY_DEBUG.
 End Rem
-Function LogDebug(category:Int, Text:String)
+Function SDLLogDebug(category:Int, Text:String)
 	Local s:Byte Ptr = Text.ToUTF8String()
 	SDL_LogDebug(category, s)
 	MemFree s
 End Function
 
 Rem
-bbdoc: Logs a message with SDL_LOG_PRIORITY_ERROR.
+bbdoc: Logs a message with #SDL_LOG_PRIORITY_ERROR.
 End Rem
-Function LogError(category:Int, Text:String)
+Function SDLLogError(category:Int, Text:String)
 	Local s:Byte Ptr = Text.ToUTF8String()
 	SDL_LogError(category, s)
 	MemFree s
 End Function
 
 Rem
-bbdoc: Logs a message with SDL_LOG_PRIORITY_CRITICAL.
+bbdoc: Logs a message with #SDL_LOG_PRIORITY_CRITICAL.
 End Rem
-Function LogCritical(category:Int, Text:String)
+Function SDLLogCritical(category:Int, Text:String)
 	Local s:Byte Ptr = Text.ToUTF8String()
 	SDL_LogCritical(category, s)
 	MemFree s
 End Function
 
 Rem
-bbdoc: Logs a message with SDL_LOG_PRIORITY_INFO.
+bbdoc: Logs a message with #SDL_LOG_PRIORITY_INFO.
 End Rem
-Function LogInfo(category:Int, Text:String)
+Function SDLLogInfo(category:Int, Text:String)
 	Local s:Byte Ptr = Text.ToUTF8String()
 	SDL_LogInfo(category, s)
 	MemFree s
 End Function
 
 Rem
-bbdoc: Logs a message with SDL_LOG_PRIORITY_VERBOSE.
+bbdoc: Logs a message with #SDL_LOG_PRIORITY_VERBOSE.
 End Rem
-Function LogVerbose(category:Int, Text:String)
+Function SDLLogVerbose(category:Int, Text:String)
 	Local s:Byte Ptr = Text.ToUTF8String()
 	SDL_LogVerbose(category, s)
 	MemFree s
 End Function
 
 Rem
-bbdoc: Logs a message with SDL_LOG_PRIORITY_WARN.
+bbdoc: Logs a message with #SDL_LOG_PRIORITY_WARN.
 End Rem
-Function LogWarn(category:Int, Text:String)
+Function SDLLogWarn(category:Int, Text:String)
 	Local s:Byte Ptr = Text.ToUTF8String()
 	SDL_LogWarn(category, s)
 	MemFree s
@@ -348,9 +356,9 @@ End Function
 
 Rem
 bbdoc: Sets the priority of all log categories.
-about: If you are debugging SDL, you might want to call this with SDL_LOG_PRIORITY_WARN.
+about: If you are debugging SDL, you might want to call this with #SDL_LOG_PRIORITY_WARN.
 End Rem
-Function LogSetAllPriority(priority:Int)
+Function SDLLogSetAllPriority(priority:Int)
 	SDL_LogSetAllPriority(priority)
 End Function
 
@@ -363,7 +371,7 @@ stored power much faster than it reports, or completely drain when reporting it
 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.
 End Rem
-Function GetPowerInfo:Int(seconds:Int Var, percent:Int Var)
+Function SDLGetPowerInfo:Int(seconds:Int Var, percent:Int Var)
 	Return SDL_GetPowerInfo(Varptr seconds, Varptr percent)
 End Function
 
@@ -374,7 +382,26 @@ Function SDLGetPixelFormatName:String(format:UInt)
 	Return String.FromUTF8String(SDL_GetPixelFormatName(format))
 End Function
 
+Rem
+bbdoc: Gets the number of milliseconds since the SDL library initialization.
+returns: A value representing the number of milliseconds since the SDL library initialized.
+about: This value wraps if the program runs for more than ~49 days.
+End Rem
 Function SDLGetTicks:UInt()
 	Return SDL_GetTicks()
 End Function
 
+Rem
+bbdoc: 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().
+End Rem
+Function SDLGetError:String()
+	Return bmx_SDL_GetError()
+End Function
+
+Rem
+bbdoc: Clears any previous error message.
+End Rem
+Function SDLClearError()
+	SDL_ClearError()
+End Function

+ 21 - 5
sdlhaptic.mod/sdlhaptic.bmx

@@ -323,7 +323,7 @@ Type TSDLHapticEffect
 	Field effectPtr:Byte Ptr
 	
 	Rem
-	bbdoc: 
+	bbdoc: Frees the effect.
 	End Rem
 	Method Free()
 		If effectPtr Then
@@ -343,6 +343,9 @@ bbdoc: A constant effect applies a constant force to the joystick in the specifi
 End Rem
 Type TSDLHapticConstant Extends TSDLHapticEffect
 	
+	Rem
+	bbdoc: Creates a new instance of the effect.
+	End Rem
 	Method New()
 		effectPtr = bmx_sdl_haptic_SDLHapticConstant_new()
 	End Method
@@ -484,7 +487,7 @@ End Rem
 Type TSDLHapticPeriodic Extends TSDLHapticEffect
 
 	Rem
-	bbdoc: 
+	bbdoc: Creates a new instance of the effect.
 	about: @waveType one of #SDL_HAPTIC_SINE, #SDL_HAPTIC_LEFTRIGHT, #SDL_HAPTIC_TRIANGLE, #SDL_HAPTIC_SAWTOOTHUP or #SDL_HAPTIC_SAWTOOTHDOWN.
 	End Rem
 	Method New(waveType:Int)
@@ -651,12 +654,13 @@ Type TSDLHapticPeriodic Extends TSDLHapticEffect
 End Type
 
 Rem
-bbdoc: 
+bbdoc: A template for a condition effect.
 End Rem
 Type TSDLHapticCondition Extends TSDLHapticEffect
 
 	Rem
-	bbdoc: @effectType one of #SDL_HAPTIC_SPRING, #SDL_HAPTIC_DAMPER, #SDL_HAPTIC_INERTIA, #SDL_HAPTIC_FRICTION
+	bbdoc: Creates a new instance of the effect.
+	about: @effectType one of #SDL_HAPTIC_SPRING, #SDL_HAPTIC_DAMPER, #SDL_HAPTIC_INERTIA, #SDL_HAPTIC_FRICTION
 	End Rem
 	Method New(effectType:Int)
 		effectPtr = bmx_sdl_haptic_SDLHapticCondition_new(effectType)
@@ -775,10 +779,16 @@ Type TSDLHapticCondition Extends TSDLHapticEffect
 End Type
 
 Rem
-bbdoc: 
+bbdoc: A template for a ramp effect.
+about: The ramp effect starts at start strength and ends at end strength.
+It augments in linear fashion. If you use attack and fade with a ramp the effects get added to the ramp effect
+making the effect become quadratic instead of linear.
 End Rem
 Type TSDLHapticRamp Extends TSDLHapticEffect
 
+	Rem
+	bbdoc: Creates a new instance of the effect.
+	End Rem
 	Method New()
 		effectPtr = bmx_sdl_haptic_SDLHapticRamp_new()
 	End Method
@@ -926,6 +936,9 @@ about: One motor is high frequency, the other is low frequency.
 End Rem
 Type TSDLHapticLeftRight Extends TSDLHapticEffect
 
+	Rem
+	bbdoc: Creates a new instance of the effect.
+	End Rem
 	Method New()
 		effectPtr = bmx_sdl_haptic_SDLHapticLeftRight_new()
 	End Method
@@ -961,6 +974,9 @@ If channels is 1, the effect is rotated using the defined direction. Otherwise i
 End Rem
 Type TSDLHapticCustom Extends TSDLHapticEffect
 
+	Rem
+	bbdoc: Creates a new instance of the effect.
+	End Rem
 	Method New()
 		effectPtr = bmx_sdl_haptic_SDLHapticCustom_new()
 	End Method

+ 16 - 0
sdlrender.mod/doc/intro.bbdoc

@@ -0,0 +1,16 @@
+SDLRender contains functions for 2D accelerated rendering.
+
+This API supports the following features:
+
+* single pixel points
+* single pixel lines
+* filled rectangles
+* texture images
+All of these may be drawn in opaque, blended, or additive modes.
+
+The texture images can have an additional color tint or alpha modulation applied to them, and may also be stretched with linear interpolation, rotated or flipped/mirrored.
+
+For advanced functionality like particle effects or actual 3D you should use SDL's OpenGL/Direct3D support or one of the many available 3D engines.
+
+> This API is not designed to be used from multiple threads.
+

+ 2 - 2
sdlsensor.mod/sdlsensor.bmx

@@ -22,7 +22,7 @@
 SuperStrict
 
 Rem
-bbdoc: 
+bbdoc: SDL Sensor
 End Rem
 Module SDL.SDLSensor
 
@@ -32,7 +32,7 @@ Import SDL.SDL
 Import "common.bmx"
 
 Rem
-bbdoc: 
+bbdoc: A Sensor
 End Rem
 Type TSDLSensor
 

+ 2 - 1
sdlvideo.mod/common.bmx

@@ -63,6 +63,7 @@ Extern
 	Function bmx_sdl_video_GetDisplayMode:Byte Ptr(index:Int, modeIndex:Int)
 	Function bmx_sdl_video_GetDesktopDisplayMode:Byte Ptr(index:Int)
 	Function bmx_sdl_video_GetCurrentDisplayMode:Byte Ptr(index:Int)
+	Function bmx_sdl_video_SDL_GetCurrentVideoDriver:String()
 
 	Function SDL_GetNumVideoDisplays:Int()
 	Function SDL_GetDisplayName:Byte Ptr(index:Int)
@@ -85,7 +86,7 @@ Extern
 	Function SDL_GetWindowDisplayIndex:Int(handle:Byte Ptr)
 	Function SDL_GetWindowPixelFormat:UInt(handle:Byte Ptr)
 	Function SDL_GetWindowID:UInt(handle:Byte Ptr)
-	Function SDL_SetWindowDisplayMode:Int(handle:Byte Ptr, mode:Byte Ptr)
+	Function SDL_SetWindowDisplayMode:Int(handle:Byte Ptr, Mode:Byte Ptr)
 	Function SDL_ShowWindow(handle:Byte Ptr)
 	Function SDL_HideWindow(handle:Byte Ptr)
 	Function SDL_RaiseWindow(handle:Byte Ptr)

+ 8 - 0
sdlvideo.mod/glue.c

@@ -96,6 +96,14 @@ SDL_DisplayMode * bmx_sdl_video_GetCurrentDisplayMode(int index) {
 	}
 }
 
+BBString * bmx_sdl_video_SDL_GetCurrentVideoDriver() {
+	if (!SDL_GetCurrentVideoDriver()) {
+		return &bbEmptyString;
+	} else {
+		return bbStringFromUTF8String(SDL_GetCurrentVideoDriver());
+	}
+}
+
 // --------------------------------------------------------
 
 SDL_DisplayMode * bmx_sdl_video_DisplayMode_new(Uint32 format, int width, int height, int refreshRate) {

+ 15 - 9
sdlvideo.mod/sdlvideo.bmx

@@ -22,7 +22,7 @@
 SuperStrict
 
 Rem
-bbdoc: 
+bbdoc: SDL Video
 End Rem
 Module SDL.SDLVideo
 
@@ -67,8 +67,8 @@ Type TSDLWindow
 	about: This only affects the display mode used when the window is fullscreen. To change the window size when the window is not fullscreen,
 	use #SetSize().
 	End Rem
-	Method SetDisplayMode:Int(mode:TSDLDisplayMode)
-		Return SDL_SetWindowDisplayMode(windowPtr, mode.modePtr)
+	Method SetDisplayMode:Int(Mode:TSDLDisplayMode)
+		Return SDL_SetWindowDisplayMode(windowPtr, Mode.modePtr)
 	End Method
 	
 	Rem
@@ -577,7 +577,7 @@ Type TSDLGLContext
 End Type
 
 Rem
-bbdoc: 
+bbdoc: Represents an indexed video display.
 End Rem
 Type TSDLDisplay
 
@@ -745,10 +745,11 @@ End Type
 
 
 Rem
-bbdoc: 
+bbdoc: Returns the list of built-in video drivers.
+about: The video drivers are presented in the order in which they are normally checked during initialization.
 End Rem
 Function SDLGetVideoDrivers:String[]()
-	Return bmx_sdl_video_GetVideoDrivers:String[]()
+	Return bmx_sdl_video_GetVideoDrivers()
 End Function
 
 Rem
@@ -769,13 +770,16 @@ Function SDLVideoQuit()
 End Function
 
 Rem
-bbdoc: 
+bbdoc: Gets the name of the currently initialized video driver.
+returns: The name of the current video driver or NULL if no driver has been initialized.
 End Rem
 Function SDLGetCurrentVideoDriver:String()
+	Return bmx_sdl_video_SDL_GetCurrentVideoDriver()
 End Function
 
 Rem
-bbdoc: Gets the number of video drivers compiled into SDL
+bbdoc: Gets the number of available video displays.
+returns: A number >= 1 or a negative error code on failure. Call #SDLGetError() for more information.
 End Rem
 Function SDLGetNumVideoDisplays:Int()
 	Return SDL_GetNumVideoDisplays()
@@ -790,7 +794,8 @@ Function SDLGetGrabbedWindow:TSDLWindow()
 End Function
 
 Rem
-bbdoc: Returns whether the screensaver is currently enabled (default off).
+bbdoc: Returns whether the screensaver is currently enabled (Default off).
+about: The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2 the screensaver was enabled by default.
 End Rem
 Function SDLIsScreenSaverEnabled:Int()
 	Return SDL_IsScreenSaverEnabled()
@@ -805,6 +810,7 @@ End Function
 
 Rem
 bbdoc: Prevents the screen from being blanked by a screensaver.
+about: If you disable the screensaver, it is automatically re-enabled when SDL quits.
 End Rem
 Function SDLDisableScreenSaver()
 	SDL_DisableScreenSaver()