Skip to content

Commit

Permalink
sdl: video: Make GL funcs into Window methods veandco#325
Browse files Browse the repository at this point in the history
  • Loading branch information
malashin committed Apr 5, 2018
1 parent d6b476b commit 8e286dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
15 changes: 8 additions & 7 deletions BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+ Renamed `GL_MakeCurrent()` to `GLMakeCurrent()`
+ Renamed `GL_SetAttribute()` to `GLSetAttribute()`
+ Renamed `GL_SetSwapInterval()` to `GLSetSwapInterval()`
+ Renamed `GL_SwapWindow()` to `GLSwapWindow()`
+ Renamed `GL_SwapWindow()` to `GLSwap()`
+ Renamed `GL_UnloadLibrary()` to `GLUnloadLibrary()`
+ Renamed `GameController.GetAttached()` to `GameController.Attached()`
+ Renamed `GameController.GetAxis()` to `GameController.Axis()`
Expand Down Expand Up @@ -65,11 +65,12 @@
+ Renamed `Texture.GL_UnbindTexture()` to `Texture.GLUnbind()`
+ Renamed `TouchId` to `TouchID` in `MultiGestureEvent` struct
+ Renamed `Unicode` to `unused` in `Keysym` struct (must have been a typo)
+ `GetCurrentDisplayMode` returns (DisplayMode, error) instead of error
+ `GLCreateContext()`, `GLMakeCurrent()`, `GLGetDrawableSize()`, `GLSwapWindow()` are now methods of `Window`
+ `GetCurrentDisplayMode()` returns (DisplayMode, error) instead of error
+ `GetCurrentVideoDriver()` returns (string, error) instead of string
+ `GetDesktopDisplayMode` returns (DisplayMode, error) instead of error
+ `GetDisplayBounds` returns (Rect, error) instead of error
+ `GetDisplayMode` returns (DisplayMode, error) instead of error
+ `GetDesktopDisplayMode()` returns (DisplayMode, error) instead of error
+ `GetDisplayBounds()` returns (Rect, error) instead of error
+ `GetDisplayMode()` returns (DisplayMode, error) instead of error
+ `GetDisplayName()` returns (string, error) instead of string
+ `GetDisplayUsableBounds` returns (Rect, error) instead of error
+ `GetNumRenderDrivers()` returns (int, error) instead of int
Expand All @@ -88,13 +89,13 @@
+ `NumHaptics()` returns (int, error) instead of int
+ `Renderer.Destroy()` returns error
+ `Renderer.GetViewport()` and `Renderer.GetClipRect()` now returns Rect instead of being passed a \*Rect
+ `ShowCursor` returns (int, error) instead of int
+ `ShowCursor()` returns (int, error) instead of int
+ `Surface.SaveBMPRW()` requires (\*RWops, bool) instead of (\*RWops, int)
+ `Surface.SetColorKey()` requires (bool, uint32) instead of (int, uint32)
+ `Surface.SetRLE()` requires bool instead of int
+ `Texture.Destroy()` returns error
+ `Window.Destroy()` returns error
+ `Window.GetDisplayMode` returns (DisplayMode, error) instead of error
+ `Window.GetDisplayMode()` returns (DisplayMode, error) instead of error
+ `Window.GetID()` returns (uint32, error) instead of uint32
+ Changed Mutex, Sem, Cond to have methods instead of functions
+ Changed `GameControllerMapping()` into `GameController.Mapping()`
Expand Down
10 changes: 5 additions & 5 deletions sdl/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ func GLGetAttribute(attr GLattr) (int, error) {

// GLCreateContext creates an OpenGL context for use with an OpenGL window, and make it current.
// (https://wiki.libsdl.org/SDL_GL_CreateContext)
func GLCreateContext(window *Window) (GLContext, error) {
func (window *Window) GLCreateContext() (GLContext, error) {
c := GLContext(C.SDL_GL_CreateContext(window.cptr()))
if c == nil {
return nil, GetError()
Expand All @@ -864,7 +864,7 @@ func GLCreateContext(window *Window) (GLContext, error) {

// GLMakeCurrent sets up an OpenGL context for rendering into an OpenGL window.
// (https://wiki.libsdl.org/SDL_GL_MakeCurrent)
func GLMakeCurrent(window *Window, glcontext GLContext) error {
func (window *Window) GLMakeCurrent(glcontext GLContext) error {
return errorFromInt(int(
C.SDL_GL_MakeCurrent(window.cptr(), C.SDL_GLContext(glcontext))))
}
Expand All @@ -885,15 +885,15 @@ func GLGetSwapInterval() (int, error) {

// GLGetDrawableSize returns the size of a window's underlying drawable in pixels (for use with glViewport).
// (https://wiki.libsdl.org/SDL_GL_GetDrawableSize)
func GLGetDrawableSize(window *Window) (w, h int32) {
func (window *Window) GLGetDrawableSize() (w, h int32) {
var _w, _h C.int
C.SDL_GL_GetDrawableSize(window.cptr(), &_w, &_h)
return int32(_w), int32(_h)
}

// GLSwapWindow updates a window with OpenGL rendering.
// GLSwap updates a window with OpenGL rendering.
// (https://wiki.libsdl.org/SDL_GL_SwapWindow)
func GLSwapWindow(window *Window) {
func (window *Window) GLSwap() {
C.SDL_GL_SwapWindow(window.cptr())
}

Expand Down

0 comments on commit 8e286dd

Please sign in to comment.