| 1 |
import |
| 2 |
strutils, math |
| 3 |
when 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" |
| 8 |
else: |
| 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.} |
| 17 |
type |
| 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 |
|
| 162 |
type 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; |
| 168 |
const |
| 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 |
| 175 |
type |
| 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 |
|
| 259 |
proc newWindow*(mode: TVideoMode, title: cstring, style: uint32, settings: PContextSettings = nil): PWindow {. |
| 260 |
cdecl, importc: "sfWindow_create", dynlib: LibW.} |
| 261 |
|
| 262 |
proc close*(window: PWindow) {. |
| 263 |
cdecl, importc: "sfWindow_close", dynlib: LibW.} |
| 264 |
proc isOpen*(window: PWindow): bool {.cdecl, importc: "sfWindow_isOpen", dynlib: LibW.} |
| 265 |
|
| 266 |
proc pollEvent*(window: PWindow, event: PEvent): bool {. |
| 267 |
cdecl, importc: "sfWindow_pollEvent", dynlib: LibW.} |
| 268 |
proc waitEvent*(window: PWindow, event: PEvent): bool {. |
| 269 |
cdecl, importc: "sfWindow_waitEvent", dynlib: LibW.} |
| 270 |
|
| 271 |
proc getDesktopMode*(): TVideoMode {. |
| 272 |
cdecl, importc: "sfVideoMode_getDesktopMode", dynlib: LibW.} |
| 273 |
proc isKeyPressed*(key: TKeyCode): bool {. |
| 274 |
cdecl, importc: "sfKeyboard_isKeyPressed", dynlib: LibW.} |
| 275 |
|
| 276 |
proc mouseIsButtonPressed*(button: TMouseButton): bool {. |
| 277 |
cdecl, importc: "sfMouse_isButtonPressed", dynlib: LibW.} |
| 278 |
proc mouseGetPosition*(relativeTo: PWindow): TVector2i {. |
| 279 |
cdecl, importc: "sfMouse_getPosition", dynlib: LibW.} |
| 280 |
proc mouseSetPosition*(position: TVector2i, relativeTo: PWindow) {. |
| 281 |
cdecl, importc: "sfMouse_setPosition", dynlib: LibW.} |
| 282 |
|
| 283 |
proc joystickIsConnected*(joystick: cint): bool {. |
| 284 |
cdecl, importc: "sfJoystick_isConnected", dynlib: LibW.} |
| 285 |
proc joystickGetButtonCount*(joystick: cint): cint {. |
| 286 |
cdecl, importc: "sfJoystick_getButtonCount", dynlib: LibW.} |
| 287 |
proc joystickHasAxis*(joystick: cint, axis: TJoystickAxis): bool {. |
| 288 |
cdecl, importc: "sfJoystick_hasAxis", dynlib: LibW.} |
| 289 |
proc joystickIsButtonPressed*(joystick: cint, button: cint): bool {. |
| 290 |
cdecl, importc: "sfJoystick_isButtonPressed", dynlib: LibW.} |
| 291 |
proc joystickGetAxisPosition*(joystick: cint, axis: TJoystickAxis): float {. |
| 292 |
cdecl, importc: "sfJoystick_getAxisPosition", dynlib: LibW.} |
| 293 |
proc joystickUpdate*(): void {. |
| 294 |
cdecl, importc: "sfJoystick_update", dynlib: LibW.} |
| 295 |
|
| 296 |
|
| 297 |
proc newRenderWindow*(handle: TWindowHandle, settings: PContextSettings = nil): PRenderWindow{. |
| 298 |
cdecl, importc: "sfRenderWindow_createFromHandle", dynlib: LibG.} |
| 299 |
proc newRenderWindow*(mode: TVideoMode, title: cstring, style: int32, settings: PContextSettings = nil): PRenderWindow {. |
| 300 |
cdecl, importc: "sfRenderWindow_create", dynlib: LibG.} |
| 301 |
|
| 302 |
proc destroy*(window: PRenderWindow) {. |
| 303 |
cdecl, importc: "sfRenderWindow_destroy", dynlib: LibG.} |
| 304 |
proc close*(window: PRenderWindow) {. |
| 305 |
cdecl, importc: "sfRenderWindow_close", dynlib: LibG.} |
| 306 |
proc 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 |
|
| 313 |
proc getSettings*(window: PRenderWindow): TContextSettings {. |
| 314 |
cdecl, importc: "sfRenderWindow_getSettings", dynlib: LibG.} |
| 315 |
|
| 316 |
proc pollEvent*(window: PRenderWindow, event: PEvent): bool {. |
| 317 |
cdecl, importc: "sfRenderWindow_pollEvent", dynlib: LibG.} |
| 318 |
proc pollEvent*(window: PRenderWindow; event: var TEvent): bool {. |
| 319 |
cdecl, importc: "sfRenderWindow_pollEvent", dynlib: LibG.} |
| 320 |
proc waitEvent*(window: PRenderWindow, event: PEvent): bool {. |
| 321 |
cdecl, importc: "sfRenderWindow_waitEvent", dynlib: LibG.} |
| 322 |
proc waitEvent*(window: PRenderWindow, event: var TEvent): bool {. |
| 323 |
cdecl, importc: "sfRenderWindow_waitEvent", dynlib: LibG.} |
| 324 |
proc getPosition*(window: PRenderWindow): TVector2i {. |
| 325 |
cdecl, importc: "sfRenderWindow_getPosition", dynlib: LibG.} |
| 326 |
proc setPosition*(window: PRenderWindow, position: TVector2i) {. |
| 327 |
cdecl, importc: "sfRenderWindow_setPosition", dynlib: LibG.} |
| 328 |
proc getSize*(window: PRenderWindow): TVector2i {. |
| 329 |
cdecl, importc: "sfRenderWindow_getSize", dynlib: LibG.} |
| 330 |
proc setSize*(window: PRenderWindow, size: TVector2i): void {. |
| 331 |
cdecl, importc: "sfRenderWindow_setSize", dynlib: LibG.} |
| 332 |
proc setTitle*(window: PRenderWindow, title: cstring): void {. |
| 333 |
cdecl, importc: "sfRenderWindow_setTitle", dynlib: LibG.} |
| 334 |
|
| 335 |
proc setVisible*(window: PRenderWindow, visible: bool) {. |
| 336 |
cdecl, importc: "sfRenderWindow_setVisible", dynlib: LibG.} |
| 337 |
proc setMouseCursorVisible*(window: PRenderWindow, show: bool) {. |
| 338 |
cdecl, importc: "sfRenderWindow_setMouseCursorVisible", dynlib: LibG.} |
| 339 |
proc setVerticalSyncEnabled*(window: PRenderWindow, enabled: bool) {. |
| 340 |
cdecl, importc: "sfRenderWindow_setVerticalSyncEnabled", dynlib: LibG.} |
| 341 |
proc setKeyRepeatEnabled*(window: PRenderWindow, enabled: bool) {. |
| 342 |
cdecl, importc: "sfRenderWindow_setKeyRepeatEnabled", dynlib: LibG.} |
| 343 |
proc setActive*(window: PRenderWindow, active: bool): bool {. |
| 344 |
cdecl, importc: "sfRenderWindow_setActive", dynlib: LibG.} |
| 345 |
proc display*(window: PRenderWindow) {. |
| 346 |
cdecl, importc: "sfRenderWindow_display", dynlib: LibG.} |
| 347 |
proc setFramerateLimit*(window: PRenderWindow, limit: uint) {. |
| 348 |
cdecl, importc: "sfRenderWindow_setFramerateLimit", dynlib: LibG.} |
| 349 |
proc setJoystickThreshold*(window: PRenderWindow, threshold: float) {. |
| 350 |
cdecl, importc: "sfRenderWindow_setJoystickThreshold", dynlib: LibG.} |
| 351 |
proc getSystemHandle*(window: PRenderWindow): TWindowHandle {. |
| 352 |
cdecl, importc: "sfRenderWindow_getSystemHandle", dynlib: LibG.} |
| 353 |
|
| 354 |
proc clear*(window: PRenderWindow, color: TColor) {. |
| 355 |
cdecl, importc: "sfRenderWindow_clear", dynlib: LibG.} |
| 356 |
|
| 357 |
proc setView*(window: PRenderWindow, view: PView) {. |
| 358 |
cdecl, importc: "sfRenderWindow_setView", dynlib: LibG.} |
| 359 |
proc getView*(window: PRenderWindow): PView {. |
| 360 |
cdecl, importc: "sfRenderWindow_getView", dynlib: LibG.} |
| 361 |
proc getDefaultView*(window: PRenderWindow): PView {. |
| 362 |
cdecl, importc: "sfRenderWindow_getDefaultView", dynlib: LibG.} |
| 363 |
proc getViewport*(window: PRenderWindow, view: PView): TIntRect {. |
| 364 |
cdecl, importc: "sfRenderWindow_getViewport", dynlib: LibG.} |
| 365 |
|
| 366 |
proc convertCoords*(window: PRenderWindow, point: TVector2i, targetView: PView): TVector2f {. |
| 367 |
cdecl, importc: "sfRenderWindow_convertCoords", dynlib: LibG.} |
| 368 |
|
| 369 |
proc draw*(window: PRenderWindow, sprite: PSprite, states: PRenderStates = nil) {. |
| 370 |
cdecl, importc: "sfRenderWindow_drawSprite", dynlib: LibG.} |
| 371 |
proc draw*(window: PRenderWindow, text: PText, states: PRenderStates = nil) {. |
| 372 |
cdecl, importc: "sfRenderWindow_drawText", dynlib: LibG.} |
| 373 |
proc draw*(window: PRenderWindow, shape: PShape, states: PRenderStates = nil) {. |
| 374 |
cdecl, importc: "sfRenderWindow_drawShape", dynlib: LibG.} |
| 375 |
proc draw*(window: PRenderWindow, shape: PCircleShape, states: PRenderStates = nil) {. |
| 376 |
cdecl, importc: "sfRenderWindow_drawCircleShape", dynlib: LibG.} |
| 377 |
proc draw*(window: PRenderWindow, shape: PRectangleShape, states: PRenderStates = nil) {. |
| 378 |
cdecl, importc: "sfRenderWindow_drawRectangleShape", dynlib: LibG.} |
| 379 |
|
| 380 |
proc draw*(window: PRenderWindow, shape: PConvexShape, states: PRenderStates = nil) {. |
| 381 |
cdecl, importc: "sfRenderWindow_drawConvexShape", dynlib: LibG.} |
| 382 |
proc draw*(window: PRenderWindow, shape: PVertexArray, states: PRenderStates = nil) {. |
| 383 |
cdecl, importc: "sfRenderWindow_drawVertexArray", dynlib: LibG.} |
| 384 |
proc draw*(window: PRenderWindow, vertices: PVertex, vertexCount: cint, |
| 385 |
vertexType: TPrimitiveType, states: PRenderStates = nil) {. |
| 386 |
cdecl, importc: "sfRenderWindow_drawPrimitives", dynlib: LibG.} |
| 387 |
|
| 388 |
proc pushGlStates*(window: PRenderWindow) {. |
| 389 |
cdecl, importc: "sfRenderWindow_pushGLStates", dynlib: LibG.} |
| 390 |
proc popGlStates*(window: PRenderWindow) {. |
| 391 |
cdecl, importc: "sfRenderWindow_popGLStates", dynlib: LibG.} |
| 392 |
proc resetGlStates*(window: PRenderWindow) {. |
| 393 |
cdecl, importc: "sfRenderWindow_resetGLStates", dynlib: LibG.} |
| 394 |
proc capture*(window: PRenderWindow): PImage {. |
| 395 |
cdecl, importc: "sfRenderWindow_capture", dynlib: LibG.} |
| 396 |
|
| 397 |
#Construct a new render texture |
| 398 |
proc newRenderTexture*(width, height: cint; depthBuffer: bool): PRenderTexture {. |
| 399 |
cdecl, importc: "sfRenderTexture_create", dynlib: LibG.} |
| 400 |
#Destroy an existing render texture |
| 401 |
proc destroy*(renderTexture: PRenderTexture){. |
| 402 |
cdecl, importc: "sfRenderTexture_destroy", dynlib: LibG.} |
| 403 |
#Get the size of the rendering region of a render texture |
| 404 |
proc getSize*(renderTexture: PRenderTexture): TVector2i {. |
| 405 |
cdecl, importc: "sfRenderTexture_getSize", dynlib: LibG.} |
| 406 |
#Activate or deactivate a render texture as the current target for rendering |
| 407 |
proc setActive*(renderTexture: PRenderTexture; active: bool): bool{. |
| 408 |
cdecl, importc: "sfRenderTexture_setActive", dynlib: LibG.} |
| 409 |
#Update the contents of the target texture |
| 410 |
proc display*(renderTexture: PRenderTexture){. |
| 411 |
cdecl, importc: "sfRenderTexture_display", dynlib: LibG.} |
| 412 |
#Clear the rendertexture with the given color |
| 413 |
proc clear*(renderTexture: PRenderTexture; color: TColor){. |
| 414 |
cdecl, importc: "sfRenderTexture_clear", dynlib: LibG.} |
| 415 |
#Change the current active view of a render texture |
| 416 |
proc setView*(renderTexture: PRenderTexture; view: PView){. |
| 417 |
cdecl, importc: "sfRenderTexture_setView", dynlib: LibG.} |
| 418 |
#Get the current active view of a render texture |
| 419 |
proc getView*(renderTexture: PRenderTexture): PView{. |
| 420 |
cdecl, importc: "sfRenderTexture_getView", dynlib: LibG.} |
| 421 |
#Get the default view of a render texture |
| 422 |
proc getDefaultView*(renderTexture: PRenderTexture): PView{. |
| 423 |
cdecl, importc: "sfRenderTexture_getDefaultView", dynlib: LibG.} |
| 424 |
#Get the viewport of a view applied to this target |
| 425 |
proc getViewport*(renderTexture: PRenderTexture; view: PView): TIntRect{. |
| 426 |
cdecl, importc: "sfRenderTexture_getViewport", dynlib: LibG.} |
| 427 |
#Convert a point in texture coordinates into view coordinates |
| 428 |
proc convertCoords*(renderTexture: PRenderTexture; point: TVector2i; targetView: PView): TVector2f{. |
| 429 |
cdecl, importc: "sfRenderTexture_convertCoords", dynlib: LibG.} |
| 430 |
#Draw a drawable object to the render-target |
| 431 |
proc draw*(renderTexture: PRenderTexture; sprite: PSprite; states: PRenderStates){. |
| 432 |
cdecl, importc: "sfRenderTexture_drawSprite", dynlib: LibG.} |
| 433 |
proc draw*(renderTexture: PRenderTexture; text: PText; states: PRenderStates){. |
| 434 |
cdecl, importc: "sfRenderTexture_drawText", dynlib: LibG.} |
| 435 |
proc draw*(renderTexture: PRenderTexture; shape: PShape; states: PRenderStates){. |
| 436 |
cdecl, importc: "sfRenderTexture_drawShape", dynlib: LibG.} |
| 437 |
proc draw*(renderTexture: PRenderTexture; shape: PCircleShape; |
| 438 |
states: PRenderStates){. |
| 439 |
cdecl, importc: "sfRenderTexture_drawCircleShape", dynlib: LibG.} |
| 440 |
proc draw*(renderTexture: PRenderTexture; shape: PConvexShape; |
| 441 |
states: PRenderStates){. |
| 442 |
cdecl, importc: "sfRenderTexture_drawConvexShape", dynlib: LibG.} |
| 443 |
proc draw*(renderTexture: PRenderTexture; shape: PRectangleShape; |
| 444 |
states: PRenderStates){. |
| 445 |
cdecl, importc: "sfRenderTexture_drawRectangleShape", dynlib: LibG.} |
| 446 |
proc 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 |
| 450 |
proc 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. |
| 469 |
proc 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. |
| 475 |
proc 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. |
| 484 |
proc resetGLStates*(renderTexture: PRenderTexture){. |
| 485 |
cdecl, importc: "sfRenderTexture_resetGLStates", dynlib: LibG.} |
| 486 |
#Get the target texture of a render texture |
| 487 |
proc getTexture*(renderTexture: PRenderTexture): PTexture{. |
| 488 |
cdecl, importc: "sfRenderTexture_getTexture", dynlib: LibG.} |
| 489 |
#Enable or disable the smooth filter on a render texture |
| 490 |
proc 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 |
| 493 |
proc isSmooth*(renderTexture: PRenderTexture): bool {. |
| 494 |
cdecl, importc: "sfRenderTexture_isSmooth", dynlib: LibG.} |
| 495 |
|
| 496 |
proc intRect*(left, top, width, height: cint): TIntRect = |
| 497 |
result.left = left |
| 498 |
result.top = top |
| 499 |
result.width = width |
| 500 |
result.height = height |
| 501 |
proc floatRect*(left, top, width, height: cfloat): TFloatRect = |
| 502 |
result.left = left |
| 503 |
result.top = top |
| 504 |
result.width = width |
| 505 |
result.height = height |
| 506 |
proc contains*(rect: PFloatRect, x, y: cfloat): bool {. |
| 507 |
cdecl, importc: "sfFloatRect_contains", dynlib: LibG.} |
| 508 |
proc contains*(rect: PIntRect, x: cint, y: cint): bool{.cdecl, |
| 509 |
importc: "sfIntRect_contains", dynlib: LibG.} |
| 510 |
proc intersects*(rect1, rect2, intersection: PFloatRect): bool {. |
| 511 |
cdecl, importc: "sfFloatRect_intersects", dynlib: LibG.} |
| 512 |
proc intersects*(rect1, rect2, intersection: PIntRect): bool {. |
| 513 |
cdecl, importc: "sfIntRect_intersects", dynlib: LibG.} |
| 514 |
|
| 515 |
proc newFont*(filename: cstring): PFont {. |
| 516 |
cdecl, importc: "sfFont_createFromFile", dynlib: LibG.} |
| 517 |
proc newFont*(data: pointer, sizeInBytes: cint): PFont {. |
| 518 |
cdecl, importc: "sfFont_createFromMemory", dynlib: LibG.} |
| 519 |
proc newFont*(stream: PInputStream): PFont {. |
| 520 |
cdecl, importc: "sfFont_createFromStream", dynlib: LibG.} |
| 521 |
proc copy*(font: PFont): PFont {. |
| 522 |
cdecl, importc: "sfFont_copy", dynlib: LibG.} |
| 523 |
proc destroy*(font: PFont) {. |
| 524 |
cdecl, importc: "sfFont_destroy", dynlib: LibG.} |
| 525 |
proc getGlyph*(font: PFont, codePoint: uint32, characterSize: cint, bold: bool): TGlyph{. |
| 526 |
cdecl, importc: "sfFont_getGlyph", dynlib: LibG.} |
| 527 |
proc getKerning*(font: PFont, first: uint32, second: uint32, characterSize: cint): cint {. |
| 528 |
cdecl, importc: "sfFont_getKerning", dynlib: LibG.} |
| 529 |
proc getLineSpacing*(font: PFont, characterSize: cint): cint {. |
| 530 |
cdecl, importc: "sfFont_getLineSpacing", dynlib: LibG.} |
| 531 |
proc getTexture*(font: PFont, characterSize: cint): PTexture {. |
| 532 |
cdecl, importc: "sfFont_getTexture", dynlib: LibG.} |
| 533 |
#getDefaultFont() has been removed from CSFML |
| 534 |
proc getDefaultFont*(): PFont {. |
| 535 |
error, cdecl, importc: "sfFont_getDefaultFont", dynlib: LibG.} |
| 536 |
|
| 537 |
proc newCircleShape*(): PCircleShape {. |
| 538 |
cdecl, importc: "sfCircleShape_create", dynlib: LibG.} |
| 539 |
proc copy*(shape: PCircleShape): PCircleShape {. |
| 540 |
cdecl, importc: "sfCircleShape_copy", dynlib: LibG.} |
| 541 |
proc destroy*(shape: PCircleShape) {. |
| 542 |
cdecl, importc: "sfCircleShape_destroy", dynlib: LibG.} |
| 543 |
proc setPosition*(shape: PCircleShape, position: TVector2f) {. |
| 544 |
cdecl, importc: "sfCircleShape_setPosition", dynlib: LibG.} |
| 545 |
proc setRotation*(shape: PCircleShape, angle: cfloat) {. |
| 546 |
cdecl, importc: "sfCircleShape_setRotation", dynlib: LibG.} |
| 547 |
proc setScale*(shape: PCircleShape, scale: TVector2f) {. |
| 548 |
cdecl, importc: "sfCircleShape_setScale", dynlib: LibG.} |
| 549 |
proc setOrigin*(shape: PCircleShape, origin: TVector2f) {. |
| 550 |
cdecl, importc: "sfCircleShape_setOrigin", dynlib: LibG.} |
| 551 |
proc getPosition*(shape: PCircleShape): TVector2f {. |
| 552 |
cdecl, importc: "sfCircleShape_getPosition", dynlib: LibG.} |
| 553 |
proc getRotation*(shape: PCircleShape): cfloat {. |
| 554 |
cdecl, importc: "sfCircleShape_getRotation", dynlib: LibG.} |
| 555 |
proc getScale*(shape: PCircleShape): TVector2f {. |
| 556 |
cdecl, importc: "sfCircleShape_getScale", dynlib: LibG.} |
| 557 |
proc getOrigin*(shape: PCircleShape): TVector2f {. |
| 558 |
cdecl, importc: "sfCircleShape_getOrigin", dynlib: LibG.} |
| 559 |
proc move*(shape: PCircleShape, offset: TVector2f) {. |
| 560 |
cdecl, importc: "sfCircleShape_move", dynlib: LibG.} |
| 561 |
proc rotate*(shape: PCircleShape, angle: cfloat){. |
| 562 |
cdecl, importc: "sfCircleShape_rotate", dynlib: LibG.} |
| 563 |
proc scale*(shape: PCircleShape, factors: TVector2f) {. |
| 564 |
cdecl, importc: "sfCircleShape_scale", dynlib: LibG.} |
| 565 |
proc getTransform*(shape: PCircleShape): TTransform {. |
| 566 |
cdecl, importc: "sfCircleShape_getTransform", dynlib: LibG.} |
| 567 |
proc getInverseTransform*(shape: PCircleShape): TTransform {. |
| 568 |
cdecl, importc: "sfCircleShape_getInverseTransform", dynlib: LibG.} |
| 569 |
proc setTexture*(shape: PCircleShape, texture: PTexture, resetRect: bool) {. |
| 570 |
cdecl, importc: "sfCircleShape_setTexture", dynlib: LibG.} |
| 571 |
proc setTextureRect*(shape: PCircleShape, rect: TIntRect) {. |
| 572 |
cdecl, importc: "sfCircleShape_setTextureRect", dynlib: LibG.} |
| 573 |
proc setFillColor*(shape: PCircleShape, color: TColor) {. |
| 574 |
cdecl, importc: "sfCircleShape_setFillColor", dynlib: LibG.} |
| 575 |
proc setOutlineColor*(shape: PCircleShape, color: TColor) {. |
| 576 |
cdecl, importc: "sfCircleShape_setOutlineColor", dynlib: LibG.} |
| 577 |
proc setOutlineThickness*(shape: PCircleShape, thickness: cfloat) {. |
| 578 |
cdecl, importc: "sfCircleShape_setOutlineThickness", dynlib: LibG.} |
| 579 |
proc getTexture*(shape: PCircleShape): PTexture {. |
| 580 |
cdecl, importc: "sfCircleShape_getTexture", dynlib: LibG.} |
| 581 |
proc getTextureRect*(shape: PCircleShape): TIntRect {. |
| 582 |
cdecl, importc: "sfCircleShape_getTextureRect", dynlib: LibG.} |
| 583 |
proc getFillColor*(shape: PCircleShape): TColor {. |
| 584 |
cdecl, importc: "sfCircleShape_getFillColor", dynlib: LibG.} |
| 585 |
proc getOutlineColor*(shape: PCircleShape): TColor {. |
| 586 |
cdecl, importc: "sfCircleShape_getOutlineColor", dynlib: LibG.} |
| 587 |
proc getOutlineThickness*(shape: PCircleShape): cfloat {. |
| 588 |
cdecl, importc: "sfCircleShape_getOutlineThickness", dynlib: LibG.} |
| 589 |
proc getPointCount*(shape: PCircleShape): cint {. |
| 590 |
cdecl, importc: "sfCircleShape_getPointCount", dynlib: LibG.} |
| 591 |
proc getPoint*(shape: PCircleShape, index: cint): TVector2f {. |
| 592 |
cdecl, importc: "sfCircleShape_getPoint", dynlib: LibG.} |
| 593 |
proc setRadius*(shape: PCircleShape, radius: cfloat) {. |
| 594 |
cdecl, importc: "sfCircleShape_setRadius", dynlib: LibG.} |
| 595 |
proc getRadius*(shape: PCircleShape): cfloat {. |
| 596 |
cdecl, importc: "sfCircleShape_getRadius", dynlib: LibG.} |
| 597 |
proc setPointCount*(shape: PCircleShape, count: cint) {. |
| 598 |
cdecl, importc: "sfCircleShape_setPointCount", dynlib: LibG.} |
| 599 |
proc getLocalBounds*(shape: PCircleShape): TFloatRect {. |
| 600 |
cdecl, importc: "sfCircleShape_getLocalBounds", dynlib: LibG.} |
| 601 |
proc getGlobalBounds*(shape: PCircleShape): TFloatRect {. |
| 602 |
cdecl, importc: "sfCircleShape_getGlobalBounds", dynlib: LibG.} |
| 603 |
|
| 604 |
proc newRectangleShape*(): PRectangleShape {. |
| 605 |
cdecl, importc: "sfRectangleShape_create", dynlib: LibG.} |
| 606 |
proc copy*(shape: PRectangleShape): PRectangleShape {. |
| 607 |
cdecl, importc: "sfRectangleShape_copy", dynlib: LibG.} |
| 608 |
proc destroy*(shape: PRectangleShape){. |
| 609 |
cdecl, importc: "sfRectangleShape_destroy", dynlib: LibG.} |
| 610 |
proc setPosition*(shape: PRectangleShape, position: TVector2f) {. |
| 611 |
cdecl, importc: "sfRectangleShape_setPosition", dynlib: LibG.} |
| 612 |
proc setRotation*(shape: PRectangleShape, angle: cfloat) {. |
| 613 |
cdecl, importc: "sfRectangleShape_setRotation", dynlib: LibG.} |
| 614 |
proc setScale*(shape: PRectangleShape, scale: TVector2f) {. |
| 615 |
cdecl, importc: "sfRectangleShape_setScale", dynlib: LibG.} |
| 616 |
proc setOrigin*(shape: PRectangleShape, origin: TVector2f) {. |
| 617 |
cdecl, importc: "sfRectangleShape_setOrigin", dynlib: LibG.} |
| 618 |
proc getPosition*(shape: PRectangleShape): TVector2f {. |
| 619 |
cdecl, importc: "sfRectangleShape_getPosition", dynlib: LibG.} |
| 620 |
proc getRotation*(shape: PRectangleShape): cfloat {. |
| 621 |
cdecl, importc: "sfRectangleShape_getRotation", dynlib: LibG.} |
| 622 |
proc getScale*(shape: PRectangleShape): TVector2f {. |
| 623 |
cdecl, importc: "sfRectangleShape_getScale", dynlib: LibG.} |
| 624 |
proc getOrigin*(shape: PRectangleShape): TVector2f {. |
| 625 |
cdecl, importc: "sfRectangleShape_getOrigin", dynlib: LibG.} |
| 626 |
proc move*(shape: PRectangleShape, offset: TVector2f) {. |
| 627 |
cdecl, importc: "sfRectangleShape_move", dynlib: LibG.} |
| 628 |
proc rotate*(shape: PRectangleShape, angle: cfloat) {. |
| 629 |
cdecl, importc: "sfRectangleShape_rotate", dynlib: LibG.} |
| 630 |
proc scale*(shape: PRectangleShape, factors: TVector2f) {. |
| 631 |
cdecl, importc: "sfRectangleShape_scale", dynlib: LibG.} |
| 632 |
proc getTransform*(shape: PRectangleShape): TTransform {. |
| 633 |
cdecl, importc: "sfRectangleShape_getTransform", dynlib: LibG.} |
| 634 |
proc getInverseTransform*(shape: PRectangleShape): TTransform {. |
| 635 |
cdecl, importc: "sfRectangleShape_getInverseTransform", dynlib: LibG.} |
| 636 |
proc setTexture*(shape: PRectangleShape, texture: PTexture, resetRect: bool) {. |
| 637 |
cdecl, importc: "sfRectangleShape_setTexture", dynlib: LibG.} |
| 638 |
proc setTextureRect*(shape: PRectangleShape, rect: TIntRect) {. |
| 639 |
cdecl, importc: "sfRectangleShape_setTextureRect", dynlib: LibG.} |
| 640 |
proc setFillColor*(shape: PRectangleShape, color: TColor) {. |
| 641 |
cdecl, importc: "sfRectangleShape_setFillColor", dynlib: LibG.} |
| 642 |
proc setOutlineColor*(shape: PRectangleShape, color: TColor) {. |
| 643 |
cdecl, importc: "sfRectangleShape_setOutlineColor", dynlib: LibG.} |
| 644 |
proc setOutlineThickness*(shape: PRectangleShape, thickness: cfloat) {. |
| 645 |
cdecl, importc: "sfRectangleShape_setOutlineThickness", dynlib: LibG.} |
| 646 |
proc getTexture*(shape: PRectangleShape): PTexture {. |
| 647 |
cdecl, importc: "sfRectangleShape_getTexture", dynlib: LibG.} |
| 648 |
proc getTextureRect*(shape: PRectangleShape): TIntRect {. |
| 649 |
cdecl, importc: "sfRectangleShape_getTextureRect", dynlib: LibG.} |
| 650 |
proc getFillColor*(shape: PRectangleShape): TColor {. |
| 651 |
cdecl, importc: "sfRectangleShape_getFillColor", dynlib: LibG.} |
| 652 |
proc getOutlineColor*(shape: PRectangleShape): TColor {. |
| 653 |
cdecl, importc: "sfRectangleShape_getOutlineColor", dynlib: LibG.} |
| 654 |
proc getOutlineThickness*(shape: PRectangleShape): cfloat {. |
| 655 |
cdecl, importc: "sfRectangleShape_getOutlineThickness", dynlib: LibG.} |
| 656 |
proc getPointCount*(shape: PRectangleShape): cint {. |
| 657 |
cdecl, importc: "sfRectangleShape_getPointCount", dynlib: LibG.} |
| 658 |
proc getPoint*(shape: PRectangleShape, index: cint): TVector2f {. |
| 659 |
cdecl, importc: "sfRectangleShape_getPoint", dynlib: LibG.} |
| 660 |
proc setSize*(shape: PRectangleShape, size: TVector2f) {. |
| 661 |
cdecl, importc: "sfRectangleShape_setSize", dynlib: LibG.} |
| 662 |
proc getSize*(shape: PRectangleShape): TVector2f {. |
| 663 |
cdecl, importc: "sfRectangleShape_getSize", dynlib: LibG.} |
| 664 |
proc getLocalBounds*(shape: PRectangleShape): TFloatRect {. |
| 665 |
cdecl, importc: "sfRectangleShape_getLocalBounds", dynlib: LibG.} |
| 666 |
proc getGlobalBounds*(shape: PRectangleShape): TFloatRect {. |
| 667 |
cdecl, importc: "sfRectangleShape_getGlobalBounds", dynlib: LibG.} |
| 668 |
|
| 669 |
|
| 670 |
proc newView*(): PView {. |
| 671 |
cdecl, importc: "sfView_create", dynlib: LibG.} |
| 672 |
proc viewFromRect*(rectangle: TFloatRect): PView{. |
| 673 |
cdecl, importc: "sfView_createFromRect", dynlib: LibG.} |
| 674 |
proc copy*(view: PView): PView {. |
| 675 |
cdecl, importc: "sfView_copy", dynlib: LibG.} |
| 676 |
proc destroy*(view: PView) {. |
| 677 |
cdecl, importc: "sfView_destroy", dynlib: LibG.} |
| 678 |
proc setCenter*(view: PView, center: TVector2f) {. |
| 679 |
cdecl, importc: "sfView_setCenter", dynlib: LibG.} |
| 680 |
proc setSize*(view: PView, size: TVector2f) {. |
| 681 |
cdecl, importc: "sfView_setSize", dynlib: LibG.} |
| 682 |
proc setRotation*(view: PView, angle: cfloat) {. |
| 683 |
cdecl, importc: "sfView_setRotation", dynlib: LibG.} |
| 684 |
proc setViewport*(view: PView, viewport: TFloatRect) {. |
| 685 |
cdecl, importc: "sfView_setViewport", dynlib: LibG.} |
| 686 |
proc reset*(view: PView, rectangle: TFloatRect) {. |
| 687 |
cdecl, importc: "sfView_reset", dynlib: LibG.} |
| 688 |
proc getCenter*(view: PView): TVector2f {. |
| 689 |
cdecl, importc: "sfView_getCenter", dynlib: LibG.} |
| 690 |
proc getSize*(view: PView): TVector2f {. |
| 691 |
cdecl, importc: "sfView_getSize", dynlib: LibG.} |
| 692 |
proc getRotation*(view: PView): cfloat {. |
| 693 |
cdecl, importc: "sfView_getRotation", dynlib: LibG.} |
| 694 |
proc getViewport*(view: PView): TFloatRect {. |
| 695 |
cdecl, importc: "sfView_getViewport", dynlib: LibG.} |
| 696 |
proc move*(view: PView, offset: TVector2f) {. |
| 697 |
cdecl, importc: "sfView_move", dynlib: LibG.} |
| 698 |
proc rotate*(view: PView, angle: cfloat) {. |
| 699 |
cdecl, importc: "sfView_rotate", dynlib: LibG.} |
| 700 |
proc zoom*(view: PView, factor: cfloat) {. |
| 701 |
cdecl, importc: "sfView_zoom", dynlib: LibG.} |
| 702 |
|
| 703 |
proc newImage*(width, height: cint): PImage {. |
| 704 |
cdecl, importc: "sfImage_create", dynlib: LibG.} |
| 705 |
proc newImage*(width, height: cint, color: TColor): PImage {. |
| 706 |
cdecl, importc: "sfImage_createFromColor", dynlib: LibG.} |
| 707 |
proc newImage*(width, height: cint, pixels: pointer): PImage {. ##same deal as setIcon() |
| 708 |
cdecl, importc: "sfImage_createFromPixels", dynlib: LibG.} |
| 709 |
proc newImage*(filename: cstring): PImage {. |
| 710 |
cdecl, importc: "sfImage_createFromFile", dynlib: LibG.} |
| 711 |
proc newImage*(data: pointer, size: cint): PImage {. |
| 712 |
cdecl, importc: "sfImage_createFromMemory", dynlib: LibG.} |
| 713 |
proc newImage*(stream: PInputStream): PImage {. |
| 714 |
cdecl, importc: "sfImage_createFromStream", dynlib: LibG.} |
| 715 |
proc copy*(image: PImage): PImage {. |
| 716 |
cdecl, importc: "sfImage_copy", dynlib: LibG.} |
| 717 |
proc destroy*(image: PImage) {. |
| 718 |
cdecl, importc: "sfImage_destroy", dynlib: LibG.} |
| 719 |
proc save*(image: PImage, filename: cstring): bool {. |
| 720 |
cdecl, importc: "sfImage_saveToFile", dynlib: LibG.} |
| 721 |
proc getSize*(image: PImage): TVector2i {. |
| 722 |
cdecl, importc: "sfImage_getSize", dynlib: LibG.} |
| 723 |
proc createMask*(image: PImage, color: TColor, alpha: cchar) {. |
| 724 |
cdecl, importc: "sfImage_createMaskFromColor", dynlib: LibG.} |
| 725 |
proc copy*(destination, source: PImage, destX, destY: cint; |
| 726 |
sourceRect: TIntRect, applyAlpha: bool) {. |
| 727 |
cdecl, importc: "sfImage_copyImage", dynlib: LibG.} |
| 728 |
proc setPixel*(image: PImage, x, y: cint, color: TColor) {. |
| 729 |
cdecl, importc: "sfImage_setPixel", dynlib: LibG.} |
| 730 |
proc getPixel*(image: PImage, x, y: cint): TColor {. |
| 731 |
cdecl, importc: "sfImage_getPixel", dynlib: LibG.} |
| 732 |
proc getPixels*(image: PImage): pointer {. |
| 733 |
cdecl, importc: "sfImage_getPixelsPtr", dynlib: LibG.} |
| 734 |
proc flipHorizontally*(image: PImage) {. |
| 735 |
cdecl, importc: "sfImage_flipHorizontally", dynlib: LibG.} |
| 736 |
proc flipVertically*(image: PImage) {. |
| 737 |
cdecl, importc: "sfImage_flipVertically", dynlib: LibG.} |
| 738 |
|
| 739 |
proc newSprite*(): PSprite {. |
| 740 |
cdecl, importc: "sfSprite_create", dynlib: LibG.} |
| 741 |
proc copy*(sprite: PSprite): PSprite {. |
| 742 |
cdecl, importc: "sfSprite_copy", dynlib: LibG.} |
| 743 |
proc destroy*(sprite: PSprite) {. |
| 744 |
cdecl, importc: "sfSprite_destroy", dynlib: LibG.} |
| 745 |
proc setPosition*(sprite: PSprite, position: TVector2f) {. |
| 746 |
cdecl, importc: "sfSprite_setPosition", dynlib: LibG.} |
| 747 |
proc setRotation*(sprite: PSprite, angle: cfloat) {. |
| 748 |
cdecl, importc: "sfSprite_setRotation", dynlib: LibG.} |
| 749 |
proc setScale*(sprite: PSprite, scale: TVector2f) {. |
| 750 |
cdecl, importc: "sfSprite_setScale", dynlib: LibG.} |
| 751 |
proc setOrigin*(sprite: PSprite, origin: TVector2f) {. |
| 752 |
cdecl, importc: "sfSprite_setOrigin", dynlib: LibG.} |
| 753 |
proc getPosition*(sprite: PSprite): TVector2f {. |
| 754 |
cdecl, importc: "sfSprite_getPosition", dynlib: LibG.} |
| 755 |
proc getRotation*(sprite: PSprite): cfloat {. |
| 756 |
cdecl, importc: "sfSprite_getRotation", dynlib: LibG.} |
| 757 |
proc getScale*(sprite: PSprite): TVector2f {. |
| 758 |
cdecl, importc: "sfSprite_getScale", dynlib: LibG.} |
| 759 |
proc getOrigin*(sprite: PSprite): TVector2f {. |
| 760 |
cdecl, importc: "sfSprite_getOrigin", dynlib: LibG.} |
| 761 |
proc move*(sprite: PSprite, offset: TVector2f) {. |
| 762 |
cdecl, importc: "sfSprite_move", dynlib: LibG.} |
| 763 |
proc rotate*(sprite: PSprite, angle: cfloat) {. |
| 764 |
cdecl, importc: "sfSprite_rotate", dynlib: LibG.} |
| 765 |
proc scale*(sprite: PSprite, factor: TVector2f) {. |
| 766 |
cdecl, importc: "sfSprite_scale", dynlib: LibG.} |
| 767 |
proc getTransform*(sprite: PSprite): TTransform {. |
| 768 |
cdecl, importc: "sfSprite_getTransform", dynlib: LibG.} |
| 769 |
proc getInverseTransform*(sprite: PSprite): TTransform {. |
| 770 |
cdecl, importc: "sfSprite_getInverseTransform", dynlib: LibG.} |
| 771 |
proc setTexture*(sprite: PSprite, texture: PTexture, resetRect: bool) {. |
| 772 |
cdecl, importc: "sfSprite_setTexture", dynlib: LibG.} |
| 773 |
proc setTextureRect*(sprite: PSprite, rectangle: TIntRect) {. |
| 774 |
cdecl, importc: "sfSprite_setTextureRect", dynlib: LibG.} |
| 775 |
proc setColor*(sprite: PSprite, color: TColor) {. |
| 776 |
cdecl, importc: "sfSprite_setColor", dynlib: LibG.} |
| 777 |
proc getTexture*(sprite: PSprite): TTexture {. |
| 778 |
cdecl, importc: "sfSprite_getTexture", dynlib: LibG.} |
| 779 |
proc getTextureRect*(sprite: PSprite): TIntRect {. |
| 780 |
cdecl, importc: "sfSprite_getTextureRect", dynlib: LibG.} |
| 781 |
proc getColor*(sprite: PSprite): TColor {. |
| 782 |
cdecl, importc: "sfSprite_getColor", dynlib: LibG.} |
| 783 |
proc getLocalBounds*(sprite: PSprite): TFloatRect {. |
| 784 |
cdecl, importc: "sfSprite_getLocalBounds", dynlib: LibG.} |
| 785 |
proc getGlobalBounds*(sprite: PSprite): TFloatRect {. |
| 786 |
cdecl, importc: "sfSprite_getGlobalBounds", dynlib: LibG.} |
| 787 |
|
| 788 |
proc newTexture*(width, height: cint): PTexture {. |
| 789 |
cdecl, importc: "sfTexture_create", dynlib: LibG.} |
| 790 |
proc newTexture*(filename: cstring): PTexture {. |
| 791 |
cdecl, importc: "sfTexture_createFromFile", dynlib: LibG.} |
| 792 |
proc newTexture*(data: pointer, size: cint, area: PIntRect): PTexture {. |
| 793 |
cdecl, importc: "sfTexture_createFromMemory", dynlib: LibG.} |
| 794 |
proc newTexture*(stream: PInputStream, area: PIntRect): PTexture {. |
| 795 |
cdecl, importc: "sfTexture_createFromStream", dynlib: LibG.} |
| 796 |
proc newTexture*(image: PImage, area: PIntRect = nil): PTexture {. |
| 797 |
cdecl, importc: "sfTexture_createFromImage", dynlib: LibG.} |
| 798 |
proc copy*(texture: PTexture): PTexture {. |
| 799 |
cdecl, importc: "sfTexture_copy", dynlib: LibG.} |
| 800 |
proc destroy*(texture: PTexture) {. |
| 801 |
cdecl, importc: "sfTexture_destroy", dynlib: LibG.} |
| 802 |
proc getSize*(texture: PTexture): TVector2i {. |
| 803 |
cdecl, importc: "sfTexture_getSize", dynlib: LibG.} |
| 804 |
proc copyToImage*(texture: PTexture): PImage {. |
| 805 |
cdecl, importc: "sfTexture_copyToImage", dynlib: LibG.} |
| 806 |
proc updateFromPixels*(texture: PTexture, pixels: pointer, width, height, x, y: cint) {. |
| 807 |
cdecl, importc: "sfTexture_updateFromPixels", dynlib: LibG.} |
| 808 |
proc updateFromImage*(texture: PTexture, image: PImage, x, y: cint) {. |
| 809 |
cdecl, importc: "sfTexture_updateFromImage", dynlib: LibG.} |
| 810 |
proc updateFromWindow*(texture: PTexture, window: PWindow, x, y: cint) {. |
| 811 |
cdecl, importc: "sfTexture_updateFromWindow", dynlib: LibG.} |
| 812 |
proc updateFromWindow*(texture: PTexture, window: PRenderWindow, x, y: cint) {. |
| 813 |
cdecl, importc: "sfTexture_updateFromRenderWindow", dynlib: LibG.} |
| 814 |
proc bindGL*(texture: PTexture) {. |
| 815 |
cdecl, importc: "sfTexture_bind", dynlib: LibG.} |
| 816 |
proc setSmooth*(texture: PTexture, smooth: bool) {. |
| 817 |
cdecl, importc: "sfTexture_setSmooth", dynlib: LibG.} |
| 818 |
proc isSmooth*(texture: PTexture): bool {. |
| 819 |
cdecl, importc: "sfTexture_isSmooth", dynlib: LibG.} |
| 820 |
proc setRepeated*(texture: PTexture, repeated: bool) {. |
| 821 |
cdecl, importc: "sfTexture_setRepeated", dynlib: LibG.} |
| 822 |
proc isRepeated*(texture: PTexture): bool {. |
| 823 |
cdecl, importc: "sfTexture_isRepeated", dynlib: LibG.} |
| 824 |
proc textureMaxSize*(): cint {. |
| 825 |
cdecl, importc: "sfTexture_getMaximumSize", dynlib: LibG.} |
| 826 |
|
| 827 |
proc newVertexArray*(): PVertexArray {. |
| 828 |
cdecl, importc: "sfVertexArray_create", dynlib: LibG.} |
| 829 |
proc copy*(vertexArray: PVertexArray): PVertexArray {. |
| 830 |
cdecl, importc: "sfVertexArray_copy", dynlib: LibG.} |
| 831 |
proc destroy*(va: PVertexArray) {. |
| 832 |
cdecl, importc: "sfVertexArray_destroy", dynlib: LibG.} |
| 833 |
proc getVertexCount*(va: PVertexArray): cint {. |
| 834 |
cdecl, importc: "sfVertexArray_getVertexCount", dynlib: LibG.} |
| 835 |
proc getVertex*(va: PVertexArray, index: cint): PVertex {. |
| 836 |
cdecl, importc: "sfVertexArray_getVertex", dynlib: LibG.} |
| 837 |
proc clear*(va: PVertexArray) {. |
| 838 |
cdecl, importc: "sfVertexArray_clear", dynlib: LibG.} |
| 839 |
proc resize*(va: PVertexArray, size: cint) {. |
| 840 |
cdecl, importc: "sfVertexArray_resize", dynlib: LibG.} |
| 841 |
proc append*(va: PVertexArray, vertex: TVertex) {. |
| 842 |
cdecl, importc: "sfVertexArray_append", dynlib: LibG.} |
| 843 |
proc setPrimitiveType*(va: PVertexArray, primitiveType: TPrimitiveType) {. |
| 844 |
cdecl, importc: "sfVertexArray_setPrimitiveType", dynlib: LibG.} |
| 845 |
proc getPrimitiveType*(va: PVertexArray): TPrimitiveType {. |
| 846 |
cdecl, importc: "sfVertexArray_getPrimitiveType", dynlib: LibG.} |
| 847 |
proc getBounds*(va: PVertexArray): TFloatRect {. |
| 848 |
cdecl, importc: "sfVertexArray_getBounds", dynlib: LibG.} |
| 849 |
|
| 850 |
|
| 851 |
proc newText*(): PText {. |
| 852 |
cdecl, importc: "sfText_create", dynlib: LibG.} |
| 853 |
proc copy*(text: PText): PText {. |
| 854 |
cdecl, importc: "sfText_copy", dynlib: LibG.} |
| 855 |
proc destroy*(text: PText) {. |
| 856 |
cdecl, importc: "sfText_destroy", dynlib: LibG.} |
| 857 |
proc setPosition*(text: PText, position: TVector2f) {. |
| 858 |
cdecl, importc: "sfText_setPosition", dynlib: LibG.} |
| 859 |
proc setRotation*(text: PText, angle: cfloat) {. |
| 860 |
cdecl, importc: "sfText_setRotation", dynlib: LibG.} |
| 861 |
proc setScale*(text: PText, scale: TVector2f) {. |
| 862 |
cdecl, importc: "sfText_setScale", dynlib: LibG.} |
| 863 |
proc setOrigin*(text: PText, origin: TVector2f) {. |
| 864 |
cdecl, importc: "sfText_setOrigin", dynlib: LibG.} |
| 865 |
proc getPosition*(text: PText): TVector2f {. |
| 866 |
cdecl, importc: "sfText_getPosition", dynlib: LibG.} |
| 867 |
proc getRotation*(text: PText): cfloat {. |
| 868 |
cdecl, importc: "sfText_getRotation", dynlib: LibG.} |
| 869 |
proc getScale*(text: PText): TVector2f {. |
| 870 |
cdecl, importc: "sfText_getScale", dynlib: LibG.} |
| 871 |
proc getOrigin*(text: PText): TVector2f {. |
| 872 |
cdecl, importc: "sfText_getOrigin", dynlib: LibG.} |
| 873 |
proc move*(text: PText, offset: TVector2f) {. |
| 874 |
cdecl, importc: "sfText_move", dynlib: LibG.} |
| 875 |
proc rotate*(text: PText, angle: cfloat) {. |
| 876 |
cdecl, importc: "sfText_rotate", dynlib: LibG.} |
| 877 |
proc scale*(text: PText, factors: TVector2f) {. |
| 878 |
cdecl, importc: "sfText_scale", dynlib: LibG.} |
| 879 |
proc getTransform*(text: PText): TTransform {. |
| 880 |
cdecl, importc: "sfText_getTransform", dynlib: LibG.} |
| 881 |
proc getInverseTransform*(text: PText): TTransform {. |
| 882 |
cdecl, importc: "sfText_getInverseTransform", dynlib: LibG.} |
| 883 |
proc setString*(text: PText, string: cstring) {. |
| 884 |
cdecl, importc: "sfText_setString", dynlib: LibG.} |
| 885 |
proc setUnicodeString*(text: PText, string: ptr uint32) {. |
| 886 |
cdecl, importc: "sfText_setUnicodeString", dynlib: LibG.} |
| 887 |
proc setFont*(text: PText, font: PFont) {. |
| 888 |
cdecl, importc: "sfText_setFont", dynlib: LibG.} |
| 889 |
proc setCharacterSize*(text: PText, size: cint) {. |
| 890 |
cdecl, importc: "sfText_setCharacterSize", dynlib: LibG.} |
| 891 |
proc setStyle*(text: PText, style: TTextStyle) {. |
| 892 |
cdecl, importc: "sfText_setStyle", dynlib: LibG.} |
| 893 |
proc setColor*(text: PText, color: TColor) {. |
| 894 |
cdecl, importc: "sfText_setColor", dynlib: LibG.} |
| 895 |
proc getString*(text: PText): cstring {. |
| 896 |
cdecl, importc: "sfText_getString", dynlib: LibG.} |
| 897 |
proc getUnicodeString*(text: PText): ptr uint32 {.cdecl, |
| 898 |
importc: "sfText_getUnicodeString", dynlib: LibG.} |
| 899 |
proc getFont*(text: PText): PFont {. |
| 900 |
cdecl, importc: "sfText_getFont", dynlib: LibG.} |
| 901 |
proc getCharacterSize*(text: PText): cint {. |
| 902 |
cdecl, importc: "sfText_getCharacterSize", dynlib: LibG.} |
| 903 |
proc getStyle*(text: PText): uint32 {. |
| 904 |
cdecl, importc: "sfText_getStyle", dynlib: LibG.} |
| 905 |
proc getColor*(text: PText): TColor {. |
| 906 |
cdecl, importc: "sfText_getColor", dynlib: LibG.} |
| 907 |
proc findCharacterPos*(text: PText, index: cint): TVector2f {. |
| 908 |
cdecl, importc: "sfText_findCharacterPos", dynlib: LibG.} |
| 909 |
proc getLocalBounds*(text: PText): TFloatRect {. |
| 910 |
cdecl, importc: "sfText_getLocalBounds", dynlib: LibG.} |
| 911 |
proc getGlobalBounds*(text: PText): TFloatRect {. |
| 912 |
cdecl, importc: "sfText_getGlobalBounds", dynlib: LibG.} |
| 913 |
|
| 914 |
proc transformFromMatrix*(a00, a01, a02, a10, a11, a12, a20, a21, a22: cfloat): TTransform {. |
| 915 |
cdecl, importc: "sfTransform_fromMatrix", dynlib: LibG.} |
| 916 |
proc getMatrix*(transform: PTransform, matrix: ptr cfloat) {. |
| 917 |
cdecl, importc: "sfTransform_getMatrix", dynlib: LibG.} |
| 918 |
proc getInverse*(transform: PTransform): TTransform {. |
| 919 |
cdecl, importc: "sfTransform_getInverse", dynlib: LibG.} |
| 920 |
proc transformPoint*(transform: PTransform, point: TVector2f): TVector2f {. |
| 921 |
cdecl, importc: "sfTransform_transformPoint", dynlib: LibG.} |
| 922 |
proc transformRect*(transform: PTransform, rectangle: TFloatRect): TFloatRect {. |
| 923 |
cdecl, importc: "sfTransform_transformRect", dynlib: LibG.} |
| 924 |
proc combine*(transform: PTransform, other: PTransform) {. |
| 925 |
cdecl, importc: "sfTransform_combine", dynlib: LibG.} |
| 926 |
proc translate*(transform: PTransform, x, y: cfloat) {. |
| 927 |
cdecl, importc: "sfTransform_translate", dynlib: LibG.} |
| 928 |
proc rotate*(transform: PTransform, angle: cfloat) {. |
| 929 |
cdecl, importc: "sfTransform_rotate", dynlib: LibG.} |
| 930 |
proc rotateWithCenter*(transform: PTransform, angle, centerX, centerY: cfloat){. |
| 931 |
cdecl, importc: "sfTransform_rotateWithCenter", dynlib: LibG.} |
| 932 |
proc scale*(transform: PTransform, scaleX, scaleY: cfloat) {. |
| 933 |
cdecl, importc: "sfTransform_scale", dynlib: LibG.} |
| 934 |
proc scaleWithCenter*(transform: PTransform, scaleX, scaleY, centerX, centerY: cfloat) {. |
| 935 |
cdecl, importc: "sfTransform_scaleWithCenter", dynlib: LibG.} |
| 936 |
let IdentityMatrix*: TTransform = transformFromMatrix(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0) |
| 937 |
|
| 938 |
|
| 939 |
proc newShader*(VSfilename: cstring, fragmentShaderFilename: cstring): PShader {. |
| 940 |
cdecl, importc: "sfShader_createFromFile", dynlib: LibG.} |
| 941 |
proc newShaderFromStr*(vertexShader: cstring, fragmentShader: cstring): PShader {. |
| 942 |
cdecl, importc: "sfShader_createFromMemory", dynlib: LibG.} |
| 943 |
proc newShader*(vertexShaderStream: PInputStream, fragmentShaderStream: PInputStream): PShader {. |
| 944 |
cdecl, importc: "sfShader_createFromStream", dynlib: LibG.} |
| 945 |
proc destroy*(shader: PShader) {. |
| 946 |
cdecl, importc: "sfShader_destroy", dynlib: LibG.} |
| 947 |
proc setFloatParameter*(shader: PShader, name: cstring, x: cfloat) {. |
| 948 |
cdecl, importc: "sfShader_setFloatParameter", dynlib: LibG.} |
| 949 |
proc setFloat2Parameter*(shader: PShader, name: cstring, x, y: cfloat) {. |
| 950 |
cdecl, importc: "sfShader_setFloat2Parameter", dynlib: LibG.} |
| 951 |
proc setFloat3Parameter*(shader: PShader, name: cstring, x, y, z: cfloat) {. |
| 952 |
cdecl, importc: "sfShader_setFloat3Parameter", dynlib: LibG.} |
| 953 |
proc setFloat4Parameter*(shader: PShader, name: cstring, x, y, z, w: cfloat) {. |
| 954 |
cdecl, importc: "sfShader_setFloat4Parameter", dynlib: LibG.} |
| 955 |
proc setVector2Parameter*(shader: PShader, name: cstring, vector: TVector2f) {. |
| 956 |
cdecl, importc: "sfShader_setVector2Parameter", dynlib: LibG.} |
| 957 |
proc setVector3Parameter*(shader: PShader, name: cstring, vector: TVector3f) {. |
| 958 |
cdecl, importc: "sfShader_setVector3Parameter", dynlib: LibG.} |
| 959 |
proc setColorParameter*(shader: PShader, name: cstring, color: TColor) {. |
| 960 |
cdecl, importc: "sfShader_setColorParameter", dynlib: LibG.} |
| 961 |
proc setTransformParameter*(shader: PShader, name: cstring, transform: TTransform) {. |
| 962 |
cdecl, importc: "sfShader_setTransformParameter", dynlib: LibG.} |
| 963 |
proc setTextureParameter*(shader: PShader, name: cstring, texture: PTexture) {. |
| 964 |
cdecl, importc: "sfShader_setTextureParameter", dynlib: LibG.} |
| 965 |
proc setCurrentTextureParameter*(shader: PShader, name: cstring) {. |
| 966 |
cdecl, importc: "sfShader_setCurrentTextureParameter", dynlib: LibG.} |
| 967 |
proc bindGL*(shader: PShader) {. |
| 968 |
cdecl, importc: "sfShader_bind", dynlib: LibG.} |
| 969 |
proc unbindGL*(shader: PShader) {. |
| 970 |
cdecl, importc: "sfShader_unbind", dynlib: LibG.} |
| 971 |
proc shaderIsAvailable*(): bool {. |
| 972 |
cdecl, importc: "sfShader_isAvailable", dynlib: LibG.} |
| 973 |
|
| 974 |
proc color*(red, green, blue: cchar): TColor {. |
| 975 |
cdecl, importc: "sfColor_fromRGB", dynlib: LibG.} |
| 976 |
proc color*(red, green, blue: int): TColor {.inline.} = |
| 977 |
return color(red.cchar, green.cchar, blue.cchar) |
| 978 |
proc color*(red, green, blue, alpha: cchar): TColor {. |
| 979 |
cdecl, importc: "sfColor_fromRGBA", dynlib: LibG.} |
| 980 |
proc color*(red, green, blue, alpha: int): TColor {.inline.} = |
| 981 |
return color(red.cchar, green.cchar, blue.cchar, alpha.cchar) |
| 982 |
proc `+`*(color1, color2: TColor): TColor {. |
| 983 |
cdecl, importc: "sfColor_add", dynlib: LibG.} |
| 984 |
proc `*`*(color1, color2: TColor): TColor {. |
| 985 |
cdecl, importc: "sfColor_modulate", dynlib: LibG.} |
| 986 |
proc newColor*(r,g,b: int): TColor {.inline.} = |
| 987 |
return color(r,g,b) |
| 988 |
proc newColor*(r,g,b,a: int): TColor {.inline.} = |
| 989 |
return color(r,g,b,a) |
| 990 |
|
| 991 |
proc newClock*(): PClock {. |
| 992 |
cdecl, importc: "sfClock_create", dynlib: LibS.} |
| 993 |
proc copy*(clocK: PClock): PClock {. |
| 994 |
cdecl, importc: "sfClock_copy", dynlib: LibS.} |
| 995 |
proc destroy*(clock: PClock): PClock {. |
| 996 |
cdecl, importc: "sfClock_destroy", dynlib: LibS.} |
| 997 |
proc getElapsedTime*(clock: PClock): TTime {. |
| 998 |
cdecl, importc: "sfClock_getElapsedTime", dynlib: LibS.} |
| 999 |
proc restart*(clock: PClock): TTime {. |
| 1000 |
cdecl, importc: "sfClock_restart", dynlib: LibS, discardable.} |
| 1001 |
proc asSeconds*(time: TTime): cfloat {. |
| 1002 |
cdecl, importc: "sfTime_asSeconds", dynlib: LibS.} |
| 1003 |
proc asMilliseconds*(time: TTime): int32 {. |
| 1004 |
cdecl, importc: "sfTime_asMilliseconds", dynlib: LibS.} |
| 1005 |
proc asMicroseconds*(time: TTime): int64 {. |
| 1006 |
cdecl, importc: "sfTime_asMicroseconds", dynlib: LibS.} |
| 1007 |
proc seconds*(seconds: cfloat): TTime {. |
| 1008 |
cdecl, importc: "sfSeconds", dynlib: LibS.} |
| 1009 |
proc milliseconds*(ms: int32): TTime {. |
| 1010 |
cdecl, importc: "sfMilliseconds", dynlib: LibS.} |
| 1011 |
proc microseconds*(us: int64): TTime {. |
| 1012 |
cdecl, importc: "sfMicroseconds", dynlib: LibS.} |
| 1013 |
|
| 1014 |
proc 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 |
|
| 1025 |
proc newCircleShape*(radius: cfloat; pointCount: cint = 30): PCircleShape = |
| 1026 |
result = newCircleShape() |
| 1027 |
result.setRadius radius |
| 1028 |
result.setPointCount pointCount |
| 1029 |
proc newText*(str: string, font: PFont, size: int): PText = |
| 1030 |
result = newText() |
| 1031 |
result.setString(str) |
| 1032 |
result.setFont(font) |
| 1033 |
result.setCharacterSize(size.cint) |
| 1034 |
proc newVertexArray*(primitiveType: TPrimitiveType, vertexCount: cint = 0): PVertexArray = |
| 1035 |
result = newVertexArray() |
| 1036 |
result.setPrimitiveType(primitiveType) |
| 1037 |
if vertexCount != 0: |
| 1038 |
result.resize(vertexCount) |
| 1039 |
proc videoMode*(width, height, bpp: cint): TVideoMode = |
| 1040 |
result.width = width |
| 1041 |
result.height = height |
| 1042 |
result.bitsPerPixel = bpp |
| 1043 |
|
| 1044 |
proc `[]`*(a: PVertexArray, index: int): PVertex = |
| 1045 |
return getVertex(a, index.cint) |
| 1046 |
|
| 1047 |
proc `$` *(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] |
| 1050 |
proc `$` *(a: TVideoMode): string = |
| 1051 |
return "<TVideoMode $1x$2 $3bpp>" % [$a.width, $a.height, $a.bitsPerPixel] |
| 1052 |
proc `$` *(a: TFloatRect): string = |
| 1053 |
return "<TFloatRect $1,$2 $3x$4>" % [$a.left, $a.top, $a.width, $a.height] |
| 1054 |
proc `$` *(a: PView): string = |
| 1055 |
return $a.getViewport() |
| 1056 |
proc `$` *(a: TVector2f): string = |
| 1057 |
return "<TVector2f $1,$2>" % [$a.x, $a.y] |
| 1058 |
|
| 1059 |
proc vec2i*(x, y: int): TVector2i = |
| 1060 |
result.x = x.cint |
| 1061 |
result.y = y.cint |
| 1062 |
proc vec2f*(x, y: float): TVector2f = |
| 1063 |
result.x = x.cfloat |
| 1064 |
result.y = y.cfloat |
| 1065 |
|
| 1066 |
proc `+`*(a, b: TVector2f): TVector2f {.inline.} = |
| 1067 |
result.x = a.x + b.x |
| 1068 |
result.y = a.y + b.y |
| 1069 |
proc `-`*(a: TVector2f): TVector2f {.inline.} = |
| 1070 |
result.x = -a.x |
| 1071 |
result.y = -a.y |
| 1072 |
proc `-`*(a, b: TVector2f): TVector2f {.inline.}= |
| 1073 |
result.x = a.x - b.x |
| 1074 |
result.y = a.y - b.y |
| 1075 |
proc `*`*(a: TVector2f, b: cfloat): TVector2f {.inline.} = |
| 1076 |
result.x = a.x * b |
| 1077 |
result.y = a.y * b |
| 1078 |
proc `*`*(a, b: TVector2f): TVector2f {.inline.} = |
| 1079 |
result.x = a.x * b.x |
| 1080 |
result.y = a.y * b.y |
| 1081 |
proc `/`*(a: TVector2f, b: cfloat): TVector2f {.inline.} = |
| 1082 |
result.x = a.x / b |
| 1083 |
result.y = a.y / b |
| 1084 |
proc `+=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = |
| 1085 |
a = a + b |
| 1086 |
proc `-=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = |
| 1087 |
a = a - b |
| 1088 |
proc `*=` *(a: var TVector2f, b: float) {.inline, noSideEffect.} = |
| 1089 |
a = a * b |
| 1090 |
proc `*=` *(a: var TVector2f, b: TVector2f) {.inline, noSideEffect.} = |
| 1091 |
a = a * b |
| 1092 |
proc `/=` *(a: var TVector2f, b: float) {.inline, noSideEffect.} = |
| 1093 |
a = a / b |
| 1094 |
proc `<` *(a, b: TVector2f): bool {.inline, noSideEffect.} = |
| 1095 |
return a.x < b.x or (a.x == b.x and a.y < b.y) |
| 1096 |
proc `<=` *(a, b: TVector2f): bool {.inline, noSideEffect.} = |
| 1097 |
return a.x <= b.x and a.y <= b.y |
| 1098 |
proc `==` *(a, b: TVector2f): bool {.inline, noSideEffect.} = |
| 1099 |
return a.x == b.x and a.y == b.y |
| 1100 |
proc length*(a: TVector2f): float {.inline.} = |
| 1101 |
return sqrt(pow(a.x, 2.0) + pow(a.y, 2.0)) |
| 1102 |
proc lengthSq*(a: TVector2f): float {.inline.} = |
| 1103 |
return pow(a.x, 2.0) + pow(a.y, 2.0) |
| 1104 |
proc distanceSq*(a, b: TVector2f): float {.inline.} = |
| 1105 |
return pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0) |
| 1106 |
proc distance*(a, b: TVector2f): float {.inline.} = |
| 1107 |
return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0)) |
| 1108 |
proc permul*(a, b: TVector2f): TVector2f = |
| 1109 |
result.x = a.x * b.x |
| 1110 |
result.y = a.y * b.y |
| 1111 |
proc 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 |
| 1116 |
proc perpendicular(a: TVector2f): TVector2f = |
| 1117 |
result.x = -a.x |
| 1118 |
result.y = a.y |
| 1119 |
proc cross(a, b: TVector2f): float = |
| 1120 |
return a.x * b.y - a.y * b.x |
| 1121 |
|