Skip to content

Commit 0ff46e4

Browse files
authored
sdl: video: Make GL funcs into Window methods #325 (#326)
1 parent 8e7373e commit 0ff46e4

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

BREAKING.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
+ Renamed `GL_MakeCurrent()` to `GLMakeCurrent()`
1515
+ Renamed `GL_SetAttribute()` to `GLSetAttribute()`
1616
+ Renamed `GL_SetSwapInterval()` to `GLSetSwapInterval()`
17-
+ Renamed `GL_SwapWindow()` to `GLSwapWindow()`
17+
+ Renamed `GL_SwapWindow()` to `GLSwap()`
1818
+ Renamed `GL_UnloadLibrary()` to `GLUnloadLibrary()`
1919
+ Renamed `GameController.GetAttached()` to `GameController.Attached()`
2020
+ Renamed `GameController.GetAxis()` to `GameController.Axis()`
@@ -65,11 +65,12 @@
6565
+ Renamed `Texture.GL_UnbindTexture()` to `Texture.GLUnbind()`
6666
+ Renamed `TouchId` to `TouchID` in `MultiGestureEvent` struct
6767
+ Renamed `Unicode` to `unused` in `Keysym` struct (must have been a typo)
68-
+ `GetCurrentDisplayMode` returns (DisplayMode, error) instead of error
68+
+ `GLCreateContext()`, `GLMakeCurrent()`, `GLGetDrawableSize()`, `GLSwapWindow()` are now methods of `Window`
69+
+ `GetCurrentDisplayMode()` returns (DisplayMode, error) instead of error
6970
+ `GetCurrentVideoDriver()` returns (string, error) instead of string
70-
+ `GetDesktopDisplayMode` returns (DisplayMode, error) instead of error
71-
+ `GetDisplayBounds` returns (Rect, error) instead of error
72-
+ `GetDisplayMode` returns (DisplayMode, error) instead of error
71+
+ `GetDesktopDisplayMode()` returns (DisplayMode, error) instead of error
72+
+ `GetDisplayBounds()` returns (Rect, error) instead of error
73+
+ `GetDisplayMode()` returns (DisplayMode, error) instead of error
7374
+ `GetDisplayName()` returns (string, error) instead of string
7475
+ `GetDisplayUsableBounds` returns (Rect, error) instead of error
7576
+ `GetNumRenderDrivers()` returns (int, error) instead of int
@@ -88,13 +89,13 @@
8889
+ `NumHaptics()` returns (int, error) instead of int
8990
+ `Renderer.Destroy()` returns error
9091
+ `Renderer.GetViewport()` and `Renderer.GetClipRect()` now returns Rect instead of being passed a \*Rect
91-
+ `ShowCursor` returns (int, error) instead of int
92+
+ `ShowCursor()` returns (int, error) instead of int
9293
+ `Surface.SaveBMPRW()` requires (\*RWops, bool) instead of (\*RWops, int)
9394
+ `Surface.SetColorKey()` requires (bool, uint32) instead of (int, uint32)
9495
+ `Surface.SetRLE()` requires bool instead of int
9596
+ `Texture.Destroy()` returns error
9697
+ `Window.Destroy()` returns error
97-
+ `Window.GetDisplayMode` returns (DisplayMode, error) instead of error
98+
+ `Window.GetDisplayMode()` returns (DisplayMode, error) instead of error
9899
+ `Window.GetID()` returns (uint32, error) instead of uint32
99100
+ Changed Mutex, Sem, Cond to have methods instead of functions
100101
+ Changed `GameControllerMapping()` into `GameController.Mapping()`

sdl/video.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ func GLGetAttribute(attr GLattr) (int, error) {
854854

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

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

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

894-
// GLSwapWindow updates a window with OpenGL rendering.
894+
// GLSwap updates a window with OpenGL rendering.
895895
// (https://wiki.libsdl.org/SDL_GL_SwapWindow)
896-
func GLSwapWindow(window *Window) {
896+
func (window *Window) GLSwap() {
897897
C.SDL_GL_SwapWindow(window.cptr())
898898
}
899899

0 commit comments

Comments
 (0)