diff options
Diffstat (limited to 'tests/manyloc/keineschweine/dependencies/sfml')
5 files changed, 2049 insertions, 0 deletions
diff --git a/tests/manyloc/keineschweine/dependencies/sfml/README.md b/tests/manyloc/keineschweine/dependencies/sfml/README.md new file mode 100644 index 000000000..bd9b3d0e7 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/README.md @@ -0,0 +1,13 @@ +sfml-nimrod +=========== + +Nimrod binding of SFML 2.0 + +This is only tested for Linux at the moment + +### What is needed for Windows / OS X? + +* The library names need filling in +* TWindowHandle is handled differently on those platforms + +I believe that is it diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim new file mode 100644 index 000000000..0060bf12b --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim @@ -0,0 +1,1121 @@ +import + strutils, math +when defined(linux): + const + LibG = "libcsfml-graphics.so.2.0" + LibS = "libcsfml-system.so.2.0" + LibW = "libcsfml-window.so.2.0" +else: + # We only compile for testing here, so it doesn't matter it's not supported + const + LibG = "libcsfml-graphics.so.2.0" + LibS = "libcsfml-system.so.2.0" + LibW = "libcsfml-window.so.2.0" + #{.error: "Platform unsupported".} + +{.pragma: pf, pure, final.} +type + PClock* = ptr TClock + TClock* {.pf.} = object + TTime* {.pf.} = object + microseconds*: int64 + TVector2i* {.pf.} = object + x*, y*: cint + TVector2f* {.pf.} = object + x*, y*: cfloat + TVector3f* {.pf.} = object + x*, y*, z*: cfloat + + PInputStream* = ptr TInputStream + TInputStream* {.pf.} = object + read*: TInputStreamReadFunc + seek*: TInputStreamSeekFunc + tell*: TInputStreamTellFunc + getSize*: TInputStreamGetSizeFunc + userData*: pointer + TInputStreamReadFunc* = proc (data: pointer, size: int64, userData: pointer): int64{. + cdecl.} + TInputStreamSeekFunc* = proc (position: int16, userData: pointer): int64{. + cdecl.} + TInputStreamTellFunc* = proc (userData: pointer): int64 {.cdecl.} + TInputStreamGetSizeFunc* = proc (userData: pointer): int64 {.cdecl.} + PWindow* = ptr TWindow + TWindow* {.pf.} = object + PContextSettings* = ptr TContextSettings + TContextSettings*{.pf.} = object + depthBits: cint + stencilBits: cint + antialiasingLevel: cint + majorVersion: cint + minorVersion: cint + TVideoMode* {.pf.} = object + width*: cint + height*: cint + bitsPerPixel*: cint + TEventType*{.size: sizeof(cint).} = enum + EvtClosed, EvtResized, EvtLostFocus, EvtGainedFocus, + EvtTextEntered, EvtKeyPressed, EvtKeyReleased, EvtMouseWheelMoved, + EvtMouseButtonPressed, EvtMouseButtonReleased, EvtMouseMoved, + EvtMouseEntered, EvtMouseLeft, EvtJoystickButtonPressed, + EvtJoystickButtonReleased, EvtJoystickMoved, EvtJoystickConnected, + EvtJoystickDisconnected + TKeyEvent*{.pf.} = object + code*: TKeyCode + alt* : bool + control*: bool + shift* : bool + system* : bool + TJoystickConnectEvent*{.pf.} = object + joystickId*: cint + TJoystickButtonEvent*{.pf.} = object + joystickId*: cint + button*: cint + TJoystickMoveEvent*{.pf.} = object + joystickId*: cint + axis*: TJoystickAxis + position*: cfloat + TMouseWheelEvent*{.pf.} = object + delta*: cint + x*: cint + y*: cint + TMouseButtonEvent*{.pf.} = object + button*: TMouseButton + x*: cint + y*: cint + TMouseMoveEvent*{.pf.} = object + x*: cint + y*: cint + TTextEvent*{.pf.} = object + unicode*: cint + PEvent* = ptr TEvent + TEvent*{.pf.} = object + case kind*: TEventType + of EvtKeyPressed, EvtKeyReleased: + key*: TKeyEvent + of EvtMouseButtonPressed, EvtMouseButtonReleased: + mouseButton*: TMouseButtonEvent + of EvtTextEntered: + text*: TTextEvent + of EvtJoystickConnected, EvtJoystickDisconnected: + joystickConnect*: TJoystickConnectEvent + of EvtJoystickMoved: + joystickMove*: TJoystickMoveEvent + of EvtJoystickButtonPressed, EvtJoystickButtonReleased: + joystickButton*: TJoystickButtonEvent + of EvtResized: + size*: TSizeEvent + of EvtMouseMoved, EvtMouseEntered, EvtMouseLeft: + mouseMove*: TMouseMoveEvent + of EvtMouseWheelMoved: + mouseWheel*: TMouseWheelEvent + else: nil + TJoystickAxis*{.size: sizeof(cint).} = enum + JoystickX, JoystickY, JoystickZ, JoystickR, + JoystickU, JoystickV, JoystickPovX, JoystickPovY + TSizeEvent*{.pf.} = object + width*: cint + height*: cint + TMouseButton*{.size: sizeof(cint).} = enum + MouseLeft, MouseRight, MouseMiddle, + MouseXButton1, MouseXButton2, MouseButtonCount + TKeyCode*{.size: sizeof(cint).} = enum + KeyUnknown = - 1, KeyA, KeyB, KeyC, KeyD, KeyE, + KeyF, KeyG, KeyH, KeyI, KeyJ, KeyK, KeyL, KeyM, #/< The M key + KeyN, KeyO, KeyP, KeyQ, KeyR, KeyS, KeyT, KeyU, #/< The U key + KeyV, KeyW, KeyX, KeyY, KeyZ, KeyNum0, KeyNum1, #/< The 1 key + KeyNum2, KeyNum3, KeyNum4, KeyNum5, KeyNum6, #/< The 6 key + KeyNum7, KeyNum8, KeyNum9, KeyEscape, KeyLControl, #/< The left Control key + KeyLShift, KeyLAlt, KeyLSystem, KeyRControl, #/< The right Control key + KeyRShift, KeyRAlt, KeyRSystem, KeyMenu, #/< The Menu key + KeyLBracket, KeyRBracket, KeySemiColon, KeyComma, #/< The , key + KeyPeriod, KeyQuote, KeySlash, KeyBackSlash, #/< The \ key + KeyTilde, KeyEqual, KeyDash, KeySpace, KeyReturn, #/< The Return key + KeyBack, KeyTab, KeyPageUp, KeyPageDown, KeyEnd, #/< The End key + KeyHome, KeyInsert, KeyDelete, KeyAdd, KeySubtract, #/< - + KeyMultiply, KeyDivide, KeyLeft, KeyRight, KeyUp, #/< Up arrow + KeyDown, KeyNumpad0, KeyNumpad1, KeyNumpad2, #/< The numpad 2 key + KeyNumpad3, #/< The numpad 3 key + KeyNumpad4, #/< The numpad 4 key + KeyNumpad5, #/< The numpad 5 key + KeyNumpad6, #/< The numpad 6 key + KeyNumpad7, #/< The numpad 7 key + KeyNumpad8, #/< The numpad 8 key + KeyNumpad9, #/< The numpad 9 key + KeyF1, #/< The F1 key + KeyF2, #/< The F2 key + KeyF3, #/< The F3 key + KeyF4, #/< The F4 key + KeyF5, #/< The F5 key + KeyF6, #/< The F6 key + KeyF7, #/< The F7 key + KeyF8, #/< The F8 key + KeyF9, #/< The F8 key + KeyF10, #/< The F10 key + KeyF11, #/< The F11 key + KeyF12, #/< The F12 key + KeyF13, #/< The F13 key + KeyF14, #/< The F14 key + KeyF15, #/< The F15 key + KeyPause, #/< The Pause key + KeyCount #/< Keep last -- the total number of keyboard keys + +type TWindowHandle* = clong + +#elif defined(mac): +# type TWindowHandle* = pointer ##typedef void* sfWindowHandle; <- whatever the hell that is +#elif defined(windows): +# type TWindowHandle* = HWND__ ? windows is crazy. ##struct HWND__; typedef struct HWND__* sfWindowHandle; +const + sfNone* = 0 + sfTitlebar* = 1 shl 0 + sfResize* = 1 shl 1 + sfClose* = 1 shl 2 + sfFullscreen* = 1 shl 3 + sfDefaultStyle* = sfTitlebar or sfResize or sfClose +type + PRenderWindow* = ptr TRenderWindow + TRenderWindow* {.pf.} = object + + PFont* = ptr TFont + TFont* {.pf.} = object + PImage* = ptr TImage + TImage* {.pf.} = object + PShader* = ptr TShader + TShader* {.pf.} = object + PSprite* = ptr TSprite + TSprite* {.pf.} = object + PText* = ptr TText + TText* {.pf.} = object + PTexture* = ptr TTexture + TTexture* {.pf.} = object + PVertexArray* = ptr TVertexArray + TVertexArray* {.pf.} = object + PView* = ptr TView + TView* {.pf.} = object + PRenderTexture* = ptr TRenderTexture + TRenderTexture* {.pf.} = object + + PShape* = ptr TShape + TShape* {.pf.} = object + PCircleShape* = ptr TCircleShape + TCircleShape* {.pf.} = object + PRectangleShape* = ptr TRectangleShape + TRectangleShape* {.pf.} = object + PConvexShape* = ptr TConvexShape + TConvexShape* {.pf.} = object + + TTextStyle*{.size: sizeof(cint).} = enum + TextRegular = 0, TextBold = 1 shl 0, TextItalic = 1 shl 1, + TextUnderlined = 1 shl 2 + + TBlendMode*{.size: sizeof(cint).} = enum + BlendAlpha, BlendAdd, BlendMultiply, BlendNone + PRenderStates* = ptr TRenderStates + TRenderStates* {.pf.} = object + blendMode*: TBlendMode + transform*: TTransform + texture*: PTexture + shader*: PShader + + PTransform* = ptr TTransform + TTransform* {.pf.} = object + matrix*: array[0..8, cfloat] + TColor* {.pf.} = object + r*: uint8 + g*: uint8 + b*: uint8 + a*: uint8 + PFloatRect* = ptr TFloatRect + TFloatRect*{.pf.} = object + left*: cfloat + top*: cfloat + width*: cfloat + height*: cfloat + PIntRect* = ptr TIntRect + TIntRect*{.pf.} = object + left*: cint + top*: cint + width*: cint + height*: cint + TGlyph* {.pf.} = object + advance*: cint + bounds*: TIntRect + textureRect*: TIntRect + PVertex* = ptr TVertex + TVertex* {.pf.} = object + position*: TVector2f + color*: TColor + texCoords*: TVector2f + TPrimitiveType*{.size: sizeof(cint).} = enum + Points, #/< List of individual points + Lines, #/< List of individual lines + LinesStrip, #/< List of connected lines, a point uses the previous point to form a line + Triangles, #/< List of individual triangles + TrianglesStrip, #/< List of connected triangles, a point uses the two previous points to form a triangle + TrianglesFan, #/< List of connected triangles, a point uses the common center and the previous point to form a triangle + Quads + + +proc newWindow*(mode: TVideoMode, title: cstring, style: uint32, settings: PContextSettings = nil): PWindow {. + cdecl, importc: "sfWindow_create", dynlib: LibW.} + +proc close*(window: PWindow) {. + cdecl, importc: "sfWindow_close", dynlib: LibW.} +proc isOpen*(window: PWindow): bool {.cdecl, importc: "sfWindow_isOpen", dynlib: LibW.} + +proc pollEvent*(window: PWindow, event: PEvent): bool {. + cdecl, importc: "sfWindow_pollEvent", dynlib: LibW.} +proc waitEvent*(window: PWindow, event: PEvent): bool {. + cdecl, importc: "sfWindow_waitEvent", dynlib: LibW.} + +proc getDesktopMode*(): TVideoMode {. + cdecl, importc: "sfVideoMode_getDesktopMode", dynlib: LibW.} +proc isKeyPressed*(key: TKeyCode): bool {. + cdecl, importc: "sfKeyboard_isKeyPressed", dynlib: LibW.} + +proc mouseIsButtonPressed*(button: TMouseButton): bool {. + cdecl, importc: "sfMouse_isButtonPressed", dynlib: LibW.} +proc mouseGetPosition*(relativeTo: PWindow): TVector2i {. + cdecl, importc: "sfMouse_getPosition", dynlib: LibW.} +proc mouseSetPosition*(position: TVector2i, relativeTo: PWindow) {. + cdecl, importc: "sfMouse_setPosition", dynlib: LibW.} + +proc joystickIsConnected*(joystick: cint): bool {. + cdecl, importc: "sfJoystick_isConnected", dynlib: LibW.} +proc joystickGetButtonCount*(joystick: cint): cint {. + cdecl, importc: "sfJoystick_getButtonCount", dynlib: LibW.} +proc joystickHasAxis*(joystick: cint, axis: TJoystickAxis): bool {. + cdecl, importc: "sfJoystick_hasAxis", dynlib: LibW.} +proc joystickIsButtonPressed*(joystick: cint, button: cint): bool {. + cdecl, importc: "sfJoystick_isButtonPressed", dynlib: LibW.} +proc joystickGetAxisPosition*(joystick: cint, axis: TJoystickAxis): float {. + cdecl, importc: "sfJoystick_getAxisPosition", dynlib: LibW.} +proc joystickUpdate*(): void {. + cdecl, importc: "sfJoystick_update", dynlib: LibW.} + + +proc newRenderWindow*(handle: TWindowHandle, settings: PContextSettings = nil): PRenderWindow{. + cdecl, importc: "sfRenderWindow_createFromHandle", dynlib: LibG.} +proc newRenderWindow*(mode: TVideoMode, title: cstring, style: int32, settings: PContextSettings = nil): PRenderWindow {. + cdecl, importc: "sfRenderWindow_create", dynlib: LibG.} + +proc destroy*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_destroy", dynlib: LibG.} +proc close*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_close", dynlib: LibG.} +proc isOpen*(window: PRenderWindow): bool {. + cdecl, importc: "sfRenderWindow_isOpen", dynlib: LibG.} + +#void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfuint8* pixels); +#proc setIcon*(window: PRenderWindow, width, height: cint, pixels: seq[uint8]) {. +# cdecl, importc: "sfRenderWindow_setIcon", dynlib: LibG.} + +proc getSettings*(window: PRenderWindow): TContextSettings {. + cdecl, importc: "sfRenderWindow_getSettings", dynlib: LibG.} + +proc pollEvent*(window: PRenderWindow, event: PEvent): bool {. + cdecl, importc: "sfRenderWindow_pollEvent", dynlib: LibG.} +proc pollEvent*(window: PRenderWindow; event: var TEvent): bool {. + cdecl, importc: "sfRenderWindow_pollEvent", dynlib: LibG.} +proc waitEvent*(window: PRenderWindow, event: PEvent): bool {. + cdecl, importc: "sfRenderWindow_waitEvent", dynlib: LibG.} +proc waitEvent*(window: PRenderWindow, event: var TEvent): bool {. + cdecl, importc: "sfRenderWindow_waitEvent", dynlib: LibG.} +proc getPosition*(window: PRenderWindow): TVector2i {. + cdecl, importc: "sfRenderWindow_getPosition", dynlib: LibG.} +proc setPosition*(window: PRenderWindow, position: TVector2i) {. + cdecl, importc: "sfRenderWindow_setPosition", dynlib: LibG.} +proc getSize*(window: PRenderWindow): TVector2i {. + cdecl, importc: "sfRenderWindow_getSize", dynlib: LibG.} +proc setSize*(window: PRenderWindow, size: TVector2i): void {. + cdecl, importc: "sfRenderWindow_setSize", dynlib: LibG.} +proc setTitle*(window: PRenderWindow, title: cstring): void {. + cdecl, importc: "sfRenderWindow_setTitle", dynlib: LibG.} + +proc setVisible*(window: PRenderWindow, visible: bool) {. + cdecl, importc: "sfRenderWindow_setVisible", dynlib: LibG.} +proc setMouseCursorVisible*(window: PRenderWindow, show: bool) {. + cdecl, importc: "sfRenderWindow_setMouseCursorVisible", dynlib: LibG.} +proc setVerticalSyncEnabled*(window: PRenderWindow, enabled: bool) {. + cdecl, importc: "sfRenderWindow_setVerticalSyncEnabled", dynlib: LibG.} +proc setKeyRepeatEnabled*(window: PRenderWindow, enabled: bool) {. + cdecl, importc: "sfRenderWindow_setKeyRepeatEnabled", dynlib: LibG.} +proc setActive*(window: PRenderWindow, active: bool): bool {. + cdecl, importc: "sfRenderWindow_setActive", dynlib: LibG.} +proc display*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_display", dynlib: LibG.} +proc setFramerateLimit*(window: PRenderWindow, limit: uint) {. + cdecl, importc: "sfRenderWindow_setFramerateLimit", dynlib: LibG.} +proc setJoystickThreshold*(window: PRenderWindow, threshold: float) {. + cdecl, importc: "sfRenderWindow_setJoystickThreshold", dynlib: LibG.} +proc getSystemHandle*(window: PRenderWindow): TWindowHandle {. + cdecl, importc: "sfRenderWindow_getSystemHandle", dynlib: LibG.} + +proc clear*(window: PRenderWindow, color: TColor) {. + cdecl, importc: "sfRenderWindow_clear", dynlib: LibG.} + +proc setView*(window: PRenderWindow, view: PView) {. + cdecl, importc: "sfRenderWindow_setView", dynlib: LibG.} +proc getView*(window: PRenderWindow): PView {. + cdecl, importc: "sfRenderWindow_getView", dynlib: LibG.} +proc getDefaultView*(window: PRenderWindow): PView {. + cdecl, importc: "sfRenderWindow_getDefaultView", dynlib: LibG.} +proc getViewport*(window: PRenderWindow, view: PView): TIntRect {. + cdecl, importc: "sfRenderWindow_getViewport", dynlib: LibG.} + +proc convertCoords*(window: PRenderWindow, point: TVector2i, targetView: PView): TVector2f {. + cdecl, importc: "sfRenderWindow_convertCoords", dynlib: LibG.} + +proc draw*(window: PRenderWindow, sprite: PSprite, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawSprite", dynlib: LibG.} +proc draw*(window: PRenderWindow, text: PText, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawText", dynlib: LibG.} +proc draw*(window: PRenderWindow, shape: PShape, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawShape", dynlib: LibG.} +proc draw*(window: PRenderWindow, shape: PCircleShape, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawCircleShape", dynlib: LibG.} +proc draw*(window: PRenderWindow, shape: PRectangleShape, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawRectangleShape", dynlib: LibG.} + +proc draw*(window: PRenderWindow, shape: PConvexShape, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawConvexShape", dynlib: LibG.} +proc draw*(window: PRenderWindow, shape: PVertexArray, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawVertexArray", dynlib: LibG.} +proc draw*(window: PRenderWindow, vertices: PVertex, vertexCount: cint, + vertexType: TPrimitiveType, states: PRenderStates = nil) {. + cdecl, importc: "sfRenderWindow_drawPrimitives", dynlib: LibG.} + +proc pushGlStates*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_pushGLStates", dynlib: LibG.} +proc popGlStates*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_popGLStates", dynlib: LibG.} +proc resetGlStates*(window: PRenderWindow) {. + cdecl, importc: "sfRenderWindow_resetGLStates", dynlib: LibG.} +proc capture*(window: PRenderWindow): PImage {. + cdecl, importc: "sfRenderWindow_capture", dynlib: LibG.} + +#Construct a new render texture +proc newRenderTexture*(width, height: cint; depthBuffer: bool): PRenderTexture {. + cdecl, importc: "sfRenderTexture_create", dynlib: LibG.} +#Destroy an existing render texture +proc destroy*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_destroy", dynlib: LibG.} +#Get the size of the rendering region of a render texture +proc getSize*(renderTexture: PRenderTexture): TVector2i {. + cdecl, importc: "sfRenderTexture_getSize", dynlib: LibG.} +#Activate or deactivate a render texture as the current target for rendering +proc setActive*(renderTexture: PRenderTexture; active: bool): bool{. + cdecl, importc: "sfRenderTexture_setActive", dynlib: LibG.} +#Update the contents of the target texture +proc display*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_display", dynlib: LibG.} +#Clear the rendertexture with the given color +proc clear*(renderTexture: PRenderTexture; color: TColor){. + cdecl, importc: "sfRenderTexture_clear", dynlib: LibG.} +#Change the current active view of a render texture +proc setView*(renderTexture: PRenderTexture; view: PView){. + cdecl, importc: "sfRenderTexture_setView", dynlib: LibG.} +#Get the current active view of a render texture +proc getView*(renderTexture: PRenderTexture): PView{. + cdecl, importc: "sfRenderTexture_getView", dynlib: LibG.} +#Get the default view of a render texture +proc getDefaultView*(renderTexture: PRenderTexture): PView{. + cdecl, importc: "sfRenderTexture_getDefaultView", dynlib: LibG.} +#Get the viewport of a view applied to this target +proc getViewport*(renderTexture: PRenderTexture; view: PView): TIntRect{. + cdecl, importc: "sfRenderTexture_getViewport", dynlib: LibG.} +#Convert a point in texture coordinates into view coordinates +proc convertCoords*(renderTexture: PRenderTexture; point: TVector2i; targetView: PView): TVector2f{. + cdecl, importc: "sfRenderTexture_convertCoords", dynlib: LibG.} +#Draw a drawable object to the render-target +proc draw*(renderTexture: PRenderTexture; sprite: PSprite; states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawSprite", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; text: PText; states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawText", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; shape: PShape; states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawShape", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; shape: PCircleShape; + states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawCircleShape", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; shape: PConvexShape; + states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawConvexShape", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; shape: PRectangleShape; + states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawRectangleShape", dynlib: LibG.} +proc draw*(renderTexture: PRenderTexture; va: PVertexArray; + states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawVertexArray", dynlib: LibG.} +#Draw primitives defined by an array of vertices to a render texture +proc draw*(renderTexture: PRenderTexture; vertices: PVertex; vertexCount: cint; + primitiveType: TPrimitiveType; states: PRenderStates){. + cdecl, importc: "sfRenderTexture_drawPrimitives", dynlib: LibG.} +#Save the current OpenGL render states and matrices +#/ +#/ This function can be used when you mix SFML drawing +#/ and direct OpenGL rendering. Combined with popGLStates, +#/ it ensures that: +#/ * SFML's internal states are not messed up by your OpenGL code +#/ * your OpenGL states are not modified by a call to a SFML function +#/ +#/ Note that this function is quite expensive: it saves all the +#/ possible OpenGL states and matrices, even the ones you +#/ don't care about. Therefore it should be used wisely. +#/ It is provided for convenience, but the best results will +#/ be achieved if you handle OpenGL states yourself (because +#/ you know which states have really changed, and need to be +#/ saved and restored). Take a look at the resetGLStates +#/ function if you do so. +proc pushGLStates*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_pushGLStates", dynlib: LibG.} +#Restore the previously saved OpenGL render states and matrices +#/ +#/ See the description of pushGLStates to get a detailed +#/ description of these functions. +proc popGLStates*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_popGLStates", dynlib: LibG.} +#Reset the internal OpenGL states so that the target is ready for drawing +#/ +#/ This function can be used when you mix SFML drawing +#/ and direct OpenGL rendering, if you choose not to use +#/ pushGLStates/popGLStates. It makes sure that all OpenGL +#/ states needed by SFML are set, so that subsequent sfRenderTexture_draw*() +#/ calls will work as expected. +proc resetGLStates*(renderTexture: PRenderTexture){. + cdecl, importc: "sfRenderTexture_resetGLStates", dynlib: LibG.} +#Get the target texture of a render texture +proc getTexture*(renderTexture: PRenderTexture): PTexture{. + cdecl, importc: "sfRenderTexture_getTexture", dynlib: LibG.} +#Enable or disable the smooth filter on a render texture +proc setSmooth*(renderTexture: PRenderTexture; smooth: bool){. + cdecl, importc: "sfRenderTexture_setSmooth", dynlib: LibG.} +#Tell whether the smooth filter is enabled or not for a render texture +proc isSmooth*(renderTexture: PRenderTexture): bool {. + cdecl, importc: "sfRenderTexture_isSmooth", dynlib: LibG.} + +proc intRect*(left, top, width, height: cint): TIntRect = + result.left = left + result.top = top + result.width = width + result.height = height +proc floatRect*(left, top, width, height: cfloat): TFloatRect = + result.left = left + result.top = top + result.width = width + result.height = height +proc contains*(rect: PFloatRect, x, y: cfloat): bool {. + cdecl, importc: "sfFloatRect_contains", dynlib: LibG.} +proc contains*(rect: PIntRect, x: cint, y: cint): bool{.cdecl, + importc: "sfIntRect_contains", dynlib: LibG.} +proc intersects*(rect1, rect2, intersection: PFloatRect): bool {. + cdecl, importc: "sfFloatRect_intersects", dynlib: LibG.} +proc intersects*(rect1, rect2, intersection: PIntRect): bool {. + cdecl, importc: "sfIntRect_intersects", dynlib: LibG.} + +proc newFont*(filename: cstring): PFont {. + cdecl, importc: "sfFont_createFromFile", dynlib: LibG.} +proc newFont*(data: pointer, sizeInBytes: cint): PFont {. + cdecl, importc: "sfFont_createFromMemory", dynlib: LibG.} +proc newFont*(stream: PInputStream): PFont {. + cdecl, importc: "sfFont_createFromStream", dynlib: LibG.} +proc copy*(font: PFont): PFont {. + cdecl, importc: "sfFont_copy", dynlib: LibG.} +proc destroy*(font: PFont) {. + cdecl, importc: "sfFont_destroy", dynlib: LibG.} +proc getGlyph*(font: PFont, codePoint: uint32, characterSize: cint, bold: bool): TGlyph{. + cdecl, importc: "sfFont_getGlyph", dynlib: LibG.} +proc getKerning*(font: PFont, first: uint32, second: uint32, characterSize: cint): cint {. + cdecl, importc: "sfFont_getKerning", dynlib: LibG.} +proc getLineSpacing*(font: PFont, characterSize: cint): cint {. + cdecl, importc: "sfFont_getLineSpacing", dynlib: LibG.} +proc getTexture*(font: PFont, characterSize: cint): PTexture {. + cdecl, importc: "sfFont_getTexture", dynlib: LibG.} +#getDefaultFont() has been removed from CSFML +proc getDefaultFont*(): PFont {. + error, cdecl, importc: "sfFont_getDefaultFont", dynlib: LibG.} + +proc newCircleShape*(): PCircleShape {. + cdecl, importc: "sfCircleShape_create", dynlib: LibG.} +proc copy*(shape: PCircleShape): PCircleShape {. + cdecl, importc: "sfCircleShape_copy", dynlib: LibG.} +proc destroy*(shape: PCircleShape) {. + cdecl, importc: "sfCircleShape_destroy", dynlib: LibG.} +proc setPosition*(shape: PCircleShape, position: TVector2f) {. + cdecl, importc: "sfCircleShape_setPosition", dynlib: LibG.} +proc setRotation*(shape: PCircleShape, angle: cfloat) {. + cdecl, importc: "sfCircleShape_setRotation", dynlib: LibG.} +proc setScale*(shape: PCircleShape, scale: TVector2f) {. + cdecl, importc: "sfCircleShape_setScale", dynlib: LibG.} +proc setOrigin*(shape: PCircleShape, origin: TVector2f) {. + cdecl, importc: "sfCircleShape_setOrigin", dynlib: LibG.} +proc getPosition*(shape: PCircleShape): TVector2f {. + cdecl, importc: "sfCircleShape_getPosition", dynlib: LibG.} +proc getRotation*(shape: PCircleShape): cfloat {. + cdecl, importc: "sfCircleShape_getRotation", dynlib: LibG.} +proc getScale*(shape: PCircleShape): TVector2f {. + cdecl, importc: "sfCircleShape_getScale", dynlib: LibG.} +proc getOrigin*(shape: PCircleShape): TVector2f {. + cdecl, importc: "sfCircleShape_getOrigin", dynlib: LibG.} +proc move*(shape: PCircleShape, offset: TVector2f) {. + cdecl, importc: "sfCircleShape_move", dynlib: LibG.} +proc rotate*(shape: PCircleShape, angle: cfloat){. + cdecl, importc: "sfCircleShape_rotate", dynlib: LibG.} +proc scale*(shape: PCircleShape, factors: TVector2f) {. + cdecl, importc: "sfCircleShape_scale", dynlib: LibG.} +proc getTransform*(shape: PCircleShape): TTransform {. + cdecl, importc: "sfCircleShape_getTransform", dynlib: LibG.} +proc getInverseTransform*(shape: PCircleShape): TTransform {. + cdecl, importc: "sfCircleShape_getInverseTransform", dynlib: LibG.} +proc setTexture*(shape: PCircleShape, texture: PTexture, resetRect: bool) {. + cdecl, importc: "sfCircleShape_setTexture", dynlib: LibG.} +proc setTextureRect*(shape: PCircleShape, rect: TIntRect) {. + cdecl, importc: "sfCircleShape_setTextureRect", dynlib: LibG.} +proc setFillColor*(shape: PCircleShape, color: TColor) {. + cdecl, importc: "sfCircleShape_setFillColor", dynlib: LibG.} +proc setOutlineColor*(shape: PCircleShape, color: TColor) {. + cdecl, importc: "sfCircleShape_setOutlineColor", dynlib: LibG.} +proc setOutlineThickness*(shape: PCircleShape, thickness: cfloat) {. + cdecl, importc: "sfCircleShape_setOutlineThickness", dynlib: LibG.} +proc getTexture*(shape: PCircleShape): PTexture {. + cdecl, importc: "sfCircleShape_getTexture", dynlib: LibG.} +proc getTextureRect*(shape: PCircleShape): TIntRect {. + cdecl, importc: "sfCircleShape_getTextureRect", dynlib: LibG.} +proc getFillColor*(shape: PCircleShape): TColor {. + cdecl, importc: "sfCircleShape_getFillColor", dynlib: LibG.} +proc getOutlineColor*(shape: PCircleShape): TColor {. + cdecl, importc: "sfCircleShape_getOutlineColor", dynlib: LibG.} +proc getOutlineThickness*(shape: PCircleShape): cfloat {. + cdecl, importc: "sfCircleShape_getOutlineThickness", dynlib: LibG.} +proc getPointCount*(shape: PCircleShape): cint {. + cdecl, importc: "sfCircleShape_getPointCount", dynlib: LibG.} +proc getPoint*(shape: PCircleShape, index: cint): TVector2f {. + cdecl, importc: "sfCircleShape_getPoint", dynlib: LibG.} +proc setRadius*(shape: PCircleShape, radius: cfloat) {. + cdecl, importc: "sfCircleShape_setRadius", dynlib: LibG.} +proc getRadius*(shape: PCircleShape): cfloat {. + cdecl, importc: "sfCircleShape_getRadius", dynlib: LibG.} +proc setPointCount*(shape: PCircleShape, count: cint) {. + cdecl, importc: "sfCircleShape_setPointCount", dynlib: LibG.} +proc getLocalBounds*(shape: PCircleShape): TFloatRect {. + cdecl, importc: "sfCircleShape_getLocalBounds", dynlib: LibG.} +proc getGlobalBounds*(shape: PCircleShape): TFloatRect {. + cdecl, importc: "sfCircleShape_getGlobalBounds", dynlib: LibG.} + +proc newRectangleShape*(): PRectangleShape {. + cdecl, importc: "sfRectangleShape_create", dynlib: LibG.} +proc copy*(shape: PRectangleShape): PRectangleShape {. + cdecl, importc: "sfRectangleShape_copy", dynlib: LibG.} +proc destroy*(shape: PRectangleShape){. + cdecl, importc: "sfRectangleShape_destroy", dynlib: LibG.} +proc setPosition*(shape: PRectangleShape, position: TVector2f) {. + cdecl, importc: "sfRectangleShape_setPosition", dynlib: LibG.} +proc setRotation*(shape: PRectangleShape, angle: cfloat) {. + cdecl, importc: "sfRectangleShape_setRotation", dynlib: LibG.} +proc setScale*(shape: PRectangleShape, scale: TVector2f) {. + cdecl, importc: "sfRectangleShape_setScale", dynlib: LibG.} +proc setOrigin*(shape: PRectangleShape, origin: TVector2f) {. + cdecl, importc: "sfRectangleShape_setOrigin", dynlib: LibG.} +proc getPosition*(shape: PRectangleShape): TVector2f {. + cdecl, importc: "sfRectangleShape_getPosition", dynlib: LibG.} +proc getRotation*(shape: PRectangleShape): cfloat {. + cdecl, importc: "sfRectangleShape_getRotation", dynlib: LibG.} +proc getScale*(shape: PRectangleShape): TVector2f {. + cdecl, importc: "sfRectangleShape_getScale", dynlib: LibG.} +proc getOrigin*(shape: PRectangleShape): TVector2f {. + cdecl, importc: "sfRectangleShape_getOrigin", dynlib: LibG.} +proc move*(shape: PRectangleShape, offset: TVector2f) {. + cdecl, importc: "sfRectangleShape_move", dynlib: LibG.} +proc rotate*(shape: PRectangleShape, angle: cfloat) {. + cdecl, importc: "sfRectangleShape_rotate", dynlib: LibG.} +proc scale*(shape: PRectangleShape, factors: TVector2f) {. + cdecl, importc: "sfRectangleShape_scale", dynlib: LibG.} +proc getTransform*(shape: PRectangleShape): TTransform {. + cdecl, importc: "sfRectangleShape_getTransform", dynlib: LibG.} +proc getInverseTransform*(shape: PRectangleShape): TTransform {. + cdecl, importc: "sfRectangleShape_getInverseTransform", dynlib: LibG.} +proc setTexture*(shape: PRectangleShape, texture: PTexture, resetRect: bool) {. + cdecl, importc: "sfRectangleShape_setTexture", dynlib: LibG.} +proc setTextureRect*(shape: PRectangleShape, rect: TIntRect) {. + cdecl, importc: "sfRectangleShape_setTextureRect", dynlib: LibG.} +proc setFillColor*(shape: PRectangleShape, color: TColor) {. + cdecl, importc: "sfRectangleShape_setFillColor", dynlib: LibG.} +proc setOutlineColor*(shape: PRectangleShape, color: TColor) {. + cdecl, importc: "sfRectangleShape_setOutlineColor", dynlib: LibG.} +proc setOutlineThickness*(shape: PRectangleShape, thickness: cfloat) {. + cdecl, importc: "sfRectangleShape_setOutlineThickness", dynlib: LibG.} +proc getTexture*(shape: PRectangleShape): PTexture {. + cdecl, importc: "sfRectangleShape_getTexture", dynlib: LibG.} +proc getTextureRect*(shape: PRectangleShape): TIntRect {. + cdecl, importc: "sfRectangleShape_getTextureRect", dynlib: LibG.} +proc getFillColor*(shape: PRectangleShape): TColor {. + cdecl, importc: "sfRectangleShape_getFillColor", dynlib: LibG.} +proc getOutlineColor*(shape: PRectangleShape): TColor {. + cdecl, importc: "sfRectangleShape_getOutlineColor", dynlib: LibG.} +proc getOutlineThickness*(shape: PRectangleShape): cfloat {. + cdecl, importc: "sfRectangleShape_getOutlineThickness", dynlib: LibG.} +proc getPointCount*(shape: PRectangleShape): cint {. + cdecl, importc: "sfRectangleShape_getPointCount", dynlib: LibG.} +proc getPoint*(shape: PRectangleShape, index: cint): TVector2f {. + cdecl, importc: "sfRectangleShape_getPoint", dynlib: LibG.} +proc setSize*(shape: PRectangleShape, size: TVector2f) {. + cdecl, importc: "sfRectangleShape_setSize", dynlib: LibG.} +proc getSize*(shape: PRectangleShape): TVector2f {. + cdecl, importc: "sfRectangleShape_getSize", dynlib: LibG.} +proc getLocalBounds*(shape: PRectangleShape): TFloatRect {. + cdecl, importc: "sfRectangleShape_getLocalBounds", dynlib: LibG.} +proc getGlobalBounds*(shape: PRectangleShape): TFloatRect {. + cdecl, importc: "sfRectangleShape_getGlobalBounds", dynlib: LibG.} + + +proc newView*(): PView {. + cdecl, importc: "sfView_create", dynlib: LibG.} +proc viewFromRect*(rectangle: TFloatRect): PView{. + cdecl, importc: "sfView_createFromRect", dynlib: LibG.} +proc copy*(view: PView): PView {. + cdecl, importc: "sfView_copy", dynlib: LibG.} +proc destroy*(view: PView) {. + cdecl, importc: "sfView_destroy", dynlib: LibG.} +proc setCenter*(view: PView, center: TVector2f) {. + cdecl, importc: "sfView_setCenter", dynlib: LibG.} +proc setSize*(view: PView, size: TVector2f) {. + cdecl, importc: "sfView_setSize", dynlib: LibG.} +proc setRotation*(view: PView, angle: cfloat) {. + cdecl, importc: "sfView_setRotation", dynlib: LibG.} +proc setViewport*(view: PView, viewport: TFloatRect) {. + cdecl, importc: "sfView_setViewport", dynlib: LibG.} +proc reset*(view: PView, rectangle: TFloatRect) {. + cdecl, importc: "sfView_reset", dynlib: LibG.} +proc getCenter*(view: PView): TVector2f {. + cdecl, importc: "sfView_getCenter", dynlib: LibG.} +proc getSize*(view: PView): TVector2f {. + cdecl, importc: "sfView_getSize", dynlib: LibG.} +proc getRotation*(view: PView): cfloat {. + cdecl, importc: "sfView_getRotation", dynlib: LibG.} +proc getViewport*(view: PView): TFloatRect {. + cdecl, importc: "sfView_getViewport", dynlib: LibG.} +proc move*(view: PView, offset: TVector2f) {. + cdecl, importc: "sfView_move", dynlib: LibG.} +proc rotate*(view: PView, angle: cfloat) {. + cdecl, importc: "sfView_rotate", dynlib: LibG.} +proc zoom*(view: PView, factor: cfloat) {. + cdecl, importc: "sfView_zoom", dynlib: LibG.} + +proc newImage*(width, height: cint): PImage {. + cdecl, importc: "sfImage_create", dynlib: LibG.} +proc newImage*(width, height: cint, color: TColor): PImage {. + cdecl, importc: "sfImage_createFromColor", dynlib: LibG.} +proc newImage*(width, height: cint, pixels: pointer): PImage {. ##same deal as setIcon() + cdecl, importc: "sfImage_createFromPixels", dynlib: LibG.} +proc newImage*(filename: cstring): PImage {. + cdecl, importc: "sfImage_createFromFile", dynlib: LibG.} +proc newImage*(data: pointer, size: cint): PImage {. + cdecl, importc: "sfImage_createFromMemory", dynlib: LibG.} +proc newImage*(stream: PInputStream): PImage {. + cdecl, importc: "sfImage_createFromStream", dynlib: LibG.} +proc copy*(image: PImage): PImage {. + cdecl, importc: "sfImage_copy", dynlib: LibG.} +proc destroy*(image: PImage) {. + cdecl, importc: "sfImage_destroy", dynlib: LibG.} +proc save*(image: PImage, filename: cstring): bool {. + cdecl, importc: "sfImage_saveToFile", dynlib: LibG.} +proc getSize*(image: PImage): TVector2i {. + cdecl, importc: "sfImage_getSize", dynlib: LibG.} +proc createMask*(image: PImage, color: TColor, alpha: cchar) {. + cdecl, importc: "sfImage_createMaskFromColor", dynlib: LibG.} +proc copy*(destination, source: PImage, destX, destY: cint; + sourceRect: TIntRect, applyAlpha: bool) {. + cdecl, importc: "sfImage_copyImage", dynlib: LibG.} +proc setPixel*(image: PImage, x, y: cint, color: TColor) {. + cdecl, importc: "sfImage_setPixel", dynlib: LibG.} +proc getPixel*(image: PImage, x, y: cint): TColor {. + cdecl, importc: "sfImage_getPixel", dynlib: LibG.} +proc getPixels*(image: PImage): pointer {. + cdecl, importc: "sfImage_getPixelsPtr", dynlib: LibG.} +proc flipHorizontally*(image: PImage) {. + cdecl, importc: "sfImage_flipHorizontally", dynlib: LibG.} +proc flipVertically*(image: PImage) {. + cdecl, importc: "sfImage_flipVertically", dynlib: LibG.} + +proc newSprite*(): PSprite {. + cdecl, importc: "sfSprite_create", dynlib: LibG.} +proc copy*(sprite: PSprite): PSprite {. + cdecl, importc: "sfSprite_copy", dynlib: LibG.} +proc destroy*(sprite: PSprite) {. + cdecl, importc: "sfSprite_destroy", dynlib: LibG.} +proc setPosition*(sprite: PSprite, position: TVector2f) {. + cdecl, importc: "sfSprite_setPosition", dynlib: LibG.} +proc setRotation*(sprite: PSprite, angle: cfloat) {. + cdecl, importc: "sfSprite_setRotation", dynlib: LibG.} +proc setScale*(sprite: PSprite, scale: TVector2f) {. + cdecl, importc: "sfSprite_setScale", dynlib: LibG.} +proc setOrigin*(sprite: PSprite, origin: TVector2f) {. + cdecl, importc: "sfSprite_setOrigin", dynlib: LibG.} +proc getPosition*(sprite: PSprite): TVector2f {. + cdecl, importc: "sfSprite_getPosition", dynlib: LibG.} +proc getRotation*(sprite: PSprite): cfloat {. + cdecl, importc: "sfSprite_getRotation", dynlib: LibG.} +proc getScale*(sprite: PSprite): TVector2f {. + cdecl, importc: "sfSprite_getScale", dynlib: LibG.} +proc getOrigin*(sprite: PSprite): TVector2f {. + cdecl, importc: "sfSprite_getOrigin", dynlib: LibG.} +proc move*(sprite: PSprite, offset: TVector2f) {. + cdecl, importc: "sfSprite_move", dynlib: LibG.} +proc rotate*(sprite: PSprite, angle: cfloat) {. + cdecl, importc: "sfSprite_rotate", dynlib: LibG.} +proc scale*(sprite: PSprite, factor: TVector2f) {. + cdecl, importc: "sfSprite_scale", dynlib: LibG.} +proc getTransform*(sprite: PSprite): TTransform {. + cdecl, importc: "sfSprite_getTransform", dynlib: LibG.} +proc getInverseTransform*(sprite: PSprite): TTransform {. + cdecl, importc: "sfSprite_getInverseTransform", dynlib: LibG.} +proc setTexture*(sprite: PSprite, texture: PTexture, resetRect: bool) {. + cdecl, importc: "sfSprite_setTexture", dynlib: LibG.} +proc setTextureRect*(sprite: PSprite, rectangle: TIntRect) {. + cdecl, importc: "sfSprite_setTextureRect", dynlib: LibG.} +proc setColor*(sprite: PSprite, color: TColor) {. + cdecl, importc: "sfSprite_setColor", dynlib: LibG.} +proc getTexture*(sprite: PSprite): TTexture {. + cdecl, importc: "sfSprite_getTexture", dynlib: LibG.} +proc getTextureRect*(sprite: PSprite): TIntRect {. + cdecl, importc: "sfSprite_getTextureRect", dynlib: LibG.} +proc getColor*(sprite: PSprite): TColor {. + cdecl, importc: "sfSprite_getColor", dynlib: LibG.} +proc getLocalBounds*(sprite: PSprite): TFloatRect {. + cdecl, importc: "sfSprite_getLocalBounds", dynlib: LibG.} +proc getGlobalBounds*(sprite: PSprite): TFloatRect {. + cdecl, importc: "sfSprite_getGlobalBounds", dynlib: LibG.} + +proc newTexture*(width, height: cint): PTexture {. + cdecl, importc: "sfTexture_create", dynlib: LibG.} +proc newTexture*(filename: cstring): PTexture {. + cdecl, importc: "sfTexture_createFromFile", dynlib: LibG.} +proc newTexture*(data: pointer, size: cint, area: PIntRect): PTexture {. + cdecl, importc: "sfTexture_createFromMemory", dynlib: LibG.} +proc newTexture*(stream: PInputStream, area: PIntRect): PTexture {. + cdecl, importc: "sfTexture_createFromStream", dynlib: LibG.} +proc newTexture*(image: PImage, area: PIntRect = nil): PTexture {. + cdecl, importc: "sfTexture_createFromImage", dynlib: LibG.} +proc copy*(texture: PTexture): PTexture {. + cdecl, importc: "sfTexture_copy", dynlib: LibG.} +proc destroy*(texture: PTexture) {. + cdecl, importc: "sfTexture_destroy", dynlib: LibG.} +proc getSize*(texture: PTexture): TVector2i {. + cdecl, importc: "sfTexture_getSize", dynlib: LibG.} +proc copyToImage*(texture: PTexture): PImage {. + cdecl, importc: "sfTexture_copyToImage", dynlib: LibG.} +proc updateFromPixels*(texture: PTexture, pixels: pointer, width, height, x, y: cint) {. + cdecl, importc: "sfTexture_updateFromPixels", dynlib: LibG.} +proc updateFromImage*(texture: PTexture, image: PImage, x, y: cint) {. + cdecl, importc: "sfTexture_updateFromImage", dynlib: LibG.} +proc updateFromWindow*(texture: PTexture, window: PWindow, x, y: cint) {. + cdecl, importc: "sfTexture_updateFromWindow", dynlib: LibG.} +proc updateFromWindow*(texture: PTexture, window: PRenderWindow, x, y: cint) {. + cdecl, importc: "sfTexture_updateFromRenderWindow", dynlib: LibG.} +proc bindGL*(texture: PTexture) {. + cdecl, importc: "sfTexture_bind", dynlib: LibG.} +proc setSmooth*(texture: PTexture, smooth: bool) {. + cdecl, importc: "sfTexture_setSmooth", dynlib: LibG.} +proc isSmooth*(texture: PTexture): bool {. + cdecl, importc: "sfTexture_isSmooth", dynlib: LibG.} +proc setRepeated*(texture: PTexture, repeated: bool) {. + cdecl, importc: "sfTexture_setRepeated", dynlib: LibG.} +proc isRepeated*(texture: PTexture): bool {. + cdecl, importc: "sfTexture_isRepeated", dynlib: LibG.} +proc textureMaxSize*(): cint {. + cdecl, importc: "sfTexture_getMaximumSize", dynlib: LibG.} + +proc newVertexArray*(): PVertexArray {. + cdecl, importc: "sfVertexArray_create", dynlib: LibG.} +proc copy*(vertexArray: PVertexArray): PVertexArray {. + cdecl, importc: "sfVertexArray_copy", dynlib: LibG.} +proc destroy*(va: PVertexArray) {. + cdecl, importc: "sfVertexArray_destroy", dynlib: LibG.} +proc getVertexCount*(va: PVertexArray): cint {. + cdecl, importc: "sfVertexArray_getVertexCount", dynlib: LibG.} +proc getVertex*(va: PVertexArray, index: cint): PVertex {. + cdecl, importc: "sfVertexArray_getVertex", dynlib: LibG.} +proc clear*(va: PVertexArray) {. + cdecl, importc: "sfVertexArray_clear", dynlib: LibG.} +proc resize*(va: PVertexArray, size: cint) {. + cdecl, importc: "sfVertexArray_resize", dynlib: LibG.} +proc append*(va: PVertexArray, vertex: TVertex) {. + cdecl, importc: "sfVertexArray_append", dynlib: LibG.} +proc setPrimitiveType*(va: PVertexArray, primitiveType: TPrimitiveType) {. + cdecl, importc: "sfVertexArray_setPrimitiveType", dynlib: LibG.} +proc getPrimitiveType*(va: PVertexArray): TPrimitiveType {. + cdecl, importc: "sfVertexArray_getPrimitiveType", dynlib: LibG.} +proc getBounds*(va: PVertexArray): TFloatRect {. + cdecl, importc: "sfVertexArray_getBounds", dynlib: LibG.} + + +proc newText*(): PText {. + cdecl, importc: "sfText_create", dynlib: LibG.} +proc copy*(text: PText): PText {. + cdecl, importc: "sfText_copy", dynlib: LibG.} +proc destroy*(text: PText) {. + cdecl, importc: "sfText_destroy", dynlib: LibG.} +proc setPosition*(text: PText, position: TVector2f) {. + cdecl, importc: "sfText_setPosition", dynlib: LibG.} +proc setRotation*(text: PText, angle: cfloat) {. + cdecl, importc: "sfText_setRotation", dynlib: LibG.} +proc setScale*(text: PText, scale: TVector2f) {. + cdecl, importc: "sfText_setScale", dynlib: LibG.} +proc setOrigin*(text: PText, origin: TVector2f) {. + cdecl, importc: "sfText_setOrigin", dynlib: LibG.} +proc getPosition*(text: PText): TVector2f {. + cdecl, importc: "sfText_getPosition", dynlib: LibG.} +proc getRotation*(text: PText): cfloat {. + cdecl, importc: "sfText_getRotation", dynlib: LibG.} +proc getScale*(text: PText): TVector2f {. + cdecl, importc: "sfText_getScale", dynlib: LibG.} +proc getOrigin*(text: PText): TVector2f {. + cdecl, importc: "sfText_getOrigin", dynlib: LibG.} +proc move*(text: PText, offset: TVector2f) {. + cdecl, importc: "sfText_move", dynlib: LibG.} +proc rotate*(text: PText, angle: cfloat) {. + cdecl, importc: "sfText_rotate", dynlib: LibG.} +proc scale*(text: PText, factors: TVector2f) {. + cdecl, importc: "sfText_scale", dynlib: LibG.} +proc getTransform*(text: PText): TTransform {. + cdecl, importc: "sfText_getTransform", dynlib: LibG.} +proc getInverseTransform*(text: PText): TTransform {. + cdecl, importc: "sfText_getInverseTransform", dynlib: LibG.} +proc setString*(text: PText, string: cstring) {. + cdecl, importc: "sfText_setString", dynlib: LibG.} +proc setUnicodeString*(text: PText, string: ptr uint32) {. + cdecl, importc: "sfText_setUnicodeString", dynlib: LibG.} +proc setFont*(text: PText, font: PFont) {. + cdecl, importc: "sfText_setFont", dynlib: LibG.} +proc setCharacterSize*(text: PText, size: cint) {. + cdecl, importc: "sfText_setCharacterSize", dynlib: LibG.} +proc setStyle*(text: PText, style: TTextStyle) {. + cdecl, importc: "sfText_setStyle", dynlib: LibG.} +proc setColor*(text: PText, color: TColor) {. + cdecl, importc: "sfText_setColor", dynlib: LibG.} +proc getString*(text: PText): cstring {. + cdecl, importc: "sfText_getString", dynlib: LibG.} +proc getUnicodeString*(text: PText): ptr uint32 {.cdecl, + importc: "sfText_getUnicodeString", dynlib: LibG.} +proc getFont*(text: PText): PFont {. + cdecl, importc: "sfText_getFont", dynlib: LibG.} +proc getCharacterSize*(text: PText): cint {. + cdecl, importc: "sfText_getCharacterSize", dynlib: LibG.} +proc getStyle*(text: PText): uint32 {. + cdecl, importc: "sfText_getStyle", dynlib: LibG.} +proc getColor*(text: PText): TColor {. + cdecl, importc: "sfText_getColor", dynlib: LibG.} +proc findCharacterPos*(text: PText, index: cint): TVector2f {. + cdecl, importc: "sfText_findCharacterPos", dynlib: LibG.} +proc getLocalBounds*(text: PText): TFloatRect {. + cdecl, importc: "sfText_getLocalBounds", dynlib: LibG.} +proc getGlobalBounds*(text: PText): TFloatRect {. + cdecl, importc: "sfText_getGlobalBounds", dynlib: LibG.} + +proc transformFromMatrix*(a00, a01, a02, a10, a11, a12, a20, a21, a22: cfloat): TTransform {. + cdecl, importc: "sfTransform_fromMatrix", dynlib: LibG.} +proc getMatrix*(transform: PTransform, matrix: ptr cfloat) {. + cdecl, importc: "sfTransform_getMatrix", dynlib: LibG.} +proc getInverse*(transform: PTransform): TTransform {. + cdecl, importc: "sfTransform_getInverse", dynlib: LibG.} +proc transformPoint*(transform: PTransform, point: TVector2f): TVector2f {. + cdecl, importc: "sfTransform_transformPoint", dynlib: LibG.} +proc transformRect*(transform: PTransform, rectangle: TFloatRect): TFloatRect {. + cdecl, importc: "sfTransform_transformRect", dynlib: LibG.} +proc combine*(transform: PTransform, other: PTransform) {. + cdecl, importc: "sfTransform_combine", dynlib: LibG.} +proc translate*(transform: PTransform, x, y: cfloat) {. + cdecl, importc: "sfTransform_translate", dynlib: LibG.} +proc rotate*(transform: PTransform, angle: cfloat) {. + cdecl, importc: "sfTransform_rotate", dynlib: LibG.} +proc rotateWithCenter*(transform: PTransform, angle, centerX, centerY: cfloat){. + cdecl, importc: "sfTransform_rotateWithCenter", dynlib: LibG.} +proc scale*(transform: PTransform, scaleX, scaleY: cfloat) {. + cdecl, importc: "sfTransform_scale", dynlib: LibG.} +proc scaleWithCenter*(transform: PTransform, scaleX, scaleY, centerX, centerY: cfloat) {. + cdecl, importc: "sfTransform_scaleWithCenter", dynlib: LibG.} +let IdentityMatrix*: TTransform = transformFromMatrix(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0) + + +proc newShader*(VSfilename: cstring, fragmentShaderFilename: cstring): PShader {. + cdecl, importc: "sfShader_createFromFile", dynlib: LibG.} +proc newShaderFromStr*(vertexShader: cstring, fragmentShader: cstring): PShader {. + cdecl, importc: "sfShader_createFromMemory", dynlib: LibG.} +proc newShader*(vertexShaderStream: PInputStream, fragmentShaderStream: PInputStream): PShader {. + cdecl, importc: "sfShader_createFromStream", dynlib: LibG.} +proc destroy*(shader: PShader) {. + cdecl, importc: "sfShader_destroy", dynlib: LibG.} +proc setFloatParameter*(shader: PShader, name: cstring, x: cfloat) {. + cdecl, importc: "sfShader_setFloatParameter", dynlib: LibG.} +proc setFloat2Parameter*(shader: PShader, name: cstring, x, y: cfloat) {. + cdecl, importc: "sfShader_setFloat2Parameter", dynlib: LibG.} +proc setFloat3Parameter*(shader: PShader, name: cstring, x, y, z: cfloat) {. + cdecl, importc: "sfShader_setFloat3Parameter", dynlib: LibG.} +proc setFloat4Parameter*(shader: PShader, name: cstring, x, y, z, w: cfloat) {. + cdecl, importc: "sfShader_setFloat4Parameter", dynlib: LibG.} +proc setVector2Parameter*(shader: PShader, name: cstring, vector: TVector2f) {. + cdecl, importc: "sfShader_setVector2Parameter", dynlib: LibG.} +proc setVector3Parameter*(shader: PShader, name: cstring, vector: TVector3f) {. + cdecl, importc: "sfShader_setVector3Parameter", dynlib: LibG.} +proc setColorParameter*(shader: PShader, name: cstring, color: TColor) {. + cdecl, importc: "sfShader_setColorParameter", dynlib: LibG.} +proc setTransformParameter*(shader: PShader, name: cstring, transform: TTransform) {. + cdecl, importc: "sfShader_setTransformParameter", dynlib: LibG.} +proc setTextureParameter*(shader: PShader, name: cstring, texture: PTexture) {. + cdecl, importc: "sfShader_setTextureParameter", dynlib: LibG.} +proc setCurrentTextureParameter*(shader: PShader, name: cstring) {. + cdecl, importc: "sfShader_setCurrentTextureParameter", dynlib: LibG.} +proc bindGL*(shader: PShader) {. + cdecl, importc: "sfShader_bind", dynlib: LibG.} +proc unbindGL*(shader: PShader) {. + cdecl, importc: "sfShader_unbind", dynlib: LibG.} +proc shaderIsAvailable*(): bool {. + cdecl, importc: "sfShader_isAvailable", dynlib: LibG.} + +proc color*(red, green, blue: cchar): TColor {. + cdecl, importc: "sfColor_fromRGB", dynlib: LibG.} +proc color*(red, green, blue: int): TColor {.inline.} = + return color(red.cchar, green.cchar, blue.cchar) +proc color*(red, green, blue, alpha: cchar): TColor {. + cdecl, importc: "sfColor_fromRGBA", dynlib: LibG.} +proc color*(red, green, blue, alpha: int): TColor {.inline.} = + return color(red.cchar, green.cchar, blue.cchar, alpha.cchar) +proc `+`*(color1, color2: TColor): TColor {. + cdecl, importc: "sfColor_add", dynlib: LibG.} +proc `*`*(color1, color2: TColor): TColor {. + cdecl, importc: "sfColor_modulate", dynlib: LibG.} +proc newColor*(r,g,b: int): TColor {.inline.} = + return color(r,g,b) +proc newColor*(r,g,b,a: int): TColor {.inline.} = + return color(r,g,b,a) + +proc newClock*(): PClock {. + cdecl, importc: "sfClock_create", dynlib: LibS.} +proc copy*(clocK: PClock): PClock {. + cdecl, importc: "sfClock_copy", dynlib: LibS.} +proc destroy*(clock: PClock): PClock {. + cdecl, importc: "sfClock_destroy", dynlib: LibS.} +proc getElapsedTime*(clock: PClock): TTime {. + cdecl, importc: "sfClock_getElapsedTime", dynlib: LibS.} +proc restart*(clock: PClock): TTime {. + cdecl, importc: "sfClock_restart", dynlib: LibS, discardable.} +proc asSeconds*(time: TTime): cfloat {. + cdecl, importc: "sfTime_asSeconds", dynlib: LibS.} +proc asMilliseconds*(time: TTime): int32 {. + cdecl, importc: "sfTime_asMilliseconds", dynlib: LibS.} +proc asMicroseconds*(time: TTime): int64 {. + cdecl, importc: "sfTime_asMicroseconds", dynlib: LibS.} +proc seconds*(seconds: cfloat): TTime {. + cdecl, importc: "sfSeconds", dynlib: LibS.} +proc milliseconds*(ms: int32): TTime {. + cdecl, importc: "sfMilliseconds", dynlib: LibS.} +proc microseconds*(us: int64): TTime {. + cdecl, importc: "sfMicroseconds", dynlib: LibS.} + +proc newContextSettings*(depthBits: cint = 0, + stencilBits: cint = 0, + antialiasingLevel: cint = 0, + majorVersion: cint = 0, + minorVersion: cint = 0): TContextSettings = + result.depthBits = depthBits + result.stencilBits = stencilBits + result.antialiasingLevel = antialiasingLevel + result.majorVersion = majorVersion + result.minorVersion = minorVersion + +proc newCircleShape*(radius: cfloat; pointCount: cint = 30): PCircleShape = + result = newCircleShape() + result.setRadius radius + result.setPointCount pointCount +proc newText*(str: string, font: PFont, size: int): PText = + result = newText() + result.setString(str) + result.setFont(font) + result.setCharacterSize(size.cint) +proc newVertexArray*(primitiveType: TPrimitiveType, vertexCount: cint = 0): PVertexArray = + result = newVertexArray() + result.setPrimitiveType(primitiveType) + if vertexCount != 0: + result.resize(vertexCount) +proc videoMode*(width, height, bpp: cint): TVideoMode = + result.width = width + result.height = height + result.bitsPerPixel = bpp + +proc `[]`*(a: PVertexArray, index: int): PVertex = + return getVertex(a, index.cint) + +proc `$` *(a: TContextSettings): string = + return "<TContextSettings stencil=$1 aa=$2 major=$3 minor=$4 depth=$5>" % [ + $a.stencilBits, $a.antialiasingLevel, $a.majorVersion, $a.minorVersion, $a.depthBits] +proc `$` *(a: TVideoMode): string = + return "<TVideoMode $1x$2 $3bpp>" % [$a.width, $a.height, $a.bitsPerPixel] +proc `$` *(a: TFloatRect): string = + return "<TFloatRect $1,$2 $3x$4>" % [$a.left, $a.top, $a.width, $a.height] +proc `$` *(a: PView): string = + return $a.getViewport() +proc `$` *(a: TVector2f): string = + return "<TVector2f $1,$2>" % [$a.x, $a.y] + +proc vec2i*(x, y: int): TVector2i = + result.x = x.cint + result.y = y.cint +proc vec2f*(x, y: float): TVector2f = + result.x = x.cfloat + result.y = y.cfloat + +proc `+`*(a, b: TVector2f): TVector2f {.inline.} = + result.x = a.x + b.x + result.y = a.y + b.y +proc `-`*(a: TVector2f): TVector2f {.inline.} = + result.x = -a.x + result.y = -a.y +proc `-`*(a, b: TVector2f): TVector2f {.inline.}= + result.x = a.x - b.x + result.y = a.y - b.y +proc `*`*(a: TVector2f, b: cfloat): TVector2f {.inline.} = + result.x = a.x * b + result.y = a.y * b +proc `*`*(a, b: TVector2f): TVector2f {.inline.} = + result.x = a.x * b.x + result.y = a.y * b.y +proc `/`*(a: TVector2f, b: cfloat): TVector2f {.inline.} = + result.x = a.x / b + result.y = a.y / b +proc `+=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = + a = a + b +proc `-=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = + a = a - b +proc `*=` *(a: var TVector2f, b: float) {.inline, noSideEffect.} = + a = a * b +proc `*=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = + a = a * b +proc `/=` *(a: var TVector2f, b: float) {.inline, noSideEffect.} = + a = a / b +proc `<` *(a, b: TVector2f): bool {.inline, noSideEffect.} = + return a.x < b.x or (a.x == b.x and a.y < b.y) +proc `<=` *(a, b: TVector2f): bool {.inline, noSideEffect.} = + return a.x <= b.x and a.y <= b.y +proc `==` *(a, b: TVector2f): bool {.inline, noSideEffect.} = + return a.x == b.x and a.y == b.y +proc length*(a: TVector2f): float {.inline.} = + return sqrt(pow(a.x, 2.0) + pow(a.y, 2.0)) +proc lengthSq*(a: TVector2f): float {.inline.} = + return pow(a.x, 2.0) + pow(a.y, 2.0) +proc distanceSq*(a, b: TVector2f): float {.inline.} = + return pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0) +proc distance*(a, b: TVector2f): float {.inline.} = + return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0)) +proc permul*(a, b: TVector2f): TVector2f = + result.x = a.x * b.x + result.y = a.y * b.y +proc rotate*(a: TVector2f, phi: float): TVector2f = + var c = cos(phi) + var s = sin(phi) + result.x = a.x * c - a.y * s + result.y = a.x * s + a.y * c +proc perpendicular(a: TVector2f): TVector2f = + result.x = -a.x + result.y = a.y +proc cross(a, b: TVector2f): float = + return a.x * b.y - a.y * b.x + diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim new file mode 100644 index 000000000..6f81e50a3 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim @@ -0,0 +1,899 @@ +import + sfml +const + Lib = "libcsfml-audio.so.2.0" +type + PMusic* = ptr TMusic + TMusic* {.pure, final.} = object + PSound* = ptr TSound + TSound* {.pure, final.} = object + PSoundBuffer* = ptr TSoundBuffer + TSoundBuffer* {.pure, final.} = object + PSoundBufferRecorder* = ptr TSoundBufferRecorder + TSoundBufferRecorder* {.pure, final.} = object + PSoundRecorder* = ptr TSoundRecorder + TSoundRecorder* {.pure, final.} = object + PSoundStream* = ptr TSoundStream + TSoundStream* {.pure, final.} = object + TSoundStatus* {.size: sizeof(cint).} = enum + Stopped, Paused, Playing + +proc newMusic*(filename: cstring): PMusic {. + cdecl, importc: "sfMusic_createFromFile", dynlib: Lib.} +proc newMusic*(data: pointer, size: cint): PMusic {. + cdecl, importc: "sfMusic_createFromMemory", dynlib: Lib.} +proc newMusic*(stream: PInputStream): PMusic {. + cdecl, importc: "sfMusic_createFromStream", dynlib: Lib.} +proc destroy*(music: PMusic) {. + cdecl, importc: "sfMusic_destroy", dynlib: Lib.} +proc setLoop*(music: PMusic, loop: bool) {. + cdecl, importc: "sfMusic_setLoop", dynlib: Lib.} +proc getLoop*(music: PMusic): bool {. + cdecl, importc: "sfMusic_getLoop", dynlib: Lib.} +proc getDuration*(music: PMusic): TTime {. + cdecl, importc: "sfMusic_getDuration", dynlib: Lib.} +proc play*(music: PMusic) {. + cdecl, importc: "sfMusic_play", dynlib: Lib.} +proc pause*(music: PMusic) {. + cdecl, importc: "sfMusic_pause", dynlib: Lib.} +proc stop*(music: PMusic) {. + cdecl, importc: "sfMusic_stop", dynlib: Lib.} +proc getChannelCount*(music: PMusic): cint {. + cdecl, importc: "sfMusic_getChannelCount", dynlib: Lib.} +proc getSampleRate*(music: PMusic): cint {. + cdecl, importc: "sfMusic_getSampleRate", dynlib: Lib.} +proc getStatus*(music: PMusic): TSoundStatus {. + cdecl, importc: "sfMusic_getStatus", dynlib: Lib.} +proc getPlayingOffset*(music: PMusic): TTime {. + cdecl, importc: "sfMusic_getPlayingOffset", dynlib: Lib.} +proc setPitch*(music: PMusic, pitch: cfloat) {. + cdecl, importc: "sfMusic_setPitch", dynlib: Lib.} +proc setVolume*(music: PMusic, volume: float) {. + cdecl, importc: "sfMusic_setVolume", dynlib: Lib.} +proc setPosition*(music: PMusic, position: TVector3f) {. + cdecl, importc: "sfMusic_setPosition", dynlib: Lib.} +proc setRelativeToListener*(music: PMusic, relative: bool) {. + cdecl, importc: "sfMusic_setRelativeToListener", dynlib: Lib.} +proc setMinDistance*(music: PMusic, distance: cfloat) {. + cdecl, importc: "sfMusic_setMinDistance", dynlib: Lib.} +proc setAttenuation*(music: PMusic, attenuation: cfloat) {. + cdecl, importc: "sfMusic_setAttenuation", dynlib: Lib.} +proc setPlayingOffset*(music: PMusic, time: TTime) {. + cdecl, importc: "sfMusic_setPlayingOffset", dynlib: Lib.} +proc getPitch*(music: PMusic): cfloat {. + cdecl, importc: "sfMusic_getPitch", dynlib: Lib.} +proc getVolume*(music: PMusic): cfloat {. + cdecl, importc: "sfMusic_getVolume", dynlib: Lib.} +proc getPosition*(music: PMusic): TVector3f {. + cdecl, importc: "sfMusic_getPosition", dynlib: Lib.} +proc isRelativeToListener*(music: PMusic): bool {. + cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.} +proc getMinDistance*(music: PMusic): cfloat {. + cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.} +proc getAttenuation*(music: PMusic): cfloat {. + cdecl, importc: "sfMusic_isRelativeToListener", dynlib: Lib.} + +#/ \brief Create a new sound +proc newSound*(): PSound{. + cdecl, importc: "sfSound_create", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound by copying an existing one +#/ +#/ \param sound Sound to copy +#/ +#/ \return A new sfSound object which is a copy of \a sound +#/ +#////////////////////////////////////////////////////////// +proc copy*(sound: PSound): PSound{. + cdecl, importc: "sfSound_copy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound +proc destroy*(sound: PSound){. + cdecl, importc: "sfSound_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Start or resume playing a sound +#/ +#/ This function starts the sound if it was stopped, resumes +#/ it if it was paused, and restarts it from beginning if it +#/ was it already playing. +#/ This function uses its own thread so that it doesn't block +#/ the rest of the program while the sound is played. +proc play*(sound: PSound){. + cdecl, importc: "sfSound_play", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ This function pauses the sound if it was playing, +#/ otherwise (sound already paused or stopped) it has no effect. +proc pause*(sound: PSound){. + cdecl, importc: "sfSound_pause", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ This function stops the sound if it was playing or paused, +#/ and does nothing if it was already stopped. +#/ It also resets the playing position (unlike sfSound_pause). +proc stop*(sound: PSound){. + cdecl, importc: "sfSound_stop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ It is important to note that the sound buffer is not copied, +#/ thus the sfSoundBuffer object must remain alive as long +#/ as it is attached to the sound. +proc setBuffer*(sound: PSound; buffer: PSoundBuffer){. + cdecl, importc: "sfSound_setBuffer", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the audio buffer attached to a sound +proc getBuffer*(sound: PSound): PSoundBuffer{. + cdecl, importc: "sfSound_getBuffer", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set whether or not a sound should loop after reaching the end +#/ +#/ If set, the sound will restart from beginning after +#/ reaching the end and so on, until it is stopped or +#/ sfSound_setLoop(sound, sfFalse) is called. +#/ The default looping state for sounds is false. +proc setLoop*(sound: PSound; loop: bool){. + cdecl, importc: "sfSound_setLoop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Tell whether or not a soud is in loop mode +proc getLoop*(sound: PSound): bool {. + cdecl, importc: "sfSound_getLoop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current status of a sound (stopped, paused, playing) +proc getStatus*(sound: PSound): TSoundStatus{. + cdecl, importc: "sfSound_getStatus", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the pitch of a sound +#/ +#/ The pitch represents the perceived fundamental frequency +#/ of a sound; thus you can make a sound more acute or grave +#/ by changing its pitch. A side effect of changing the pitch +#/ is to modify the playing speed of the sound as well. +#/ The default value for the pitch is 1. +proc setPitch*(sound: PSound; pitch: cfloat){. + cdecl, importc: "sfSound_setPitch", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the volume of a sound +#/ +#/ The volume is a value between 0 (mute) and 100 (full volume). +#/ The default value for the volume is 100. +proc setVolume*(sound: PSound; volume: cfloat){. + cdecl, importc: "sfSound_setVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the 3D position of a sound in the audio scene +#/ +#/ Only sounds with one channel (mono sounds) can be +#/ spatialized. +#/ The default position of a sound is (0, 0, 0). +proc setPosition*(sound: PSound; position: TVector3f){. + cdecl, importc: "sfSound_setPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Make the sound's position relative to the listener or absolute +#/ +#/ Making a sound relative to the listener will ensure that it will always +#/ be played the same way regardless the position of the listener. +#/ This can be useful for non-spatialized sounds, sounds that are +#/ produced by the listener, or sounds attached to it. +#/ The default value is false (position is absolute). +proc setRelativeToListener*(sound: PSound; relative: bool){. + cdecl, importc: "sfSound_setRelativeToListener", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the minimum distance of a sound +#/ +#/ The "minimum distance" of a sound is the maximum +#/ distance at which it is heard at its maximum volume. Further +#/ than the minimum distance, it will start to fade out according +#/ to its attenuation factor. A value of 0 ("inside the head +#/ of the listener") is an invalid value and is forbidden. +#/ The default value of the minimum distance is 1. +proc setMinDistance*(sound: PSound; distance: cfloat){. + cdecl, importc: "sfSound_setMinDistance", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the attenuation factor of a sound +#/ +#/ The attenuation is a multiplicative factor which makes +#/ the sound more or less loud according to its distance +#/ from the listener. An attenuation of 0 will produce a +#/ non-attenuated sound, i.e. its volume will always be the same +#/ whether it is heard from near or from far. On the other hand, +#/ an attenuation value such as 100 will make the sound fade out +#/ very quickly as it gets further from the listener. +#/ The default value of the attenuation is 1. +proc setAttenuation*(sound: PSound; attenuation: cfloat){. + cdecl, importc: "sfSound_setAttenuation", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Change the current playing position of a sound +#/ +#/ The playing position can be changed when the sound is +#/ either paused or playing. +proc setPlayingOffset*(sound: PSound; timeOffset: sfml.TTime){. + cdecl, importc: "sfSound_setPlayingOffset", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the pitch of a sound +proc getPitch*(sound: PSound): cfloat{. + cdecl, importc: "sfSound_getPitch", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the volume of a sound +proc getVolume*(sound: PSound): cfloat{. + cdecl, importc: "sfSound_getVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the 3D position of a sound in the audio scene +proc getPosition*(sound: PSound): TVector3f{. + cdecl, importc: "sfSound_getPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Tell whether a sound's position is relative to the +#/ listener or is absolute +proc isRelativeToListener*(sound: PSound): bool{. + cdecl, importc: "sfSound_isRelativeToListener", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the minimum distance of a sound +proc getMinDistance*(sound: PSound): cfloat{. + cdecl, importc: "sfSound_getMinDistance", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the attenuation factor of a sound +proc getAttenuation*(sound: PSound): cfloat{. + cdecl, importc: "sfSound_getAttenuation", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current playing position of a sound +proc getPlayingOffset*(sound: PSound): TTime{. + cdecl, importc: "sfSound_getPlayingOffset", dynlib: Lib.} + +#////////////////////////////////////////////////////////// +# Headers +#////////////////////////////////////////////////////////// +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer and load it from a file +#/ +#/ Here is a complete list of all the supported audio formats: +#/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, +#/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. +#/ +#/ \param filename Path of the sound file to load +#/ +#/ \return A new sfSoundBuffer object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundBuffer*(filename: cstring): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_createFromFile", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer and load it from a file in memory +#/ +#/ Here is a complete list of all the supported audio formats: +#/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, +#/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. +#/ +#/ \param data Pointer to the file data in memory +#/ \param sizeInBytes Size of the data to load, in bytes +#/ +#/ \return A new sfSoundBuffer object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundBuffer*(data: pointer; sizeInBytes: cint): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_createFromMemory", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer and load it from a custom stream +#/ +#/ Here is a complete list of all the supported audio formats: +#/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, +#/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. +#/ +#/ \param stream Source stream to read from +#/ +#/ \return A new sfSoundBuffer object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundBuffer*(stream: PInputStream): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_createFromStream", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer and load it from an array of samples in memory +#/ +#/ The assumed format of the audio samples is 16 bits signed integer +#/ (sfint16). +#/ +#/ \param samples Pointer to the array of samples in memory +#/ \param sampleCount Number of samples in the array +#/ \param channelCount Number of channels (1 = mono, 2 = stereo, ...) +#/ \param sampleRate Sample rate (number of samples to play per second) +#/ +#/ \return A new sfSoundBuffer object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc createFromSamples*(samples: ptr int16; sampleCount: cuint; + channelCount: cuint; sampleRate: cuint): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_createFromSamples", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer by copying an existing one +#/ +#/ \param soundBuffer Sound buffer to copy +#/ +#/ \return A new sfSoundBuffer object which is a copy of \a soundBuffer +#/ +#////////////////////////////////////////////////////////// +proc copy*(soundBuffer: PSoundBuffer): PSoundBuffer{. + cdecl, importc: "sfSoundBuffer_copy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound buffer +#/ +#/ \param soundBuffer Sound buffer to destroy +#/ +#////////////////////////////////////////////////////////// +proc destroy*(soundBuffer: PSoundBuffer){. + cdecl, importc: "sfSoundBuffer_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Save a sound buffer to an audio file +#/ +#/ Here is a complete list of all the supported audio formats: +#/ ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, +#/ w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. +#/ +#/ \param soundBuffer Sound buffer object +#/ \param filename Path of the sound file to write +#/ +#/ \return sfTrue if saving succeeded, sfFalse if it failed +#/ +#////////////////////////////////////////////////////////// +proc saveToFile*(soundBuffer: PSoundBuffer; filename: cstring): bool {. + cdecl, importc: "sfSoundBuffer_saveToFile", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the array of audio samples stored in a sound buffer +#/ +#/ The format of the returned samples is 16 bits signed integer +#/ (sfint16). The total number of samples in this array +#/ is given by the sfSoundBuffer_getSampleCount function. +#/ +#/ \param soundBuffer Sound buffer object +#/ +#/ \return Read-only pointer to the array of sound samples +#/ +#////////////////////////////////////////////////////////// +proc sfSoundBuffer_getSamples*(soundBuffer: PSoundBuffer): ptr int16{. + cdecl, importc: "sfSoundBuffer_getSamples", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the number of samples stored in a sound buffer +#/ +#/ The array of samples can be accessed with the +#/ sfSoundBuffer_getSamples function. +proc getSampleCount*(soundBuffer: PSoundBuffer): cint{. + cdecl, importc: "sfSoundBuffer_getSampleCount", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sample rate of a sound buffer +#/ +#/ The sample rate is the number of samples played per second. +#/ The higher, the better the quality (for example, 44100 +#/ samples/s is CD quality). +proc getSampleRate*(soundBuffer: PSoundBuffer): cuint{. + cdecl, importc: "sfSoundBuffer_getSampleRate", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the number of channels used by a sound buffer +#/ +#/ If the sound is mono then the number of channels will +#/ be 1, 2 for stereo, etc. +proc getChannelCount*(soundBuffer: PSoundBuffer): cuint{. + cdecl, importc: "sfSoundBuffer_getChannelCount", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the total duration of a sound buffer +#/ +#/ \param soundBuffer Sound buffer object +#/ +#/ \return Sound duration +#/ +#////////////////////////////////////////////////////////// +proc getDuration*(soundBuffer: PSoundBuffer): TTime{. + cdecl, importc: "sfSoundBuffer_getDuration", dynlib: Lib.} + +#////////////////////////////////////////////////////////// +#/ \brief Change the global volume of all the sounds and musics +#/ +#/ The volume is a number between 0 and 100; it is combined with +#/ the individual volume of each sound / music. +#/ The default value for the volume is 100 (maximum). +#/ +#/ \param volume New global volume, in the range [0, 100] +#/ +#////////////////////////////////////////////////////////// +proc listenerSetGlobalVolume*(volume: cfloat){. + cdecl, importc: "sfListener_setGlobalVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current value of the global volume +#/ +#/ \return Current global volume, in the range [0, 100] +#/ +#////////////////////////////////////////////////////////// +proc listenerGetGlobalVolume*(): cfloat{. + cdecl, importc: "sfListener_getGlobalVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the position of the listener in the scene +#/ +#/ The default listener's position is (0, 0, 0). +#/ +#/ \param position New position of the listener +#/ +#////////////////////////////////////////////////////////// +proc listenerSetPosition*(position: TVector3f){. + cdecl, importc: "sfListener_setPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current position of the listener in the scene +#/ +#/ \return The listener's position +#/ +#////////////////////////////////////////////////////////// +proc listenerGetPosition*(): TVector3f{. + cdecl, importc: "sfListener_getPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the orientation of the listener in the scene +#/ +#/ The orientation defines the 3D axes of the listener +#/ (left, up, front) in the scene. The orientation vector +#/ doesn't have to be normalized. +#/ The default listener's orientation is (0, 0, -1). +#/ +#/ \param position New direction of the listener +#/ +#////////////////////////////////////////////////////////// +proc listenerSetDirection*(orientation: TVector3f){. + cdecl, importc: "sfListener_setDirection", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current orientation of the listener in the scene +#/ +#/ \return The listener's direction +#/ +#////////////////////////////////////////////////////////// +proc listenerGetDirection*(): TVector3f{. + cdecl, importc: "sfListener_getDirection", dynlib: Lib.} + +type + TSoundRecorderStartCallback* = proc (a2: pointer): bool {.cdecl.} + #/< Type of the callback used when starting a capture + TSoundRecorderProcessCallback* = proc(a2: ptr int16; a3: cuint; + a4: pointer): bool {.cdecl.} + #/< Type of the callback used to process audio data + TSoundRecorderStopCallback* = proc (a2: pointer){.cdecl.} + #/< Type of the callback used when stopping a capture +#////////////////////////////////////////////////////////// +#/ \brief Construct a new sound recorder from callback functions +#/ +#/ \param onStart Callback function which will be called when a new capture starts (can be NULL) +#/ \param onProcess Callback function which will be called each time there's audio data to process +#/ \param onStop Callback function which will be called when the current capture stops (can be NULL) +#/ \param userData Data to pass to the callback function (can be NULL) +#/ +#/ \return A new sfSoundRecorder object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundRecorder*(onStart: TSoundRecorderStartCallback; + onProcess: TSoundRecorderProcessCallback; + onStop: TSoundRecorderStopCallback; + userData: pointer = nil): PSoundRecorder{. + cdecl, importc: "sfSoundRecorder_create", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound recorder +#/ +#/ \param soundRecorder Sound recorder to destroy +#/ +#////////////////////////////////////////////////////////// +proc destroy*(soundRecorder: PSoundRecorder){. + cdecl, importc: "sfSoundRecorder_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Start the capture of a sound recorder +#/ +#/ The \a sampleRate parameter defines the number of audio samples +#/ captured per second. The higher, the better the quality +#/ (for example, 44100 samples/sec is CD quality). +#/ This function uses its own thread so that it doesn't block +#/ the rest of the program while the capture runs. +#/ Please note that only one capture can happen at the same time. +#/ +#/ \param soundRecorder Sound recorder object +#/ \param sampleRate Desired capture rate, in number of samples per second +#/ +#////////////////////////////////////////////////////////// +proc start*(soundRecorder: PSoundRecorder; sampleRate: cuint){. + cdecl, importc: "sfSoundRecorder_start", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Stop the capture of a sound recorder +#/ +#/ \param soundRecorder Sound recorder object +#/ +#////////////////////////////////////////////////////////// +proc stop*(soundRecorder: PSoundRecorder){. + cdecl, importc: "sfSoundRecorder_stop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sample rate of a sound recorder +#/ +#/ The sample rate defines the number of audio samples +#/ captured per second. The higher, the better the quality +#/ (for example, 44100 samples/sec is CD quality). +#/ +#/ \param soundRecorder Sound recorder object +#/ +#/ \return Sample rate, in samples per second +#/ +#////////////////////////////////////////////////////////// +proc getSampleRate*(soundRecorder: PSoundRecorder): cuint{. + cdecl, importc: "sfSoundRecorder_getSampleRate", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Check if the system supports audio capture +#/ +#/ This function should always be called before using +#/ the audio capture features. If it returns false, then +#/ any attempt to use sfSoundRecorder will fail. +#/ +#/ \return sfTrue if audio capture is supported, sfFalse otherwise +#/ +#////////////////////////////////////////////////////////// +proc soundRecorderIsAvailable*(): bool {. + cdecl, importc: "sfSoundRecorder_isAvailable", dynlib: Lib.} + +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound buffer recorder +#/ +#/ \return A new sfSoundBufferRecorder object (NULL if failed) +#/ +#////////////////////////////////////////////////////////// +proc newSoundBufferRecorder*(): PSoundBufferRecorder{. + cdecl, importc: "sfSoundBufferRecorder_create", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound buffer recorder +#/ +#/ \param soundBufferRecorder Sound buffer recorder to destroy +#/ +#////////////////////////////////////////////////////////// +proc destroy*(soundBufferRecorder: PSoundBufferRecorder){. + cdecl, importc: "sfSoundBufferRecorder_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Start the capture of a sound recorder recorder +#/ +#/ The \a sampleRate parameter defines the number of audio samples +#/ captured per second. The higher, the better the quality +#/ (for example, 44100 samples/sec is CD quality). +#/ This function uses its own thread so that it doesn't block +#/ the rest of the program while the capture runs. +#/ Please note that only one capture can happen at the same time. +#/ +#/ \param soundBufferRecorder Sound buffer recorder object +#/ \param sampleRate Desired capture rate, in number of samples per second +#/ +#////////////////////////////////////////////////////////// +proc start*(soundBufferRecorder: PSoundBufferRecorder; sampleRate: cuint){. + cdecl, importc: "sfSoundBufferRecorder_start", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Stop the capture of a sound recorder +#/ +#/ \param soundBufferRecorder Sound buffer recorder object +#/ +#////////////////////////////////////////////////////////// +proc stop*(soundBufferRecorder: PSoundBufferRecorder){. + cdecl, importc: "sfSoundBufferRecorder_stop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sample rate of a sound buffer recorder +#/ +#/ The sample rate defines the number of audio samples +#/ captured per second. The higher, the better the quality +#/ (for example, 44100 samples/sec is CD quality). +#/ +#/ \param soundBufferRecorder Sound buffer recorder object +#/ +#/ \return Sample rate, in samples per second +#/ +#////////////////////////////////////////////////////////// +proc getSampleRate*(soundBufferRecorder: PSoundBufferRecorder): cuint{. + cdecl, importc: "sfSoundBufferRecorder_getSampleRate", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sound buffer containing the captured audio data +#/ +#/ The sound buffer is valid only after the capture has ended. +#/ This function provides a read-only access to the internal +#/ sound buffer, but it can be copied if you need to +#/ make any modification to it. +#/ +#/ \param soundBufferRecorder Sound buffer recorder object +#/ +#/ \return Read-only access to the sound buffer +#/ +#////////////////////////////////////////////////////////// +proc getBuffer*(soundBufferRecorder: PSoundBufferRecorder): PSoundBuffer{. + cdecl, importc: "sfSoundBufferRecorder_getBuffer", dynlib: Lib.} + + +#////////////////////////////////////////////////////////// +#/ \brief defines the data to fill by the OnGetData callback +#/ +#////////////////////////////////////////////////////////// +type + PSoundStreamChunk* = ptr TSoundStreamChunk + TSoundStreamChunk*{.pure, final.} = object + samples*: ptr int16 #/< Pointer to the audio samples + sampleCount*: cuint #/< Number of samples pointed by Samples + + TSoundStreamGetDataCallback* = proc (a2: PSoundStreamChunk; + a3: pointer): bool{.cdecl.} + #/< Type of the callback used to get a sound stream data + TSoundStreamSeekCallback* = proc (a2: TTime; a3: pointer){.cdecl.} + #/< Type of the callback used to seek in a sound stream +#////////////////////////////////////////////////////////// +#/ \brief Create a new sound stream +#/ +#/ \param onGetData Function called when the stream needs more data (can't be NULL) +#/ \param onSeek Function called when the stream seeks (can't be NULL) +#/ \param channelCount Number of channels to use (1 = mono, 2 = stereo) +#/ \param sampleRate Sample rate of the sound (44100 = CD quality) +#/ \param userData Data to pass to the callback functions +#/ +#/ \return A new sfSoundStream object +#/ +#////////////////////////////////////////////////////////// +proc create*(onGetData: TSoundStreamGetDataCallback; onSeek: TSoundStreamSeekCallback; + channelCount: cuint; sampleRate: cuint; userData: pointer): PSoundStream{. + cdecl, importc: "sfSoundStream_create", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Destroy a sound stream +#/ +#/ \param soundStream Sound stream to destroy +#/ +#////////////////////////////////////////////////////////// +proc destroy*(soundStream: PSoundStream){. + cdecl, importc: "sfSoundStream_destroy", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Start or resume playing a sound stream +#/ +#/ This function starts the stream if it was stopped, resumes +#/ it if it was paused, and restarts it from beginning if it +#/ was it already playing. +#/ This function uses its own thread so that it doesn't block +#/ the rest of the program while the music is played. +#/ +#/ \param soundStream Sound stream object +#/ +#////////////////////////////////////////////////////////// +proc play*(soundStream: PSoundStream){. + cdecl, importc: "sfSoundStream_play", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Pause a sound stream +#/ +#/ This function pauses the stream if it was playing, +#/ otherwise (stream already paused or stopped) it has no effect. +#/ +#/ \param soundStream Sound stream object +#/ +#////////////////////////////////////////////////////////// +proc pause*(soundStream: PSoundStream){. + cdecl, importc: "sfSoundStream_pause", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Stop playing a sound stream +#/ +#/ This function stops the stream if it was playing or paused, +#/ and does nothing if it was already stopped. +#/ It also resets the playing position (unlike sfSoundStream_pause). +#/ +#/ \param soundStream Sound stream object +#/ +#////////////////////////////////////////////////////////// +proc stop*(soundStream: PSoundStream){. + cdecl, importc: "sfSoundStream_stop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current status of a sound stream (stopped, paused, playing) +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Current status +#/ +#////////////////////////////////////////////////////////// +proc getStatus*(soundStream: PSoundStream): TSoundStatus{. + cdecl, importc: "sfSoundStream_getStatus", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Return the number of channels of a sound stream +#/ +#/ 1 channel means a mono sound, 2 means stereo, etc. +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Number of channels +#/ +#////////////////////////////////////////////////////////// +proc getChannelCount*(soundStream: PSoundStream): cuint{. + cdecl, importc: "sfSoundStream_getChannelCount", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the sample rate of a sound stream +#/ +#/ The sample rate is the number of audio samples played per +#/ second. The higher, the better the quality. +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Sample rate, in number of samples per second +#/ +#////////////////////////////////////////////////////////// +proc getSampleRate*(soundStream: PSoundStream): cuint{. + cdecl, importc: "sfSoundStream_getSampleRate", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the pitch of a sound stream +#/ +#/ The pitch represents the perceived fundamental frequency +#/ of a sound; thus you can make a stream more acute or grave +#/ by changing its pitch. A side effect of changing the pitch +#/ is to modify the playing speed of the stream as well. +#/ The default value for the pitch is 1. +#/ +#/ \param soundStream Sound stream object +#/ \param pitch New pitch to apply to the stream +#/ +#////////////////////////////////////////////////////////// +proc setPitch*(soundStream: PSoundStream; pitch: cfloat){. + cdecl, importc: "sfSoundStream_setPitch", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the volume of a sound stream +#/ +#/ The volume is a value between 0 (mute) and 100 (full volume). +#/ The default value for the volume is 100. +#/ +#/ \param soundStream Sound stream object +#/ \param volume Volume of the stream +#/ +#////////////////////////////////////////////////////////// +proc setVolume*(soundStream: PSoundStream; volume: cfloat){. + cdecl, importc: "sfSoundStream_setVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the 3D position of a sound stream in the audio scene +#/ +#/ Only streams with one channel (mono streams) can be +#/ spatialized. +#/ The default position of a stream is (0, 0, 0). +#/ +#/ \param soundStream Sound stream object +#/ \param position Position of the stream in the scene +#/ +#////////////////////////////////////////////////////////// +proc setPosition*(soundStream: PSoundStream; position: TVector3f){. + cdecl, importc: "sfSoundStream_setPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Make a sound stream's position relative to the listener or absolute +#/ +#/ Making a stream relative to the listener will ensure that it will always +#/ be played the same way regardless the position of the listener. +#/ This can be useful for non-spatialized streams, streams that are +#/ produced by the listener, or streams attached to it. +#/ The default value is false (position is absolute). +#/ +#/ \param soundStream Sound stream object +#/ \param relative sfTrue to set the position relative, sfFalse to set it absolute +#/ +#////////////////////////////////////////////////////////// +proc setRelativeToListener*(soundStream: PSoundStream; relative: bool){. + cdecl, importc: "sfSoundStream_setRelativeToListener", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the minimum distance of a sound stream +#/ +#/ The "minimum distance" of a stream is the maximum +#/ distance at which it is heard at its maximum volume. Further +#/ than the minimum distance, it will start to fade out according +#/ to its attenuation factor. A value of 0 ("inside the head +#/ of the listener") is an invalid value and is forbidden. +#/ The default value of the minimum distance is 1. +#/ +#/ \param soundStream Sound stream object +#/ \param distance New minimum distance of the stream +#/ +#////////////////////////////////////////////////////////// +proc setMinDistance*(soundStream: PSoundStream; distance: cfloat){. + cdecl, importc: "sfSoundStream_setMinDistance", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set the attenuation factor of a sound stream +#/ +#/ The attenuation is a multiplicative factor which makes +#/ the stream more or less loud according to its distance +#/ from the listener. An attenuation of 0 will produce a +#/ non-attenuated stream, i.e. its volume will always be the same +#/ whether it is heard from near or from far. On the other hand, +#/ an attenuation value such as 100 will make the stream fade out +#/ very quickly as it gets further from the listener. +#/ The default value of the attenuation is 1. +#/ +#/ \param soundStream Sound stream object +#/ \param attenuation New attenuation factor of the stream +#/ +#////////////////////////////////////////////////////////// +proc setAttenuation*(soundStream: PSoundStream; attenuation: cfloat){. + cdecl, importc: "sfSoundStream_setAttenuation", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Change the current playing position of a sound stream +#/ +#/ The playing position can be changed when the stream is +#/ either paused or playing. +#/ +#/ \param soundStream Sound stream object +#/ \param timeOffset New playing position +#/ +#////////////////////////////////////////////////////////// +proc setPlayingOffset*(soundStream: PSoundStream; timeOffset: TTime){. + cdecl, importc: "sfSoundStream_setPlayingOffset", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Set whether or not a sound stream should loop after reaching the end +#/ +#/ If set, the stream will restart from beginning after +#/ reaching the end and so on, until it is stopped or +#/ sfSoundStream_setLoop(stream, sfFalse) is called. +#/ The default looping state for sound streams is false. +#/ +#/ \param soundStream Sound stream object +#/ \param loop sfTrue to play in loop, sfFalse to play once +#/ +#////////////////////////////////////////////////////////// +proc setLoop*(soundStream: PSoundStream; loop: bool){. + cdecl, importc: "sfSoundStream_setLoop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the pitch of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Pitch of the stream +#/ +#////////////////////////////////////////////////////////// +proc getPitch*(soundStream: PSoundStream): cfloat{. + cdecl, importc: "sfSoundStream_getPitch", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the volume of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Volume of the stream, in the range [0, 100] +#/ +#////////////////////////////////////////////////////////// +proc getVolume*(soundStream: PSoundStream): cfloat{. + cdecl, importc: "sfSoundStream_getVolume", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the 3D position of a sound stream in the audio scene +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Position of the stream in the world +#/ +#////////////////////////////////////////////////////////// +proc getPosition*(soundStream: PSoundStream): TVector3f{. + cdecl, importc: "sfSoundStream_getPosition", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Tell whether a sound stream's position is relative to the +#/ listener or is absolute +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return sfTrue if the position is relative, sfFalse if it's absolute +#/ +#////////////////////////////////////////////////////////// +proc isRelativeToListener*(soundStream: PSoundStream): bool{. + cdecl, importc: "sfSoundStream_isRelativeToListener", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the minimum distance of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Minimum distance of the stream +#/ +#////////////////////////////////////////////////////////// +proc getMinDistance*(soundStream: PSoundStream): cfloat{. + cdecl, importc: "sfSoundStream_getMinDistance", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the attenuation factor of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Attenuation factor of the stream +#/ +#////////////////////////////////////////////////////////// +proc getAttenuation*(soundStream: PSoundStream): cfloat{. + cdecl, importc: "sfSoundStream_getAttenuation", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Tell whether or not a sound stream is in loop mode +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return sfTrue if the music is looping, sfFalse otherwise +#/ +#////////////////////////////////////////////////////////// +proc getLoop*(soundStream: PSoundStream): bool{. + cdecl, importc: "sfSoundStream_getLoop", dynlib: Lib.} +#////////////////////////////////////////////////////////// +#/ \brief Get the current playing position of a sound stream +#/ +#/ \param soundStream Sound stream object +#/ +#/ \return Current playing position +#/ +#////////////////////////////////////////////////////////// +proc getPlayingOffset*(soundStream: PSoundStream): TTime{. + cdecl, importc: "sfSoundStream_getPlayingOffset", dynlib: Lib.} diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim new file mode 100644 index 000000000..b4eb1b8f0 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_colors.nim @@ -0,0 +1,15 @@ +import sfml + +let + Black*: TColor = color(0, 0, 0) + White*: TColor = color(255, 255, 255) + Red*: TColor = color(255, 0, 0) + Green*: TColor = color(0, 255, 0) + Blue*: TColor = color(0, 0, 255) + Yellow*: TColor = color(255, 255, 0) + Magenta*: TColor = color(255, 0, 255) + Cyan*: TColor = color(0, 255, 255) + Transparent*: TColor = color(0, 0, 0, 0) + Gray* = color(84, 84, 84) + RoyalBlue* = color(65, 105, 225) +##todo: define more colors lul diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_vector.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_vector.nim new file mode 100644 index 000000000..94c5308a9 --- /dev/null +++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_vector.nim @@ -0,0 +1 @@ +import sfml, math, strutils |