Skip to content

Commit e35e34d

Browse files
authored
video: no C. prefix in pub functions, fix GL enum and opaque type (#223)
1 parent 00d0400 commit e35e34d

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

video.c.v

+27-29
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,11 @@ pub enum FlashOperation {
180180
until_focused = C.SDL_FLASH_UNTIL_FOCUSED // Flash the window until it gets focus
181181
}
182182

183+
// typedef void *SDL_GLContext;
184+
// type C.SDL_GLContext = voidptr // <- We can't do this in V 0.2.4 54b0a2a
183185
// GLContext is an opaque handle to an OpenGL context.
184-
185-
// typedef void *SDL_GLContext; // ??
186-
[typedef]
187-
struct C.SDL_GLContext {}
188-
189-
pub type GLContext = C.SDL_GLContext
186+
// GLContext is C.SDL_GLContext
187+
pub type GLContext = voidptr
190188

191189
// GLattr is OpenGL configuration attributes
192190
// GLattr is C.SDL_GLattr
@@ -406,7 +404,7 @@ fn C.SDL_GetDisplayBounds(display_index int, rect &C.SDL_Rect) int
406404
// SDL_GetError() for more information.
407405
//
408406
// See also: SDL_GetNumVideoDisplays
409-
pub fn get_display_bounds(display_index int, rect &C.SDL_Rect) int {
407+
pub fn get_display_bounds(display_index int, rect &Rect) int {
410408
return C.SDL_GetDisplayBounds(display_index, rect)
411409
}
412410

@@ -439,7 +437,7 @@ fn C.SDL_GetDisplayUsableBounds(display_index int, rect &C.SDL_Rect) int
439437
//
440438
// See also: SDL_GetDisplayBounds
441439
// See also: SDL_GetNumVideoDisplays
442-
pub fn get_display_usable_bounds(display_index int, rect &C.SDL_Rect) int {
440+
pub fn get_display_usable_bounds(display_index int, rect &Rect) int {
443441
return C.SDL_GetDisplayUsableBounds(display_index, rect)
444442
}
445443

@@ -523,7 +521,7 @@ fn C.SDL_GetDisplayMode(display_index int, mode_index int, mode &C.SDL_DisplayMo
523521
// SDL_GetError() for more information.
524522
//
525523
// See also: SDL_GetNumDisplayModes
526-
pub fn get_display_mode(display_index int, mode_index int, mode &C.SDL_DisplayMode) int {
524+
pub fn get_display_mode(display_index int, mode_index int, mode &DisplayMode) int {
527525
return C.SDL_GetDisplayMode(display_index, mode_index, mode)
528526
}
529527

@@ -545,7 +543,7 @@ fn C.SDL_GetDesktopDisplayMode(display_index int, mode &C.SDL_DisplayMode) int
545543
// See also: SDL_GetCurrentDisplayMode
546544
// See also: SDL_GetDisplayMode
547545
// See also: SDL_SetWindowDisplayMode
548-
pub fn get_desktop_display_mode(display_index int, mode &C.SDL_DisplayMode) int {
546+
pub fn get_desktop_display_mode(display_index int, mode &DisplayMode) int {
549547
return C.SDL_GetDesktopDisplayMode(display_index, mode)
550548
}
551549

@@ -568,7 +566,7 @@ fn C.SDL_GetCurrentDisplayMode(display_index int, mode &C.SDL_DisplayMode) int
568566
// See also: SDL_GetDisplayMode
569567
// See also: SDL_GetNumVideoDisplays
570568
// See also: SDL_SetWindowDisplayMode
571-
pub fn get_current_display_mode(display_index int, mode &C.SDL_DisplayMode) int {
569+
pub fn get_current_display_mode(display_index int, mode &DisplayMode) int {
572570
return C.SDL_GetCurrentDisplayMode(display_index, mode)
573571
}
574572

@@ -593,7 +591,7 @@ fn C.SDL_GetClosestDisplayMode(display_index int, const_mode &C.SDL_DisplayMode,
593591
//
594592
// See also: SDL_GetDisplayMode
595593
// See also: SDL_GetNumDisplayModes
596-
pub fn get_closest_display_mode(display_index int, const_mode &C.SDL_DisplayMode, closest &C.SDL_DisplayMode) &C.SDL_DisplayMode {
594+
pub fn get_closest_display_mode(display_index int, const_mode &DisplayMode, closest &DisplayMode) &DisplayMode {
597595
return C.SDL_GetClosestDisplayMode(display_index, const_mode, closest)
598596
}
599597

@@ -629,7 +627,7 @@ fn C.SDL_SetWindowDisplayMode(window &C.SDL_Window, const_mode &C.SDL_DisplayMod
629627
//
630628
// See also: SDL_GetWindowDisplayMode
631629
// See also: SDL_SetWindowFullscreen
632-
pub fn set_window_display_mode(window &Window, const_mode &C.SDL_DisplayMode) int {
630+
pub fn set_window_display_mode(window &Window, const_mode &DisplayMode) int {
633631
return C.SDL_SetWindowDisplayMode(window, const_mode)
634632
}
635633

@@ -645,7 +643,7 @@ fn C.SDL_GetWindowDisplayMode(window &C.SDL_Window, mode &C.SDL_DisplayMode) int
645643
//
646644
// See also: SDL_SetWindowDisplayMode
647645
// See also: SDL_SetWindowFullscreen
648-
pub fn get_window_display_mode(window &Window, mode &C.SDL_DisplayMode) int {
646+
pub fn get_window_display_mode(window &Window, mode &DisplayMode) int {
649647
return C.SDL_GetWindowDisplayMode(window, mode)
650648
}
651649

@@ -837,7 +835,7 @@ fn C.SDL_SetWindowIcon(window &C.SDL_Window, icon &C.SDL_Surface)
837835
//
838836
// `window` the window to change
839837
// `icon` an SDL_Surface structure containing the icon for the window
840-
pub fn set_window_icon(window &Window, icon &C.SDL_Surface) {
838+
pub fn set_window_icon(window &Window, icon &Surface) {
841839
C.SDL_SetWindowIcon(window, icon)
842840
}
843841

@@ -1749,7 +1747,7 @@ pub fn gl_unload_library() {
17491747
C.SDL_GL_UnloadLibrary()
17501748
}
17511749

1752-
fn C.SDL_GL_ExtensionSupported(extension &C.char) bool
1750+
fn C.SDL_GL_ExtensionSupported(extension &char) bool
17531751

17541752
// gl_extension_supported checks if an OpenGL extension is supported for the current context.
17551753
//
@@ -1768,7 +1766,7 @@ fn C.SDL_GL_ExtensionSupported(extension &C.char) bool
17681766
// returns SDL_TRUE if the extension is supported, SDL_FALSE otherwise.
17691767
//
17701768
// NOTE This function is available since SDL 2.0.0.
1771-
pub fn gl_extension_supported(extension &C.char) bool {
1769+
pub fn gl_extension_supported(extension &char) bool {
17721770
return C.SDL_GL_ExtensionSupported(extension)
17731771
}
17741772

@@ -1800,8 +1798,8 @@ fn C.SDL_GL_SetAttribute(attr C.SDL_GLattr, value int) int
18001798
//
18011799
// See also: SDL_GL_GetAttribute
18021800
// See also: SDL_GL_ResetAttributes
1803-
pub fn gl_set_attribute(attr C.SDL_GLattr, value int) int {
1804-
return C.SDL_GL_SetAttribute(attr, value)
1801+
pub fn gl_set_attribute(attr GLattr, value int) int {
1802+
return C.SDL_GL_SetAttribute(C.SDL_GLattr(int(attr)), value)
18051803
}
18061804

18071805
fn C.SDL_GL_GetAttribute(attr C.SDL_GLattr, value &int) int
@@ -1815,8 +1813,8 @@ fn C.SDL_GL_GetAttribute(attr C.SDL_GLattr, value &int) int
18151813
//
18161814
// See also: SDL_GL_ResetAttributes
18171815
// See also: SDL_GL_SetAttribute
1818-
pub fn gl_get_attribute(attr C.SDL_GLattr, value &int) int {
1819-
return C.SDL_GL_GetAttribute(attr, value)
1816+
pub fn gl_get_attribute(attr GLattr, value &int) int {
1817+
return C.SDL_GL_GetAttribute(C.SDL_GLattr(int(attr)), value)
18201818
}
18211819

18221820
fn C.SDL_GL_CreateContext(window &C.SDL_Window) C.SDL_GLContext
@@ -1837,8 +1835,8 @@ fn C.SDL_GL_CreateContext(window &C.SDL_Window) C.SDL_GLContext
18371835
//
18381836
// See also: SDL_GL_DeleteContext
18391837
// See also: SDL_GL_MakeCurrent
1840-
pub fn gl_create_context(window &Window) C.SDL_GLContext {
1841-
return C.SDL_GL_CreateContext(window)
1838+
pub fn gl_create_context(window &Window) GLContext {
1839+
return GLContext(voidptr(C.SDL_GL_CreateContext(window)))
18421840
}
18431841

18441842
fn C.SDL_GL_MakeCurrent(window &C.SDL_Window, context C.SDL_GLContext) int
@@ -1853,8 +1851,8 @@ fn C.SDL_GL_MakeCurrent(window &C.SDL_Window, context C.SDL_GLContext) int
18531851
// SDL_GetError() for more information.
18541852
//
18551853
// See also: SDL_GL_CreateContext
1856-
pub fn gl_make_current(window &Window, context C.SDL_GLContext) int {
1857-
return C.SDL_GL_MakeCurrent(window, context)
1854+
pub fn gl_make_current(window &Window, context GLContext) int {
1855+
return C.SDL_GL_MakeCurrent(window, voidptr(context))
18581856
}
18591857

18601858
fn C.SDL_GL_GetCurrentWindow() &C.SDL_Window
@@ -1879,8 +1877,8 @@ fn C.SDL_GL_GetCurrentContext() C.SDL_GLContext
18791877
// NOTE This function is available since SDL 2.0.0.
18801878
//
18811879
// See also: SDL_GL_MakeCurrent
1882-
pub fn gl_get_current_context() C.SDL_GLContext {
1883-
return C.SDL_GL_GetCurrentContext()
1880+
pub fn gl_get_current_context() GLContext {
1881+
return GLContext(voidptr(C.SDL_GL_GetCurrentContext()))
18841882
}
18851883

18861884
fn C.SDL_GL_GetDrawableSize(window &C.SDL_Window, w &int, h &int)
@@ -1985,6 +1983,6 @@ fn C.SDL_GL_DeleteContext(context C.SDL_GLContext)
19851983
// `context` the OpenGL context to be deleted
19861984
//
19871985
// See also: SDL_GL_CreateContext
1988-
pub fn gl_delete_context(context C.SDL_GLContext) {
1989-
C.SDL_GL_DeleteContext(context)
1986+
pub fn gl_delete_context(context GLContext) {
1987+
C.SDL_GL_DeleteContext(voidptr(context))
19901988
}

0 commit comments

Comments
 (0)