1import 2 strutils, math 3when defined(linux): 4 const 5 LibG = "libcsfml-graphics.so.2.0" 6 LibS = "libcsfml-system.so.2.0" 7 LibW = "libcsfml-window.so.2.0" 8else: 9 # We only compile for testing here, so it doesn't matter it's not supported 10 const 11 LibG = "libcsfml-graphics.so.2.0" 12 LibS = "libcsfml-system.so.2.0" 13 LibW = "libcsfml-window.so.2.0" 14 #{.error: "Platform unsupported".} 15 16{.pragma: pf, pure, final.} 17type 18 PClock* = ptr TClock 19 TClock* {.pf.} = object 20 TTime* {.pf.} = object 21 microseconds*: int64 22 TVector2i* {.pf.} = object 23 x*, y*: cint 24 TVector2f* {.pf.} = object 25 x*, y*: cfloat 26 TVector3f* {.pf.} = object 27 x*, y*, z*: cfloat 28 29 PInputStream* = ptr TInputStream 30 TInputStream* {.pf.} = object 31 read*: TInputStreamReadFunc 32 seek*: TInputStreamSeekFunc 33 tell*: TInputStreamTellFunc 34 getSize*: TInputStreamGetSizeFunc 35 userData*: pointer 36 TInputStreamReadFunc* = proc (data: pointer, size: int64, userData: pointer): int64{. 37 cdecl.} 38 TInputStreamSeekFunc* = proc (position: int16, userData: pointer): int64{. 39 cdecl.} 40 TInputStreamTellFunc* = proc (userData: pointer): int64 {.cdecl.} 41 TInputStreamGetSizeFunc* = proc (userData: pointer): int64 {.cdecl.} 42 PWindow* = ptr TWindow 43 TWindow* {.pf.} = object 44 PContextSettings* = ptr TContextSettings 45 TContextSettings*{.pf.} = object 46 depthBits: cint 47 stencilBits: cint 48 antialiasingLevel: cint 49 majorVersion: cint 50 minorVersion: cint 51 TVideoMode* {.pf.} = object 52 width*: cint 53 height*: cint 54 bitsPerPixel*: cint 55 TEventType*{.size: sizeof(cint).} = enum 56 EvtClosed, EvtResized, EvtLostFocus, EvtGainedFocus, 57 EvtTextEntered, EvtKeyPressed, EvtKeyReleased, EvtMouseWheelMoved, 58 EvtMouseButtonPressed, EvtMouseButtonReleased, EvtMouseMoved, 59 EvtMouseEntered, EvtMouseLeft, EvtJoystickButtonPressed, 60 EvtJoystickButtonReleased, EvtJoystickMoved, EvtJoystickConnected, 61 EvtJoystickDisconnected 62 TKeyEvent*{.pf.} = object 63 code*: TKeyCode 64 alt* : bool 65 control*: bool 66 shift* : bool 67 system* : bool 68 TJoystickConnectEvent*{.pf.} = object 69 joystickId*: cint 70 TJoystickButtonEvent*{.pf.} = object 71 joystickId*: cint 72 button*: cint 73 TJoystickMoveEvent*{.pf.} = object 74 joystickId*: cint 75 axis*: TJoystickAxis 76 position*: cfloat 77 TMouseWheelEvent*{.pf.} = object 78 delta*: cint 79 x*: cint 80 y*: cint 81 TMouseButtonEvent*{.pf.} = object 82 button*: TMouseButton 83 x*: cint 84 y*: cint 85 TMouseMoveEvent*{.pf.} = object 86 x*: cint 87 y*: cint 88 TTextEvent*{.pf.} = object 89 unicode*: cint 90 PEvent* = ptr TEvent 91 TEvent*{.pf.} = object 92 case kind*: TEventType 93 of EvtKeyPressed, EvtKeyReleased: 94 key*: TKeyEvent 95 of EvtMouseButtonPressed, EvtMouseButtonReleased: 96 mouseButton*: TMouseButtonEvent 97 of EvtTextEntered: 98 text*: TTextEvent 99 of EvtJoystickConnected, EvtJoystickDisconnected: 100 joystickConnect*: TJoystickConnectEvent 101 of EvtJoystickMoved: 102 joystickMove*: TJoystickMoveEvent 103 of EvtJoystickButtonPressed, EvtJoystickButtonReleased: 104 joystickButton*: TJoystickButtonEvent 105 of EvtResized: 106 size*: TSizeEvent 107 of EvtMouseMoved, EvtMouseEntered, EvtMouseLeft: 108 mouseMove*: TMouseMoveEvent 109 of EvtMouseWheelMoved: 110 mouseWheel*: TMouseWheelEvent 111 else: nil 112 TJoystickAxis*{.size: sizeof(cint).} = enum 113 JoystickX, JoystickY, JoystickZ, JoystickR, 114 JoystickU, JoystickV, JoystickPovX, JoystickPovY 115 TSizeEvent*{.pf.} = object 116 width*: cint 117 height*: cint 118 TMouseButton*{.size: sizeof(cint).} = enum 119 MouseLeft, MouseRight, MouseMiddle, 120 MouseXButton1, MouseXButton2, MouseButtonCount 121 TKeyCode*{.size: sizeof(cint).} = enum 122 KeyUnknown = - 1, KeyA, KeyB, KeyC, KeyD, KeyE, 123 KeyF, KeyG, KeyH, KeyI, KeyJ, KeyK, KeyL, KeyM, #/< The M key 124 KeyN, KeyO, KeyP, KeyQ, KeyR, KeyS, KeyT, KeyU, #/< The U key 125 KeyV, KeyW, KeyX, KeyY, KeyZ, KeyNum0, KeyNum1, #/< The 1 key 126 KeyNum2, KeyNum3, KeyNum4, KeyNum5, KeyNum6, #/< The 6 key 127 KeyNum7, KeyNum8, KeyNum9, KeyEscape, KeyLControl, #/< The left Control key 128 KeyLShift, KeyLAlt, KeyLSystem, KeyRControl, #/< The right Control key 129 KeyRShift, KeyRAlt, KeyRSystem, KeyMenu, #/< The Menu key 130 KeyLBracket, KeyRBracket, KeySemiColon, KeyComma, #/< The , key 131 KeyPeriod, KeyQuote, KeySlash, KeyBackSlash, #/< The \ key 132 KeyTilde, KeyEqual, KeyDash, KeySpace, KeyReturn, #/< The Return key 133 KeyBack, KeyTab, KeyPageUp, KeyPageDown, KeyEnd, #/< The End key 134 KeyHome, KeyInsert, KeyDelete, KeyAdd, KeySubtract, #/< - 135 KeyMultiply, KeyDivide, KeyLeft, KeyRight, KeyUp, #/< Up arrow 136 KeyDown, KeyNumpad0, KeyNumpad1, KeyNumpad2, #/< The numpad 2 key 137 KeyNumpad3, #/< The numpad 3 key 138 KeyNumpad4, #/< The numpad 4 key 139 KeyNumpad5, #/< The numpad 5 key 140 KeyNumpad6, #/< The numpad 6 key 141 KeyNumpad7, #/< The numpad 7 key 142 KeyNumpad8, #/< The numpad 8 key 143 KeyNumpad9, #/< The numpad 9 key 144 KeyF1, #/< The F1 key 145 KeyF2, #/< The F2 key 146 KeyF3, #/< The F3 key 147 KeyF4, #/< The F4 key 148 KeyF5, #/< The F5 key 149 KeyF6, #/< The F6 key 150 KeyF7, #/< The F7 key 151 KeyF8, #/< The F8 key 152 KeyF9, #/< The F8 key 153 KeyF10, #/< The F10 key 154 KeyF11, #/< The F11 key 155 KeyF12, #/< The F12 key 156 KeyF13, #/< The F13 key 157 KeyF14, #/< The F14 key 158 KeyF15, #/< The F15 key 159 KeyPause, #/< The Pause key 160 KeyCount #/< Keep last -- the total number of keyboard keys 161 162type TWindowHandle* = clong 163 164#elif defined(mac): 165# type TWindowHandle* = pointer ##typedef void* sfWindowHandle; <- whatever the hell that is 166#elif defined(windows): 167# type TWindowHandle* = HWND__ ? windows is crazy. ##struct HWND__; typedef struct HWND__* sfWindowHandle; 168const 169 sfNone* = 0 170 sfTitlebar* = 1 shl 0 171 sfResize* = 1 shl 1 172 sfClose* = 1 shl 2 173 sfFullscreen* = 1 shl 3 174 sfDefaultStyle* = sfTitlebar or sfResize or sfClose 175type 176 PRenderWindow* = ptr TRenderWindow 177 TRenderWindow* {.pf.} = object 178 179 PFont* = ptr TFont 180 TFont* {.pf.} = object 181 PImage* = ptr TImage 182 TImage* {.pf.} = object 183 PShader* = ptr TShader 184 TShader* {.pf.} = object 185 PSprite* = ptr TSprite 186 TSprite* {.pf.} = object 187 PText* = ptr TText 188 TText* {.pf.} = object 189 PTexture* = ptr TTexture 190 TTexture* {.pf.} = object 191 PVertexArray* = ptr TVertexArray 192 TVertexArray* {.pf.} = object 193 PView* = ptr TView 194 TView* {.pf.} = object 195 PRenderTexture* = ptr TRenderTexture 196 TRenderTexture* {.pf.} = object 197 198 PShape* = ptr TShape 199 TShape* {.pf.} = object 200 PCircleShape* = ptr TCircleShape 201 TCircleShape* {.pf.} = object 202 PRectangleShape* = ptr TRectangleShape 203 TRectangleShape* {.pf.} = object 204 PConvexShape* = ptr TConvexShape 205 TConvexShape* {.pf.} = object 206 207 TTextStyle*{.size: sizeof(cint).} = enum 208 TextRegular = 0, TextBold = 1 shl 0, TextItalic = 1 shl 1, 209 TextUnderlined = 1 shl 2 210 211 TBlendMode*{.size: sizeof(cint).} = enum 212 BlendAlpha, BlendAdd, BlendMultiply, BlendNone 213 PRenderStates* = ptr TRenderStates 214 TRenderStates* {.pf.} = object 215 blendMode*: TBlendMode 216 transform*: TTransform 217 texture*: PTexture 218 shader*: PShader 219 220 PTransform* = ptr TTransform 221 TTransform* {.pf.} = object 222 matrix*: array[0..8, cfloat] 223 TColor* {.pf.} = object 224 r*: uint8 225 g*: uint8 226 b*: uint8 227 a*: uint8 228 PFloatRect* = ptr TFloatRect 229 TFloatRect*{.pf.} = object 230 left*: cfloat 231 top*: cfloat 232 width*: cfloat 233 height*: cfloat 234 PIntRect* = ptr TIntRect 235 TIntRect*{.pf.} = object 236 left*: cint 237 top*: cint 238 width*: cint 239 height*: cint 240 TGlyph* {.pf.} = object 241 advance*: cint 242 bounds*: TIntRect 243 textureRect*: TIntRect 244 PVertex* = ptr TVertex 245 TVertex* {.pf.} = object 246 position*: TVector2f 247 color*: TColor 248 texCoords*: TVector2f 249 TPrimitiveType*{.size: sizeof(cint).} = enum 250 Points, #/< List of individual points 251 Lines, #/< List of individual lines 252 LinesStrip, #/< List of connected lines, a point uses the previous point to form a line 253 Triangles, #/< List of individual triangles 254 TrianglesStrip, #/< List of connected triangles, a point uses the two previous points to form a triangle 255 TrianglesFan, #/< List of connected triangles, a point uses the common center and the previous point to form a triangle 256 Quads 257 258 259proc newWindow*(mode: TVideoMode, title: cstring, style: uint32, settings: PContextSettings = nil): PWindow {. 260 cdecl, importc: "sfWindow_create", dynlib: LibW.} 261 262proc close*(window: PWindow) {. 263 cdecl, importc: "sfWindow_close", dynlib: LibW.} 264proc isOpen*(window: PWindow): bool {.cdecl, importc: "sfWindow_isOpen", dynlib: LibW.} 265 266proc pollEvent*(window: PWindow, event: PEvent): bool {. 267 cdecl, importc: "sfWindow_pollEvent", dynlib: LibW.} 268proc waitEvent*(window: PWindow, event: PEvent): bool {. 269 cdecl, importc: "sfWindow_waitEvent", dynlib: LibW.} 270 271proc getDesktopMode*(): TVideoMode {. 272 cdecl, importc: "sfVideoMode_getDesktopMode", dynlib: LibW.} 273proc isKeyPressed*(key: TKeyCode): bool {. 274 cdecl, importc: "sfKeyboard_isKeyPressed", dynlib: LibW.} 275 276proc mouseIsButtonPressed*(button: TMouseButton): bool {. 277 cdecl, importc: "sfMouse_isButtonPressed", dynlib: LibW.} 278proc mouseGetPosition*(relativeTo: PWindow): TVector2i {. 279 cdecl, importc: "sfMouse_getPosition", dynlib: LibW.} 280proc mouseSetPosition*(position: TVector2i, relativeTo: PWindow) {. 281 cdecl, importc: "sfMouse_setPosition", dynlib: LibW.} 282 283proc joystickIsConnected*(joystick: cint): bool {. 284 cdecl, importc: "sfJoystick_isConnected", dynlib: LibW.} 285proc joystickGetButtonCount*(joystick: cint): cint {. 286 cdecl, importc: "sfJoystick_getButtonCount", dynlib: LibW.} 287proc joystickHasAxis*(joystick: cint, axis: TJoystickAxis): bool {. 288 cdecl, importc: "sfJoystick_hasAxis", dynlib: LibW.} 289proc joystickIsButtonPressed*(joystick: cint, button: cint): bool {. 290 cdecl, importc: "sfJoystick_isButtonPressed", dynlib: LibW.} 291proc joystickGetAxisPosition*(joystick: cint, axis: TJoystickAxis): float {. 292 cdecl, importc: "sfJoystick_getAxisPosition", dynlib: LibW.} 293proc joystickUpdate*(): void {. 294 cdecl, importc: "sfJoystick_update", dynlib: LibW.} 295 296 297proc newRenderWindow*(handle: TWindowHandle, settings: PContextSettings = nil): PRenderWindow{. 298 cdecl, importc: "sfRenderWindow_createFromHandle", dynlib: LibG.} 299proc newRenderWindow*(mode: TVideoMode, title: cstring, style: int32, settings: PContextSettings = nil): PRenderWindow {. 300 cdecl, importc: "sfRenderWindow_create", dynlib: LibG.} 301 302proc destroy*(window: PRenderWindow) {. 303 cdecl, importc: "sfRenderWindow_destroy", dynlib: LibG.} 304proc close*(window: PRenderWindow) {. 305 cdecl, importc: "sfRenderWindow_close", dynlib: LibG.} 306proc isOpen*(window: PRenderWindow): bool {. 307 cdecl, importc: "sfRenderWindow_isOpen", dynlib: LibG.} 308 309#void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfuint8* pixels); 310#proc setIcon*(window: PRenderWindow, width, height: cint, pixels: seq[uint8]) {. 311# cdecl, importc: "sfRenderWindow_setIcon", dynlib: LibG.} 312 313proc getSettings*(window: PRenderWindow): TContextSettings {. 314 cdecl, importc: "sfRenderWindow_getSettings", dynlib: LibG.} 315 316proc pollEvent*(window: PRenderWindow, event: PEvent): bool {. 317 cdecl, importc: "sfRenderWindow_pollEvent", dynlib: LibG.} 318proc pollEvent*(window: PRenderWindow; event: var TEvent): bool {. 319 cdecl, importc: "sfRenderWindow_pollEvent", dynlib: LibG.} 320proc waitEvent*(window: PRenderWindow, event: PEvent): bool {. 321 cdecl, importc: "sfRenderWindow_waitEvent", dynlib: LibG.} 322proc waitEvent*(window: PRenderWindow, event: var TEvent): bool {. 323 cdecl, importc: "sfRenderWindow_waitEvent", dynlib: LibG.} 324proc getPosition*(window: PRenderWindow): TVector2i {. 325 cdecl, importc: "sfRenderWindow_getPosition", dynlib: LibG.} 326proc setPosition*(window: PRenderWindow, position: TVector2i) {. 327 cdecl, importc: "sfRenderWindow_setPosition", dynlib: LibG.} 328proc getSize*(window: PRenderWindow): TVector2i {. 329 cdecl, importc: "sfRenderWindow_getSize", dynlib: LibG.} 330proc setSize*(window: PRenderWindow, size: TVector2i): void {. 331 cdecl, importc: "sfRenderWindow_setSize", dynlib: LibG.} 332proc setTitle*(window: PRenderWindow, title: cstring): void {. 333 cdecl, importc: "sfRenderWindow_setTitle", dynlib: LibG.} 334 335proc setVisible*(window: PRenderWindow, visible: bool) {. 336 cdecl, importc: "sfRenderWindow_setVisible", dynlib: LibG.} 337proc setMouseCursorVisible*(window: PRenderWindow, show: bool) {. 338 cdecl, importc: "sfRenderWindow_setMouseCursorVisible", dynlib: LibG.} 339proc setVerticalSyncEnabled*(window: PRenderWindow, enabled: bool) {. 340 cdecl, importc: "sfRenderWindow_setVerticalSyncEnabled", dynlib: LibG.} 341proc setKeyRepeatEnabled*(window: PRenderWindow, enabled: bool) {. 342 cdecl, importc: "sfRenderWindow_setKeyRepeatEnabled", dynlib: LibG.} 343proc setActive*(window: PRenderWindow, active: bool): bool {. 344 cdecl, importc: "sfRenderWindow_setActive", dynlib: LibG.} 345proc display*(window: PRenderWindow) {. 346 cdecl, importc: "sfRenderWindow_display", dynlib: LibG.} 347proc setFramerateLimit*(window: PRenderWindow, limit: uint) {. 348 cdecl, importc: "sfRenderWindow_setFramerateLimit", dynlib: LibG.} 349proc setJoystickThreshold*(window: PRenderWindow, threshold: float) {. 350 cdecl, importc: "sfRenderWindow_setJoystickThreshold", dynlib: LibG.} 351proc getSystemHandle*(window: PRenderWindow): TWindowHandle {. 352 cdecl, importc: "sfRenderWindow_getSystemHandle", dynlib: LibG.} 353 354proc clear*(window: PRenderWindow, color: TColor) {. 355 cdecl, importc: "sfRenderWindow_clear", dynlib: LibG.} 356 357proc setView*(window: PRenderWindow, view: PView) {. 358 cdecl, importc: "sfRenderWindow_setView", dynlib: LibG.} 359proc getView*(window: PRenderWindow): PView {. 360 cdecl, importc: "sfRenderWindow_getView", dynlib: LibG.} 361proc getDefaultView*(window: PRenderWindow): PView {. 362 cdecl, importc: "sfRenderWindow_getDefaultView", dynlib: LibG.} 363proc getViewport*(window: PRenderWindow, view: PView): TIntRect {. 364 cdecl, importc: "sfRenderWindow_getViewport", dynlib: LibG.} 365 366proc convertCoords*(window: PRenderWindow, point: TVector2i, targetView: PView): TVector2f {. 367 cdecl, importc: "sfRenderWindow_convertCoords", dynlib: LibG.} 368 369proc draw*(window: PRenderWindow, sprite: PSprite, states: PRenderStates = nil) {. 370 cdecl, importc: "sfRenderWindow_drawSprite", dynlib: LibG.} 371proc draw*(window: PRenderWindow, text: PText, states: PRenderStates = nil) {. 372 cdecl, importc: "sfRenderWindow_drawText", dynlib: LibG.} 373proc draw*(window: PRenderWindow, shape: PShape, states: PRenderStates = nil) {. 374 cdecl, importc: "sfRenderWindow_drawShape", dynlib: LibG.} 375proc draw*(window: PRenderWindow, shape: PCircleShape, states: PRenderStates = nil) {. 376 cdecl, importc: "sfRenderWindow_drawCircleShape", dynlib: LibG.} 377proc draw*(window: PRenderWindow, shape: PRectangleShape, states: PRenderStates = nil) {. 378 cdecl, importc: "sfRenderWindow_drawRectangleShape", dynlib: LibG.} 379 380proc draw*(window: PRenderWindow, shape: PConvexShape, states: PRenderStates = nil) {. 381 cdecl, importc: "sfRenderWindow_drawConvexShape", dynlib: LibG.} 382proc draw*(window: PRenderWindow, shape: PVertexArray, states: PRenderStates = nil) {. 383 cdecl, importc: "sfRenderWindow_drawVertexArray", dynlib: LibG.} 384proc draw*(window: PRenderWindow, vertices: PVertex, vertexCount: cint, 385 vertexType: TPrimitiveType, states: PRenderStates = nil) {. 386 cdecl, importc: "sfRenderWindow_drawPrimitives", dynlib: LibG.} 387 388proc pushGlStates*(window: PRenderWindow) {. 389 cdecl, importc: "sfRenderWindow_pushGLStates", dynlib: LibG.} 390proc popGlStates*(window: PRenderWindow) {. 391 cdecl, importc: "sfRenderWindow_popGLStates", dynlib: LibG.} 392proc resetGlStates*(window: PRenderWindow) {. 393 cdecl, importc: "sfRenderWindow_resetGLStates", dynlib: LibG.} 394proc capture*(window: PRenderWindow): PImage {. 395 cdecl, importc: "sfRenderWindow_capture", dynlib: LibG.} 396 397#Construct a new render texture 398proc newRenderTexture*(width, height: cint; depthBuffer: bool): PRenderTexture {. 399 cdecl, importc: "sfRenderTexture_create", dynlib: LibG.} 400#Destroy an existing render texture 401proc destroy*(renderTexture: PRenderTexture){. 402 cdecl, importc: "sfRenderTexture_destroy", dynlib: LibG.} 403#Get the size of the rendering region of a render texture 404proc getSize*(renderTexture: PRenderTexture): TVector2i {. 405 cdecl, importc: "sfRenderTexture_getSize", dynlib: LibG.} 406#Activate or deactivate a render texture as the current target for rendering 407proc setActive*(renderTexture: PRenderTexture; active: bool): bool{. 408 cdecl, importc: "sfRenderTexture_setActive", dynlib: LibG.} 409#Update the contents of the target texture 410proc display*(renderTexture: PRenderTexture){. 411 cdecl, importc: "sfRenderTexture_display", dynlib: LibG.} 412#Clear the rendertexture with the given color 413proc clear*(renderTexture: PRenderTexture; color: TColor){. 414 cdecl, importc: "sfRenderTexture_clear", dynlib: LibG.} 415#Change the current active view of a render texture 416proc setView*(renderTexture: PRenderTexture; view: PView){. 417 cdecl, importc: "sfRenderTexture_setView", dynlib: LibG.} 418#Get the current active view of a render texture 419proc getView*(renderTexture: PRenderTexture): PView{. 420 cdecl, importc: "sfRenderTexture_getView", dynlib: LibG.} 421#Get the default view of a render texture 422proc getDefaultView*(renderTexture: PRenderTexture): PView{. 423 cdecl, importc: "sfRenderTexture_getDefaultView", dynlib: LibG.} 424#Get the viewport of a view applied to this target 425proc getViewport*(renderTexture: PRenderTexture; view: PView): TIntRect{. 426 cdecl, importc: "sfRenderTexture_getViewport", dynlib: LibG.} 427#Convert a point in texture coordinates into view coordinates 428proc convertCoords*(renderTexture: PRenderTexture; point: TVector2i; targetView: PView): TVector2f{. 429 cdecl, importc: "sfRenderTexture_convertCoords", dynlib: LibG.} 430#Draw a drawable object to the render-target 431proc draw*(renderTexture: PRenderTexture; sprite: PSprite; states: PRenderStates){. 432 cdecl, importc: "sfRenderTexture_drawSprite", dynlib: LibG.} 433proc draw*(renderTexture: PRenderTexture; text: PText; states: PRenderStates){. 434 cdecl, importc: "sfRenderTexture_drawText", dynlib: LibG.} 435proc draw*(renderTexture: PRenderTexture; shape: PShape; states: PRenderStates){. 436 cdecl, importc: "sfRenderTexture_drawShape", dynlib: LibG.} 437proc draw*(renderTexture: PRenderTexture; shape: PCircleShape; 438 states: PRenderStates){. 439 cdecl, importc: "sfRenderTexture_drawCircleShape", dynlib: LibG.} 440proc draw*(renderTexture: PRenderTexture; shape: PConvexShape; 441 states: PRenderStates){. 442 cdecl, importc: "sfRenderTexture_drawConvexShape", dynlib: LibG.} 443proc draw*(renderTexture: PRenderTexture; shape: PRectangleShape; 444 states: PRenderStates){. 445 cdecl, importc: "sfRenderTexture_drawRectangleShape", dynlib: LibG.} 446proc draw*(renderTexture: PRenderTexture; va: PVertexArray; 447 states: PRenderStates){. 448 cdecl, importc: "sfRenderTexture_drawVertexArray", dynlib: LibG.} 449#Draw primitives defined by an array of vertices to a render texture 450proc draw*(renderTexture: PRenderTexture; vertices: PVertex; vertexCount: cint; 451 primitiveType: TPrimitiveType; states: PRenderStates){. 452 cdecl, importc: "sfRenderTexture_drawPrimitives", dynlib: LibG.} 453#Save the current OpenGL render states and matrices 454#/ 455#/ This function can be used when you mix SFML drawing 456#/ and direct OpenGL rendering. Combined with popGLStates, 457#/ it ensures that: 458#/ * SFML's internal states are not messed up by your OpenGL code 459#/ * your OpenGL states are not modified by a call to a SFML function 460#/ 461#/ Note that this function is quite expensive: it saves all the 462#/ possible OpenGL states and matrices, even the ones you 463#/ don't care about. Therefore it should be used wisely. 464#/ It is provided for convenience, but the best results will 465#/ be achieved if you handle OpenGL states yourself (because 466#/ you know which states have really changed, and need to be 467#/ saved and restored). Take a look at the resetGLStates 468#/ function if you do so. 469proc pushGLStates*(renderTexture: PRenderTexture){. 470 cdecl, importc: "sfRenderTexture_pushGLStates", dynlib: LibG.} 471#Restore the previously saved OpenGL render states and matrices 472#/ 473#/ See the description of pushGLStates to get a detailed 474#/ description of these functions. 475proc popGLStates*(renderTexture: PRenderTexture){. 476 cdecl, importc: "sfRenderTexture_popGLStates", dynlib: LibG.} 477#Reset the internal OpenGL states so that the target is ready for drawing 478#/ 479#/ This function can be used when you mix SFML drawing 480#/ and direct OpenGL rendering, if you choose not to use 481#/ pushGLStates/popGLStates. It makes sure that all OpenGL 482#/ states needed by SFML are set, so that subsequent sfRenderTexture_draw*() 483#/ calls will work as expected. 484proc resetGLStates*(renderTexture: PRenderTexture){. 485 cdecl, importc: "sfRenderTexture_resetGLStates", dynlib: LibG.} 486#Get the target texture of a render texture 487proc getTexture*(renderTexture: PRenderTexture): PTexture{. 488 cdecl, importc: "sfRenderTexture_getTexture", dynlib: LibG.} 489#Enable or disable the smooth filter on a render texture 490proc setSmooth*(renderTexture: PRenderTexture; smooth: bool){. 491 cdecl, importc: "sfRenderTexture_setSmooth", dynlib: LibG.} 492#Tell whether the smooth filter is enabled or not for a render texture 493proc isSmooth*(renderTexture: PRenderTexture): bool {. 494 cdecl, importc: "sfRenderTexture_isSmooth", dynlib: LibG.} 495 496proc intRect*(left, top, width, height: cint): TIntRect = 497 result.left = left 498 result.top = top 499 result.width = width 500 result.height = height 501proc floatRect*(left, top, width, height: cfloat): TFloatRect = 502 result.left = left 503 result.top = top 504 result.width = width 505 result.height = height 506proc contains*(rect: PFloatRect, x, y: cfloat): bool {. 507 cdecl, importc: "sfFloatRect_contains", dynlib: LibG.} 508proc contains*(rect: PIntRect, x: cint, y: cint): bool{.cdecl, 509 importc: "sfIntRect_contains", dynlib: LibG.} 510proc intersects*(rect1, rect2, intersection: PFloatRect): bool {. 511 cdecl, importc: "sfFloatRect_intersects", dynlib: LibG.} 512proc intersects*(rect1, rect2, intersection: PIntRect): bool {. 513 cdecl, importc: "sfIntRect_intersects", dynlib: LibG.} 514 515proc newFont*(filename: cstring): PFont {. 516 cdecl, importc: "sfFont_createFromFile", dynlib: LibG.} 517proc newFont*(data: pointer, sizeInBytes: cint): PFont {. 518 cdecl, importc: "sfFont_createFromMemory", dynlib: LibG.} 519proc newFont*(stream: PInputStream): PFont {. 520 cdecl, importc: "sfFont_createFromStream", dynlib: LibG.} 521proc copy*(font: PFont): PFont {. 522 cdecl, importc: "sfFont_copy", dynlib: LibG.} 523proc destroy*(font: PFont) {. 524 cdecl, importc: "sfFont_destroy", dynlib: LibG.} 525proc getGlyph*(font: PFont, codePoint: uint32, characterSize: cint, bold: bool): TGlyph{. 526 cdecl, importc: "sfFont_getGlyph", dynlib: LibG.} 527proc getKerning*(font: PFont, first: uint32, second: uint32, characterSize: cint): cint {. 528 cdecl, importc: "sfFont_getKerning", dynlib: LibG.} 529proc getLineSpacing*(font: PFont, characterSize: cint): cint {. 530 cdecl, importc: "sfFont_getLineSpacing", dynlib: LibG.} 531proc getTexture*(font: PFont, characterSize: cint): PTexture {. 532 cdecl, importc: "sfFont_getTexture", dynlib: LibG.} 533#getDefaultFont() has been removed from CSFML 534proc getDefaultFont*(): PFont {. 535 error, cdecl, importc: "sfFont_getDefaultFont", dynlib: LibG.} 536 537proc newCircleShape*(): PCircleShape {. 538 cdecl, importc: "sfCircleShape_create", dynlib: LibG.} 539proc copy*(shape: PCircleShape): PCircleShape {. 540 cdecl, importc: "sfCircleShape_copy", dynlib: LibG.} 541proc destroy*(shape: PCircleShape) {. 542 cdecl, importc: "sfCircleShape_destroy", dynlib: LibG.} 543proc setPosition*(shape: PCircleShape, position: TVector2f) {. 544 cdecl, importc: "sfCircleShape_setPosition", dynlib: LibG.} 545proc setRotation*(shape: PCircleShape, angle: cfloat) {. 546 cdecl, importc: "sfCircleShape_setRotation", dynlib: LibG.} 547proc setScale*(shape: PCircleShape, scale: TVector2f) {. 548 cdecl, importc: "sfCircleShape_setScale", dynlib: LibG.} 549proc setOrigin*(shape: PCircleShape, origin: TVector2f) {. 550 cdecl, importc: "sfCircleShape_setOrigin", dynlib: LibG.} 551proc getPosition*(shape: PCircleShape): TVector2f {. 552 cdecl, importc: "sfCircleShape_getPosition", dynlib: LibG.} 553proc getRotation*(shape: PCircleShape): cfloat {. 554 cdecl, importc: "sfCircleShape_getRotation", dynlib: LibG.} 555proc getScale*(shape: PCircleShape): TVector2f {. 556 cdecl, importc: "sfCircleShape_getScale", dynlib: LibG.} 557proc getOrigin*(shape: PCircleShape): TVector2f {. 558 cdecl, importc: "sfCircleShape_getOrigin", dynlib: LibG.} 559proc move*(shape: PCircleShape, offset: TVector2f) {. 560 cdecl, importc: "sfCircleShape_move", dynlib: LibG.} 561proc rotate*(shape: PCircleShape, angle: cfloat){. 562 cdecl, importc: "sfCircleShape_rotate", dynlib: LibG.} 563proc scale*(shape: PCircleShape, factors: TVector2f) {. 564 cdecl, importc: "sfCircleShape_scale", dynlib: LibG.} 565proc getTransform*(shape: PCircleShape): TTransform {. 566 cdecl, importc: "sfCircleShape_getTransform", dynlib: LibG.} 567proc getInverseTransform*(shape: PCircleShape): TTransform {. 568 cdecl, importc: "sfCircleShape_getInverseTransform", dynlib: LibG.} 569proc setTexture*(shape: PCircleShape, texture: PTexture, resetRect: bool) {. 570 cdecl, importc: "sfCircleShape_setTexture", dynlib: LibG.} 571proc setTextureRect*(shape: PCircleShape, rect: TIntRect) {. 572 cdecl, importc: "sfCircleShape_setTextureRect", dynlib: LibG.} 573proc setFillColor*(shape: PCircleShape, color: TColor) {. 574 cdecl, importc: "sfCircleShape_setFillColor", dynlib: LibG.} 575proc setOutlineColor*(shape: PCircleShape, color: TColor) {. 576 cdecl, importc: "sfCircleShape_setOutlineColor", dynlib: LibG.} 577proc setOutlineThickness*(shape: PCircleShape, thickness: cfloat) {. 578 cdecl, importc: "sfCircleShape_setOutlineThickness", dynlib: LibG.} 579proc getTexture*(shape: PCircleShape): PTexture {. 580 cdecl, importc: "sfCircleShape_getTexture", dynlib: LibG.} 581proc getTextureRect*(shape: PCircleShape): TIntRect {. 582 cdecl, importc: "sfCircleShape_getTextureRect", dynlib: LibG.} 583proc getFillColor*(shape: PCircleShape): TColor {. 584 cdecl, importc: "sfCircleShape_getFillColor", dynlib: LibG.} 585proc getOutlineColor*(shape: PCircleShape): TColor {. 586 cdecl, importc: "sfCircleShape_getOutlineColor", dynlib: LibG.} 587proc getOutlineThickness*(shape: PCircleShape): cfloat {. 588 cdecl, importc: "sfCircleShape_getOutlineThickness", dynlib: LibG.} 589proc getPointCount*(shape: PCircleShape): cint {. 590 cdecl, importc: "sfCircleShape_getPointCount", dynlib: LibG.} 591proc getPoint*(shape: PCircleShape, index: cint): TVector2f {. 592 cdecl, importc: "sfCircleShape_getPoint", dynlib: LibG.} 593proc setRadius*(shape: PCircleShape, radius: cfloat) {. 594 cdecl, importc: "sfCircleShape_setRadius", dynlib: LibG.} 595proc getRadius*(shape: PCircleShape): cfloat {. 596 cdecl, importc: "sfCircleShape_getRadius", dynlib: LibG.} 597proc setPointCount*(shape: PCircleShape, count: cint) {. 598 cdecl, importc: "sfCircleShape_setPointCount", dynlib: LibG.} 599proc getLocalBounds*(shape: PCircleShape): TFloatRect {. 600 cdecl, importc: "sfCircleShape_getLocalBounds", dynlib: LibG.} 601proc getGlobalBounds*(shape: PCircleShape): TFloatRect {. 602 cdecl, importc: "sfCircleShape_getGlobalBounds", dynlib: LibG.} 603 604proc newRectangleShape*(): PRectangleShape {. 605 cdecl, importc: "sfRectangleShape_create", dynlib: LibG.} 606proc copy*(shape: PRectangleShape): PRectangleShape {. 607 cdecl, importc: "sfRectangleShape_copy", dynlib: LibG.} 608proc destroy*(shape: PRectangleShape){. 609 cdecl, importc: "sfRectangleShape_destroy", dynlib: LibG.} 610proc setPosition*(shape: PRectangleShape, position: TVector2f) {. 611 cdecl, importc: "sfRectangleShape_setPosition", dynlib: LibG.} 612proc setRotation*(shape: PRectangleShape, angle: cfloat) {. 613 cdecl, importc: "sfRectangleShape_setRotation", dynlib: LibG.} 614proc setScale*(shape: PRectangleShape, scale: TVector2f) {. 615 cdecl, importc: "sfRectangleShape_setScale", dynlib: LibG.} 616proc setOrigin*(shape: PRectangleShape, origin: TVector2f) {. 617 cdecl, importc: "sfRectangleShape_setOrigin", dynlib: LibG.} 618proc getPosition*(shape: PRectangleShape): TVector2f {. 619 cdecl, importc: "sfRectangleShape_getPosition", dynlib: LibG.} 620proc getRotation*(shape: PRectangleShape): cfloat {. 621 cdecl, importc: "sfRectangleShape_getRotation", dynlib: LibG.} 622proc getScale*(shape: PRectangleShape): TVector2f {. 623 cdecl, importc: "sfRectangleShape_getScale", dynlib: LibG.} 624proc getOrigin*(shape: PRectangleShape): TVector2f {. 625 cdecl, importc: "sfRectangleShape_getOrigin", dynlib: LibG.} 626proc move*(shape: PRectangleShape, offset: TVector2f) {. 627 cdecl, importc: "sfRectangleShape_move", dynlib: LibG.} 628proc rotate*(shape: PRectangleShape, angle: cfloat) {. 629 cdecl, importc: "sfRectangleShape_rotate", dynlib: LibG.} 630proc scale*(shape: PRectangleShape, factors: TVector2f) {. 631 cdecl, importc: "sfRectangleShape_scale", dynlib: LibG.} 632proc getTransform*(shape: PRectangleShape): TTransform {. 633 cdecl, importc: "sfRectangleShape_getTransform", dynlib: LibG.} 634proc getInverseTransform*(shape: PRectangleShape): TTransform {. 635 cdecl, importc: "sfRectangleShape_getInverseTransform", dynlib: LibG.} 636proc setTexture*(shape: PRectangleShape, texture: PTexture, resetRect: bool) {. 637 cdecl, importc: "sfRectangleShape_setTexture", dynlib: LibG.} 638proc setTextureRect*(shape: PRectangleShape, rect: TIntRect) {. 639 cdecl, importc: "sfRectangleShape_setTextureRect", dynlib: LibG.} 640proc setFillColor*(shape: PRectangleShape, color: TColor) {. 641 cdecl, importc: "sfRectangleShape_setFillColor", dynlib: LibG.} 642proc setOutlineColor*(shape: PRectangleShape, color: TColor) {. 643 cdecl, importc: "sfRectangleShape_setOutlineColor", dynlib: LibG.} 644proc setOutlineThickness*(shape: PRectangleShape, thickness: cfloat) {. 645 cdecl, importc: "sfRectangleShape_setOutlineThickness", dynlib: LibG.} 646proc getTexture*(shape: PRectangleShape): PTexture {. 647 cdecl, importc: "sfRectangleShape_getTexture", dynlib: LibG.} 648proc getTextureRect*(shape: PRectangleShape): TIntRect {. 649 cdecl, importc: "sfRectangleShape_getTextureRect", dynlib: LibG.} 650proc getFillColor*(shape: PRectangleShape): TColor {. 651 cdecl, importc: "sfRectangleShape_getFillColor", dynlib: LibG.} 652proc getOutlineColor*(shape: PRectangleShape): TColor {. 653 cdecl, importc: "sfRectangleShape_getOutlineColor", dynlib: LibG.} 654proc getOutlineThickness*(shape: PRectangleShape): cfloat {. 655 cdecl, importc: "sfRectangleShape_getOutlineThickness", dynlib: LibG.} 656proc getPointCount*(shape: PRectangleShape): cint {. 657 cdecl, importc: "sfRectangleShape_getPointCount", dynlib: LibG.} 658proc getPoint*(shape: PRectangleShape, index: cint): TVector2f {. 659 cdecl, importc: "sfRectangleShape_getPoint", dynlib: LibG.} 660proc setSize*(shape: PRectangleShape, size: TVector2f) {. 661 cdecl, importc: "sfRectangleShape_setSize", dynlib: LibG.} 662proc getSize*(shape: PRectangleShape): TVector2f {. 663 cdecl, importc: "sfRectangleShape_getSize", dynlib: LibG.} 664proc getLocalBounds*(shape: PRectangleShape): TFloatRect {. 665 cdecl, importc: "sfRectangleShape_getLocalBounds", dynlib: LibG.} 666proc getGlobalBounds*(shape: PRectangleShape): TFloatRect {. 667 cdecl, importc: "sfRectangleShape_getGlobalBounds", dynlib: LibG.} 668 669 670proc newView*(): PView {. 671 cdecl, importc: "sfView_create", dynlib: LibG.} 672proc viewFromRect*(rectangle: TFloatRect): PView{. 673 cdecl, importc: "sfView_createFromRect", dynlib: LibG.} 674proc copy*(view: PView): PView {. 675 cdecl, importc: "sfView_copy", dynlib: LibG.} 676proc destroy*(view: PView) {. 677 cdecl, importc: "sfView_destroy", dynlib: LibG.} 678proc setCenter*(view: PView, center: TVector2f) {. 679 cdecl, importc: "sfView_setCenter", dynlib: LibG.} 680proc setSize*(view: PView, size: TVector2f) {. 681 cdecl, importc: "sfView_setSize", dynlib: LibG.} 682proc setRotation*(view: PView, angle: cfloat) {. 683 cdecl, importc: "sfView_setRotation", dynlib: LibG.} 684proc setViewport*(view: PView, viewport: TFloatRect) {. 685 cdecl, importc: "sfView_setViewport", dynlib: LibG.} 686proc reset*(view: PView, rectangle: TFloatRect) {. 687 cdecl, importc: "sfView_reset", dynlib: LibG.} 688proc getCenter*(view: PView): TVector2f {. 689 cdecl, importc: "sfView_getCenter", dynlib: LibG.} 690proc getSize*(view: PView): TVector2f {. 691 cdecl, importc: "sfView_getSize", dynlib: LibG.} 692proc getRotation*(view: PView): cfloat {. 693 cdecl, importc: "sfView_getRotation", dynlib: LibG.} 694proc getViewport*(view: PView): TFloatRect {. 695 cdecl, importc: "sfView_getViewport", dynlib: LibG.} 696proc move*(view: PView, offset: TVector2f) {. 697 cdecl, importc: "sfView_move", dynlib: LibG.} 698proc rotate*(view: PView, angle: cfloat) {. 699 cdecl, importc: "sfView_rotate", dynlib: LibG.} 700proc zoom*(view: PView, factor: cfloat) {. 701 cdecl, importc: "sfView_zoom", dynlib: LibG.} 702 703proc newImage*(width, height: cint): PImage {. 704 cdecl, importc: "sfImage_create", dynlib: LibG.} 705proc newImage*(width, height: cint, color: TColor): PImage {. 706 cdecl, importc: "sfImage_createFromColor", dynlib: LibG.} 707proc newImage*(width, height: cint, pixels: pointer): PImage {. ##same deal as setIcon() 708 cdecl, importc: "sfImage_createFromPixels", dynlib: LibG.} 709proc newImage*(filename: cstring): PImage {. 710 cdecl, importc: "sfImage_createFromFile", dynlib: LibG.} 711proc newImage*(data: pointer, size: cint): PImage {. 712 cdecl, importc: "sfImage_createFromMemory", dynlib: LibG.} 713proc newImage*(stream: PInputStream): PImage {. 714 cdecl, importc: "sfImage_createFromStream", dynlib: LibG.} 715proc copy*(image: PImage): PImage {. 716 cdecl, importc: "sfImage_copy", dynlib: LibG.} 717proc destroy*(image: PImage) {. 718 cdecl, importc: "sfImage_destroy", dynlib: LibG.} 719proc save*(image: PImage, filename: cstring): bool {. 720 cdecl, importc: "sfImage_saveToFile", dynlib: LibG.} 721proc getSize*(image: PImage): TVector2i {. 722 cdecl, importc: "sfImage_getSize", dynlib: LibG.} 723proc createMask*(image: PImage, color: TColor, alpha: cchar) {. 724 cdecl, importc: "sfImage_createMaskFromColor", dynlib: LibG.} 725proc copy*(destination, source: PImage, destX, destY: cint; 726 sourceRect: TIntRect, applyAlpha: bool) {. 727 cdecl, importc: "sfImage_copyImage", dynlib: LibG.} 728proc setPixel*(image: PImage, x, y: cint, color: TColor) {. 729 cdecl, importc: "sfImage_setPixel", dynlib: LibG.} 730proc getPixel*(image: PImage, x, y: cint): TColor {. 731 cdecl, importc: "sfImage_getPixel", dynlib: LibG.} 732proc getPixels*(image: PImage): pointer {. 733 cdecl, importc: "sfImage_getPixelsPtr", dynlib: LibG.} 734proc flipHorizontally*(image: PImage) {. 735 cdecl, importc: "sfImage_flipHorizontally", dynlib: LibG.} 736proc flipVertically*(image: PImage) {. 737 cdecl, importc: "sfImage_flipVertically", dynlib: LibG.} 738 739proc newSprite*(): PSprite {. 740 cdecl, importc: "sfSprite_create", dynlib: LibG.} 741proc copy*(sprite: PSprite): PSprite {. 742 cdecl, importc: "sfSprite_copy", dynlib: LibG.} 743proc destroy*(sprite: PSprite) {. 744 cdecl, importc: "sfSprite_destroy", dynlib: LibG.} 745proc setPosition*(sprite: PSprite, position: TVector2f) {. 746 cdecl, importc: "sfSprite_setPosition", dynlib: LibG.} 747proc setRotation*(sprite: PSprite, angle: cfloat) {. 748 cdecl, importc: "sfSprite_setRotation", dynlib: LibG.} 749proc setScale*(sprite: PSprite, scale: TVector2f) {. 750 cdecl, importc: "sfSprite_setScale", dynlib: LibG.} 751proc setOrigin*(sprite: PSprite, origin: TVector2f) {. 752 cdecl, importc: "sfSprite_setOrigin", dynlib: LibG.} 753proc getPosition*(sprite: PSprite): TVector2f {. 754 cdecl, importc: "sfSprite_getPosition", dynlib: LibG.} 755proc getRotation*(sprite: PSprite): cfloat {. 756 cdecl, importc: "sfSprite_getRotation", dynlib: LibG.} 757proc getScale*(sprite: PSprite): TVector2f {. 758 cdecl, importc: "sfSprite_getScale", dynlib: LibG.} 759proc getOrigin*(sprite: PSprite): TVector2f {. 760 cdecl, importc: "sfSprite_getOrigin", dynlib: LibG.} 761proc move*(sprite: PSprite, offset: TVector2f) {. 762 cdecl, importc: "sfSprite_move", dynlib: LibG.} 763proc rotate*(sprite: PSprite, angle: cfloat) {. 764 cdecl, importc: "sfSprite_rotate", dynlib: LibG.} 765proc scale*(sprite: PSprite, factor: TVector2f) {. 766 cdecl, importc: "sfSprite_scale", dynlib: LibG.} 767proc getTransform*(sprite: PSprite): TTransform {. 768 cdecl, importc: "sfSprite_getTransform", dynlib: LibG.} 769proc getInverseTransform*(sprite: PSprite): TTransform {. 770 cdecl, importc: "sfSprite_getInverseTransform", dynlib: LibG.} 771proc setTexture*(sprite: PSprite, texture: PTexture, resetRect: bool) {. 772 cdecl, importc: "sfSprite_setTexture", dynlib: LibG.} 773proc setTextureRect*(sprite: PSprite, rectangle: TIntRect) {. 774 cdecl, importc: "sfSprite_setTextureRect", dynlib: LibG.} 775proc setColor*(sprite: PSprite, color: TColor) {. 776 cdecl, importc: "sfSprite_setColor", dynlib: LibG.} 777proc getTexture*(sprite: PSprite): TTexture {. 778 cdecl, importc: "sfSprite_getTexture", dynlib: LibG.} 779proc getTextureRect*(sprite: PSprite): TIntRect {. 780 cdecl, importc: "sfSprite_getTextureRect", dynlib: LibG.} 781proc getColor*(sprite: PSprite): TColor {. 782 cdecl, importc: "sfSprite_getColor", dynlib: LibG.} 783proc getLocalBounds*(sprite: PSprite): TFloatRect {. 784 cdecl, importc: "sfSprite_getLocalBounds", dynlib: LibG.} 785proc getGlobalBounds*(sprite: PSprite): TFloatRect {. 786 cdecl, importc: "sfSprite_getGlobalBounds", dynlib: LibG.} 787 788proc newTexture*(width, height: cint): PTexture {. 789 cdecl, importc: "sfTexture_create", dynlib: LibG.} 790proc newTexture*(filename: cstring): PTexture {. 791 cdecl, importc: "sfTexture_createFromFile", dynlib: LibG.} 792proc newTexture*(data: pointer, size: cint, area: PIntRect): PTexture {. 793 cdecl, importc: "sfTexture_createFromMemory", dynlib: LibG.} 794proc newTexture*(stream: PInputStream, area: PIntRect): PTexture {. 795 cdecl, importc: "sfTexture_createFromStream", dynlib: LibG.} 796proc newTexture*(image: PImage, area: PIntRect = nil): PTexture {. 797 cdecl, importc: "sfTexture_createFromImage", dynlib: LibG.} 798proc copy*(texture: PTexture): PTexture {. 799 cdecl, importc: "sfTexture_copy", dynlib: LibG.} 800proc destroy*(texture: PTexture) {. 801 cdecl, importc: "sfTexture_destroy", dynlib: LibG.} 802proc getSize*(texture: PTexture): TVector2i {. 803 cdecl, importc: "sfTexture_getSize", dynlib: LibG.} 804proc copyToImage*(texture: PTexture): PImage {. 805 cdecl, importc: "sfTexture_copyToImage", dynlib: LibG.} 806proc updateFromPixels*(texture: PTexture, pixels: pointer, width, height, x, y: cint) {. 807 cdecl, importc: "sfTexture_updateFromPixels", dynlib: LibG.} 808proc updateFromImage*(texture: PTexture, image: PImage, x, y: cint) {. 809 cdecl, importc: "sfTexture_updateFromImage", dynlib: LibG.} 810proc updateFromWindow*(texture: PTexture, window: PWindow, x, y: cint) {. 811 cdecl, importc: "sfTexture_updateFromWindow", dynlib: LibG.} 812proc updateFromWindow*(texture: PTexture, window: PRenderWindow, x, y: cint) {. 813 cdecl, importc: "sfTexture_updateFromRenderWindow", dynlib: LibG.} 814proc bindGL*(texture: PTexture) {. 815 cdecl, importc: "sfTexture_bind", dynlib: LibG.} 816proc setSmooth*(texture: PTexture, smooth: bool) {. 817 cdecl, importc: "sfTexture_setSmooth", dynlib: LibG.} 818proc isSmooth*(texture: PTexture): bool {. 819 cdecl, importc: "sfTexture_isSmooth", dynlib: LibG.} 820proc setRepeated*(texture: PTexture, repeated: bool) {. 821 cdecl, importc: "sfTexture_setRepeated", dynlib: LibG.} 822proc isRepeated*(texture: PTexture): bool {. 823 cdecl, importc: "sfTexture_isRepeated", dynlib: LibG.} 824proc textureMaxSize*(): cint {. 825 cdecl, importc: "sfTexture_getMaximumSize", dynlib: LibG.} 826 827proc newVertexArray*(): PVertexArray {. 828 cdecl, importc: "sfVertexArray_create", dynlib: LibG.} 829proc copy*(vertexArray: PVertexArray): PVertexArray {. 830 cdecl, importc: "sfVertexArray_copy", dynlib: LibG.} 831proc destroy*(va: PVertexArray) {. 832 cdecl, importc: "sfVertexArray_destroy", dynlib: LibG.} 833proc getVertexCount*(va: PVertexArray): cint {. 834 cdecl, importc: "sfVertexArray_getVertexCount", dynlib: LibG.} 835proc getVertex*(va: PVertexArray, index: cint): PVertex {. 836 cdecl, importc: "sfVertexArray_getVertex", dynlib: LibG.} 837proc clear*(va: PVertexArray) {. 838 cdecl, importc: "sfVertexArray_clear", dynlib: LibG.} 839proc resize*(va: PVertexArray, size: cint) {. 840 cdecl, importc: "sfVertexArray_resize", dynlib: LibG.} 841proc append*(va: PVertexArray, vertex: TVertex) {. 842 cdecl, importc: "sfVertexArray_append", dynlib: LibG.} 843proc setPrimitiveType*(va: PVertexArray, primitiveType: TPrimitiveType) {. 844 cdecl, importc: "sfVertexArray_setPrimitiveType", dynlib: LibG.} 845proc getPrimitiveType*(va: PVertexArray): TPrimitiveType {. 846 cdecl, importc: "sfVertexArray_getPrimitiveType", dynlib: LibG.} 847proc getBounds*(va: PVertexArray): TFloatRect {. 848 cdecl, importc: "sfVertexArray_getBounds", dynlib: LibG.} 849 850 851proc newText*(): PText {. 852 cdecl, importc: "sfText_create", dynlib: LibG.} 853proc copy*(text: PText): PText {. 854 cdecl, importc: "sfText_copy", dynlib: LibG.} 855proc destroy*(text: PText) {. 856 cdecl, importc: "sfText_destroy", dynlib: LibG.} 857proc setPosition*(text: PText, position: TVector2f) {. 858 cdecl, importc: "sfText_setPosition", dynlib: LibG.} 859proc setRotation*(text: PText, angle: cfloat) {. 860 cdecl, importc: "sfText_setRotation", dynlib: LibG.} 861proc setScale*(text: PText, scale: TVector2f) {. 862 cdecl, importc: "sfText_setScale", dynlib: LibG.} 863proc setOrigin*(text: PText, origin: TVector2f) {. 864 cdecl, importc: "sfText_setOrigin", dynlib: LibG.} 865proc getPosition*(text: PText): TVector2f {. 866 cdecl, importc: "sfText_getPosition", dynlib: LibG.} 867proc getRotation*(text: PText): cfloat {. 868 cdecl, importc: "sfText_getRotation", dynlib: LibG.} 869proc getScale*(text: PText): TVector2f {. 870 cdecl, importc: "sfText_getScale", dynlib: LibG.} 871proc getOrigin*(text: PText): TVector2f {. 872 cdecl, importc: "sfText_getOrigin", dynlib: LibG.} 873proc move*(text: PText, offset: TVector2f) {. 874 cdecl, importc: "sfText_move", dynlib: LibG.} 875proc rotate*(text: PText, angle: cfloat) {. 876 cdecl, importc: "sfText_rotate", dynlib: LibG.} 877proc scale*(text: PText, factors: TVector2f) {. 878 cdecl, importc: "sfText_scale", dynlib: LibG.} 879proc getTransform*(text: PText): TTransform {. 880 cdecl, importc: "sfText_getTransform", dynlib: LibG.} 881proc getInverseTransform*(text: PText): TTransform {. 882 cdecl, importc: "sfText_getInverseTransform", dynlib: LibG.} 883proc setString*(text: PText, string: cstring) {. 884 cdecl, importc: "sfText_setString", dynlib: LibG.} 885proc setUnicodeString*(text: PText, string: ptr uint32) {. 886 cdecl, importc: "sfText_setUnicodeString", dynlib: LibG.} 887proc setFont*(text: PText, font: PFont) {. 888 cdecl, importc: "sfText_setFont", dynlib: LibG.} 889proc setCharacterSize*(text: PText, size: cint) {. 890 cdecl, importc: "sfText_setCharacterSize", dynlib: LibG.} 891proc setStyle*(text: PText, style: TTextStyle) {. 892 cdecl, importc: "sfText_setStyle", dynlib: LibG.} 893proc setColor*(text: PText, color: TColor) {. 894 cdecl, importc: "sfText_setColor", dynlib: LibG.} 895proc getString*(text: PText): cstring {. 896 cdecl, importc: "sfText_getString", dynlib: LibG.} 897proc getUnicodeString*(text: PText): ptr uint32 {.cdecl, 898 importc: "sfText_getUnicodeString", dynlib: LibG.} 899proc getFont*(text: PText): PFont {. 900 cdecl, importc: "sfText_getFont", dynlib: LibG.} 901proc getCharacterSize*(text: PText): cint {. 902 cdecl, importc: "sfText_getCharacterSize", dynlib: LibG.} 903proc getStyle*(text: PText): uint32 {. 904 cdecl, importc: "sfText_getStyle", dynlib: LibG.} 905proc getColor*(text: PText): TColor {. 906 cdecl, importc: "sfText_getColor", dynlib: LibG.} 907proc findCharacterPos*(text: PText, index: cint): TVector2f {. 908 cdecl, importc: "sfText_findCharacterPos", dynlib: LibG.} 909proc getLocalBounds*(text: PText): TFloatRect {. 910 cdecl, importc: "sfText_getLocalBounds", dynlib: LibG.} 911proc getGlobalBounds*(text: PText): TFloatRect {. 912 cdecl, importc: "sfText_getGlobalBounds", dynlib: LibG.} 913 914proc transformFromMatrix*(a00, a01, a02, a10, a11, a12, a20, a21, a22: cfloat): TTransform {. 915 cdecl, importc: "sfTransform_fromMatrix", dynlib: LibG.} 916proc getMatrix*(transform: PTransform, matrix: ptr cfloat) {. 917 cdecl, importc: "sfTransform_getMatrix", dynlib: LibG.} 918proc getInverse*(transform: PTransform): TTransform {. 919 cdecl, importc: "sfTransform_getInverse", dynlib: LibG.} 920proc transformPoint*(transform: PTransform, point: TVector2f): TVector2f {. 921 cdecl, importc: "sfTransform_transformPoint", dynlib: LibG.} 922proc transformRect*(transform: PTransform, rectangle: TFloatRect): TFloatRect {. 923 cdecl, importc: "sfTransform_transformRect", dynlib: LibG.} 924proc combine*(transform: PTransform, other: PTransform) {. 925 cdecl, importc: "sfTransform_combine", dynlib: LibG.} 926proc translate*(transform: PTransform, x, y: cfloat) {. 927 cdecl, importc: "sfTransform_translate", dynlib: LibG.} 928proc rotate*(transform: PTransform, angle: cfloat) {. 929 cdecl, importc: "sfTransform_rotate", dynlib: LibG.} 930proc rotateWithCenter*(transform: PTransform, angle, centerX, centerY: cfloat){. 931 cdecl, importc: "sfTransform_rotateWithCenter", dynlib: LibG.} 932proc scale*(transform: PTransform, scaleX, scaleY: cfloat) {. 933 cdecl, importc: "sfTransform_scale", dynlib: LibG.} 934proc scaleWithCenter*(transform: PTransform, scaleX, scaleY, centerX, centerY: cfloat) {. 935 cdecl, importc: "sfTransform_scaleWithCenter", dynlib: LibG.} 936let IdentityMatrix*: TTransform = transformFromMatrix(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0) 937 938 939proc newShader*(VSfilename: cstring, fragmentShaderFilename: cstring): PShader {. 940 cdecl, importc: "sfShader_createFromFile", dynlib: LibG.} 941proc newShaderFromStr*(vertexShader: cstring, fragmentShader: cstring): PShader {. 942 cdecl, importc: "sfShader_createFromMemory", dynlib: LibG.} 943proc newShader*(vertexShaderStream: PInputStream, fragmentShaderStream: PInputStream): PShader {. 944 cdecl, importc: "sfShader_createFromStream", dynlib: LibG.} 945proc destroy*(shader: PShader) {. 946 cdecl, importc: "sfShader_destroy", dynlib: LibG.} 947proc setFloatParameter*(shader: PShader, name: cstring, x: cfloat) {. 948 cdecl, importc: "sfShader_setFloatParameter", dynlib: LibG.} 949proc setFloat2Parameter*(shader: PShader, name: cstring, x, y: cfloat) {. 950 cdecl, importc: "sfShader_setFloat2Parameter", dynlib: LibG.} 951proc setFloat3Parameter*(shader: PShader, name: cstring, x, y, z: cfloat) {. 952 cdecl, importc: "sfShader_setFloat3Parameter", dynlib: LibG.} 953proc setFloat4Parameter*(shader: PShader, name: cstring, x, y, z, w: cfloat) {. 954 cdecl, importc: "sfShader_setFloat4Parameter", dynlib: LibG.} 955proc setVector2Parameter*(shader: PShader, name: cstring, vector: TVector2f) {. 956 cdecl, importc: "sfShader_setVector2Parameter", dynlib: LibG.} 957proc setVector3Parameter*(shader: PShader, name: cstring, vector: TVector3f) {. 958 cdecl, importc: "sfShader_setVector3Parameter", dynlib: LibG.} 959proc setColorParameter*(shader: PShader, name: cstring, color: TColor) {. 960 cdecl, importc: "sfShader_setColorParameter", dynlib: LibG.} 961proc setTransformParameter*(shader: PShader, name: cstring, transform: TTransform) {. 962 cdecl, importc: "sfShader_setTransformParameter", dynlib: LibG.} 963proc setTextureParameter*(shader: PShader, name: cstring, texture: PTexture) {. 964 cdecl, importc: "sfShader_setTextureParameter", dynlib: LibG.} 965proc setCurrentTextureParameter*(shader: PShader, name: cstring) {. 966 cdecl, importc: "sfShader_setCurrentTextureParameter", dynlib: LibG.} 967proc bindGL*(shader: PShader) {. 968 cdecl, importc: "sfShader_bind", dynlib: LibG.} 969proc unbindGL*(shader: PShader) {. 970 cdecl, importc: "sfShader_unbind", dynlib: LibG.} 971proc shaderIsAvailable*(): bool {. 972 cdecl, importc: "sfShader_isAvailable", dynlib: LibG.} 973 974proc color*(red, green, blue: cchar): TColor {. 975 cdecl, importc: "sfColor_fromRGB", dynlib: LibG.} 976proc color*(red, green, blue: int): TColor {.inline.} = 977 return color(red.cchar, green.cchar, blue.cchar) 978proc color*(red, green, blue, alpha: cchar): TColor {. 979 cdecl, importc: "sfColor_fromRGBA", dynlib: LibG.} 980proc color*(red, green, blue, alpha: int): TColor {.inline.} = 981 return color(red.cchar, green.cchar, blue.cchar, alpha.cchar) 982proc `+`*(color1, color2: TColor): TColor {. 983 cdecl, importc: "sfColor_add", dynlib: LibG.} 984proc `*`*(color1, color2: TColor): TColor {. 985 cdecl, importc: "sfColor_modulate", dynlib: LibG.} 986proc newColor*(r,g,b: int): TColor {.inline.} = 987 return color(r,g,b) 988proc newColor*(r,g,b,a: int): TColor {.inline.} = 989 return color(r,g,b,a) 990 991proc newClock*(): PClock {. 992 cdecl, importc: "sfClock_create", dynlib: LibS.} 993proc copy*(clocK: PClock): PClock {. 994 cdecl, importc: "sfClock_copy", dynlib: LibS.} 995proc destroy*(clock: PClock): PClock {. 996 cdecl, importc: "sfClock_destroy", dynlib: LibS.} 997proc getElapsedTime*(clock: PClock): TTime {. 998 cdecl, importc: "sfClock_getElapsedTime", dynlib: LibS.} 999proc restart*(clock: PClock): TTime {. 1000 cdecl, importc: "sfClock_restart", dynlib: LibS, discardable.} 1001proc asSeconds*(time: TTime): cfloat {. 1002 cdecl, importc: "sfTime_asSeconds", dynlib: LibS.} 1003proc asMilliseconds*(time: TTime): int32 {. 1004 cdecl, importc: "sfTime_asMilliseconds", dynlib: LibS.} 1005proc asMicroseconds*(time: TTime): int64 {. 1006 cdecl, importc: "sfTime_asMicroseconds", dynlib: LibS.} 1007proc seconds*(seconds: cfloat): TTime {. 1008 cdecl, importc: "sfSeconds", dynlib: LibS.} 1009proc milliseconds*(ms: int32): TTime {. 1010 cdecl, importc: "sfMilliseconds", dynlib: LibS.} 1011proc microseconds*(us: int64): TTime {. 1012 cdecl, importc: "sfMicroseconds", dynlib: LibS.} 1013 1014proc newContextSettings*(depthBits: cint = 0, 1015 stencilBits: cint = 0, 1016 antialiasingLevel: cint = 0, 1017 majorVersion: cint = 0, 1018 minorVersion: cint = 0): TContextSettings = 1019 result.depthBits = depthBits 1020 result.stencilBits = stencilBits 1021 result.antialiasingLevel = antialiasingLevel 1022 result.majorVersion = majorVersion 1023 result.minorVersion = minorVersion 1024 1025proc newCircleShape*(radius: cfloat; pointCount: cint = 30): PCircleShape = 1026 result = newCircleShape() 1027 result.setRadius radius 1028 result.setPointCount pointCount 1029proc newText*(str: string, font: PFont, size: int): PText = 1030 result = newText() 1031 result.setString(str) 1032 result.setFont(font) 1033 result.setCharacterSize(size.cint) 1034proc newVertexArray*(primitiveType: TPrimitiveType, vertexCount: cint = 0): PVertexArray = 1035 result = newVertexArray() 1036 result.setPrimitiveType(primitiveType) 1037 if vertexCount != 0: 1038 result.resize(vertexCount) 1039proc videoMode*(width, height, bpp: cint): TVideoMode = 1040 result.width = width 1041 result.height = height 1042 result.bitsPerPixel = bpp 1043 1044proc `[]`*(a: PVertexArray, index: int): PVertex = 1045 return getVertex(a, index.cint) 1046 1047proc `$` *(a: TContextSettings): string = 1048 return "<TContextSettings stencil=$1 aa=$2 major=$3 minor=$4 depth=$5>" % [ 1049 $a.stencilBits, $a.antialiasingLevel, $a.majorVersion, $a.minorVersion, $a.depthBits] 1050proc `$` *(a: TVideoMode): string = 1051 return "<TVideoMode $1x$2 $3bpp>" % [$a.width, $a.height, $a.bitsPerPixel] 1052proc `$` *(a: TFloatRect): string = 1053 return "<TFloatRect $1,$2 $3x$4>" % [$a.left, $a.top, $a.width, $a.height] 1054proc `$` *(a: PView): string = 1055 return $a.getViewport() 1056proc `$` *(a: TVector2f): string = 1057 return "<TVector2f $1,$2>" % [$a.x, $a.y] 1058 1059proc vec2i*(x, y: int): TVector2i = 1060 result.x = x.cint 1061 result.y = y.cint 1062proc vec2f*(x, y: float): TVector2f = 1063 result.x = x.cfloat 1064 result.y = y.cfloat 1065 1066proc `+`*(a, b: TVector2f): TVector2f {.inline.} = 1067 result.x = a.x + b.x 1068 result.y = a.y + b.y 1069proc `-`*(a: TVector2f): TVector2f {.inline.} = 1070 result.x = -a.x 1071 result.y = -a.y 1072proc `-`*(a, b: TVector2f): TVector2f {.inline.}= 1073 result.x = a.x - b.x 1074 result.y = a.y - b.y 1075proc `*`*(a: TVector2f, b: cfloat): TVector2f {.inline.} = 1076 result.x = a.x * b 1077 result.y = a.y * b 1078proc `*`*(a, b: TVector2f): TVector2f {.inline.} = 1079 result.x = a.x * b.x 1080 result.y = a.y * b.y 1081proc `/`*(a: TVector2f, b: cfloat): TVector2f {.inline.} = 1082 result.x = a.x / b 1083 result.y = a.y / b 1084proc `+=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = 1085 a = a + b 1086proc `-=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = 1087 a = a - b 1088proc `*=` *(a: var TVector2f, b: float) {.inline, noSideEffect.} = 1089 a = a * b 1090proc `*=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = 1091 a = a * b 1092proc `/=` *(a: var TVector2f, b: float) {.inline, noSideEffect.} = 1093 a = a / b 1094proc `<` *(a, b: TVector2f): bool {.inline, noSideEffect.} = 1095 return a.x < b.x or (a.x == b.x and a.y < b.y) 1096proc `<=` *(a, b: TVector2f): bool {.inline, noSideEffect.} = 1097 return a.x <= b.x and a.y <= b.y 1098proc `==` *(a, b: TVector2f): bool {.inline, noSideEffect.} = 1099 return a.x == b.x and a.y == b.y 1100proc length*(a: TVector2f): float {.inline.} = 1101 return sqrt(pow(a.x, 2.0) + pow(a.y, 2.0)) 1102proc lengthSq*(a: TVector2f): float {.inline.} = 1103 return pow(a.x, 2.0) + pow(a.y, 2.0) 1104proc distanceSq*(a, b: TVector2f): float {.inline.} = 1105 return pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0) 1106proc distance*(a, b: TVector2f): float {.inline.} = 1107 return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0)) 1108proc permul*(a, b: TVector2f): TVector2f = 1109 result.x = a.x * b.x 1110 result.y = a.y * b.y 1111proc rotate*(a: TVector2f, phi: float): TVector2f = 1112 var c = cos(phi) 1113 var s = sin(phi) 1114 result.x = a.x * c - a.y * s 1115 result.y = a.x * s + a.y * c 1116proc perpendicular(a: TVector2f): TVector2f = 1117 result.x = -a.x 1118 result.y = a.y 1119proc cross(a, b: TVector2f): float = 1120 return a.x * b.y - a.y * b.x 1121 1122