Permalink
Browse files

SaveBMP, mouse button definitions

  • Loading branch information...
1 parent aef3e69 commit afdaf21914f7acb5fce4991a6db6020325889729 @salviati salviati committed with Jan 19, 2011
Showing with 20 additions and 1 deletion.
  1. +7 −0 sdl/constants.go
  2. +13 −1 sdl/sdl.go
View
@@ -351,6 +351,13 @@ const (
DISABLE = 0
IGNORE = 0
QUERY = -1
+ BUTTON_LEFT = 1
+ BUTTON_MIDDLE = 2
+ BUTTON_RIGHT = 3
+ BUTTON_WHEELUP = 4
+ BUTTON_WHEELDOWN = 5
+ BUTTON_X1 = 6
+ BUTTON_X2 = 7
)
// Types
View
@@ -256,6 +256,11 @@ func MapRGB(format *PixelFormat, r, g, b uint8) uint32 {
return (uint32)(C.SDL_MapRGB((*C.SDL_PixelFormat)(cast(format)), (C.Uint8)(r), (C.Uint8)(g), (C.Uint8)(b)))
}
+// Gets RGB values from a pixel in the specified pixel format.
+func GetRGB(color uint32, format *PixelFormat, r, g, b *uint8) {
+ C.SDL_GetRGB(C.Uint32(color), (*C.SDL_PixelFormat)(cast(format)), (*C.Uint8)(r), (*C.Uint8)(g), (*C.Uint8)(b))
+}
+
// Map a RGBA color value to a pixel format.
func MapRGBA(format *PixelFormat, r, g, b, a uint8) uint32 {
return (uint32)(C.SDL_MapRGBA((*C.SDL_PixelFormat)(cast(format)), (C.Uint8)(r), (C.Uint8)(g), (C.Uint8)(b), (C.Uint8)(a)))
@@ -274,6 +279,13 @@ func Load(file string) *Surface {
return (*Surface)(cast(screen))
}
+func (src *Surface) SaveBMP(file string) int {
+ cfile := C.CString(file)
+ res := C.__SDL_SaveBMP( (*C.SDL_Surface)(cast(src)), cfile)
+ C.free(unsafe.Pointer(cfile))
+ return int(res)
+}
+
// Loads Surface from RWops (using IMG_Load_RW).
func Load_RW(rw *RWops, ac bool) *Surface {
acArg := C.int(0)
@@ -332,7 +344,7 @@ func CreateRGBSurface(flags uint32, width int, height int, bpp int, Rmask uint32
// Converts a surface to the display format
func DisplayFormat(src *Surface) *Surface {
- p := C.SDL_DisplayFormat((*C.SDL_Surface)(cast(src)))
+ p := C.SDL_DisplayFormat( (*C.SDL_Surface)(cast(src)) )
return (*Surface)(cast(p))
}

0 comments on commit afdaf21

Please sign in to comment.