From 2a4139e71cc5d2f6b79126174bb587cd19120c0f Mon Sep 17 00:00:00 2001 From: AmjadHD Date: Mon, 13 Nov 2023 19:23:01 +0100 Subject: [PATCH 1/4] Improve API * Remove special casing of `RectF` and `PointF`. * Use `openarray` for `fillRects`, `drawRects` and `drawPoints`. * allow passing `let` variables to proc expecting address. * `copyEx` => `copy`. --- src/sdl2.nim | 170 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 136 insertions(+), 34 deletions(-) diff --git a/src/sdl2.nim b/src/sdl2.nim index 90a765c..8c75a1e 100644 --- a/src/sdl2.nim +++ b/src/sdl2.nim @@ -2068,7 +2068,7 @@ proc drawPoint*(renderer: RendererPtr; x, y: cint): SDL_Return {. ## ## `y` The y coordinate of the point. -proc drawPointF*(renderer: RendererPtr; x, y: cfloat): SDL_Return {. +proc drawPoint*(renderer: RendererPtr; x, y: cfloat): SDL_Return {. importc: "SDL_RenderDrawPointF", discardable.} ## Draw a point on the current rendering target. ## @@ -2090,7 +2090,12 @@ proc drawPoints*(renderer: RendererPtr; points: ptr Point; ## ## `Return` `0` on success, or `-1` on error. -proc drawPointsF*(renderer: RendererPtr; points: ptr PointF; +proc drawPoints*(renderer: RendererPtr; + points: openarray[Point]): SDL_Return {.inline, discardable.} = + ## Draw multiple points on the current rendering target. + drawPoints(renderer, points[0].unsafeAddr, points.len.cint) + +proc drawPoints*(renderer: RendererPtr; points: ptr PointF; count: cint): SDL_Return {.importc: "SDL_RenderDrawPointsF", discardable.} ## Draw multiple points on the current rendering target. ## @@ -2101,6 +2106,10 @@ proc drawPointsF*(renderer: RendererPtr; points: ptr PointF; ## `count` The number of points to draw. ## ## `Return` `0` on success, or `-1` on error. +proc drawPoints*(renderer: RendererPtr; + points: openarray[PointF]): SDL_Return {.inline, discardable.} = + ## Draw multiple points on the current rendering target. + drawPoints(renderer, points[0].unsafeAddr, points.len.cint) proc drawLine*(renderer: RendererPtr; x1, y1, x2, y2: cint): SDL_Return {. importc: "SDL_RenderDrawLine", discardable.} @@ -2116,7 +2125,7 @@ proc drawLine*(renderer: RendererPtr; x1, y1, x2, y2: cint): SDL_Return {. ## ## `y2` The y coordinate of the end point. -proc drawLineF*(renderer: RendererPtr; x1, y1, x2, y2: cfloat): SDL_Return {. +proc drawLine*(renderer: RendererPtr; x1, y1, x2, y2: cfloat): SDL_Return {. importc: "SDL_RenderDrawLineF", discardable.} ## Draw a line on the current rendering target. ## @@ -2140,7 +2149,12 @@ proc drawLines*(renderer: RendererPtr; points: ptr Point; ## ## `count` The number of points, drawing `count-1` lines. -proc drawLinesF*(renderer: RendererPtr; points: ptr PointF; +proc drawLines*(renderer: RendererPtr; + points: openarray[Point]): SDL_Return {.inline, discardable.} = + ## Draw a series of connected lines on the current rendering target. + drawLines(renderer, points[0].unsafeAddr, points.len.cint) + +proc drawLines*(renderer: RendererPtr; points: ptr PointF; count: cint): SDL_Return {.importc: "SDL_RenderDrawLinesF", discardable.} ## Draw a series of connected lines on the current rendering target. ## @@ -2150,11 +2164,10 @@ proc drawLinesF*(renderer: RendererPtr; points: ptr PointF; ## ## `count` The number of points, drawing `count-1` lines. -proc drawRect*(renderer: RendererPtr; rect: var Rect): SDL_Return{. - importc: "SDL_RenderDrawRect", discardable.} - -proc drawRectF*(renderer: RendererPtr; rect: var RectF): SDL_Return{. - importc: "SDL_RenderDrawRectF", discardable.} +proc drawLines*(renderer: RendererPtr; + points: openarray[PointF]): SDL_Return {.inline, discardable.} = + ## Draw a series of connected lines on the current rendering target. + drawLines(renderer, points[0].unsafeAddr, points.len.cint) proc drawRect*(renderer: RendererPtr; rect: ptr Rect = nil): SDL_Return{. importc: "SDL_RenderDrawRect", discardable.} @@ -2165,7 +2178,10 @@ proc drawRect*(renderer: RendererPtr; rect: ptr Rect = nil): SDL_Return{. ## `rect` A pointer to the destination rectangle, ## or `nil` to outline the entire rendering target. -proc drawRectF*(renderer: RendererPtr; rect: ptr RectF = nil): SDL_Return{. +proc drawRect*(renderer: RendererPtr; rect: Rect): SDL_Return {.inline, discardable.} = + drawRect(renderer, rect.unsafeAddr) + +proc drawRect*(renderer: RendererPtr; rect: ptr RectF): SDL_Return {. importc: "SDL_RenderDrawRectF", discardable.} ## Draw a rectangle on the current rendering target. ## @@ -2174,6 +2190,9 @@ proc drawRectF*(renderer: RendererPtr; rect: ptr RectF = nil): SDL_Return{. ## `rect` A pointer to the destination rectangle, ## or `nil` to outline the entire rendering target. +proc drawRect*(renderer: RendererPtr; rect: RectF): SDL_Return {.inline, discardable.} = + drawRect(renderer, rect.unsafeAddr) + proc drawRects*(renderer: RendererPtr; rects: ptr Rect; count: cint): SDL_Return {.importc: "SDL_RenderDrawRects".} ## Draw some number of rectangles on the current rendering target. @@ -2184,21 +2203,16 @@ proc drawRects*(renderer: RendererPtr; rects: ptr Rect; ## ## `count` The number of rectangles. -proc drawRectsF*(renderer: RendererPtr; rects: ptr RectF; - count: cint): SDL_Return {.importc: "SDL_RenderDrawRectsF".} +proc drawRects*(renderer: RendererPtr; rects: openarray[Rect]): SDL_Return {.inline.} = ## Draw some number of rectangles on the current rendering target. - ## - ## `renderer` The renderer which should draw multiple rectangles. - ## - ## `rects` A pointer to an array of destination rectangles. - ## - ## `count` The number of rectangles. + drawRects(renderer, rects[0].unsafeAddr, rects.len.cint) -proc fillRect*(renderer: RendererPtr; rect: var Rect): SDL_Return {. - importc: "SDL_RenderFillRect", discardable.} +proc drawRects*(renderer: RendererPtr; rects: ptr RectF; + count: cint): SDL_Return {.importc: "SDL_RenderDrawRectsF".} -proc fillRectF*(renderer: RendererPtr; rect: var RectF): SDL_Return {. - importc: "SDL_RenderFillRectF", discardable.} +proc drawRects*(renderer: RendererPtr; rects: openarray[RectF]): SDL_Return {.inline.} = + ## Draw some number of rectangles on the current rendering target. + drawRects(renderer, rects[0].unsafeAddr, rects.len.cint) proc fillRect*(renderer: RendererPtr; rect: ptr Rect = nil): SDL_Return {. importc: "SDL_RenderFillRect", discardable.} @@ -2209,7 +2223,11 @@ proc fillRect*(renderer: RendererPtr; rect: ptr Rect = nil): SDL_Return {. ## `rect` A pointer to the destination rectangle, ## or `nil` for the entire rendering target. -proc fillRectF*(renderer: RendererPtr; rect: ptr RectF = nil): SDL_Return {. +proc fillRect*(renderer: RendererPtr; rect: Rect): SDL_Return {.inline, discardable.} = + ## Fill a rectangle on the current rendering target with the drawing color. + fillRect(renderer, rect.unsafeAddr) + +proc fillRect*(renderer: RendererPtr; rect: ptr RectF): SDL_Return {. importc: "SDL_RenderFillRectF", discardable.} ## Fill a rectangle on the current rendering target with the drawing color. ## @@ -2218,6 +2236,10 @@ proc fillRectF*(renderer: RendererPtr; rect: ptr RectF = nil): SDL_Return {. ## `rect` A pointer to the destination rectangle, ## or `nil` for the entire rendering target. +proc fillRect*(renderer: RendererPtr; rect: RectF): SDL_Return {.inline, discardable.} = + ## Fill a rectangle on the current rendering target with the drawing color. + fillRect(renderer, rect.unsafeAddr) + proc fillRects*(renderer: RendererPtr; rects: ptr Rect; count: cint): SDL_Return {.importc: "SDL_RenderFillRects", discardable.} ## Fill some number of rectangles on the current rendering target @@ -2229,7 +2251,12 @@ proc fillRects*(renderer: RendererPtr; rects: ptr Rect; ## ## `count` The number of rectangles. -proc fillRectsF*(renderer: RendererPtr; rects: ptr RectF; +proc fillRects*(renderer: RendererPtr; rects: openarray[Rect]): SDL_Return {.inline, discardable.} = + ## Fill some number of rectangles on the current rendering target + ## with the drawing color. + fillRects(renderer, rects[0].unsafeAddr, rects.len.cint) + +proc fillRects*(renderer: RendererPtr; rects: ptr RectF; count: cint): SDL_Return {.importc: "SDL_RenderFillRectsF", discardable.} ## Fill some number of rectangles on the current rendering target ## with the drawing color. @@ -2240,6 +2267,11 @@ proc fillRectsF*(renderer: RendererPtr; rects: ptr RectF; ## ## `count` The number of rectangles. +proc fillRects*(renderer: RendererPtr, rects: openarray[RectF]): SDL_Return {.inline, discardable.} = + ## Fill some number of rectangles on the current rendering target + ## with the drawing color. + fillRects(renderer, rects[0].unsafeAddr, rects.len.cint) + proc copy*(renderer: RendererPtr; texture: TexturePtr; srcrect, dstrect: ptr Rect): SDL_Return {. importc: "SDL_RenderCopy", discardable.} @@ -2255,7 +2287,12 @@ proc copy*(renderer: RendererPtr; texture: TexturePtr; ## `dstrect` A pointer to the destination rectangle, ## or `nil` for the entire rendering target. -proc copyF*(renderer: RendererPtr; texture: TexturePtr; +proc copy*(renderer: RendererPtr; texture: TexturePtr; + srcrect, dstrect: Rect): SDL_Return {.inline, discardable.} = + ## Copy a portion of the texture to the current rendering target. + copy(renderer, texture, srcrect.unsafeAddr, dstrect.unsafeAddr) + +proc copy*(renderer: RendererPtr; texture: TexturePtr; srcrect: ptr Rect, dstrect: ptr RectF): SDL_Return {. importc: "SDL_RenderCopyF", discardable.} ## Copy a portion of the texture to the current rendering target. @@ -2270,11 +2307,16 @@ proc copyF*(renderer: RendererPtr; texture: TexturePtr; ## `dstrect` A pointer to the destination rectangle, ## or `nil` for the entire rendering target. +proc copy*(renderer: RendererPtr; texture: TexturePtr; + srcrect: Rect, dstrect: RectF): SDL_Return {.inline, discardable.} = + ## Copy a portion of the texture to the current rendering target. + copy(renderer, texture, srcrect.unsafeAddr, dstrect.unsafeAddr) + proc copyEx*(renderer: RendererPtr; texture: TexturePtr; srcrect, dstrect: var Rect; angle: cdouble; center: ptr Point; flip: RendererFlip = SDL_FLIP_NONE): SDL_Return {. importc: "SDL_RenderCopyEx", discardable.} -proc copyEx*(renderer: RendererPtr; texture: TexturePtr; +proc copy*(renderer: RendererPtr; texture: TexturePtr; srcrect, dstrect: ptr Rect; angle: cdouble; center: ptr Point; flip: RendererFlip = SDL_FLIP_NONE): SDL_Return {. importc: "SDL_RenderCopyEx", discardable.} @@ -2301,11 +2343,14 @@ proc copyEx*(renderer: RendererPtr; texture: TexturePtr; ## `flip` `RendererFlip` value stating which flipping actions should be ## performed on the texture. -proc copyExF*(renderer: RendererPtr; texture: TexturePtr; - srcrect: ptr Rect, dstrect: var RectF; angle: cdouble; center: ptr PointF; - flip: RendererFlip = SDL_FLIP_NONE): SDL_Return {. - importc: "SDL_RenderCopyExF", discardable.} -proc copyExF*(renderer: RendererPtr; texture: TexturePtr; +proc copy*(renderer: RendererPtr; texture: TexturePtr; + srcrect, dstrect: Rect; angle: cdouble; center: Point; + flip: RendererFlip = SDL_FLIP_NONE): SDL_Return {.inline, discardable.} = + ## Copy a portion of the source texture to the current rendering target, + ## rotating it by angle around the given center. + copy(renderer, texture, srcrect.unsafeAddr, dstrect.unsafeAddr, angle, center.unsafeAddr, flip) + +proc copy*(renderer: RendererPtr; texture: TexturePtr; srcrect: ptr Rect, dstrect: ptr RectF; angle: cdouble; center: ptr PointF; flip: RendererFlip = SDL_FLIP_NONE): SDL_Return {. importc: "SDL_RenderCopyExF", discardable.} @@ -2332,6 +2377,11 @@ proc copyExF*(renderer: RendererPtr; texture: TexturePtr; ## `flip` `RendererFlip` value stating which flipping actions should be ## performed on the texture. +proc copy*(renderer: RendererPtr; texture: TexturePtr; + srcrect: Rect, dstrect: RectF; angle: cdouble; center: PointF; + flip: RendererFlip = SDL_FLIP_NONE): SDL_Return {.inline, discardable.} = + copy(renderer, texture, srcrect.unsafeAddr, dstrect.unsafeAddr, angle, center.unsafeAddr, flip) + proc clear*(renderer: RendererPtr): SDL_Return {. importc: "SDL_RenderClear", discardable.} ## Clear the current rendering target with the drawing color. @@ -2339,9 +2389,6 @@ proc clear*(renderer: RendererPtr): SDL_Return {. ## This procedure clears the entire rendering target, ignoring the viewport, ## and the clip rectangle. - -proc readPixels*(renderer: RendererPtr; rect: var Rect; format: cint; - pixels: pointer; pitch: cint): cint {.importc: "SDL_RenderReadPixels".} proc readPixels*(renderer: RendererPtr; rect: ptr Rect; format: cint; pixels: pointer; pitch: cint): cint {.importc: "SDL_RenderReadPixels".} ## Read pixels from the current rendering target. @@ -2363,6 +2410,10 @@ proc readPixels*(renderer: RendererPtr; rect: ptr Rect; format: cint; ## `Warning:` This is a very slow operation, ## and should not be used frequently. +proc readPixels*(renderer: RendererPtr; rect: Rect; format: cint; + pixels: pointer; pitch: cint): cint {.inline.} = + readPixels(renderer, rect.unsafeAddr, format, pixels, pitch) + proc present*(renderer: RendererPtr) {.importc: "SDL_RenderPresent".} ## Update the screen with rendering performed. @@ -2425,6 +2476,10 @@ proc setPalette*(surface: SurfacePtr; palette: ptr Palette): cint {. ## ## **Note:** A single palette can be shared with many surfaces. +proc setPalette*(surface: SurfacePtr; palette: Palette): cint {.inline.} = + ## Set the palette used by a surface. + setPalette(surface, palette.unsafeAddr) + proc lockSurface*(surface: SurfacePtr): cint {.importc: "SDL_LockSurface".} proc lock*(surface: SurfacePtr): cint {.importc: "SDL_LockSurface".} ## Sets up a surface for directly accessing the pixels. @@ -2634,6 +2689,8 @@ proc setClipRect*(surface: SurfacePtr; rect: ptr Rect): Bool32 {. ## ## Note that blits are automatically clipped to the edges of the source ## and destination surfaces. +proc setClipRect*(surface: SurfacePtr; rect: Rect): Bool32 {.inline.} = + setClipRect(surface, rect.unsafeAddr) proc getClipRect*(surface: SurfacePtr; rect: ptr Rect) {. importc: "SDL_GetClipRect".} @@ -2642,6 +2699,8 @@ proc getClipRect*(surface: SurfacePtr; rect: ptr Rect) {. ## `rect` must be a pointer to a valid rectangle which will be filled ## with the correct values. +proc getClipRect*(surface: SurfacePtr; rect: var Rect) {. + importc: "SDL_GetClipRect".} proc setClipRect*(renderer: RendererPtr; rect: ptr Rect): cint {. importc: "SDL_RenderSetClipRect".} @@ -2657,6 +2716,9 @@ proc setClipRect*(renderer: RendererPtr; rect: ptr Rect): cint {. ## **See also:** ## * `getClipRect proc<#getClipRect,RendererPtr,ptr.Rect>`_ +proc setClipRect*(renderer: RendererPtr; rect: Rect): cint {.inline.} = + setClipRect(renderer, rect.unsafeAddr) + proc getClipRect*(renderer: RendererPtr; rect: ptr Rect): cint {. importc: "SDL_RenderGetClipRect".} ## Get the clip rectangle for the current target. @@ -2669,6 +2731,9 @@ proc getClipRect*(renderer: RendererPtr; rect: ptr Rect): cint {. ## **See also:** ## * `setClipRect proc<#setClipRect,SurfacePtr,ptr.Rect>`_ +proc getClipRect*(renderer: RendererPtr; rect: var Rect): cint {. + importc: "SDL_RenderGetClipRect".} + proc isClipEnabled*(renderer: RendererPtr): cint {. importc: "SDL_RenderIsClipEnabled".} ## Get whether clipping is enabled on the given renderer. @@ -2692,6 +2757,9 @@ proc convert*(src: SurfacePtr; fmt: ptr PixelFormat; ## SDL will try to RLE accelerate colorkey and alpha blits in the resulting ## surface. +proc convert*(src: SurfacePtr; fmt: PixelFormat; flags: cint): SurfacePtr {.inline.} = + convert(src, fmt, flags) + proc convertSurfaceFormat*(src: SurfacePtr; pixel_format, flags: uint32): SurfacePtr {.importc: "SDL_ConvertSurfaceFormat".} proc convert*(src: SurfacePtr; pixel_format, @@ -2713,19 +2781,36 @@ proc fillRect*(dst: SurfacePtr; rect: ptr Rect; color: uint32): SDL_Return {. ## ## `Return` `0` on success, or `-1` on error. +proc fillRect*(dst: SurfacePtr; rect: Rect; color: uint32): SDL_Return {.inline, discardable.} = + fillRect(dst, rect.unsafeAddr, color) + proc fillRects*(dst: SurfacePtr; rects: ptr Rect; count: cint; color: uint32): cint {.importc: "SDL_FillRects".} +proc fillRects*(dst: SurfacePtr; rects: openarray[Rect]; color: uint32): cint {.inline.} = + fillRects(dst, rects[0].unsafeAddr, rects.len.cint, color) + proc upperBlit*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; dstrect: ptr Rect): SDL_Return {.importc: "SDL_UpperBlit".} ## This is the public blit procedure, `blitSurface()`, and it performs ## rectangle validation and clipping before passing it to `lowerBlit()`. +proc upperBlit*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; + dstrect: Rect): SDL_Return {.inline.} = + ## This is the public blit procedure, `blitSurface()`, and it performs + ## rectangle validation and clipping before passing it to `lowerBlit()`. + upperBlit(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) + proc lowerBlit*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; dstrect: ptr Rect): SDL_Return {.importc: "SDL_LowerBlit".} ## This is a semi-private blit procedure and it performs low-level surface ## blitting only. +proc lowerBlit*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; + dstrect: Rect): SDL_Return {.inline.} = + ## This is a semi-private blit procedure and it performs low-level surface + ## blitting only. + lowerBlit(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) proc softStretch*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; dstrect: ptr Rect): SDL_Return {.importc: "SDL_SoftStretch".} @@ -2734,6 +2819,13 @@ proc softStretch*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; ## ## **Note:** This procedure uses a static buffer, and is not thread-safe. +proc softStretch*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; + dstrect: Rect): SDL_Return {.inline.} = + ## Perform a fast, low quality, stretch blit between two surfaces of the + ## same pixel format. + ## + ## **Note:** This procedure uses a static buffer, and is not thread-safe. + softStretch(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) proc upperBlitScaled*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; dstrect: ptr Rect): SDL_Return {.importc: "SDL_UpperBlitScaled".} @@ -2741,11 +2833,21 @@ proc upperBlitScaled*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; ## and it performs rectangle validation and clipping before ## passing it to `lowerBlitScaled()`. +proc upperBlitScaled*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; + dstrect: Rect): SDL_Return {.inline.} = + ## This is the public scaled blit procedure, `blitScaled()`, + ## and it performs rectangle validation and clipping before + ## passing it to `lowerBlitScaled()`. + upperBlitScaled(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) + proc lowerBlitScaled*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; dstrect: ptr Rect): SDL_Return {.importc: "SDL_LowerBlitScaled".} ## This is a semi-private blit procedure and it performs low-level surface ## scaled blitting only. +proc lowerBlitScaled*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; + dstrect: Rect): SDL_Return {.inline.} = + lowerBlitScaled(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) proc readU8*(src: RWopsPtr): uint8 {.importc: "SDL_ReadU8".} proc readLE16*(src: RWopsPtr): uint16 {.importc: "SDL_ReadLE16".} From 3f3c1e4da0fa98b9b20b12336718afaaa9099797 Mon Sep 17 00:00:00 2001 From: AmjadHD Date: Thu, 16 Nov 2023 21:25:50 +0100 Subject: [PATCH 2/4] Fix return types --- src/sdl2.nim | 200 +++++++++++++++++++++--------------------- src/sdl2/audio.nim | 14 +-- src/sdl2/gfx.nim | 6 +- src/sdl2/haptic.nim | 26 +++--- src/sdl2/image.nim | 4 +- src/sdl2/joystick.nim | 6 +- src/sdl2/mixer.nim | 24 ++--- src/sdl2/net.nim | 4 +- src/sdl2/ttf.nim | 4 +- 9 files changed, 144 insertions(+), 144 deletions(-) diff --git a/src/sdl2.nim b/src/sdl2.nim index 8c75a1e..e4ce8b2 100644 --- a/src/sdl2.nim +++ b/src/sdl2.nim @@ -1188,7 +1188,7 @@ proc destroy*(renderer: RendererPtr) {.importc: "SDL_DestroyRenderer".} proc getDisplayIndex*(window: WindowPtr): cint {.importc: "SDL_GetWindowDisplayIndex".} proc setDisplayMode*(window: WindowPtr; - mode: ptr DisplayMode): SDL_Return {.importc: "SDL_SetWindowDisplayMode".} + mode: ptr DisplayMode): SDL_Return {.importc: "SDL_SetWindowDisplayMode", discardable.} proc getDisplayMode*(window: WindowPtr; mode: var DisplayMode): cint {. importc: "SDL_GetWindowDisplayMode".} @@ -1339,7 +1339,7 @@ proc setBordered*(window: WindowPtr; bordered: Bool32) {.importc: "SDL_SetWindow ## * `getFlags proc<#getFlags,WindowPtr>`_ proc setFullscreen*(window: WindowPtr; - fullscreen: uint32): SDL_Return {.importc: "SDL_SetWindowFullscreen".} + fullscreen: uint32): SDL_Return {.importc: "SDL_SetWindowFullscreen", discardable.} ## Set a window's fullscreen state. ## ## `Return` `0` on success, or `-1` if setting the display mode failed. @@ -1363,7 +1363,7 @@ proc getSurface*(window: WindowPtr): SurfacePtr {.importc: "SDL_GetWindowSurface ## * `updateSurface proc<#updateSurface,WindowPtr>`_ ## * `updateSurfaceRects proc<#updateSurfaceRects,WindowPtr,ptr.Rect,cint>`_ -proc updateSurface*(window: WindowPtr): SDL_Return {.importc: "SDL_UpdateWindowSurface".} +proc updateSurface*(window: WindowPtr): SDL_Return {.importc: "SDL_UpdateWindowSurface", discardable.} ## Copy the window surface to the screen. ## ## `Return` `0` on success, or `-1` on error. @@ -1373,7 +1373,7 @@ proc updateSurface*(window: WindowPtr): SDL_Return {.importc: "SDL_UpdateWindow ## * `updateSurfaceRects proc<#updateSurfaceRects,WindowPtr,ptr.Rect,cint>`_ proc updateSurfaceRects*(window: WindowPtr; rects: ptr Rect; - numrects: cint): SDL_Return {.importc: "SDL_UpdateWindowSurfaceRects".} + numrects: cint): SDL_Return {.importc: "SDL_UpdateWindowSurfaceRects", discardable.} ## Copy a number of rectangles on the window surface to the screen. ## ## `Return` `0` on success, or `-1` on error. @@ -1404,7 +1404,7 @@ proc getGrab*(window: WindowPtr): Bool32 {.importc: "SDL_GetWindowGrab".} ## * `setGrab proc<#setGrab,WindowPtr,Bool32>`_ proc setBrightness*(window: WindowPtr; - brightness: cfloat): SDL_Return {.importc: "SDL_SetWindowBrightness".} + brightness: cfloat): SDL_Return {.importc: "SDL_SetWindowBrightness", discardable.} ## Set the brightness (gamma correction) for a window. ## ## `Return` `0` on success, @@ -1423,7 +1423,7 @@ proc getBrightness*(window: WindowPtr): cfloat {.importc: "SDL_GetWindowBrightne ## * `setBrightness proc<#setBrightness,WindowPtr,cfloat>`_ proc setGammaRamp*(window: WindowPtr; - red, green, blue: ptr uint16): SDL_Return {.importc: "SDL_SetWindowGammaRamp".} + red, green, blue: ptr uint16): SDL_Return {.importc: "SDL_SetWindowGammaRamp", discardable.} ## Set the gamma ramp for a window. ## ## `window` The window for which the gamma ramp should be set. @@ -1447,7 +1447,7 @@ proc setGammaRamp*(window: WindowPtr; proc getGammaRamp*(window: WindowPtr; red: ptr uint16; green: ptr uint16; - blue: ptr uint16): cint {.importc: "SDL_GetWindowGammaRamp".} + blue: ptr uint16): SDL_Return {.importc: "SDL_GetWindowGammaRamp", discardable.} ## Get the gamma ramp for a window. ## ## `window` The window from which the gamma ramp should be queried. @@ -1627,7 +1627,7 @@ proc getNumRenderDrivers*(): cint {.importc: "SDL_GetNumRenderDrivers".} ## * `createRenderer proc<#createRenderer,WindowPtr,cint,cint>`_ proc getRenderDriverInfo*(index: cint; info: var RendererInfo): SDL_Return {. - importc: "SDL_GetRenderDriverInfo".} + importc: "SDL_GetRenderDriverInfo", discardable.} ## Get information about a specific 2D rendering driver ## for the current display. ## @@ -1643,7 +1643,7 @@ proc getRenderDriverInfo*(index: cint; info: var RendererInfo): SDL_Return {. proc createWindowAndRenderer*(width, height: cint; window_flags: uint32; window: var WindowPtr; renderer: var RendererPtr): SDL_Return {. - importc: "SDL_CreateWindowAndRenderer".} + importc: "SDL_CreateWindowAndRenderer", discardable.} ## Create a window and default renderer. ## ## `width` The width of the window. @@ -1763,9 +1763,9 @@ proc query*(texture: TexturePtr; format: ptr uint32; proc setTextureColorMod*(texture: TexturePtr; r, g, b: uint8): SDL_Return {. - importc: "SDL_SetTextureColorMod".} + importc: "SDL_SetTextureColorMod", discardable.} proc setColorMod*(texture: TexturePtr; r, g, b: uint8): SDL_Return {. - importc: "SDL_SetTextureColorMod".} + importc: "SDL_SetTextureColorMod", discardable.} ## Set an additional color value used in render copy operations. ## ## `texture` The texture to update. @@ -1783,9 +1783,9 @@ proc setColorMod*(texture: TexturePtr; r, g, b: uint8): SDL_Return {. ## * `getColorMod proc<#getColorMod,TexturePtr,uint8,uint8,uint8>`_ proc getTextureColorMod*(texture: TexturePtr; r, g, b: var uint8): SDL_Return {. - importc: "SDL_GetTextureColorMod".} + importc: "SDL_GetTextureColorMod", discardable.} proc getColorMod*(texture: TexturePtr; r, g, b: var uint8): SDL_Return {. - importc: "SDL_GetTextureColorMod".} + importc: "SDL_GetTextureColorMod", discardable.} ## Get the additional color value used in render copy operations. ## ## `texture` The texture to query. @@ -2194,7 +2194,7 @@ proc drawRect*(renderer: RendererPtr; rect: RectF): SDL_Return {.inline, discard drawRect(renderer, rect.unsafeAddr) proc drawRects*(renderer: RendererPtr; rects: ptr Rect; - count: cint): SDL_Return {.importc: "SDL_RenderDrawRects".} + count: cint): SDL_Return {.importc: "SDL_RenderDrawRects", discardable.} ## Draw some number of rectangles on the current rendering target. ## ## `renderer` The renderer which should draw multiple rectangles. @@ -2203,14 +2203,14 @@ proc drawRects*(renderer: RendererPtr; rects: ptr Rect; ## ## `count` The number of rectangles. -proc drawRects*(renderer: RendererPtr; rects: openarray[Rect]): SDL_Return {.inline.} = +proc drawRects*(renderer: RendererPtr; rects: openarray[Rect]): SDL_Return {.inline, discardable.} = ## Draw some number of rectangles on the current rendering target. drawRects(renderer, rects[0].unsafeAddr, rects.len.cint) proc drawRects*(renderer: RendererPtr; rects: ptr RectF; - count: cint): SDL_Return {.importc: "SDL_RenderDrawRectsF".} + count: cint): SDL_Return {.importc: "SDL_RenderDrawRectsF", discardable.} -proc drawRects*(renderer: RendererPtr; rects: openarray[RectF]): SDL_Return {.inline.} = +proc drawRects*(renderer: RendererPtr; rects: openarray[RectF]): SDL_Return {.inline, discardable.} = ## Draw some number of rectangles on the current rendering target. drawRects(renderer, rects[0].unsafeAddr, rects.len.cint) @@ -2390,7 +2390,7 @@ proc clear*(renderer: RendererPtr): SDL_Return {. ## and the clip rectangle. proc readPixels*(renderer: RendererPtr; rect: ptr Rect; format: cint; - pixels: pointer; pitch: cint): cint {.importc: "SDL_RenderReadPixels".} + pixels: pointer; pitch: cint): SDL_Return {.importc: "SDL_RenderReadPixels", discardable.} ## Read pixels from the current rendering target. ## ## `renderer` The renderer from which pixels should be read. @@ -2411,15 +2411,15 @@ proc readPixels*(renderer: RendererPtr; rect: ptr Rect; format: cint; ## and should not be used frequently. proc readPixels*(renderer: RendererPtr; rect: Rect; format: cint; - pixels: pointer; pitch: cint): cint {.inline.} = + pixels: pointer; pitch: cint): SDL_Return {.inline, discardable.} = readPixels(renderer, rect.unsafeAddr, format, pixels, pitch) proc present*(renderer: RendererPtr) {.importc: "SDL_RenderPresent".} ## Update the screen with rendering performed. -proc glBindTexture*(texture: TexturePtr; texw, texh: var cfloat): cint {. - importc: "SDL_GL_BindTexture".} +proc glBindTexture*(texture: TexturePtr; texw, texh: var cfloat): SDL_Return {. + importc: "SDL_GL_BindTexture", discardable.} ## Bind the texture to the current OpenGL/ES/ES2 context for use ## with OpenGL instructions. ## @@ -2480,8 +2480,8 @@ proc setPalette*(surface: SurfacePtr; palette: Palette): cint {.inline.} = ## Set the palette used by a surface. setPalette(surface, palette.unsafeAddr) -proc lockSurface*(surface: SurfacePtr): cint {.importc: "SDL_LockSurface".} -proc lock*(surface: SurfacePtr): cint {.importc: "SDL_LockSurface".} +proc lockSurface*(surface: SurfacePtr): SDL_Return {.importc: "SDL_LockSurface", discardable.} +proc lock*(surface: SurfacePtr): SDL_Return {.importc: "SDL_LockSurface", discardable.} ## Sets up a surface for directly accessing the pixels. ## ## Between calls to `lock()` / `unlock()`, you can write @@ -2529,7 +2529,7 @@ proc freeRW*(area: RWopsPtr) {.importc: "SDL_FreeRW".} proc saveBMP_RW*(surface: SurfacePtr; dst: RWopsPtr; - freedst: cint): SDL_Return {.importc: "SDL_SaveBMP_RW".} + freedst: cint): SDL_Return {.importc: "SDL_SaveBMP_RW", discardable.} ## Save a surface to a seekable SDL data stream (memory or file). ## ## Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the @@ -2543,8 +2543,8 @@ proc saveBMP_RW*(surface: SurfacePtr; dst: RWopsPtr; ## `Return` `0` if successful or `-1` if there was an error. -proc setSurfaceRLE*(surface: SurfacePtr; flag: cint): cint {. - importc:"SDL_SetSurfaceRLE".} +proc setSurfaceRLE*(surface: SurfacePtr; flag: cint): SDL_Return {. + importc:"SDL_SetSurfaceRLE", discardable.} ## Sets the RLE acceleration hint for a surface. ## ## `Return` `0` on success, or `-1` if the surface is not valid. @@ -2553,8 +2553,8 @@ proc setSurfaceRLE*(surface: SurfacePtr; flag: cint): cint {. ## much faster, but the surface must be locked before directly ## accessing the pixels. -proc setColorKey*(surface: SurfacePtr; flag: cint; key: uint32): cint {. - importc: "SDL_SetColorKey".} +proc setColorKey*(surface: SurfacePtr; flag: cint; key: uint32): SDL_Return {. + importc: "SDL_SetColorKey", discardable.} ## Sets the color key (transparent pixel) in a blittable surface. ## ## `surface` The surface to update. @@ -2567,8 +2567,8 @@ proc setColorKey*(surface: SurfacePtr; flag: cint; key: uint32): cint {. ## ## You can pass `SDL_RLEACCEL` to enable RLE accelerated blits. -proc getColorKey*(surface: SurfacePtr; key: var uint32): cint {. - importc: "SDL_GetColorKey".} +proc getColorKey*(surface: SurfacePtr; key: var uint32): SDL_Return {. + importc: "SDL_GetColorKey", discardable.} ## Gets the color key (transparent pixel) in a blittable surface. ## ## `surface` The surface to update. @@ -2579,10 +2579,10 @@ proc getColorKey*(surface: SurfacePtr; key: var uint32): cint {. ## `Return` `0` on success, or `-1` if the surface is not valid or ## colorkey is not enabled. -proc setSurfaceColorMod*(surface: SurfacePtr; r, g, b: uint8): cint {. - importc: "SDL_SetSurfaceColorMod".} -proc setColorMod*(surface: SurfacePtr; r, g, b: uint8): cint {. - importc: "SDL_SetSurfaceColorMod".} +proc setSurfaceColorMod*(surface: SurfacePtr; r, g, b: uint8): SDL_Return {. + importc: "SDL_SetSurfaceColorMod", discardable.} +proc setColorMod*(surface: SurfacePtr; r, g, b: uint8): SDL_Return {. + importc: "SDL_SetSurfaceColorMod", discardable.} ## Set an additional color value used in blit operations. ## ## `surface` The surface to update. @@ -2598,10 +2598,10 @@ proc setColorMod*(surface: SurfacePtr; r, g, b: uint8): cint {. ## **See also:** ## * `getColorMod proc<#getColorMod,SurfacePtr,uint8,uint8,uint8>`_ -proc getSurfaceColorMod*(surface: SurfacePtr; r, g, b: var uint8): cint {. - importc: "SDL_GetSurfaceColorMod".} -proc getColorMod*(surface: SurfacePtr; r, g, b: var uint8): cint {. - importc: "SDL_GetSurfaceColorMod".} +proc getSurfaceColorMod*(surface: SurfacePtr; r, g, b: var uint8): SDL_Return {. + importc: "SDL_GetSurfaceColorMod", discardable.} +proc getColorMod*(surface: SurfacePtr; r, g, b: var uint8): SDL_Return {. + importc: "SDL_GetSurfaceColorMod", discardable.} ## Get the additional color value used in blit operations. ## ## `surface` The surface to query. @@ -2617,10 +2617,10 @@ proc getColorMod*(surface: SurfacePtr; r, g, b: var uint8): cint {. ## **See also:** ## * `setColorMod proc<#setColorMod,SurfacePtr,uint8,uint8,uint8>`_ -proc setSurfaceAlphaMod*(surface: SurfacePtr; alpha: uint8): cint {. - importc: "SDL_SetSurfaceAlphaMod".} -proc setAlphaMod*(surface: SurfacePtr; alpha: uint8): cint {. - importc: "SDL_SetSurfaceAlphaMod".} +proc setSurfaceAlphaMod*(surface: SurfacePtr; alpha: uint8): SDL_Return {. + importc: "SDL_SetSurfaceAlphaMod", discardable.} +proc setAlphaMod*(surface: SurfacePtr; alpha: uint8): SDL_Return {. + importc: "SDL_SetSurfaceAlphaMod", discardable.} ## Set an additional alpha value used in blit operations. ## ## `surface` The surface to update. @@ -2632,10 +2632,10 @@ proc setAlphaMod*(surface: SurfacePtr; alpha: uint8): cint {. ## **See also:** ## * `getAlphaMod proc<#getAlphaMod,SurfacePtr,uint8>`_ -proc getSurfaceAlphaMod*(surface: SurfacePtr; alpha: var uint8): cint {. - importc: "SDL_GetSurfaceAlphaMod".} -proc getAlphaMod*(surface: SurfacePtr; alpha: var uint8): cint {. - importc: "SDL_GetSurfaceAlphaMod".} +proc getSurfaceAlphaMod*(surface: SurfacePtr; alpha: var uint8): SDL_Return {. + importc: "SDL_GetSurfaceAlphaMod", discardable.} +proc getAlphaMod*(surface: SurfacePtr; alpha: var uint8): SDL_Return {. + importc: "SDL_GetSurfaceAlphaMod", discardable.} ## Get the additional alpha value used in blit operations. ## ## `surface` The surface to query. @@ -2647,10 +2647,10 @@ proc getAlphaMod*(surface: SurfacePtr; alpha: var uint8): cint {. ## **See also:** ## * `setAlphaMod proc<#setAlphaMod,SurfacePtr,uint8>`_ -proc setSurfaceBlendMode*(surface: SurfacePtr; blendMode: BlendMode): cint {. - importc: "SDL_SetSurfaceBlendMode".} -proc setBlendMode*(surface: SurfacePtr; blendMode: BlendMode): cint {. - importc: "SDL_SetSurfaceBlendMode".} +proc setSurfaceBlendMode*(surface: SurfacePtr; blendMode: BlendMode): SDL_Return {. + importc: "SDL_SetSurfaceBlendMode", discardable.} +proc setBlendMode*(surface: SurfacePtr; blendMode: BlendMode): SDL_Return {. + importc: "SDL_SetSurfaceBlendMode", discardable.} ## Set the blend mode used for blit operations. ## ## `surface` The surface to update. @@ -2662,10 +2662,10 @@ proc setBlendMode*(surface: SurfacePtr; blendMode: BlendMode): cint {. ## **See also:** ## * `getBlendMode proc<#getBlendMode,SurfacePtr,ptr.BlendMode>`_ -proc getSurfaceBlendMode*(surface: SurfacePtr; blendMode: ptr BlendMode): cint {. - importc: "SDL_GetSurfaceBlendMode".} -proc getBlendMode*(surface: SurfacePtr; blendMode: ptr BlendMode): cint {. - importc: "SDL_GetSurfaceBlendMode".} +proc getSurfaceBlendMode*(surface: SurfacePtr; blendMode: ptr BlendMode): SDL_Return {. + importc: "SDL_GetSurfaceBlendMode", discardable.} +proc getBlendMode*(surface: SurfacePtr; blendMode: ptr BlendMode): SDL_Return {. + importc: "SDL_GetSurfaceBlendMode", discardable.} ## Get the blend mode used for blit operations. ## ## `surface` The surface to query. @@ -2702,8 +2702,8 @@ proc getClipRect*(surface: SurfacePtr; rect: ptr Rect) {. proc getClipRect*(surface: SurfacePtr; rect: var Rect) {. importc: "SDL_GetClipRect".} -proc setClipRect*(renderer: RendererPtr; rect: ptr Rect): cint {. - importc: "SDL_RenderSetClipRect".} +proc setClipRect*(renderer: RendererPtr; rect: ptr Rect): SDL_Return {. + importc: "SDL_RenderSetClipRect", discardable.} ## Set the clip rectangle for the current target. ## ## `renderer` The renderer for which clip rectangle should be set. @@ -2716,10 +2716,10 @@ proc setClipRect*(renderer: RendererPtr; rect: ptr Rect): cint {. ## **See also:** ## * `getClipRect proc<#getClipRect,RendererPtr,ptr.Rect>`_ -proc setClipRect*(renderer: RendererPtr; rect: Rect): cint {.inline.} = +proc setClipRect*(renderer: RendererPtr; rect: Rect): SDL_Return {.inline, discardable.} = setClipRect(renderer, rect.unsafeAddr) -proc getClipRect*(renderer: RendererPtr; rect: ptr Rect): cint {. +proc getClipRect*(renderer: RendererPtr; rect: ptr Rect) {. importc: "SDL_RenderGetClipRect".} ## Get the clip rectangle for the current target. ## @@ -2731,10 +2731,10 @@ proc getClipRect*(renderer: RendererPtr; rect: ptr Rect): cint {. ## **See also:** ## * `setClipRect proc<#setClipRect,SurfacePtr,ptr.Rect>`_ -proc getClipRect*(renderer: RendererPtr; rect: var Rect): cint {. +proc getClipRect*(renderer: RendererPtr; rect: var Rect) {. importc: "SDL_RenderGetClipRect".} -proc isClipEnabled*(renderer: RendererPtr): cint {. +proc isClipEnabled*(renderer: RendererPtr): Bool32 {. importc: "SDL_RenderIsClipEnabled".} ## Get whether clipping is enabled on the given renderer. ## @@ -2766,8 +2766,8 @@ proc convert*(src: SurfacePtr; pixel_format, flags: uint32): SurfacePtr {.importc: "SDL_ConvertSurfaceFormat".} proc convertPixels*(width, height: cint; src_format: uint32; src: pointer; - src_pitch: cint; dst_format: uint32; dst: pointer; dst_pitch: cint): cint {. - importc: "SDL_ConvertPixels".} + src_pitch: cint; dst_format: uint32; dst: pointer; dst_pitch: cint): SDL_Return {. + importc: "SDL_ConvertPixels", discardable.} ## Copy a block of pixels of one format to another format. ## ## `Return` `0` on success, or `-1` if there was an error. @@ -2791,36 +2791,36 @@ proc fillRects*(dst: SurfacePtr; rects: openarray[Rect]; color: uint32): cint {. fillRects(dst, rects[0].unsafeAddr, rects.len.cint, color) proc upperBlit*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; - dstrect: ptr Rect): SDL_Return {.importc: "SDL_UpperBlit".} + dstrect: ptr Rect): SDL_Return {.importc: "SDL_UpperBlit", discardable.} ## This is the public blit procedure, `blitSurface()`, and it performs ## rectangle validation and clipping before passing it to `lowerBlit()`. proc upperBlit*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; - dstrect: Rect): SDL_Return {.inline.} = + dstrect: Rect): SDL_Return {.inline, discardable.} = ## This is the public blit procedure, `blitSurface()`, and it performs ## rectangle validation and clipping before passing it to `lowerBlit()`. upperBlit(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) proc lowerBlit*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; - dstrect: ptr Rect): SDL_Return {.importc: "SDL_LowerBlit".} + dstrect: ptr Rect): SDL_Return {.importc: "SDL_LowerBlit", discardable.} ## This is a semi-private blit procedure and it performs low-level surface ## blitting only. proc lowerBlit*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; - dstrect: Rect): SDL_Return {.inline.} = + dstrect: Rect): SDL_Return {.inline, discardable.} = ## This is a semi-private blit procedure and it performs low-level surface ## blitting only. lowerBlit(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) proc softStretch*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; - dstrect: ptr Rect): SDL_Return {.importc: "SDL_SoftStretch".} + dstrect: ptr Rect): SDL_Return {.importc: "SDL_SoftStretch", discardable.} ## Perform a fast, low quality, stretch blit between two surfaces of the ## same pixel format. ## ## **Note:** This procedure uses a static buffer, and is not thread-safe. proc softStretch*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; - dstrect: Rect): SDL_Return {.inline.} = + dstrect: Rect): SDL_Return {.inline, discardable.} = ## Perform a fast, low quality, stretch blit between two surfaces of the ## same pixel format. ## @@ -2828,25 +2828,25 @@ proc softStretch*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; softStretch(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) proc upperBlitScaled*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; - dstrect: ptr Rect): SDL_Return {.importc: "SDL_UpperBlitScaled".} + dstrect: ptr Rect): SDL_Return {.importc: "SDL_UpperBlitScaled", discardable.} ## This is the public scaled blit procedure, `blitScaled()`, ## and it performs rectangle validation and clipping before ## passing it to `lowerBlitScaled()`. proc upperBlitScaled*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; - dstrect: Rect): SDL_Return {.inline.} = + dstrect: Rect): SDL_Return {.inline, discardable.} = ## This is the public scaled blit procedure, `blitScaled()`, ## and it performs rectangle validation and clipping before ## passing it to `lowerBlitScaled()`. upperBlitScaled(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) proc lowerBlitScaled*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr; - dstrect: ptr Rect): SDL_Return {.importc: "SDL_LowerBlitScaled".} + dstrect: ptr Rect): SDL_Return {.importc: "SDL_LowerBlitScaled", discardable.} ## This is a semi-private blit procedure and it performs low-level surface ## scaled blitting only. proc lowerBlitScaled*(src: SurfacePtr; srcrect: Rect; dst: SurfacePtr; - dstrect: Rect): SDL_Return {.inline.} = + dstrect: Rect): SDL_Return {.inline, discardable.} = lowerBlitScaled(src, srcrect.unsafeAddr, dst, dstrect.unsafeAddr) proc readU8*(src: RWopsPtr): uint8 {.importc: "SDL_ReadU8".} @@ -2865,7 +2865,7 @@ proc writeLE64*(dst: RWopsPtr; value: uint64): csize_t {.importc: "SDL_WriteLE64 proc writeBE64*(dst: RWopsPtr; value: uint64): csize_t {.importc: "SDL_WriteBE64".} proc showMessageBox*(messageboxdata: ptr MessageBoxData; - buttonid: var cint): cint {.importc: "SDL_ShowMessageBox".} + buttonid: var cint): SDL_Return {.importc: "SDL_ShowMessageBox", discardable.} ## Create a modal message box. ## ## `messageboxdata` The `MessageBoxData` object with title, text, etc. @@ -2881,7 +2881,7 @@ proc showMessageBox*(messageboxdata: ptr MessageBoxData; ## closes the messagebox. proc showSimpleMessageBox*(flags: uint32; title, message: cstring; - window: WindowPtr): cint {.importc: "SDL_ShowSimpleMessageBox".} + window: WindowPtr): SDL_Return {.importc: "SDL_ShowSimpleMessageBox", discardable.} ## Create a simple modal message box. ## ## `flags` `MessageBoxFlags` @@ -2914,7 +2914,7 @@ proc getVideoDriver*(index: cint): cstring {.importc: "SDL_GetVideoDriver".} ## **See also:** ## * `getNumVideoDrivers proc<#getNumVideoDrivers>`_ -proc videoInit*(driver_name: cstring): SDL_Return {.importc: "SDL_VideoInit".} +proc videoInit*(driver_name: cstring): SDL_Return {.importc: "SDL_VideoInit", discardable.} ## Initialize the video subsystem, optionally specifying a video driver. ## ## `driver_name` Initialize a specific driver by name, or `nil` for the @@ -2954,7 +2954,7 @@ proc getNumVideoDisplays*(): cint {.importc: "SDL_GetNumVideoDisplays".} ## * `getDisplayBounds proc<#getDisplayBounds,cint,Rect>`_ proc getDisplayBounds*(displayIndex: cint; rect: var Rect): SDL_Return {. - importc: "SDL_GetDisplayBounds".} + importc: "SDL_GetDisplayBounds", discardable.} ## Get the desktop area represented by a display, ## with the primary display located at `0,0`. ## @@ -3020,7 +3020,7 @@ proc getClosestDisplayMode*(displayIndex: cint; mode: ptr DisplayMode; ## * `getDisplayMode proc<#getDisplayMode,WindowPtr,DisplayMode>`_ proc getDisplayDPI*(displayIndex: cint; - ddpi, hdpi, vdpi: ptr cfloat): SDL_Return {.importc: "SDL_GetDisplayDPI".} + ddpi, hdpi, vdpi: ptr cfloat): SDL_Return {.importc: "SDL_GetDisplayDPI", discardable.} ## Get the dots/pixels-per-inch for a display. ## ## **Note:** Diagonal, horizontal and vertical DPI can all be optionally @@ -3232,21 +3232,21 @@ proc glUnloadLibrary* {.importc: "SDL_GL_UnloadLibrary".} ## **See also:** ## * `glLoadLibrary proc<#glLoadLibrary,cstring>`_ -proc glExtensionSupported*(extension: cstring): bool {. +proc glExtensionSupported*(extension: cstring): Bool32 {. importc: "SDL_GL_ExtensionSupported".} ## `Return` `true` if an OpenGL extension is supported ## for the current context. -proc glSetAttribute*(attr: GLattr; value: cint): cint {. - importc: "SDL_GL_SetAttribute".} +proc glSetAttribute*(attr: GLattr; value: cint): SDL_Return {. + importc: "SDL_GL_SetAttribute", discardable.} ## Set an OpenGL window attribute before window creation. ## ## `Return` `0` on success, or `-1` if the attribute could not be set. -proc glGetAttribute*(attr: GLattr; value: var cint): cint {. - importc: "SDL_GL_GetAttribute".} +proc glGetAttribute*(attr: GLattr; value: var cint): SDL_Return {. + importc: "SDL_GL_GetAttribute", discardable.} ## Get the actual value for an attribute from the current context. ## ## `Return` `0` on success, @@ -3294,8 +3294,8 @@ proc glGetDrawableSize*(window: WindowPtr; w,h: var cint) {. ## * `createWindow proc<#createWindow,cstring,cint,cint,cint,cint,uint32>`_ # TODO: Add `HINT_VIDEO_HIGHDPI_DISABLED` -proc glSetSwapInterval*(interval: cint): cint {. - importc: "SDL_GL_SetSwapInterval".} +proc glSetSwapInterval*(interval: cint): SDL_Return {. + importc: "SDL_GL_SetSwapInterval", discardable.} ## Set the swap interval for the current OpenGL context. ## ## `interval` `0` for immediate updates, `1` for updates synchronized @@ -3339,8 +3339,8 @@ type VulkanInstance* = VkHandle type VulkanSurface* = VkNonDispatchableHandle -proc vulkanLoadLibrary*(path: cstring): cint {. - importc: "SDL_Vulkan_LoadLibrary".} +proc vulkanLoadLibrary*(path: cstring): SDL_Return {. + importc: "SDL_Vulkan_LoadLibrary", discardable.} ## Dynamically load a Vulkan loader library. ## ## `path` The platform dependent Vulkan loader library name, or `nil`. @@ -3589,7 +3589,7 @@ proc startTextInput* {.importc: "SDL_StartTextInput".} ## * `setTextInputRect proc<#setTextInputRect,ptr.Rect>`_ ## * `hasScreenKeyboardSupport proc<#hasScreenKeyboardSupport>`_ -proc isTextInputActive*: bool {.importc: "SDL_IsTextInputActive".} +proc isTextInputActive*: Bool32 {.importc: "SDL_IsTextInputActive".} ## Return whether or not Unicode text input events are enabled. ## ## **See also:** @@ -3613,7 +3613,7 @@ proc setTextInputRect*(rect: ptr Rect) {.importc: "SDL_SetTextInputRect".} ## **See also:** ## * `startTextInput proc<#startTextInput>`_ -proc hasScreenKeyboardSupport*: bool {.importc: "SDL_HasScreenKeyboardSupport".} +proc hasScreenKeyboardSupport*: Bool32 {.importc: "SDL_HasScreenKeyboardSupport".} ## Returns whether the platform has some screen keyboard support. ## ## `Return` `true` if some keyboard support is available else `false`. @@ -3624,7 +3624,7 @@ proc hasScreenKeyboardSupport*: bool {.importc: "SDL_HasScreenKeyboardSupport".} ## **See also:** ## * `isScreenKeyboardShown proc<#isScreenKeyboardShown,WindowPtr>`_ -proc isScreenKeyboardShown*(window: WindowPtr): bool {.importc: "SDL_IsScreenKeyboardShown".} +proc isScreenKeyboardShown*(window: WindowPtr): Bool32 {.importc: "SDL_IsScreenKeyboardShown".} ## Returns whether the screen keyboard is shown for given window. ## ## `window` The window for which screen keyboard should be queried. @@ -3673,7 +3673,7 @@ proc warpMouse*(window: WindowPtr; x, y: cint) {. ## **Note:** This procedure generates a mouse motion event. proc setRelativeMouseMode*(enabled: Bool32): SDL_Return {. - importc: "SDL_SetRelativeMouseMode".} + importc: "SDL_SetRelativeMouseMode", discardable.} ## Set relative mouse mode. ## ## `enabled` Whether or not to enable relative mode @@ -3691,7 +3691,7 @@ proc setRelativeMouseMode*(enabled: Bool32): SDL_Return {. ## * `getRelativeMouseMode proc<#getRelativeMouseMode>`_ proc captureMouse*(enabled: Bool32): SDL_Return {. - importc: "SDL_CaptureMouse" .} + importc: "SDL_CaptureMouse", discardable.} ## Capture the mouse, to track input outside an SDL window. ## ## `enabled` Whether or not to enable capturing @@ -3965,7 +3965,7 @@ proc getPixelFormatName*(format: uint32): cstring {. ## Get the human readable name of a pixel format proc pixelFormatEnumToMasks*(format: uint32; bpp: var cint; - Rmask, Gmask, Bmask, Amask: var uint32): bool {. + Rmask, Gmask, Bmask, Amask: var uint32): Bool32 {. importc: "SDL_PixelFormatEnumToMasks".} ## Convert one of the enumerated pixel formats to a bpp and RGBA masks. ## Returns `true` or `false` if the conversion wasn't possible. @@ -4096,18 +4096,18 @@ elif defined(iPhone) or defined(ios): callback: VoidCallback, callbackParam: pointer): cint {. importc: "SDL_iPhoneSetAnimationCallback".} - proc iPhoneSetEventPump*(enabled: bool) {.importc: "SDL_iPhoneSetEventPump".} + proc iPhoneSetEventPump*(enabled: Bool32) {.importc: "SDL_iPhoneSetEventPump".} - proc iPhoneKeyboardShow*(window:WindowPtr): cint {. + proc iPhoneKeyboardShow*(window: WindowPtr): cint {. importc: "SDL_iPhoneKeyboardShow".} - proc iPhoneKeyboardHide*(window:WindowPtr): cint {. + proc iPhoneKeyboardHide*(window: WindowPtr): cint {. importc: "SDL_iPhoneKeyboardHide".} - proc iPhoneKeyboardIsShown*(window:WindowPtr): bool {. + proc iPhoneKeyboardIsShown*(window: WindowPtr): Bool32 {. importc: "SDL_iPhoneKeyboardIsShown".} - proc iPhoneKeyboardToggle*(window:WindowPtr): cint {. + proc iPhoneKeyboardToggle*(window: WindowPtr): cint {. importc: "SDL_iPhoneKeyboardToggle".} elif defined(android): @@ -4218,12 +4218,12 @@ const ## ## By default nearest pixel sampling is used. -proc setHint*(name: cstring, value: cstring): bool {.importc: "SDL_SetHint".} +proc setHint*(name: cstring, value: cstring): Bool32 {.importc: "SDL_SetHint".} ## Set a hint with normal priority. ## ## `Return` `true` if the hint was set, `false` otherwise. -proc setHintWithPriority*(name: cstring, value: cstring, priority: cint): bool {. +proc setHintWithPriority*(name: cstring, value: cstring, priority: cint): Bool32 {. importc: "SDL_SetHintWithPriority".} ## Set a hint with a specific priority. ## @@ -4264,7 +4264,7 @@ proc write*(ctx: RWopsPtr; `ptr`: pointer; size, num: csize_t): csize_t {.inline ## `Return` the number of objects written, or `0` at error or end of file. ctx.write(ctx, `ptr`, size, num) -proc close*(ctx: RWopsPtr): cint {.inline.} = +proc close*(ctx: RWopsPtr): SDL_Return {.inline, discardable.} = ## Close and free an allocated `sdl.RWops` object. ## ## `Return` `0` if successful or `-1` on write error when flushing data. diff --git a/src/sdl2/audio.nim b/src/sdl2/audio.nim index 6ac6f10..e18f04d 100644 --- a/src/sdl2/audio.nim +++ b/src/sdl2/audio.nim @@ -317,8 +317,8 @@ proc getCurrentAudioDriver*(): cstring {.importc: "SDL_GetCurrentAudioDriver".} ## This procedure returns the name of the current audio driver, or `nil` ## if no driver has been initialized. -proc openAudio*(desired: ptr AudioSpec; obtained: ptr AudioSpec): cint {. - importc: "SDL_OpenAudio".} +proc openAudio*(desired: ptr AudioSpec; obtained: ptr AudioSpec): SDL_Return {. + importc: "SDL_OpenAudio", discardable.} ## This procedure opens the audio device with the desired parameters, and ## returns `0` if successful, placing the actual hardware parameters in the ## object pointed to by `obtained`. If `obtained` is `nil`, the audio @@ -457,8 +457,8 @@ proc getQueuedAudioSize*(dev: AudioDeviceID): uint32 {. ## **See also:** ## * `queueAudio proc<#queueAudio,AudioDeviceID,pointer,uint32>`_ -proc queueAudio*(dev: AudioDeviceID, data: pointer, len: uint32): cint {. - importc: "SDL_QueueAudio".} +proc queueAudio*(dev: AudioDeviceID, data: pointer, len: uint32): SDL_Return {. + importc: "SDL_QueueAudio", discardable.} ## Queue more audio on non-callback devices. ## ## (If you are looking to retrieve queued audio from a non-callback capture @@ -654,7 +654,7 @@ proc buildAudioCVT*(cvt: ptr AudioCVT; src_format: AudioFormat; ## `Return` `0` if no conversion is needed, ## `1` if the audio filter is set up, or `-1` on error. -proc convertAudio*(cvt: ptr AudioCVT): cint {.importc: "SDL_ConvertAudio".} +proc convertAudio*(cvt: ptr AudioCVT): SDL_Return {.importc: "SDL_ConvertAudio", discardable.} ## Once you have initialized the `cvt` object using `buildAudioCVT()`, ## created an audio buffer `cvt.buf`, and filled it with `cvt.len` bytes ## of audio data in the source format, this procedure will convert it @@ -757,7 +757,7 @@ proc newAudioStream*(srcSpec, destSpec: AudioSpec): AudioStreamPtr = proc put*( stream: AudioStreamPtr, buf: pointer, - len: cint): cint {.importc: "SDL_AudioStreamPut".} + len: cint): SDL_Return {.importc: "SDL_AudioStreamPut", discardable.} ## (Available since SDL 2.0.7) ## Add data to be converted/resampled to the stream.Returns 0 on success, or -1 on error. ## @@ -798,7 +798,7 @@ proc available*(stream: AudioStreamPtr): cint {. ## **See also:** ## * `AudioStreamPtr type<#AudioStreamPtr>`_ -proc flush*(stream: AudioStreamPtr): cint {.importc: "SDL_AudioStreamFlush".} +proc flush*(stream: AudioStreamPtr): SDL_Return {.importc: "SDL_AudioStreamFlush", discardable.} ## (Available since SDL 2.0.7) ## Tell the stream that you're done sending data, and anything being buffered ## should be converted/resampled and made available immediately. Returns 0 diff --git a/src/sdl2/gfx.nim b/src/sdl2/gfx.nim index ada70b9..843fab2 100644 --- a/src/sdl2/gfx.nim +++ b/src/sdl2/gfx.nim @@ -658,7 +658,7 @@ proc gfxPrimitivesSetFontRotation*(rotation: uint32) {.importc.} ## `rotation` Number of 90deg clockwise steps to rotate. proc characterColor*(renderer: RendererPtr; x: int16; y: int16; - c: char; color: uint32): SDL_Return {.importc.} + c: char; color: uint32): SDL_Return {.importc, discardable.} ## Draw a character of the currently set font. ## ## `x`, `y` Coordinates of the upper left corner of the character. @@ -666,7 +666,7 @@ proc characterColor*(renderer: RendererPtr; x: int16; y: int16; ## `c` The character to draw. proc characterRGBA*(renderer: RendererPtr; x: int16; y: int16; c: char; - r, g, b, a: uint8): SDL_Return {.importc.} + r, g, b, a: uint8): SDL_Return {.importc, discardable.} ## Draw a character of the currently set font. ## ## `x`, `y` Coordinates of the upper left corner of the character. @@ -674,7 +674,7 @@ proc characterRGBA*(renderer: RendererPtr; x: int16; y: int16; c: char; ## `c` The character to draw. proc stringColor*(renderer: RendererPtr; x: int16; y: int16; - s: cstring; color: uint32): SDL_Return {.importc.} + s: cstring; color: uint32): SDL_Return {.importc, discardable.} ## Draw a string in the currently set font. ## ## `x`, `y` Coordinates of the upper left corner of the string. diff --git a/src/sdl2/haptic.nim b/src/sdl2/haptic.nim index b43b051..c5a6d69 100644 --- a/src/sdl2/haptic.nim +++ b/src/sdl2/haptic.nim @@ -861,7 +861,7 @@ proc newEffect*(haptic: HapticPtr, effect: ptr HapticEffect): cint {. ## * `destroyEffect proc<#destroyEffect,HapticPtr,cint>`_ proc updateEffect*(haptic: HapticPtr, effect: cint, - data: ptr HapticEffect): cint {.importc: "SDL_HapticUpdateEffect".} + data: ptr HapticEffect): SDL_Return {.importc: "SDL_HapticUpdateEffect", discardable.} ## Updates the properties of an effect. ## ## Can be used dynamically, although behavior when dynamically changing @@ -883,7 +883,7 @@ proc updateEffect*(haptic: HapticPtr, effect: cint, ## * `destroyEffect proc<#destroyEffect,HapticPtr,cint>`_ proc runEffect*(haptic: HapticPtr, effect: cint, - iterations: uint32): cint {.importc: "SDL_HapticRunEffect".} + iterations: uint32): SDL_Return {.importc: "SDL_HapticRunEffect", discardable.} ## Runs the haptic effect on its associated haptic device. ## ## If iterations are `HAPTIC_INFINITY`, it'll run the effect over and over @@ -906,7 +906,7 @@ proc runEffect*(haptic: HapticPtr, effect: cint, ## * `getEffectStatus proc<#getEffectStatus,HapticPtr,cint>`_ proc stopEffect*(haptic: HapticPtr, - effect: cint): cint {.importc: "SDL_HapticStopEffect".} + effect: cint): SDL_Return {.importc: "SDL_HapticStopEffect", discardable.} ## Stops the haptic effect on its associated haptic device. ## ## `haptic` Haptic device to stop the effect on. @@ -951,7 +951,7 @@ proc getEffectStatus*(haptic: HapticPtr, effect: cint): cint {. ## * `stopEffect proc<#stopEffect,HapticPtr,cint>`_ proc setGain*(haptic: HapticPtr, - gain: int): cint {.importc: "SDL_HapticSetGain".} + gain: int): SDL_Return {.importc: "SDL_HapticSetGain", discardable.} ## Sets the global gain of the device. ## ## Device must support the `HAPTIC_GAIN` feature. @@ -970,8 +970,8 @@ proc setGain*(haptic: HapticPtr, ## **See also:** ## * `query proc<#query,HapticPtr>`_ -proc setAutocenter*(haptic: HapticPtr, autocenter: int): cint {. - importc: "SDL_HapticSetAutocenter".} +proc setAutocenter*(haptic: HapticPtr, autocenter: int): SDL_Return {. + importc: "SDL_HapticSetAutocenter", discardable.} ## Sets the global autocenter of the device. ## ## Autocenter should be between `0` and `100`. @@ -988,7 +988,7 @@ proc setAutocenter*(haptic: HapticPtr, autocenter: int): cint {. ## **See also:** ## * `query proc<#query,HapticPtr>`_ -proc pause*(haptic: HapticPtr): cint {.importc: "SDL_HapticPause".} +proc pause*(haptic: HapticPtr): SDL_Return {.importc: "SDL_HapticPause", discardable.} ## Pauses a haptic device. ## ## Device must support the `HAPTIC_PAUSE` feature. @@ -1004,7 +1004,7 @@ proc pause*(haptic: HapticPtr): cint {.importc: "SDL_HapticPause".} ## **See also:** ## * `unpause proc<#unpause,HapticPtr>`_ -proc unpause*(haptic: HapticPtr): cint {.importc: "SDL_HapticUnpause".} +proc unpause*(haptic: HapticPtr): SDL_Return {.importc: "SDL_HapticUnpause", discardable.} ## Unpauses a haptic device. ## ## Call to unpause after `pause()`. @@ -1016,7 +1016,7 @@ proc unpause*(haptic: HapticPtr): cint {.importc: "SDL_HapticUnpause".} ## **See also:** ## * `pause proc<#pause,HapticPtr>`_ -proc stopAll*(haptic: HapticPtr): cint {.importc: "SDL_HapticStopAll".} +proc stopAll*(haptic: HapticPtr): SDL_Return {.importc: "SDL_HapticStopAll", discardable.} ## Stops all the currently playing effects on a haptic device. ## ## `haptic` Haptic device to stop. @@ -1037,7 +1037,7 @@ proc rumbleSupported*(haptic: HapticPtr): cint {. ## * `rumblePlay proc<#rumblePlay,HapticPtr,float,uint32>`_ ## * `rumbleStop proc<#rumbleStop,HapticPtr>`_ -proc rumbleInit*(haptic: HapticPtr): cint {.importc: "SDL_HapticRumbleInit".} +proc rumbleInit*(haptic: HapticPtr): SDL_Return {.importc: "SDL_HapticRumbleInit", discardable.} ## Initializes the haptic device for simple rumble playback. ## ## `haptic` Haptic device to initialize for simple rumble playback. @@ -1050,8 +1050,8 @@ proc rumbleInit*(haptic: HapticPtr): cint {.importc: "SDL_HapticRumbleInit".} ## * `rumblePlay proc<#rumblePlay,HapticPtr,float,uint32>`_ ## * `rumbleStop proc<#rumbleStop,HapticPtr>`_ -proc rumblePlay*(haptic: HapticPtr, strength: float, length: uint32): cint {. - importc: "SDL_HapticRumblePlay".} +proc rumblePlay*(haptic: HapticPtr, strength: float, length: uint32): SDL_Return {. + importc: "SDL_HapticRumblePlay", discardable.} ## Runs simple rumble on a haptic device ## ## `haptic` Haptic device to play rumble effect on. @@ -1067,7 +1067,7 @@ proc rumblePlay*(haptic: HapticPtr, strength: float, length: uint32): cint {. ## * `rumbleInit proc<#rumbleInit,HapticPtr>`_ ## * `rumbleStop proc<#rumbleStop,HapticPtr>`_ -proc rumbleStop*(haptic: HapticPtr):cint {.importc: "SDL_HapticRumbleStop".} +proc rumbleStop*(haptic: HapticPtr): SDL_Return {.importc: "SDL_HapticRumbleStop", discardable.} ## Stops the simple rumble on a haptic device. ## ## `haptic` Haptic to stop the rumble on. diff --git a/src/sdl2/image.nim b/src/sdl2/image.nim index 7453e84..38313a0 100644 --- a/src/sdl2/image.nim +++ b/src/sdl2/image.nim @@ -114,13 +114,13 @@ proc loadXCF*(src: RWopsPtr): SurfacePtr {.importc: "IMG_LoadXCF_RW".} proc loadXPM_RW*(src: RWopsPtr): SurfacePtr {.importc: "IMG_LoadXPM_RW".} proc loadXPM*(src: RWopsPtr): SurfacePtr {.importc: "IMG_LoadXPM_RW".} proc loadXV_RW*(src: RWopsPtr): SurfacePtr {.importc: "IMG_LoadXV_RW".} -proc loadXV(src: RWopsPtr): SurfacePtr {.importc: "IMG_LoadXV_RW".} +proc loadXV*(src: RWopsPtr): SurfacePtr {.importc: "IMG_LoadXV_RW".} proc loadWEBP_RW*(src: RWopsPtr): SurfacePtr {.importc: "IMG_LoadWEBP_RW".} proc loadWEBP*(src: RWopsPtr): SurfacePtr {.importc: "IMG_LoadWEBP_RW".} proc readXPMFromArray*(xpm: cstringArray): SurfacePtr {.importc: "IMG_ReadXPMFromArray".} proc readXPM*(xpm: cstringArray): SurfacePtr {.importc: "IMG_ReadXPMFromArray".} # Saving functions -proc savePNG*(surface: SurfacePtr, file: cstring): cint {.importc: "IMG_SavePNG".} +proc savePNG*(surface: SurfacePtr, file: cstring): SDL_Return {.importc: "IMG_SavePNG", discardable.} when not defined(SDL_Static): {.pop.} diff --git a/src/sdl2/joystick.nim b/src/sdl2/joystick.nim index 912f04b..f56f720 100644 --- a/src/sdl2/joystick.nim +++ b/src/sdl2/joystick.nim @@ -258,15 +258,15 @@ proc getHat*(joystick: JoystickPtr, hat: cint): uint8 {.inline.} = ## * SDL_HAT_LEFTDOWN joystick.joystickGetHat(hat) -proc joystickGetBall*(joystick: JoystickPtr, ball: cint, dx: ptr cint, dy: ptr cint): cint {. - importc: "SDL_JoystickGetBall".} +proc joystickGetBall*(joystick: JoystickPtr, ball: cint, dx: ptr cint, dy: ptr cint): SDL_Return {. + importc: "SDL_JoystickGetBall", discardable.} ## Get the ball axis change since the last poll. ## ## `Return` `0`, or `-1` if you passed it invalid parameters. ## ## The ball indices start at index `0`. -proc getBall*(joystick: JoystickPtr, ball: cint, dx: ptr cint, dy: ptr cint): cint {.inline.} = +proc getBall*(joystick: JoystickPtr, ball: cint, dx: ptr cint, dy: ptr cint): SDL_Return {.inline, discardable.} = ## Get the ball axis change since the last poll. ## ## `Return` `0`, or `-1` if you passed it invalid parameters. diff --git a/src/sdl2/mixer.nim b/src/sdl2/mixer.nim index 31ae898..df1a25b 100644 --- a/src/sdl2/mixer.nim +++ b/src/sdl2/mixer.nim @@ -189,7 +189,7 @@ type # Open the mixer with a certain audio format proc openAudio*(frequency: cint; format: uint16; channels: cint; - chunksize: cint): cint {.importc: "Mix_OpenAudio".} + chunksize: cint): SDL_Return {.importc: "Mix_OpenAudio", discardable.} ## Open the mixer with a certain audio format. ## ## `frequency` Output sampling frequency in samples per second (Hz). @@ -1084,8 +1084,8 @@ template playChannel*(channel, chunk, loops: untyped): untyped = ## On any errors, `-1` is returned. playChannelTimed(channel, chunk, loops, - 1) -proc playMusic*(music: ptr Music; loops: cint): cint {.importc: "Mix_PlayMusic".} -proc play*(music: ptr Music; loops: cint): cint {.importc: "Mix_PlayMusic".} +proc playMusic*(music: ptr Music; loops: cint): SDL_Return {.importc: "Mix_PlayMusic", discardable.} +proc play*(music: ptr Music; loops: cint): SDL_Return {.importc: "Mix_PlayMusic", discardable.} ## Play the loaded `music` `loops` times through from start to finish. ## ## `music` Pointer to `mixer.Music` to play. @@ -1099,10 +1099,10 @@ proc play*(music: ptr Music; loops: cint): cint {.importc: "Mix_PlayMusic".} ## ## `Return` `0` on success, or `-1` on errors. -proc fadeInMusic*(music: ptr Music; loops: cint; ms: cint): cint {. - importc: "Mix_FadeInMusic".} -proc fadeIn*(music: ptr Music; loops: cint; ms: cint): cint {. - importc: "Mix_FadeInMusic".} +proc fadeInMusic*(music: ptr Music; loops: cint; ms: cint): SDL_Return {. + importc: "Mix_FadeInMusic", discardable.} +proc fadeIn*(music: ptr Music; loops: cint; ms: cint): SDL_Return {. + importc: "Mix_FadeInMusic", discardable.} ## Fade in over `ms` milliseconds of time, the loaded `music`, ## playing it `loops` times through from start to finish. ## @@ -1123,9 +1123,9 @@ proc fadeIn*(music: ptr Music; loops: cint; ms: cint): cint {. ## `Return` `0` on success, or `-1` on errors. proc fadeInMusicPos*(music: ptr Music; loops: cint; ms: cint; - position: cdouble): cint {.importc: "Mix_FadeInMusicPos".} + position: cdouble): SDL_Return {.importc: "Mix_FadeInMusicPos", discardable.} proc fadeInPos*(music: ptr Music; loops: cint; ms: cint; - position: cdouble): cint {.importc: "Mix_FadeInMusicPos".} + position: cdouble): SDL_Return {.importc: "Mix_FadeInMusicPos", discardable.} ## Fade in over `ms` milliseconds of time, the loaded `music`, ## playing it `loops` times through from start to finish. ## @@ -1444,8 +1444,8 @@ proc pausedMusic*(): cint {.importc: "Mix_PausedMusic".} ## ## `Return` `0` if music is not paused. `1` if it is paused. -proc setMusicPosition*(position: cdouble): cint {. - importc: "Mix_SetMusicPosition".} +proc setMusicPosition*(position: cdouble): SDL_Return {. + importc: "Mix_SetMusicPosition", discardable.} ## Set the current `position` in the music stream. ## ## `position` Posistion to play from. @@ -1493,7 +1493,7 @@ proc playingMusic*(): cint {.importc: "Mix_PlayingMusic".} ## ## `Return` `0` if the music is not playing, or `1` if it is playing. -proc setMusicCMD*(command: cstring): cint {.importc: "Mix_SetMusicCMD".} +proc setMusicCMD*(command: cstring): SDL_Return {.importc: "Mix_SetMusicCMD", discardable.} ## Stop music and set external music playback command. ## ## `command` System command to play the music. diff --git a/src/sdl2/net.nim b/src/sdl2/net.nim index 58a9962..cada3e5 100644 --- a/src/sdl2/net.nim +++ b/src/sdl2/net.nim @@ -160,8 +160,8 @@ proc quit*() {.importc: "SDLNet_Quit".} # IPv4 hostname resolution API #********************************************************************* -proc resolveHost*(address: ptr IpAddress; host: cstring; port: uint16): cint {. - importc: "SDLNet_ResolveHost".} +proc resolveHost*(address: ptr IpAddress; host: cstring; port: uint16): SDL_Return {. + importc: "SDLNet_ResolveHost", discardable.} ## Resolve a host name and port to an IP address in network form. ## ## `address` points to the `IPaddress` that will be filled in. diff --git a/src/sdl2/ttf.nim b/src/sdl2/ttf.nim index 9f9701f..4defde3 100644 --- a/src/sdl2/ttf.nim +++ b/src/sdl2/ttf.nim @@ -130,7 +130,7 @@ proc fontFaceIsFixedWidth*(font: FontPtr): cint {.importc: "TTF_FontFaceIsFixedW proc fontFaceFamilyName*(font: FontPtr): cstring {.importc: "TTF_FontFaceFamilyName".} proc fontFaceStyleName*(font: FontPtr): cstring {.importc: "TTF_FontFaceStyleName".} -proc glyphIsProvided*(font: FontPtr; ch: uint16): cint {. +proc glyphIsProvided*(font: FontPtr; ch: uint16): Bool32 {. importc: "TTF_GlyphIsProvided".} ## Check wether a glyph is provided by the font or not. @@ -269,7 +269,7 @@ proc close*(font: FontPtr) {.importc: "TTF_CloseFont".} proc ttfQuit*() {.importc: "TTF_Quit".} ## De-initialize the TTF engine. -proc ttfWasInit*(): bool {.importc: "TTF_WasInit".} +proc ttfWasInit*(): Bool32 {.importc: "TTF_WasInit".} ## Check if the TTF engine is initialized. proc getFontKerningSize*(font: FontPtr; prev_index, indx: cint): cint {. From 309cd0c8fd5af6e4bb8f810f5e7849c2d3b44907 Mon Sep 17 00:00:00 2001 From: AmjadHD Date: Thu, 16 Nov 2023 21:54:18 +0100 Subject: [PATCH 3/4] More --- src/sdl2.nim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sdl2.nim b/src/sdl2.nim index e4ce8b2..1d35850 100644 --- a/src/sdl2.nim +++ b/src/sdl2.nim @@ -1039,7 +1039,7 @@ type ## `Return` the number of objects written, ## or `0` at error or end of file. - close*: proc (context: RWopsPtr): cint {.cdecl, tags: [WriteIOEffect].} + close*: proc (context: RWopsPtr): SDL_Return {.cdecl, tags: [WriteIOEffect].} ## Close and free an allocated RWops object. ## ## `Return` `0` if successful, @@ -1373,7 +1373,7 @@ proc updateSurface*(window: WindowPtr): SDL_Return {.importc: "SDL_UpdateWindow ## * `updateSurfaceRects proc<#updateSurfaceRects,WindowPtr,ptr.Rect,cint>`_ proc updateSurfaceRects*(window: WindowPtr; rects: ptr Rect; - numrects: cint): SDL_Return {.importc: "SDL_UpdateWindowSurfaceRects", discardable.} + numrects: cint): SDL_Return {.importc: "SDL_UpdateWindowSurfaceRects", discardable.} ## Copy a number of rectangles on the window surface to the screen. ## ## `Return` `0` on success, or `-1` on error. @@ -1381,6 +1381,10 @@ proc updateSurfaceRects*(window: WindowPtr; rects: ptr Rect; ## **See also:** ## * `getSurface proc<#getSurface,WindowPtr>`_ ## * `updateSurface proc<#updateSurface,WindowPtr>`_ +proc updateSurfaceRects*(window: WindowPtr; + rects: openarray[Rect]): SDL_Return {.inline, discardable.} = + ## Copy a number of rectangles on the window surface to the screen. + updateSurfaceRects(window, rects[0].unsafeAddr, rects.len.cint) proc setGrab*(window: WindowPtr; grabbed: Bool32) {.importc: "SDL_SetWindowGrab".} ## Set a window's input grab mode. @@ -1694,10 +1698,16 @@ proc getRenderer*(window: WindowPtr): RendererPtr {. proc getRendererInfo*(renderer: RendererPtr; info: RendererInfoPtr): cint {. importc: "SDL_GetRendererInfo".} ## Get information about a rendering context. +proc getInfo*(renderer: RendererPtr; info: RendererInfoPtr): cint {. + importc: "SDL_GetRendererInfo".} + ## Get information about a rendering context. proc getRendererOutputSize*(renderer: RendererPtr, w: ptr cint, h: ptr cint): cint {. importc: "SDL_GetRendererOutputSize".} ## Get the output size in pixels of a rendering context. +proc getOutputSize*(renderer: RendererPtr, w: ptr cint, h: ptr cint): cint {. + importc: "SDL_GetRendererOutputSize".} + ## Get the output size in pixels of a rendering context. proc createTexture*(renderer: RendererPtr; format: uint32; access, w, h: cint): TexturePtr {.importc: "SDL_CreateTexture".} From 350bec5b163d0e5b5ae942f05c343191fd8a81c1 Mon Sep 17 00:00:00 2001 From: AmjadHD Date: Sat, 18 Nov 2023 13:23:46 +0100 Subject: [PATCH 4/4] Fix --- src/sdl2.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl2.nim b/src/sdl2.nim index 1d35850..62a264f 100644 --- a/src/sdl2.nim +++ b/src/sdl2.nim @@ -607,6 +607,7 @@ const # WindowFlags converter toBool*(some: Bool32): bool = bool(some) converter toBool*(some: SDL_Return): bool = some == SdlSuccess +converter toCint*(some: SDL_Return): cint = some.cint converter toCint*(some: TextureAccess): cint = some.cint # pixel format flags