Skip to content

Commit

Permalink
sdl: video: Make several functions return values instead of modifying…
Browse files Browse the repository at this point in the history
… user-provided values through pointers

Signed-off-by: Lilis Iskandar <lilis@veand.co>
  • Loading branch information
veeableful committed Mar 5, 2018
1 parent e5fd0c8 commit 1cae00e
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions sdl/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,37 +365,42 @@ func GetNumDisplayModes(displayIndex int) (int, error) {

// GetDisplayBounds returns the desktop area represented by a display, with the primary display located at 0,0.
// (https://wiki.libsdl.org/SDL_GetDisplayBounds)
func GetDisplayBounds(displayIndex int, rect *Rect) error {
return errorFromInt(int(
C.SDL_GetDisplayBounds(C.int(displayIndex), rect.cptr())))
func GetDisplayBounds(displayIndex int) (rect Rect, err error) {
err = errorFromInt(int(
C.SDL_GetDisplayBounds(C.int(displayIndex), (&rect).cptr())))
return
}

// GetDisplayUsableBounds returns the usable desktop area represented by a display, with the primary display located at 0,0.
// (https://wiki.libsdl.org/SDL_GetDisplayUsableBounds)
func GetDisplayUsableBounds(displayIndex int, rect *Rect) error {
return errorFromInt(int(
func GetDisplayUsableBounds(displayIndex int) (rect Rect, err error) {
err = errorFromInt(int(
C.SDL_GetDisplayUsableBounds(C.int(displayIndex), rect.cptr())))
return
}

// GetDisplayMode retruns information about a specific display mode.
// (https://wiki.libsdl.org/SDL_GetDisplayMode)
func GetDisplayMode(displayIndex int, modeIndex int, mode *DisplayMode) error {
return errorFromInt(int(
C.SDL_GetDisplayMode(C.int(displayIndex), C.int(modeIndex), mode.cptr())))
func GetDisplayMode(displayIndex int, modeIndex int) (mode DisplayMode, err error) {
err = errorFromInt(int(
C.SDL_GetDisplayMode(C.int(displayIndex), C.int(modeIndex), (&mode).cptr())))
return
}

// GetDesktopDisplayMode returns information about the desktop display mode.
// (https://wiki.libsdl.org/SDL_GetDesktopDisplayMode)
func GetDesktopDisplayMode(displayIndex int, mode *DisplayMode) error {
return errorFromInt(int(
C.SDL_GetDesktopDisplayMode(C.int(displayIndex), mode.cptr())))
func GetDesktopDisplayMode(displayIndex int) (mode DisplayMode, err error) {
err = errorFromInt(int(
C.SDL_GetDesktopDisplayMode(C.int(displayIndex), (&mode).cptr())))
return
}

// GetCurrentDisplayMode returns information about the current display mode.
// (https://wiki.libsdl.org/SDL_GetCurrentDisplayMode)
func GetCurrentDisplayMode(displayIndex int, mode *DisplayMode) error {
return errorFromInt(int(
C.SDL_GetCurrentDisplayMode(C.int(displayIndex), mode.cptr())))
func GetCurrentDisplayMode(displayIndex int) (mode DisplayMode, err error) {
err = errorFromInt(int(
C.SDL_GetCurrentDisplayMode(C.int(displayIndex), (&mode).cptr())))
return
}

// GetClosestDisplayMode returns the closest match to the requested display mode.
Expand Down Expand Up @@ -432,9 +437,10 @@ func (window *Window) SetDisplayMode(mode *DisplayMode) error {

// GetDisplayMode fills in information about the display mode to use when the window is visible at fullscreen.
// (https://wiki.libsdl.org/SDL_GetWindowDisplayMode)
func (window *Window) GetDisplayMode(mode *DisplayMode) error {
return errorFromInt(int(
C.SDL_GetWindowDisplayMode(window.cptr(), mode.cptr())))
func (window *Window) GetDisplayMode() (mode DisplayMode, err error) {
err = errorFromInt(int(
C.SDL_GetWindowDisplayMode(window.cptr(), (&mode).cptr())))
return
}

// GetPixelFormat returns the pixel format associated with the window.
Expand Down

0 comments on commit 1cae00e

Please sign in to comment.