SDL Community Project

BlitzMax Forums/BlitzMax Programming/SDL Community Project

Dear community,

SDL's renderer represents the opportunity to take Blitzmax to the next level with robust software fallback. While there isn't scale and rotation, it gives you the power to support win, linux and mac cards which either have bad drivers or no 3D capability - and they are far more common than you might think!

To this end, I am proposing this thread be made sticky and we work together to create a definitive max 2D rendering solution. Lets get started!

The libs - precompiled is most convenient and no GPL issues but modules also welcome:

windows:
http://www.libsdl.org/release/SDL-1.2.8-win32.zip

linux:
http://www.libsdl.org/release/SDL-1.2.8-1.i386.rpm

mac:
http://www.libsdl.org/release/SDL-1.2.8.pkg.tar.gz

source in c:
http://www.libsdl.org/download-1.2.php

Please note these are all precompiled which is easier (unless someone wants to make a mod! Some brave soul...) And we are going for a windows version first.

Docs:
http://www.libsdl.org/cgi/docwiki.cgi/

Homepage:
http://www.libsdl.org/

Source code so far:

Contributed by noel cower (this is a very limited bit of source that just shows us some of the keywords, types and constants - perhaps it will help us get started:
Strict
Module Pub.SDL
ModuleInfo "BlitzMax SDL Implementation"
ModuleInfo "www.libsdl.org"
ModuleInfo "GNU Lesser General Public License"

Import "-lSDL"

Const SDL_INIT_TIMER		=$00000001
Const SDL_INIT_AUDIO		=$00000010
Const SDL_INIT_VIDEO		=$00000020
Const SDL_INIT_CDROM		=$00000100
Const SDL_INIT_JOYSTICK	=$00000200
Const SDL_INIT_NOPARACHUTE	=$00100000	' Don't catch fatal signals 
Const SDL_INIT_EVENTTHREAD	=$01000000	' Not supported on all OS's 
Const SDL_INIT_EVERYTHING	=$0000FFFF
Const SDL_APPMOUSEFOCUS	=$01		' The app has mouse coverage 
Const SDL_APPINPUTFOCUS	=$02		' The app has input focus 
Const SDL_APPACTIVE		=$04		' The application is active 
Const AUDIO_U8	=$0008	' Unsigned 8-bit samples 
Const AUDIO_S8	=$8008	' Signed 8-bit samples 
Const AUDIO_U16LSB	=$0010	' Unsigned 16-bit samples 
Const AUDIO_S16LSB	=$8010	' Signed 16-bit samples 
Const AUDIO_U16MSB	=$1010	' As above, but big-endian byte order 
Const AUDIO_S16MSB	=$9010	' As above, but big-endian byte order 
Const SDL_AUDIO_TRACK	=$00
Const SDL_DATA_TRACK	=$04
Const SDL_ALLEVENTS		=$FFFFFFFF
Const SDL_HAT_CENTERED	=$00
Const SDL_HAT_UP		=$01
Const SDL_HAT_RIGHT		=$02
Const SDL_HAT_DOWN		=$04
Const SDL_HAT_LEFT		=$08
Const SDL_HAT_RIGHTUP = SDL_HAT_RIGHT|SDL_HAT_UP
Const SDL_HAT_LEFTUP = SDL_HAT_LEFT|SDL_HAT_UP
Const SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT|SDL_HAT_DOWN
Const SDL_HAT_LEFTDOWN = SDL_HAT_LEFT|SDL_HAT_DOWN
Const SDL_ALL_HOTKEYS		=$FFFFFFFF
Const SDL_SWSURFACE	=$00000000	' Surface is in system memory 
Const SDL_HWSURFACE	=$00000001	' Surface is in video memory 
Const SDL_ASYNCBLIT	=$00000004	' Use asynchronous blits if possible 
Const SDL_ANYFORMAT	=$10000000	' Allow any video depth/pixel-format 
Const SDL_HWPALETTE	=$20000000	' Surface has exclusive palette 
Const SDL_DOUBLEBUF	=$40000000	' Set up double-buffered video mode 
Const SDL_FULLSCREEN	=$80000000	' Surface is a full screen display 
Const SDL_OPENGL      =$00000002      ' Create an OpenGL rendering context 
Const SDL_OPENGLBLIT	=$0000000A	' Create an OpenGL rendering context and use it for blitting 
Const SDL_RESIZABLE	=$00000010	' This video mode may be resized 
Const SDL_NOFRAME	=$00000020	' No window caption or edge frame 
Const SDL_HWACCEL	=$00000100	' Blit uses hardware acceleration 
Const SDL_SRCCOLORKEY	=$00001000	' Blit uses a source color key 
Const SDL_RLEACCELOK	=$00002000	' Private flag 
Const SDL_RLEACCEL	=$00004000	' Surface is RLE encoded 
Const SDL_SRCALPHA	=$00010000	' Blit uses source alpha blending 
Const SDL_PREALLOC	=$01000000	' Surface uses preallocated memory 
Const SDL_YV12_OVERLAY  =$32315659	' Planar mode: Y + V + U  (3 planes) 
Const SDL_IYUV_OVERLAY  =$56555949	' Planar mode: Y + U + V  (3 planes) 
Const SDL_YUY2_OVERLAY  =$32595559	' Packed mode: Y0+U0+Y1+V0 (1 plane) 
Const SDL_UYVY_OVERLAY  =$59565955	' Packed mode: U0+Y0+V0+Y1 (1 plane) 
Const SDL_YVYU_OVERLAY  =$55595659	' Packed mode: Y0+V0+Y1+U0 (1 plane) 
Const SDL_LOGPAL =$01
Const SDL_PHYSPAL =$02
Const SDL_AUDIO_STOPPED = 0
Const SDL_AUDIO_PLAYING = 1
Const SDL_AUDIO_PAUSED = 2
Const SDL_GL_RED_SIZE = 0
Const SDL_GL_GREEN_SIZE = 1
Const SDL_GL_BLUE_SIZE = 2
Const SDL_GL_ALPHA_SIZE = 3
Const SDL_GL_BUFFER_SIZE = 4
Const SDL_GL_DOUBLEBUFFER = 5
Const SDL_GL_DEPTH_SIZE = 6
Const SDL_GL_STENCIL_SIZE = 7
Const SDL_GL_ACCUM_RED_SIZE =8
Const SDL_GL_ACCUM_GREEN_SIZE =9
Const SDL_GL_ACCUM_BLUE_SIZE =10
Const SDL_GL_ACCUM_ALPHA_SIZE =11
Const SDL_GL_STEREO =12
Const SDL_GL_MULTISAMPLEBUFFERS =13
Const SDL_GL_MULTISAMPLESAMPLES =14
Const SDL_GRAB_QUERY = -1
Const SDL_GRAB_OFF = 0
Const SDL_GRAB_ON = 1
Const SDL_GRAB_FULLSCREEN = 2			' Used internally
Const CD_TRAYEMPTY = 0
Const CD_STOPPED = 1
Const CD_PLAYING = 2
Const CD_PAUSED = 3
Const CD_ERROR = -1
Const SDL_ENOMEM = 0
Const SDL_EFREAD = 1
Const SDL_EFWRITE = 2
Const SDL_EFSEEK = 3
Const SDL_LASTERROR = 4
Const SDL_NOEVENT = 0
Const SDL_ACTIVEEVENT = 1
Const SDL_KEYDOWN = 2
Const SDL_KEYUP = 3
Const SDL_MOUSEMOTION = 4
Const SDL_MOUSEBUTTONDOWN = 5
Const SDL_MOUSEBUTTONUP = 6
Const SDL_JOYAXISMOTION = 7
Const SDL_JOYBALLMOTION = 8
Const SDL_JOYHATMOTION = 9
Const SDL_JOYBUTTONDOWN = 10
Const SDL_JOYBUTTONUP = 11
Const SDL_QUIT = 12
Const SDL_SYSWMEVENT = 13
Const SDL_EVENT_RESERVEDA = 14
Const SDL_EVENT_RESERVEDB = 15
Const SDL_VIDEORESIZE = 16
Const SDL_VIDEOEXPOSE = 17
Const SDL_EVENT_RESERVED2 = 18
Const SDL_EVENT_RESERVED3 = 19
Const SDL_EVENT_RESERVED4 = 20
Const SDL_EVENT_RESERVED5 = 21
Const SDL_EVENT_RESERVED6 = 22
Const SDL_EVENT_RESERVED7 = 23
Const SDL_USEREVENT = 24
Const SDL_NUMEVENTS = 32
Const SDL_ALLEVENTS = $FFFFFFFF
Const SDL_ACTIVEEVENTMASK = 1
Const SDL_KEYDOWNMASK = 2
Const SDL_KEYUPMASK = 4
Const SDL_MOUSEMOTIONMASK = 8
Const SDL_MOUSEBUTTONDOWNMA = 16
Const SDL_MOUSEBUTTONUPMASK = 32
Const SDL_MOUSEEVENTMASK = 64
Const SDL_JOYAXISMOTIONMASK = 128
Const SDL_JOYBALLMOTIONMASK = 256
Const SDL_JOYHATMOTIONMASK = 512
Const SDL_JOYBUTTONDOWNMASK = 1024
Const SDL_JOYBUTTONUPMASK = 2048
Const SDL_JOYEVENTMASK = 4096
Const SDL_VIDEORESIZEMASK = 8192
Const SDL_VIDEOEXPOSEMASK = 16384
Const SDL_QUITMASK		 = 66536
Const SDL_SYSWMEVENTMASK = 131072
Const SDL_QUERY = -1
Const SDL_IGNORE = 0
Const SDL_DISABLE = 0
Const SDL_ENABLE = 1
Const SDL_ADDEVENT = 0
Const SDL_PEEKEVENT = 1
Const SDL_GETEVENT = 2
Const SDLK_UNKNOWN		= 0
Const SDLK_FIRST		= 0
Const SDLK_BACKSPACE		= 8
Const SDLK_TAB		= 9
Const SDLK_CLEAR		= 12
Const SDLK_RETURN		= 13
Const SDLK_PAUSE		= 19
Const SDLK_ESCAPE		= 27
Const SDLK_SPACE		= 32
Const SDLK_EXCLAIM		= 33
Const SDLK_QUOTEDBL		= 34
Const SDLK_HASH		= 35
Const SDLK_DOLLAR		= 36
Const SDLK_AMPERSAND		= 38
Const SDLK_QUOTE		= 39
Const SDLK_LEFTPAREN		= 40
Const SDLK_RIGHTPAREN		= 41
Const SDLK_ASTERISK		= 42
Const SDLK_PLUS		= 43
Const SDLK_COMMA		= 44
Const SDLK_MINUS		= 45
Const SDLK_PERIOD		= 46
Const SDLK_SLASH		= 47
Const SDLK_0			= 48
Const SDLK_1			= 49
Const SDLK_2			= 50
Const SDLK_3			= 51
Const SDLK_4			= 52
Const SDLK_5			= 53
Const SDLK_6			= 54
Const SDLK_7			= 55
Const SDLK_8			= 56
Const SDLK_9			= 57
Const SDLK_COLON		= 58
Const SDLK_SEMICOLON		= 59
Const SDLK_LESS		= 60
Const SDLK_EQUALS		= 61
Const SDLK_GREATER		= 62
Const SDLK_QUESTION		= 63
Const SDLK_AT			= 64
	' Skip uppercase letters
Const SDLK_LEFTBRACKET	= 91
Const SDLK_BACKSLASH		= 92
Const SDLK_RIGHTBRACKET	= 93
Const SDLK_CARET		= 94
Const SDLK_UNDERSCORE		= 95
Const SDLK_BACKQUOTE		= 96
Const SDLK_a			= 97
Const SDLK_b			= 98
Const SDLK_c			= 99
Const SDLK_d			= 100
Const SDLK_e			= 101
Const SDLK_f			= 102
Const SDLK_g			= 103
Const SDLK_h			= 104
Const SDLK_i			= 105
Const SDLK_j			= 106
Const SDLK_k			= 107
Const SDLK_l			= 108
Const SDLK_m			= 109
Const SDLK_n			= 110
Const SDLK_o			= 111
Const SDLK_p			= 112
Const SDLK_q			= 113
Const SDLK_r			= 114
Const SDLK_s			= 115
Const SDLK_t			= 116
Const SDLK_u			= 117
Const SDLK_v			= 118
Const SDLK_w			= 119
Const SDLK_x			= 120
Const SDLK_y			= 121
Const SDLK_z			= 122
Const SDLK_DELETE		= 127
	' End of ASCII mapped keysyms 
	' International keyboard syms 
Const SDLK_WORLD_0		= 160		' $A0 
Const SDLK_WORLD_1		= 161
Const SDLK_WORLD_2		= 162
Const SDLK_WORLD_3		= 163
Const SDLK_WORLD_4		= 164
Const SDLK_WORLD_5		= 165
Const SDLK_WORLD_6		= 166
Const SDLK_WORLD_7		= 167
Const SDLK_WORLD_8		= 168
Const SDLK_WORLD_9		= 169
Const SDLK_WORLD_10		= 170
Const SDLK_WORLD_11		= 171
Const SDLK_WORLD_12		= 172
Const SDLK_WORLD_13		= 173
Const SDLK_WORLD_14		= 174
Const SDLK_WORLD_15		= 175
Const SDLK_WORLD_16		= 176
Const SDLK_WORLD_17		= 177
Const SDLK_WORLD_18		= 178
Const SDLK_WORLD_19		= 179
Const SDLK_WORLD_20		= 180
Const SDLK_WORLD_21		= 181
Const SDLK_WORLD_22		= 182
Const SDLK_WORLD_23		= 183
Const SDLK_WORLD_24		= 184
Const SDLK_WORLD_25		= 185
Const SDLK_WORLD_26		= 186
Const SDLK_WORLD_27		= 187
Const SDLK_WORLD_28		= 188
Const SDLK_WORLD_29		= 189
Const SDLK_WORLD_30		= 190
Const SDLK_WORLD_31		= 191
Const SDLK_WORLD_32		= 192
Const SDLK_WORLD_33		= 193
Const SDLK_WORLD_34		= 194
Const SDLK_WORLD_35		= 195
Const SDLK_WORLD_36		= 196
Const SDLK_WORLD_37		= 197
Const SDLK_WORLD_38		= 198
Const SDLK_WORLD_39		= 199
Const SDLK_WORLD_40		= 200
Const SDLK_WORLD_41		= 201
Const SDLK_WORLD_42		= 202
Const SDLK_WORLD_43		= 203
Const SDLK_WORLD_44		= 204
Const SDLK_WORLD_45		= 205
Const SDLK_WORLD_46		= 206
Const SDLK_WORLD_47		= 207
Const SDLK_WORLD_48		= 208
Const SDLK_WORLD_49		= 209
Const SDLK_WORLD_50		= 210
Const SDLK_WORLD_51		= 211
Const SDLK_WORLD_52		= 212
Const SDLK_WORLD_53		= 213
Const SDLK_WORLD_54		= 214
Const SDLK_WORLD_55		= 215
Const SDLK_WORLD_56		= 216
Const SDLK_WORLD_57		= 217
Const SDLK_WORLD_58		= 218
Const SDLK_WORLD_59		= 219
Const SDLK_WORLD_60		= 220
Const SDLK_WORLD_61		= 221
Const SDLK_WORLD_62		= 222
Const SDLK_WORLD_63		= 223
Const SDLK_WORLD_64		= 224
Const SDLK_WORLD_65		= 225
Const SDLK_WORLD_66		= 226
Const SDLK_WORLD_67		= 227
Const SDLK_WORLD_68		= 228
Const SDLK_WORLD_69		= 229
Const SDLK_WORLD_70		= 230
Const SDLK_WORLD_71		= 231
Const SDLK_WORLD_72		= 232
Const SDLK_WORLD_73		= 233
Const SDLK_WORLD_74		= 234
Const SDLK_WORLD_75		= 235
Const SDLK_WORLD_76		= 236
Const SDLK_WORLD_77		= 237
Const SDLK_WORLD_78		= 238
Const SDLK_WORLD_79		= 239
Const SDLK_WORLD_80		= 240
Const SDLK_WORLD_81		= 241
Const SDLK_WORLD_82		= 242
Const SDLK_WORLD_83		= 243
Const SDLK_WORLD_84		= 244
Const SDLK_WORLD_85		= 245
Const SDLK_WORLD_86		= 246
Const SDLK_WORLD_87		= 247
Const SDLK_WORLD_88		= 248
Const SDLK_WORLD_89		= 249
Const SDLK_WORLD_90		= 250
Const SDLK_WORLD_91		= 251
Const SDLK_WORLD_92		= 252
Const SDLK_WORLD_93		= 253
Const SDLK_WORLD_94		= 254
Const SDLK_WORLD_95		= 255		' $FF 
	' Numeric keypad 
Const SDLK_KP0		= 256
Const SDLK_KP1		= 257
Const SDLK_KP2		= 258
Const SDLK_KP3		= 259
Const SDLK_KP4		= 260
Const SDLK_KP5		= 261
Const SDLK_KP6		= 262
Const SDLK_KP7		= 263
Const SDLK_KP8		= 264
Const SDLK_KP9		= 265
Const SDLK_KP_PERIOD		= 266
Const SDLK_KP_DIVIDE		= 267
Const SDLK_KP_MULTIPLY	= 268
Const SDLK_KP_MINUS		= 269
Const SDLK_KP_PLUS		= 270
Const SDLK_KP_ENTER		= 271
Const SDLK_KP_EQUALS		= 272
	' Arrows + Home/End pad 
Const SDLK_UP			= 273
Const SDLK_DOWN		= 274
Const SDLK_RIGHT		= 275
Const SDLK_LEFT		= 276
Const SDLK_INSERT		= 277
Const SDLK_HOME		= 278
Const SDLK_END		= 279
Const SDLK_PAGEUP		= 280
Const SDLK_PAGEDOWN		= 281
	' Function keys 
Const SDLK_F1			= 282
Const SDLK_F2			= 283
Const SDLK_F3			= 284
Const SDLK_F4			= 285
Const SDLK_F5			= 286
Const SDLK_F6			= 287
Const SDLK_F7			= 288
Const SDLK_F8			= 289
Const SDLK_F9			= 290
Const SDLK_F10		= 291
Const SDLK_F11		= 292
Const SDLK_F12		= 293
Const SDLK_F13		= 294
Const SDLK_F14		= 295
Const SDLK_F15		= 296
	' Key state modifier keys 
Const SDLK_NUMLOCK		= 300
Const SDLK_CAPSLOCK		= 301
Const SDLK_SCROLLOCK		= 302
Const SDLK_RSHIFT		= 303
Const SDLK_LSHIFT		= 304
Const SDLK_RCTRL		= 305
Const SDLK_LCTRL		= 306
Const SDLK_RALT		= 307
Const SDLK_LALT		= 308
Const SDLK_RMETA		= 309
Const SDLK_LMETA		= 310
Const SDLK_LSUPER		= 311		' Left "Windows" key 
Const SDLK_RSUPER		= 312		' Right "Windows" key 
Const SDLK_MODE		= 313		' "Alt Gr" key 
Const SDLK_COMPOSE		= 314		' Multi-key compose key 
	' Miscellaneous function keys 
Const SDLK_HELP		= 315
Const SDLK_PRINT		= 316
Const SDLK_SYSREQ		= 317
Const SDLK_BREAK		= 318
Const SDLK_MENU		= 319
Const SDLK_POWER		= 320		' Power Macintosh power key 
Const SDLK_EURO		= 321		' Some european keyboards 
Const SDLK_UNDO		= 322		' Atari keyboard has Undo 
Const SDLK_LAST		= 323
Const KMOD_NONE  = $0000
Const KMOD_LSHIFT= $0001
Const KMOD_RSHIFT= $0002
Const KMOD_LCTRL = $0040
Const KMOD_RCTRL = $0080
Const KMOD_LALT  = $0100
Const KMOD_RALT  = $0200
Const KMOD_LMETA = $0400
Const KMOD_RMETA = $0800
Const KMOD_NUM   = $1000
Const KMOD_CAPS  = $2000
Const KMOD_MODE  = $4000
Const KMOD_RESERVED = $8000
Const KMOD_CTRL = KMOD_LCTRL|KMOD_RCTRL
Const KMOD_SHIFT = KMOD_LSHIFT|KMOD_RSHIFT
Const KMOD_ALT = KMOD_LALT|KMOD_RALT
Const KMOD_META = KMOD_LMETA|KMOD_RMETA
Const SDL_BUTTON_LEFT = 1
Const SDL_BUTTON_MIDDLE = 2
Const SDL_BUTTON_RIGHT = 3
Const SDL_BUTTON_WHEELUP = 4
Const SDL_BUTTON_WHEELDOWN = 5

Extern "C"
	Function SDL_Init(flags:Int)
	Function SDL_InitSubSystem(flags:Int)
	Function SDL_QuitSubSystem(flags:Int)
	Function SDL_Quit()
	Function SDL_WasInit:Int(flags:Int)
	Function SDL_GetError:Byte Ptr()
	
	Function SDL_GetVideoSurface:Byte Ptr()
End Extern

Type SDL_Surface
	Field flags:Int
	Field format:Byte Ptr
	Field w:Int,h:Int
	Field pitch@@
	Field pixels:Byte Ptr
	Field clip_rect:Byte Ptr
	Field refCount:Int
End Type

Type SDL_Rect
	Field x@@,y@@
	Field w@@,h@@
End Type

Type SDL_Color
	Field r@,g@,b@,unused@
End Type

Type SDL_Palette
	Field ncolors:Int
	Field colors:Byte Ptr
End Type

Type SDL_PixelFormat
	Field palette:Byte Ptr
	Field BitsPerPixel@
	Field BytesPerPixel@
	Field Rmask:Int,Gmask:Int,Bmask:Int,Amask:Int
	Field Rshift@,Gshift@,Bshift@,Ashift@
	Field Rloss@,Gloss@,Bloss@,Aloss@
	Field colorkey:Int
	Field alpha@
End Type

Type SDL_VideoInfo
	Field hw_available
	Field wm_available
	Field blit_hw
	Field blit_hw_CC
	Field blit_hw_A
	Field blit_sw
	Field blit_sw_CC
	Field blit_sw_A
	Field blit_fill
	Field video_mem
	Field vfmt:Byte Ptr
End Type

Type SDL_Overlay
	Field format
	Field w,h
	Field planes
	Field pitches:Short Ptr
	Field pixels:Byte Ptr
	Field hw_overlay
End Type

Type SDL_AudioSpec
	Field freq:Int
	Field format:Short
	Field channels:Byte
	Field Silence:Byte
	Field Samples:Short
	Field Padding:Short
	Field Size:Int
	Field callback(userdata:Byte Ptr, stream:Byte Ptr, length:Int)
	Field userdata:Byte Ptr
End Type

Type SDL_AudioCVT
	Field needed:Int
	Field src_format@@
	Field dst_format@@
	Field rate_incr!
	Field buf:Byte Ptr
	Field length:Int
	Field len_cvt:Int
	Field len_mult:Int
	Field len_ratio!
	Field filters(cvt:Byte Ptr, format@@)[10]
End Type

Type SDL_CDtrack
	Field id@,type@,unused@@,length,offset
End Type

Type SDL_CD
	Field id,status,numtracks,cur_track,cur_frame
	Field track:SDL_CDtrack[100]
End Type

Type SDL_ActiveEvent
	Field _type@,gain@,state@
End Type

Type SDL_KeyboardEvent
	Field _type@,which@,state@
	Field keysym:Byte Ptr
End Type

Type SDL_MouseMotionEvent
	Field _type@,which@,state@,x@@,y@@,xrel@@,yrel@@
End Type

Type SDL_MouseButtonEvent
	Field _type@,which@,button@,state@,x@@,y@@
End Type

Type SDL_JoyAxisEvent
	Field _type@,which@,axis@,x@@,y@@
End Type

Type SDL_JoyBallEvent
	Field _type@,which@,ball@,x@@,y@@
End Type

Type  SDL_JoyHatEvent
	Field _type@,which@,hat@,value@
End Type

Type SDL_JoyButtonEvent
	Field _type@,which@,button@,state@
End Type

Type SDL_ResizeEvent
	Field _type@,w,h
End Type

Type SDL_ExposeEvent
	Field _type@
End Type

Type SDL_QuitEvent
	Field _type@
End Type

Type SDL_UserEvent
	Field _type@
	Field code
	Field data1:Byte Ptr
	Field data2:Byte Ptr
End Type

Type SDL_Event
	Field _type@
	Field active:SDL_ActiveEvent
	Field key:SDL_KeyboardEvent
	Field motion:SDL_MouseMotionEvent
	Field button:SDL_MouseButtonEvent
	Field jaxin:SDL_JoyAxisEvent
	Field jball:SDL_JoyBallEvent
	Field jhat:SDL_JoyHatEvent
	Field jbutton:SDL_JoyButtonEvent
	Field resize:SDL_ResizeEvent
	Field expose:SDL_ExposeEvent
	Field quit:SDL_QuitEvent
	Field user:SDL_UserEvent
	Field syswm:Byte Ptr
End Type

Type SDL_Cursor
	Field area:Byte Ptr,hot_x@@,hot_y@@,data:Byte Ptr,mask:Byte Ptr,save:Byte Ptr[2],wm_cursor:Byte Ptr
End Type

Type WMcursor Abstract
End Type


And here's some alternative code - linking to a DLL but I don't know where to go from here as there isn't much documentation on this (thanks to Sarge on IRC):
global lib = LoadLibraryA("SDL.dll")
Extern...
End Extern...


The goal is to do all the software rendering externs and calls so we can with ease, fall back to SDL software rendering (bmax provides the hardware rendering).

To this end we might need SDL's mouse handling if it has it, and the rect class as it's animated surfaces require that.

I look forwards to your replies and any help you can give towards this open source blitzmax project. I will share everything I learn from it with you all, so all may benefit. Lets grow blitzmax beyond by working as a team!

Your contributions are valued and greatly appreciated.

Software fallback is a great idea.

I wonder, though, if it would be easier to just go DirectDraw under DirectX7?

I wonder, though, if it would be easier to just go DirectDraw under DirectX7?


It wouldn't.

This is the SDL_cpuinfo file, i will do some more later.
Extern "win32"

	'SDL_cpuinfo
	Function SDL_HasMMX() = "SDL_HasMMX"
	Function SDL_HasRDTSC() = "SDL_HasRDTSC"
	Function SDL_HasMMXExt() = "SDL_HasMMXExt"
	Function SDL_Has3DNow() = "SDL_Has3DNow"
	Function SDL_Has3DNowExt() = "SDL_Has3DNowExt"
	Function SDL_HasSSE() = "SDL_HasSSE"
	Function SDL_HasSSE2() = "SDL_HasSSE2"
	Function SDL_HasAltiVec() = "SDL_HasAltiVec"

End Extern


This would be great, not sure If I have the skills to help but I'll give you 100% support.

New update from James L Boyd!
To easily call DLL's from Blitzmax under windows we can go...
' Load relevant DLLs...

 user32 = LoadLibraryA ("user32.dll")

' Check they loaded...

 If user32 = 0 Then Print "Failed to open user32.dll"; End

' Create Blitz function prototypes (to match Win32 API parameters)...

 Global Info (window, message$z, title$z, flags) "win32"

' Point Blitz functions to DLL functions...

 Info = GetProcAddress (user32, "MessageBoxA")

' Call user32's MessageBox...

 Info 0, "Hello world!", "Amazing...", 0


BIG thanks to James for pointing this out. All we need to do now is take a really close look at the SDL functions and maybe find out if any need callbacks.

For Linux and Mac, there's also precompiled files for SDL, but we don't yet know how they will talk to Blitzmax.

Things for us to find out:
* list of SDL calls and parameters for DLL calling
* how callbacks work with DLLs
* how precompiled SDL works with Mac (.pax?) and Linux (see files above)

Keep it coming, folks!

Remember on mirc,
Global Libary=LoadLibraryA( "SDL.dll" )
Global SDL_HasMMX()"win32"=getprocaddress(Libary,"SDL_HasMMX")

Print SDL_HasMMX() 


Looks like my b spawn of a module is going somewhere.

Please edit for swearing. Thanks so far for everyone's contribution - keep it coming, and only post if you have something constructive to say :)

Hi
The code on your first post dont work, Fish. Many Duplicate Identifiers.
I think it´s better to go step by step and i have created one sample.

- You need the "Win32 Development Libraries" (SDL-devel-1.2.8-mingw32.tar.gz (Mingw32))
from http://www.libsdl.org/download-1.2.php .

-Put the "libSDL.dll.a" file in your BlitzMax Lib dir.

Now you can run my code.


Strict 


'*********************** SDL LIB **************************************

Import "-lSDL"


Const SDL_INIT_TIMER              = $00000001
Const SDL_INIT_AUDIO              = $00000010
Const SDL_INIT_VIDEO              = $00000020
Const SDL_INIT_CDROM              = $00000100
Const SDL_INIT_JOYSTICK           = $00000200
Const SDL_INIT_NOPARACHUTE        = $00100000    
Const SDL_INIT_EVENTTHREAD        = $01000000    
Const SDL_INIT_EVERYTHING         = $0000FFFF



Const SDL_END                     = 12

Const SDL_ALPHA_OPAQUE            = 255
Const SDL_ALPHA_TRANSPARENT       = 0
Const SDL_SWSURFACE               = $00000000
Const SDL_HWSURFACE               = $00000001
Const SDL_ASYNCBLIT               = $00000004
Const SDL_ANYFORMAT               = $10000000
Const SDL_HWPALETTE               = $20000000
Const SDL_DOUBLEBUF               = $40000000
Const SDL_FULLSCREEN              = $80000000
Const SDL_OPENGL                  = $00000002
Const SDL_OPENGLBLIT              = $0000000A
Const SDL_RESIZABLE               = $00000010
Const SDL_NOFRAME                 = $00000020
Const SDL_HWACCEL                 = $00000100
Const SDL_SRCCOLORKEY             = $00001000
Const SDL_RLEACCELOK              = $00002000
Const SDL_RLEACCEL                = $00004000
Const SDL_SRCALPHA                = $00010000
Const SDL_PREALLOC                = $01000000
Const SDL_YV12_OVERLAY            = $32315659
Const SDL_IYUV_OVERLAY            = $56555949
Const SDL_YUY2_OVERLAY            = $32595559
Const SDL_UYVY_OVERLAY            = $59565955
Const SDL_YVYU_OVERLAY            = $55595659
Const SDL_LOGPAL                  = $01
Const SDL_PHYSPAL                 = $02



Type SDL_Surface
	Field flags:Int
	Field format:Byte Ptr
	Field w:Int,h:Int
	Field pitch@@
	Field pixels:Byte Ptr
	Field clip_rect:Byte Ptr
	Field refCount:Int
End Type

Type SDL_Rect
	Field x@@,y@@
	Field w@@,h@@
End Type

Type SDL_Color
	Field r@,g@,b@,unused@
End Type

Type SDL_Palette
	Field ncolors:Int
	Field colors:Byte Ptr
End Type

Type SDL_PixelFormat
	Field palette:Byte Ptr
	Field BitsPerPixel@
	Field BytesPerPixel@
	Field Rmask:Int,Gmask:Int,Bmask:Int,Amask:Int
	Field Rshift@,Gshift@,Bshift@,Ashift@
	Field Rloss@,Gloss@,Bloss@,Aloss@
	Field colorkey:Int
	Field alpha@
End Type

Type SDL_VideoInfo
	Field hw_available
	Field wm_available
	Field blit_hw
	Field blit_hw_CC
	Field blit_hw_A
	Field blit_sw
	Field blit_sw_CC
	Field blit_sw_A
	Field blit_fill
	Field video_mem
	Field vfmt:Byte Ptr
End Type

Type SDL_Overlay
	Field format
	Field w,h
	Field planes
	Field pitches:Short Ptr
	Field pixels:Byte Ptr
	Field hw_overlay
End Type

Type SDL_AudioSpec
	Field freq:Int
	Field format:Short
	Field channels:Byte
	Field Silence:Byte
	Field Samples:Short
	Field Padding:Short
	Field Size:Int
	Field callback(userdata:Byte Ptr, stream:Byte Ptr, length:Int)
	Field userdata:Byte Ptr
End Type

Type SDL_AudioCVT
	Field needed:Int
	Field src_format@@
	Field dst_format@@
	Field rate_incr!
	Field buf:Byte Ptr
	Field length:Int
	Field len_cvt:Int
	Field len_mult:Int
	Field len_ratio!
	Field filters(cvt:Byte Ptr, format@@)[10]
End Type

Type SDL_CDtrack
	Field id@,Type_@,unused@@,length,offset
End Type

Type SDL_CD
	Field id,status,numtracks,cur_track,cur_frame
	Field track:SDL_CDtrack[100]
End Type

Type SDL_ActiveEvent
	Field _type@,gain@,state@
End Type

Type SDL_KeyboardEvent
	Field _type@,which@,state@
	Field keysym:Byte Ptr
End Type

Type SDL_MouseMotionEvent
	Field _type@,which@,state@,x@@,y@@,xrel@@,yrel@@
End Type

Type SDL_MouseButtonEvent
	Field _type@,which@,button@,state@,x@@,y@@
End Type

Type SDL_JoyAxisEvent
	Field _type@,which@,axis@,x@@,y@@
End Type

Type SDL_JoyBallEvent
	Field _type@,which@,ball@,x@@,y@@
End Type

Type  SDL_JoyHatEvent
	Field _type@,which@,hat@,value@
End Type

Type SDL_JoyButtonEvent
	Field _type@,which@,button@,state@
End Type

Type SDL_ResizeEvent
	Field _type@,w,h
End Type

Type SDL_ExposeEvent
	Field _type@
End Type

Type SDL_QuitEvent
	Field _type@
End Type

Type SDL_UserEvent
	Field _type@
	Field code
	Field data1:Byte Ptr
	Field data2:Byte Ptr
End Type

Type SDL_Event
	Field _type@
	Field active:SDL_ActiveEvent
	Field key:SDL_KeyboardEvent
	Field motion:SDL_MouseMotionEvent
	Field button:SDL_MouseButtonEvent
	Field jaxin:SDL_JoyAxisEvent
	Field jball:SDL_JoyBallEvent
	Field jhat:SDL_JoyHatEvent
	Field jbutton:SDL_JoyButtonEvent
	Field resize:SDL_ResizeEvent
	Field expose:SDL_ExposeEvent
	Field quit:SDL_QuitEvent
	Field user:SDL_UserEvent
	Field syswm:Byte Ptr
End Type

Type SDL_Cursor
	Field area:Byte Ptr,hot_x@@,hot_y@@,data:Byte Ptr,mask:Byte Ptr,save:Byte Ptr[2],wm_cursor:Byte Ptr
End Type

Type WMcursor Abstract
End Type




Function SDLSurfaceCast:SDL_Surface(Data:Byte Ptr)
	Local Surface:SDL_Surface = New SDL_Surface
	MemCopy Surface,Data,SizeOf(Surface)
	Return Surface
End Function 


Function SDLPixelFormatCast:SDL_PixelFormat(Data:Byte Ptr)
	Local PixelFormat:SDL_PixelFormat = New SDL_PixelFormat
	MemCopy PixelFormat,Data,SizeOf(PixelFormat)
	Return PixelFormat
End Function 



Extern "C"
	Function SDL_Init(flags:Int)
	Function SDL_InitSubSystem(flags:Int)
	Function SDL_QuitSubSystem(flags:Int)
	Function SDL_Quit()
	Function SDL_WasInit:Int(flags:Int)
	Function SDL_GetError:Byte Ptr()
	
	Function SDL_GetVideoSurface:Byte Ptr()
	Function SDL_GetVideoInfo:Byte Ptr()
	Function SDL_VideoDriverName:Byte Ptr(namebuf:Byte Ptr, maxlen)
	Function SDL_VideoModeOK(Width:Int, Height:Int, bpp:Int, flags:Int)
	Function SDL_SetVideoMode:Byte Ptr(Width:Int, Height:Int, Depth:Int, Flags:Int)
End Extern



'****************************************************************************







'*******************  SAMPLE ***********************************************





If SDL_Init(SDL_INIT_VIDEO) = -1
	Notify("Couldn't initialize SDL: "+string.FromBytes(SDL_GetError(), 1024))
	End
EndIf



OnEnd(SDL_Quit)




Local DriverNameBuf:Byte Ptr = New Byte[1024]
Local DriverName:String = ""

SDL_VideoDriverName(DriverNameBuf, 1024)
DriverName = Trim(String.FromBytes(DriverNameBuf, 1024))



Print "Videodriver name: "+DriverName



Local ScreenFlags:Int = SDL_HWSURFACE|SDL_DOUBLEBUF
Local ScreenSurface:SDL_Surface = SDLSurfaceCast(SDL_SetVideoMode(800,600,32,ScreenFlags))


Print "Screen Width: "+ScreenSurface.w
Print "Screen Height: "+ScreenSurface.h



Local Format:SDL_PixelFormat = SDLPixelFormatCast(ScreenSurface.Format)



Print "BitPerPixel: "+Format.BitsPerPixel




Repeat




Until KeyHit(KEY_ESCAPE)


End


It´s a bit hard to work without CStructs.
First, small sample. Hope i can help
Mfg Suco

Many, many thanks Suco-X! this is amazingly well done! I must commend you on the excellent and thoughtful contribution, thank you :)

I will examine your code - you are actually using the .a file so this is very interesting! It looks like we can expand this example to cover the entire command set for SDL windows. Do you think this will work cross platform?

Once again, thank you for the wonderful contribution.

No Problem, Fish.
Ok, next Version. This sample show you how you can load Surface from Pixmaps and i have some more functions added.
The Image:
Rename to "asteroid1.png"

Sample:

Strict 


'*********************** SDL LIB **************************************

Import "-lSDL"


Const SDL_INIT_TIMER              = $00000001
Const SDL_INIT_AUDIO              = $00000010
Const SDL_INIT_VIDEO              = $00000020
Const SDL_INIT_CDROM              = $00000100
Const SDL_INIT_JOYSTICK           = $00000200
Const SDL_INIT_NOPARACHUTE        = $00100000    
Const SDL_INIT_EVENTTHREAD        = $01000000    
Const SDL_INIT_EVERYTHING         = $0000FFFF



Const SDL_END                     = 12

Const SDL_ALPHA_OPAQUE            = 255
Const SDL_ALPHA_TRANSPARENT       = 0
Const SDL_SWSURFACE               = $00000000
Const SDL_HWSURFACE               = $00000001
Const SDL_ASYNCBLIT               = $00000004
Const SDL_ANYFORMAT               = $10000000
Const SDL_HWPALETTE               = $20000000
Const SDL_DOUBLEBUF               = $40000000
Const SDL_FULLSCREEN              = $80000000
Const SDL_OPENGL                  = $00000002
Const SDL_OPENGLBLIT              = $0000000A
Const SDL_RESIZABLE               = $00000010
Const SDL_NOFRAME                 = $00000020
Const SDL_HWACCEL                 = $00000100
Const SDL_SRCCOLORKEY             = $00001000
Const SDL_RLEACCELOK              = $00002000
Const SDL_RLEACCEL                = $00004000
Const SDL_SRCALPHA                = $00010000
Const SDL_PREALLOC                = $01000000
Const SDL_YV12_OVERLAY            = $32315659
Const SDL_IYUV_OVERLAY            = $56555949
Const SDL_YUY2_OVERLAY            = $32595559
Const SDL_UYVY_OVERLAY            = $59565955
Const SDL_YVYU_OVERLAY            = $55595659
Const SDL_LOGPAL                  = $01
Const SDL_PHYSPAL                 = $02



Type SDL_Surface
	Field flags:Int
	Field format:Byte Ptr
	Field w:Int,h:Int
	Field pitch@@
	Field pixels:Byte Ptr
	Field clip_rect:Byte Ptr
	Field refCount:Int
End Type

Type SDL_Rect
	Field x@@,y@@
	Field w@@,h@@
End Type

Type SDL_Color
	Field r@,g@,b@,unused@
End Type

Type SDL_Palette
	Field ncolors:Int
	Field colors:Byte Ptr
End Type

Type SDL_PixelFormat
	Field palette:Byte Ptr
	Field BitsPerPixel@
	Field BytesPerPixel@
	Field Rmask:Int,Gmask:Int,Bmask:Int,Amask:Int
	Field Rshift@,Gshift@,Bshift@,Ashift@
	Field Rloss@,Gloss@,Bloss@,Aloss@
	Field colorkey:Int
	Field alpha@
End Type

Type SDL_VideoInfo
	Field hw_available
	Field wm_available
	Field blit_hw
	Field blit_hw_CC
	Field blit_hw_A
	Field blit_sw
	Field blit_sw_CC
	Field blit_sw_A
	Field blit_fill
	Field video_mem
	Field vfmt:Byte Ptr
End Type

Type SDL_Overlay
	Field format
	Field w,h
	Field planes
	Field pitches:Short Ptr
	Field pixels:Byte Ptr
	Field hw_overlay
End Type

Type SDL_AudioSpec
	Field freq:Int
	Field format:Short
	Field channels:Byte
	Field Silence:Byte
	Field Samples:Short
	Field Padding:Short
	Field Size:Int
	Field callback(userdata:Byte Ptr, stream:Byte Ptr, length:Int)
	Field userdata:Byte Ptr
End Type

Type SDL_AudioCVT
	Field needed:Int
	Field src_format@@
	Field dst_format@@
	Field rate_incr!
	Field buf:Byte Ptr
	Field length:Int
	Field len_cvt:Int
	Field len_mult:Int
	Field len_ratio!
	Field filters(cvt:Byte Ptr, format@@)[10]
End Type

Type SDL_CDtrack
	Field id@,Type_@,unused@@,length,offset
End Type

Type SDL_CD
	Field id,status,numtracks,cur_track,cur_frame
	Field track:SDL_CDtrack[100]
End Type

Type SDL_ActiveEvent
	Field _type@,gain@,state@
End Type

Type SDL_KeyboardEvent
	Field _type@,which@,state@
	Field keysym:Byte Ptr
End Type

Type SDL_MouseMotionEvent
	Field _type@,which@,state@,x@@,y@@,xrel@@,yrel@@
End Type

Type SDL_MouseButtonEvent
	Field _type@,which@,button@,state@,x@@,y@@
End Type

Type SDL_JoyAxisEvent
	Field _type@,which@,axis@,x@@,y@@
End Type

Type SDL_JoyBallEvent
	Field _type@,which@,ball@,x@@,y@@
End Type

Type  SDL_JoyHatEvent
	Field _type@,which@,hat@,value@
End Type

Type SDL_JoyButtonEvent
	Field _type@,which@,button@,state@
End Type

Type SDL_ResizeEvent
	Field _type@,w,h
End Type

Type SDL_ExposeEvent
	Field _type@
End Type

Type SDL_QuitEvent
	Field _type@
End Type

Type SDL_UserEvent
	Field _type@
	Field code
	Field data1:Byte Ptr
	Field data2:Byte Ptr
End Type

Type SDL_Event
	Field _type@
	Field active:SDL_ActiveEvent
	Field key:SDL_KeyboardEvent
	Field motion:SDL_MouseMotionEvent
	Field button:SDL_MouseButtonEvent
	Field jaxin:SDL_JoyAxisEvent
	Field jball:SDL_JoyBallEvent
	Field jhat:SDL_JoyHatEvent
	Field jbutton:SDL_JoyButtonEvent
	Field resize:SDL_ResizeEvent
	Field expose:SDL_ExposeEvent
	Field quit:SDL_QuitEvent
	Field user:SDL_UserEvent
	Field syswm:Byte Ptr
End Type

Type SDL_Cursor
	Field area:Byte Ptr,hot_x@@,hot_y@@,data:Byte Ptr,mask:Byte Ptr,save:Byte Ptr[2],wm_cursor:Byte Ptr
End Type

Type WMcursor Abstract
End Type




Function SDLSurfaceCast:SDL_Surface(Data:Byte Ptr)
	Local Surface:SDL_Surface = New SDL_Surface
	MemCopy Surface,Data,SizeOf(Surface)
	Return Surface
End Function 


Function SDLPixelFormatCast:SDL_PixelFormat(Data:Byte Ptr)
	Local PixelFormat:SDL_PixelFormat = New SDL_PixelFormat
	MemCopy PixelFormat,Data,SizeOf(PixelFormat)
	Return PixelFormat
End Function 



Extern "C"
	Function SDL_Init(flags:Int)
	Function SDL_InitSubSystem(flags:Int)
	Function SDL_QuitSubSystem(flags:Int)
	Function SDL_Quit()
	Function SDL_WasInit:Int(flags:Int)
	Function SDL_GetError:Byte Ptr()
	
	Function SDL_GetVideoSurface:Byte Ptr()
	Function SDL_GetVideoInfo:Byte Ptr()
	Function SDL_VideoDriverName:Byte Ptr(namebuf:Byte Ptr, maxlen)
	Function SDL_VideoModeOK(Width:Int, Height:Int, bpp:Int, flags:Int)
	Function SDL_SetVideoMode:Byte Ptr(Width:Int, Height:Int, Depth:Int, Flags:Int)
	Function SDL_UpdateRect(Screen:Byte Ptr, X:Int, Y:Int, W:Int, H:Int)
	Function SDL_UpdateRects(screen:Byte Ptr, numrects:Int, rects:Byte Ptr)
	Function SDL_Flip(ScreenSurface:Byte Ptr)
	Function SDL_SetColors(surface:Byte Ptr, colors:Byte Ptr, firstcolor:Int, ncolors:Int)
	Function SDL_SetPalette(surface:Byte Ptr, flags:Int, colors:Byte Ptr, firstcolor:Int, ncolors:Int)
	Function SDL_SetGamma(redgamma:Float, greengamma:Float, bluegamma:Float)
	Function SDL_GetGammaRamp(redtable:Byte Ptr, greentable:Byte Ptr, bluetable:Byte Ptr)
	Function SDL_SetGammaRamp(redtable:Byte Ptr, greentable:Byte Ptr, bluetable:Byte Ptr)
	Function SDL_MapRGB(fmt:Byte Ptr, r:Byte, g:Byte, b:Byte)
	Function SDL_MapRGBA(fmt:Byte Ptr, r:Byte, g:Byte, b:Byte, a:Byte)
	Function SDL_GetRGB(pixel:Int, fmt:Byte Ptr, r:Byte Ptr, g:Byte Ptr, b:Byte Ptr)
	Function SDL_GetRGBA(pixel:Int, fmt:Byte Ptr, r:Byte Ptr, g:Byte Ptr, b:Byte Ptr, a:Byte Ptr)
	Function SDL_CreateRGBSurface:Byte Ptr(Flags:Int, Width:Int, Height:Int, Depth:Int, RMask:Int, GMask:Int, BMask:Int, AMask:Int)
	Function SDL_CreateRGBSurfaceFrom:Byte Ptr(pixels:Byte Ptr, Width:Int, Height:Int, depth:Int, pitch:Int, RMask:Int, GMask:Int, BMask:Int, AMask:Int)
	Function SDL_FreeSurface(Surface:Byte Ptr)
	Function SDL_LockSurface(Surface:Byte Ptr)
	Function SDL_UnlockSurface(Surface:Byte Ptr)
	'Function SDL_LoadBMP:byte ptr(file$z) 'We dont need this, we have Pixmaps and CreateRGBSurfaceFrom (Yeahaaa)
	'Function SDL_SaveBMP(surface:Byte Ptr, file$z) ' The Same, go away useles function
	Function SDL_SetColorKey(Surface:Byte Ptr, Flag:Int, key:Int)
	Function SDL_SetAlpha(Surface:Byte Ptr, flags:Int, alpha:Byte)
	Function SDL_SetClipRect(surface:Byte Ptr, rect:Byte Ptr)
	Function SDL_GetClipRect(surface:Byte Ptr, rect:Byte Ptr)
	Function SDL_ConvertSurface(src:Byte Ptr, fmt:Byte Ptr, flags:Int)
	'Function SDL_BlitSurface(src:Byte Ptr, srcrect:Byte Ptr, dst:Byte Ptr, dstrect:Byte Ptr) 
	Function SDL_UpperBlit(src:Byte Ptr, srcrect:Byte Ptr, dst:Byte Ptr, dstrect:Byte Ptr)
	Function SDL_LowerBlit(src:Byte Ptr, srcrect:Byte Ptr, dst:Byte Ptr, dstrect:Byte Ptr)
	Function SDL_FillRect(dst:Byte Ptr, dstrect:Byte Ptr, color:Int)
	Function SDL_DisplayFormat:Byte Ptr(Surface:Byte Ptr)
	Function SDL_DisplayFormatAlpha:Byte Ptr(Surface:Byte Ptr)

End Extern



'****************************************************************************







'*******************  SAMPLE ***********************************************





If SDL_Init(SDL_INIT_VIDEO) = -1
	Notify("Couldn't initialize SDL: "+string.FromBytes(SDL_GetError(), 1024))
	End
EndIf



OnEnd(SDL_Quit)




Local DriverNameBuf:Byte Ptr = New Byte[1024]
Local DriverName:String = ""

SDL_VideoDriverName(DriverNameBuf, 1024)
DriverName = Trim(String.FromBytes(DriverNameBuf, 1024))



Print "Videodriver name: "+DriverName



Local ScreenFlags:Int = SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN

Local ScreenSurface:Byte Ptr = SDL_SetVideoMode(800,600,32,ScreenFlags)

Local ScreenSurfaceInfo:SDL_Surface = SDLSurfaceCast(ScreenSurface)

Print "Screen Width: "+ScreenSurfaceInfo.w
Print "Screen Height: "+ScreenSurfaceInfo.h



Local Format:SDL_PixelFormat = SDLPixelFormatCast(ScreenSurfaceInfo.Format)



Print "BitPerPixel: "+Format.BitsPerPixel


Local asteroid1_img:Byte Ptr = SDLLoadIMage("asteroid1.png")



Local ImagePosition:SDL_Rect = New SDL_Rect 
ImagePosition.x = 10
ImagePosition.y = 200




Repeat

SDL_FillRect(ScreenSurface, Null, $AAAAAA)


ImagePosition.x:+2

If ImagePosition.x>ScreenSurfaceInfo.w
	'Position cant go negative ;(
	ImagePosition.x = 0
EndIf


SDL_UpperBlit(asteroid1_img, Null, ScreenSurface, ImagePosition)


SDL_Flip(ScreenSurface)

Until KeyHit(KEY_ESCAPE)



End







Function SDLLoadImage:Byte Ptr(Url:Object)
	
	Local TempPixmap:TPixmap
	Local FinalImage:Byte Ptr
	Local TempHandle:Byte Ptr
	Local Bits:Byte = 0
	
	
	If TPixmap(Url)
		TempPixmap = TPixmap(Url)
	ElseIf String(Url)
		TempPixmap = LoadPixmap(String(Url))
	EndIf

	
		
	Select TempPixmap.Format
			
		Case PF_RGB888
			TempPixmap = ConvertPixmap(TempPixmap,PF_BGR888)
			bits = 24

		Case PF_RGBA8888
			TempPixmap = ConvertPixmap(TempPixmap,PF_BGRA8888)
			bits = 32

		Default
			TempPixmap = ConvertPixmap(TempPixmap,PF_BGRA8888)
			bits = 32

	End Select 


	
	
	TempHandle= SDL_CreateRGBSurfaceFrom(TempPixmap.Pixels, TempPixmap.Width, TempPixmap.Height,..
											Bits, TempPixmap.Pitch, 0, 0, 0, 0)


	FinalImage = SDL_DisplayFormat(TempHandle)
	
	SDL_SetColorKey(FinalImage,SDL_SRCCOLORKEY|SDL_RLEACCEL, $00000000)
	
	SDL_FreeSurface(TempHandle)
	
	Return FinalImage
End Function 





This code is very alpha but it works without errors(I Hope ;) )

And yes, it works cross platform.
Mfg Suco

Hi
Next Update, all SDL functions and 2 helper functions.


'*********************** SDL LIB for Blitz Max**************************************

Import "-lSDL"


Const SDL_INIT_TIMER              = $00000001
Const SDL_INIT_AUDIO              = $00000010
Const SDL_INIT_VIDEO              = $00000020
Const SDL_INIT_CDROM              = $00000100
Const SDL_INIT_JOYSTICK           = $00000200
Const SDL_INIT_NOPARACHUTE        = $00100000    
Const SDL_INIT_EVENTTHREAD        = $01000000    
Const SDL_INIT_EVERYTHING         = $0000FFFF



Const SDL_END                     = 12

Const SDL_ALPHA_OPAQUE            = 255
Const SDL_ALPHA_TRANSPARENT       = 0
Const SDL_SWSURFACE               = $00000000
Const SDL_HWSURFACE               = $00000001
Const SDL_ASYNCBLIT               = $00000004
Const SDL_ANYFORMAT               = $10000000
Const SDL_HWPALETTE               = $20000000
Const SDL_DOUBLEBUF               = $40000000
Const SDL_FULLSCREEN              = $80000000
Const SDL_OPENGL                  = $00000002
Const SDL_OPENGLBLIT              = $0000000A
Const SDL_RESIZABLE               = $00000010
Const SDL_NOFRAME                 = $00000020
Const SDL_HWACCEL                 = $00000100
Const SDL_SRCCOLORKEY             = $00001000
Const SDL_RLEACCELOK              = $00002000
Const SDL_RLEACCEL                = $00004000
Const SDL_SRCALPHA                = $00010000
Const SDL_PREALLOC                = $01000000
Const SDL_YV12_OVERLAY            = $32315659
Const SDL_IYUV_OVERLAY            = $56555949
Const SDL_YUY2_OVERLAY            = $32595559
Const SDL_UYVY_OVERLAY            = $59565955
Const SDL_YVYU_OVERLAY            = $55595659
Const SDL_LOGPAL                  = $01
Const SDL_PHYSPAL                 = $02



Type SDL_Surface
	Field flags:Int
	Field format:Byte Ptr
	Field w:Int,h:Int
	Field pitch@@
	Field pixels:Byte Ptr
	Field clip_rect:Byte Ptr
	Field refCount:Int
End Type

Type SDL_Rect
	Field x@@,y@@
	Field w@@,h@@
End Type

Type SDL_Color
	Field r@,g@,b@,unused@
End Type

Type SDL_Palette
	Field ncolors:Int
	Field colors:Byte Ptr
End Type

Type SDL_PixelFormat
	Field palette:Byte Ptr
	Field BitsPerPixel@
	Field BytesPerPixel@
	Field Rmask:Int,Gmask:Int,Bmask:Int,Amask:Int
	Field Rshift@,Gshift@,Bshift@,Ashift@
	Field Rloss@,Gloss@,Bloss@,Aloss@
	Field colorkey:Int
	Field alpha@
End Type

Type SDL_VideoInfo
	Field hw_available
	Field wm_available
	Field blit_hw
	Field blit_hw_CC
	Field blit_hw_A
	Field blit_sw
	Field blit_sw_CC
	Field blit_sw_A
	Field blit_fill
	Field video_mem
	Field vfmt:Byte Ptr
End Type

Type SDL_Overlay
	Field format
	Field w,h
	Field planes
	Field pitches:Short Ptr
	Field pixels:Byte Ptr
	Field hw_overlay
End Type

Type SDL_AudioSpec
	Field freq:Int
	Field format:Short
	Field channels:Byte
	Field Silence:Byte
	Field Samples:Short
	Field Padding:Short
	Field Size:Int
	Field callback(userdata:Byte Ptr, stream:Byte Ptr, length:Int)
	Field userdata:Byte Ptr
End Type

Type SDL_AudioCVT
	Field needed:Int
	Field src_format@@
	Field dst_format@@
	Field rate_incr!
	Field buf:Byte Ptr
	Field length:Int
	Field len_cvt:Int
	Field len_mult:Int
	Field len_ratio!
	Field filters(cvt:Byte Ptr, format@@)[10]
End Type

Type SDL_CDtrack
	Field id@,Type_@,unused@@,length,offset
End Type

Type SDL_CD
	Field id,status,numtracks,cur_track,cur_frame
	Field track:SDL_CDtrack[100]
End Type

Type SDL_ActiveEvent
	Field _type@,gain@,state@
End Type

Type SDL_KeyboardEvent
	Field _type@,which@,state@
	Field keysym:Byte Ptr
End Type

Type SDL_MouseMotionEvent
	Field _type@,which@,state@,x@@,y@@,xrel@@,yrel@@
End Type

Type SDL_MouseButtonEvent
	Field _type@,which@,button@,state@,x@@,y@@
End Type

Type SDL_JoyAxisEvent
	Field _type@,which@,axis@,x@@,y@@
End Type

Type SDL_JoyBallEvent
	Field _type@,which@,ball@,x@@,y@@
End Type

Type  SDL_JoyHatEvent
	Field _type@,which@,hat@,value@
End Type

Type SDL_JoyButtonEvent
	Field _type@,which@,button@,state@
End Type

Type SDL_ResizeEvent
	Field _type@,w,h
End Type

Type SDL_ExposeEvent
	Field _type@
End Type

Type SDL_QuitEvent
	Field _type@
End Type

Type SDL_UserEvent
	Field _type@
	Field code
	Field data1:Byte Ptr
	Field data2:Byte Ptr
End Type

Type SDL_Event
	Field _type@
	Field active:SDL_ActiveEvent
	Field key:SDL_KeyboardEvent
	Field motion:SDL_MouseMotionEvent
	Field button:SDL_MouseButtonEvent
	Field jaxin:SDL_JoyAxisEvent
	Field jball:SDL_JoyBallEvent
	Field jhat:SDL_JoyHatEvent
	Field jbutton:SDL_JoyButtonEvent
	Field resize:SDL_ResizeEvent
	Field expose:SDL_ExposeEvent
	Field quit:SDL_QuitEvent
	Field user:SDL_UserEvent
	Field syswm:Byte Ptr
End Type

Type SDL_Cursor
	Field area:Byte Ptr,hot_x@@,hot_y@@,data:Byte Ptr,mask:Byte Ptr,save:Byte Ptr[2],wm_cursor:Byte Ptr
End Type

Type WMcursor Abstract
End Type








Extern "C"

	'General
	Function SDL_Init(flags:Int)
	Function SDL_InitSubSystem(flags:Int)
	Function SDL_QuitSubSystem(flags:Int)
	Function SDL_Quit()
	Function SDL_WasInit:Int(flags:Int)
	Function SDL_GetError:Byte Ptr()
	Function SDL_LoadObject:Byte Ptr(sofile:Byte Ptr)
	Function SDL_LoadFunction:Byte Ptr(handle:Byte Ptr, name:Byte Ptr)
	Function SDL_UnloadObject(handle:Byte Ptr)
	
	
	
	
	'Video
	Function SDL_GetVideoSurface:Byte Ptr()
	Function SDL_GetVideoInfo:Byte Ptr()
	Function SDL_VideoDriverName:Byte Ptr(namebuf:Byte Ptr, maxlen)
	Function SDL_VideoModeOK(Width:Int, Height:Int, bpp:Int, flags:Int)
	Function SDL_SetVideoMode:Byte Ptr(Width:Int, Height:Int, Depth:Int, Flags:Int)
	Function SDL_UpdateRect(Screen:Byte Ptr, X:Int, Y:Int, W:Int, H:Int)
	Function SDL_UpdateRects(screen:Byte Ptr, numrects:Int, rects:Byte Ptr)
	Function SDL_Flip(ScreenSurface:Byte Ptr)
	Function SDL_SetColors(surface:Byte Ptr, colors:Byte Ptr, firstcolor:Int, ncolors:Int)
	Function SDL_SetPalette(surface:Byte Ptr, flags:Int, colors:Byte Ptr, firstcolor:Int, ncolors:Int)
	Function SDL_SetGamma(redgamma:Float, greengamma:Float, bluegamma:Float)
	Function SDL_GetGammaRamp(redtable:Byte Ptr, greentable:Byte Ptr, bluetable:Byte Ptr)
	Function SDL_SetGammaRamp(redtable:Byte Ptr, greentable:Byte Ptr, bluetable:Byte Ptr)
	Function SDL_MapRGB(fmt:Byte Ptr, r:Byte, g:Byte, b:Byte)
	Function SDL_MapRGBA(fmt:Byte Ptr, r:Byte, g:Byte, b:Byte, a:Byte)
	Function SDL_GetRGB(pixel:Int, fmt:Byte Ptr, r:Byte Ptr, g:Byte Ptr, b:Byte Ptr)
	Function SDL_GetRGBA(pixel:Int, fmt:Byte Ptr, r:Byte Ptr, g:Byte Ptr, b:Byte Ptr, a:Byte Ptr)
	Function SDL_CreateRGBSurface:Byte Ptr(Flags:Int, Width:Int, Height:Int, Depth:Int, RMask:Int, GMask:Int, BMask:Int, AMask:Int)
	Function SDL_CreateRGBSurfaceFrom:Byte Ptr(pixels:Byte Ptr, Width:Int, Height:Int, depth:Int, pitch:Int, RMask:Int, GMask:Int, BMask:Int, AMask:Int)
	Function SDL_FreeSurface(Surface:Byte Ptr)
	Function SDL_LockSurface(Surface:Byte Ptr)
	Function SDL_UnlockSurface(Surface:Byte Ptr)
	'Function SDL_LoadBMP:byte ptr(file$z) 'We dont need this, we have Pixmaps and CreateRGBSurfaceFrom (Yeahaaa)
	'Function SDL_SaveBMP(surface:Byte Ptr, file$z) ' The Same, go away useles function
	Function SDL_SetColorKey(Surface:Byte Ptr, Flag:Int, key:Int)
	Function SDL_SetAlpha(Surface:Byte Ptr, flags:Int, alpha:Byte)
	Function SDL_SetClipRect(surface:Byte Ptr, rect:Byte Ptr)
	Function SDL_GetClipRect(surface:Byte Ptr, rect:Byte Ptr)
	Function SDL_ConvertSurface(src:Byte Ptr, fmt:Byte Ptr, flags:Int)
	'Function SDL_BlitSurface(src:Byte Ptr, srcrect:Byte Ptr, dst:Byte Ptr, dstrect:Byte Ptr) 
	Function SDL_UpperBlit(src:Byte Ptr, srcrect:Byte Ptr, dst:Byte Ptr, dstrect:Byte Ptr)
	Function SDL_LowerBlit(src:Byte Ptr, srcrect:Byte Ptr, dst:Byte Ptr, dstrect:Byte Ptr)
	Function SDL_FillRect(dst:Byte Ptr, dstrect:Byte Ptr, color:Int)
	Function SDL_DisplayFormat:Byte Ptr(Surface:Byte Ptr)
	Function SDL_DisplayFormatAlpha:Byte Ptr(Surface:Byte Ptr)
	Function SDL_WarpMouse(x:Int, y:Int)
	Function SDL_CreateCursor:Byte Ptr(data:Byte Ptr, mask:Byte Ptr, w:Int, h:Int, hot_x:Int, hot_y:Int)
	Function SDL_FreeCursor(cursor:Byte Ptr)
	Function SDL_SetCursor(cursor:Byte Ptr)
	Function SDL_GetCursor:Byte Ptr()
	Function SDL_ShowCursor(toggle:Int)
	Function SDL_GL_LoadLibrary(path:Byte Ptr)
	Function SDL_GL_GetProcAddress:Byte Ptr(proc:Byte Ptr)
	Function SDL_GL_GetAttribute(attr, value:Byte Ptr)
	Function SDL_GL_SetAttribute(attr, value:Int)
	Function SDL_GL_SwapBuffers()
	Function SDL_CreateYUVOverlay:Byte Ptr(width:Int, height:Int, format:Int, display:Byte Ptr)
	Function SDL_LockYUVOverlay(overlay:Byte Ptr)
	Function SDL_UnlockYUVOverlay(overlay:Byte Ptr)
	Function SDL_DisplayYUVOverlay(overlay:Byte Ptr, dstrect:Byte Ptr)
	Function SDL_FreeYUVOverlay(overlay:Byte Ptr)
	
	
	
	'Window Management	
	Function SDL_GetWMInfo(info:Byte Ptr)
	Function SDL_WM_SetCaption(title:Byte Ptr, icon:Byte Ptr)
	Function SDL_WM_GetCaption(title:Byte Ptr, icon:Byte Ptr)
	Function SDL_WM_SetIcon(icon:Byte Ptr, mask:Byte Ptr)
	Function SDL_WM_IconifyWindow()
	Function SDL_WM_ToggleFullscreen(surface:Byte Ptr)
	Function SDL_WM_GrabInput(mode)
	
	
	
	'Events
	Function SDL_PumpEvents()
	Function SDL_PeepEvents(events:Byte Ptr, numevents:Int, action:Int, mask:Int)
	Function SDL_PollEvent(event:Byte Ptr)
	Function SDL_WaitEvent(event:Byte Ptr)
	Function SDL_PushEvent(event:Byte Ptr)
	Function SDL_SetEventFilter(filter:Int)
	Function SDL_EventState(type_:Int, state:Int)
	Function SDL_GetKeyState:Byte Ptr(numkeys:Byte Ptr)
	Function SDL_GetModState()
	Function SDL_SetModState(modstate:Int)
	Function SDL_GetKeyName:Byte Ptr(key:Int)
	Function SDL_EnableUNICODE(enable:Int)
	Function SDL_EnableKeyRepeat(Delay_:Int, interval:Int)
	Function SDL_GetMouseState(x:Byte Ptr, y:Byte Ptr)
	Function SDL_GetRelativeMouseState(x:Byte Ptr, y:Byte Ptr)
	Function SDL_GetAppState()
	Function SDL_JoystickEventState(state:Int)
	
	
	'Joystick
	Function SDL_NumJoysticks()
	Function SDL_JoystickName:Byte Ptr(index:Int)
	Function SDL_JoystickOpen:Byte Ptr(index:Int)
	Function SDL_JoystickOpened(index:Int)
	Function SDL_JoystickIndex(joystick:Byte Ptr)
	Function SDL_JoystickNumAxes(joystick:Byte Ptr)
	Function SDL_JoystickNumBalls(joystick:Byte Ptr)
	Function SDL_JoystickNumHats(joystick:Byte Ptr)
	Function SDL_JoystickNumButtons(joystick:Byte Ptr)	
	Function SDL_JoystickUpdate()
	Function SDL_JoystickGetAxis(joystick:Byte Ptr, axis:Int)
	Function SDL_JoystickGetHat(joystick:Byte Ptr, hat:Int)
	Function SDL_JoystickGetButton(joystick:Byte Ptr, button:Int)
	Function SDL_JoystickGetBall(joystick:Byte Ptr, ball:Int, dx:Byte Ptr, dy:Byte Ptr)
	Function SDL_JoystickClose(joystick:Byte Ptr)
	
	
	
	'Audio
	Rem 
		BlitzMax has own Audio/Sound Modules
	End Rem 
	
	
	
	
	'CD-ROM
	Rem
		Anybody need this??? ;)
	End Rem 
	
	
	
	'Multi-threaded Programming
	Rem 
		I dont understand the most function flags
	End Rem 
	
	
	'Time
	Rem 
		BlitzMax has time functions
	End Rem  
	
	
	
	'Files
	Rem
		Useless for us
	End Rem 
	
	
	
	
End Extern



'****************************************************************************




'************ Helper Functions*****************************
Function SDLSurfaceCast:SDL_Surface(Data:Byte Ptr)
	Local Surface:SDL_Surface = New SDL_Surface
	MemCopy Surface,Data,SizeOf(Surface)
	Return Surface
End Function 


Function SDLPixelFormatCast:SDL_PixelFormat(Data:Byte Ptr)
	Local PixelFormat:SDL_PixelFormat = New SDL_PixelFormat
	MemCopy PixelFormat,Data,SizeOf(PixelFormat)
	Return PixelFormat
End Function 

'********************************************************


I'm at work at the moment but when I return, I will immediately dive in and try this wonderful module out :)

Good man! I can't believe you've done this in full. You have my utmost gratitude on behalf of the entire Blitzmax community! Thank you :)

You have single-handedly solved all the SDL problems for mac, win and linux - now anyone can make blitzmax games with 100% reliability regardless of target hardware...

Thats the gift you've given us :)

Finally, I move to ask BRL if they will make SDL module an official part of the Blitzmax modules.

Finally, I move to ask BRL if they will make SDL module an official part of the Blitzmax modules.

I second this request.

Good work to everyone who worked on this btw :)

Hi
I have created a small Gametest with SDL. Please test with Win/Mac/Linux.

http://www.sucox.art-fx.org/BlitzPastingv2/uploads/useruploads/rSsjR131877_7005760.zip

(code+exe)
Mfg Suco

Making it an official part has some probs ... for example they can not include the library itself ... and a module that does not work after downloaded until you download other things isn't that good.

Suco: works with XP SP2 no prob with any part :-)

Suco-X - try and use <codebox> instead of <code>. I've edited your posts to use codebox instead.

Sucro-X
I downloaded the demo and it did not work at first, but I added the SDL.DLL and then it worked PERFECTLY! very smooth - great test!

I imagine that for Mac and linux we need to include the relevent runtimes for each os?

fish: Yepp but official modules for BM are for syncmod. But for SDL you need the sdl.dll or whatever which are
1. not plattform indipendent
2. can not be included due to their license

This makes them useless as official BM mod.

And no you don't need to include. you need to link to the sdl page as you are not allowed to include it without special permission

windowed mode fails to draw anything or even seem to flip

Cyanide, how do you invoke windowed mode? Can you post code?

Its great work so I don't want to spoil it to anyone.
I just want to prevent a "please make it official" hype which would cost many nerves at BRL just for nothing because some people don't read licenses of stuff they use.

TLibSDL.Graphics(800,600,32,false) (last flag, true for fullscreen)

edit: thou sdl does the same for me in c++ with windowed mode, so probally my intel pos

Barely informed rambling -- feel free to correct!

If you Google around to try and clarify the SDL/LGPL requirements, you'll find there's a lot of confusion (eg. http://www.gamedev.net/community/forums/topic.asp?topic_id=301120&whichpage=1 ), but mostly the debates seem to eventually agree that you basically have to a) distribute the unchanged .dll and LGPL licence with your game, b) make clear reference to the LGPL and c) provide a link to download the SDL source code on your own site. (DISCLAIMER: not legal advice!)

Sami Lantingen is the author of SDL, and his thoughts are here:
http://www.devolution.com/pipermail/sdl/2000-August/029476.html

Only thing is, the current conversion by Suco-X (very nice work!) seems to link statically as far as I can tell, ie. it imports sdl.a (which I think may import other .a libs in turn?), though it still requires the DLL. Maybe I don't fully understand static vs dynamic linking yet, but I'd have thought that using static .a linking wouldn't require the DLL (?).

As far as I can tell, you'd have to be linking dynamically (ie. using only the DLL) to fit these conditions. Linking statically means you have to distribute the source or object code to your own programs, as the library is effectively embedded in your program, as opposed to being a separate .dll file. Linking dynamically would mean doing similar to what Sarge suggests for each function...

I'm gonna go with what the author says - include the runtime and a nice little text doc.

The rest can get stuffed because it's not strictly statically linking as the DLL is still required. We are also making no changes to the original source. So, for me, DLL and text doc :)

James,

When linking to DLL there are two ways to do this. Static Linking or Dynamic Linking.

Static Linking is done by creating an import lib from the DLL and linking to that. ie libXXX.a for mingw. The "XXX.dll" is still loaded at runtime but the linker resolving the references via libXXX.a

Dynamic Linking is of the form

Lib=LoadLibary("xxx.dll")
func=GetProcAddress(lib,"Foo")

Either way can be used for DLLs however personally although more work Dynamic is better since if the DLL is not on the machine you can programtically error out vs implict your program just crashes saying it cant find some dependent file. Another benfit to Dynamic Linking is if you dont have the libXXXX.a file you can still use the DLL as long as you know the name and paramters of the entry points.

Hope this helps understand DLLs and different forms of linking

Doug Stastny

Thanks Budman. I know the very basics, but the below is something I wondered about (just because I know that in some cases the .a being linked into the executable is all that's needed, and so assumed that was always the case):


Static Linking is done by creating an import lib from the DLL and linking to that. ie libXXX.a for mingw. The "XXX.dll" is still loaded at runtime but the linker resolving the references via libXXX.a



... so knowing this as well is very helpful, thanks.

This is totally awesome!

Indeed. I'm very proud of the community that helped made this happen, and continue to evolve it... it's not finished yet :)

now dont shoot me for asking but I thought SDL was slower then directx and opengl and that it was more or less just an opengl wrapper? am I wrong please explain

You are wrong. It has OGL, DX and Software rendering. Software rendering is why we like it.

so its a wrapper for DX and OGL?

No, the whole point is it doesn't need either (although it can make use of them if available).

Stay tuned folkes, doing a nice demo for Blitzmax which falls back from hardware to software.

Got a problem trying to detect if hardware is present.

Use the troubleshoot tab on your windows display preferences -> advanced window to disable 3D to test.

The problem I'm having is: blitzmax throws an unhandled exception on both DX and OpenGL when not present --- nasty!

How do we work around this? Ideally Graphics() should return true or false if it worked or not.

What's the situation with screen resolutions in SDL? Can I have really low ones like 320x200 that aren't supported by modern graphics cards, or will it still fail?

Update: we've fixed the problem with detecting if Graphics modes exist, see this thread.

SDL specific questions must be referred to http://www.libsdl.org/ as I can't answer that. But I will try - yeah most modern graphics cards do in actual fact, support really low resolutions like 320x200, however windows XP won't show much below 800x600. Some might not though.

You can always do it in a higher resolution like 640x480. I recommend you do... just draw half the size, then scale it up after. There's a version of SDL which does scaling, and you might be able to integrate it with the above code. Why not let us know how you get on?

Even better, just draw your sprites in 320x200, then pre-scale them up twice the size. It all depends if you want 320 for the "look" or if you're doing mental pixel stuff...

If I can find anything else to help you, I'll post it in this thread.

Is this now complete? ie. Can I use this with Blending modes and rotation/scaling of images?

The initial SDL doesn't support "rotozoom", you need to addon another SDL package for that. If you manage to do it, please contribute it here in respect for the good work done so far to set us off.

The link is: http://www.ferzkopp.net/~aschiffler/Software/SDL_gfx-2.0/

So if you manage it (Should be fairly simple based off the above code) please post how in this thread :)

tis only fair...

Has anyone made further work on this? I am slowly starting to get to the point in my project in which I'll start adding SDL fallback functionality. I'd hate to do unnecessary double work. :)

I think I need to (at least) add LoadAnimImage functionality and try to find a code based solution to making images with per-pixel alpha display OK with SDL. The first one should be no biggie and I hope the second can be solved simply by masking pixels that have "enough" alpha.

Has anyone looked yet into SDL_gfx 2.0?

LoadAnimImage functionality is in, but not the way you expect it to be. It uses some sort of rect mechanism to copy the desired frame from a larger image.

I would like to see it updated with LoadAnimImage too, but more importantly - has anyone got it working with the mac?

You're right - can we do alpha fading with an image with a normal mask?

What happened to this?

Well it all works but it got de-stickied for FMOD, which is why people miss it a lot. Not much mac support.

Does this SDL module allow me to write games for the GP2X (http://www.gp2x.co.uk) in BlitzMax?

Only if gp2x supports pc or mac hardware.

<bump>

So is this complete?

Russell

Seems to be.

As on http://www.blitzbasic.com/Community/posts.php?topic=57179

I'd like it to be seemlessly integrated as a Max2D module, i.e instead of using SDL dedicated functions to open a display and draw things on it,
it should be very cool to just issue a:

SetGfxDriver SDLMax2DDriver() and then use usual commands (Graphics, DrawLine, ...)

Has anyone began to work on this integration ?

Bump.

We need LoadAnimImage and RotoZoom, anyone? based off 1.2.9 SDL... this is new stuff :)

Current problems

How to draw offscreen, for example -1

How to draw from cells of images like LoadAnimImage

How to Rotate images

Why not have a go at it yourself then?

On some systems that don't have hardware-accelerated support, their OpenGL driver, for example, will do everything in software, anyway.

What you're proposing isn't a replacement for the system that is already in place, you are proposing a different graphics library of deliberately software-based rendering.

On my ibook for example there is no hardware acceleration, the OpenGL driver is entirely in software. Max2D works totally fine. There is no need for software fallback routines.

I don't know if dx is the same.

Now, proposing 256-color indexed graphics support would be another matter and that would be useful perhaps, for doing software rendering in. Otherwise I don't see why you need to create your own software fallback.

On my ibook for example there is no hardware acceleration, the OpenGL driver is entirely in software. Max2D works totally fine. There is no need for software fallback routines.

The mac is vastly superior at its OpenGL software emulation. I regret to say the pc isn't even close in this regard.

I have tried this on the PC, on three different machines. OpenGL in software corrupts really badly before ultimately crashing. It is also garbage in visuals. It also runs at an appalling framerate. This is to be expected, but not this badly...

@Chris C, I am trying, I am also asking for help on this. All findings are shared in this thread.

Everyone can and will stand to benefit.

Does anyone have the source for the asteroid demo ?


www.sucox.art-fx.org/BlitzPastingv2/uploads/useruploads/rSsjR131877_7005760.zip

404... :(

Ahh, I see, I didn't realize it was so bad on the PC. Then it certainly looks like y'all have good reason to seek a software fallback.

Managed to get something going :) Will post what I have if its any good.

Hi everybody, I just tried to create a SDL backend for Max2D, based on SDL 1.2.11 and SDL_gfx 3.0 (no dll for this last one, c files directly included).

I currently can display images scaled and rotated (thanks to SDL_gfx), also calling SetAlpha will have an effect on displayed image.

I still have a problem with rotation (as SDL_gfx always rotate according to the top left corner of the image, whereas Max2D can rotated according to whichever handle is set before) and alpha channel (which may produce garbage depending on images).

I also receive keyboard and window close events and forward them succesfully to blitzmax internal event handler.

If you want sources and try an example, go grab it at http://perso.wanadoo.fr/chrisgames/sdlmax.zip (windows only for the moment)

(press ESC or close window to stop example).

Is it worth creating a community project ?

Waiting for your comments ...