forked from bastienleonard/pysfml-cython
/
decl.pxd
688 lines (606 loc) · 20.6 KB
/
decl.pxd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# -*- python -*-
# -*- coding: utf-8 -*-
# Copyright 2010, 2011, 2012 Bastien Léonard. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# THIS SOFTWARE IS PROVIDED BY BASTIEN LÉONARD ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BASTIEN LÉONARD OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
from libcpp.vector cimport vector
# Forward declarations, to avoid some circular import errors when
# these declarations are imported elsewhere (e.g. from declmouse.pxd)
cdef extern from "SFML/Graphics.hpp" namespace "sf":
cppclass RenderWindow
cppclass Vector2i
cimport declkey
cimport decljoy
cimport declmouse
cimport declprimitive
cimport declshader
cdef extern from "hacks.hpp":
void replace_error_handler()
Drawable* transformable_to_drawable(Transformable*)
cdef cppclass CppDrawable:
CppDrawable()
CppDrawable(void*)
# This is a PyObject*, but for some reason Cython doesn't
# accept ``object''
void *drawable
cdef cppclass CppShape:
CppShape()
CppShape(void*)
void *shape
unsigned int GetPointCount()
Vector2f GetPoint(unsigned int)
cdef cppclass ShapeWithUpdate:
ShapeWithUpdate()
Color& GetFillColor()
FloatRect GetLocalBounds()
FloatRect GetGlobalBounds()
Transform& GetInverseTransform()
Vector2f& GetOrigin()
Color& GetOutlineColor()
float GetOutlineThickness()
Vector2f GetPoint(unsigned int)
unsigned int GetPointCount()
Vector2f& GetPosition()
float GetRotation()
Vector2f& GetScale()
Texture* GetTexture()
IntRect& GetTextureRect()
Transform& GetTransform()
void Move(float, float)
void Move(Vector2f&)
void Rotate(float)
void SetFillColor(Color&)
void Scale(float, float)
void Scale(Vector2f&)
void SetOrigin(float, float)
void SetOrigin(Vector2f&)
void SetOutlineColor(Color&)
void SetOutlineThickness(float)
void SetPosition(float, float)
void SetPosition(Vector2f&)
void SetRotation(float)
void SetScale(float, float)
void SetScale(Vector2f&)
void SetTexture(Texture*)
void SetTexture(Texture*, bint)
void SetTextureRect(IntRect&)
void Update()
# Declaration of the standard std::string class. This is useful
# e.g. when you get a std::string and want to return a Python string,
# use c_str() and it will be converted to a Python object
# automatically if needed.
# Do not confuse with String, which is sf::String!
# TODO: replace this with Cython's string declaration
cdef extern from "<string>" namespace "std":
cdef cppclass string:
char* c_str()
cdef extern from "SFML/Graphics.hpp" namespace "sf::Event":
cdef struct SizeEvent:
unsigned int Width
unsigned int Height
cdef struct KeyEvent:
int Code
bint Alt
bint Control
bint Shift
bint System
cdef struct MouseMoveEvent:
int X
int Y
cdef struct MouseButtonEvent:
int Button
int X
int Y
cdef struct TextEvent:
int Unicode
cdef struct MouseWheelEvent:
int Delta
int X
int Y
cdef struct JoystickMoveEvent:
unsigned int JoystickId
int Axis
float Position
cdef struct JoystickButtonEvent:
unsigned int JoystickId
unsigned int Button
cdef struct JoystickConnectEvent:
unsigned int JoystickId
cdef extern from "SFML/System.hpp" namespace "sf":
ctypedef short Int16
ctypedef unsigned char Uint8
ctypedef int Int32
ctypedef unsigned int Uint32
ctypedef long int Int64
ctypedef unsigned long int Uint64
cdef extern from "SFML/Graphics.hpp" namespace "sf":
# Forward declarations
cdef cppclass RenderWindow
cdef cppclass BlendMode:
pass
cdef int BlendAlpha
cdef int BlendAdd
cdef int BlendMultiply
cdef int BlendNone
cdef cppclass PrimitiveType:
pass
cdef int Points
cdef int Lines
cdef int LinesStrip
cdef int Triangles
cdef int TrianglesStrip
cdef int TrianglesFan
cdef int Quads
cdef cppclass Vector2f:
Vector2f()
Vector2f(float, float)
float x
float y
cdef cppclass Vector2i:
Vector2i()
Vector2i(int, int)
int x
int y
cdef cppclass Vector3f:
Vector3f()
Vector3f(float, float, float)
float x
float y
float z
cdef cppclass IntRect:
IntRect()
IntRect(int, int, int, int)
bint Contains(int, int)
bint Intersects(IntRect&)
bint Intersects(IntRect&, IntRect&)
int Left
int Top
int Width
int Height
cdef cppclass FloatRect:
FloatRect()
FloatRect(float, float, float, float)
bint Contains(int, int)
bint Intersects(FloatRect&)
bint Intersects(FloatRect&, FloatRect&)
float Left
float Top
float Width
float Height
cdef cppclass Transform:
Transform()
Transform(float, float, float,
float, float, float,
float, float, float)
Transform(Transform&)
Transform Combine(Transform&)
Transform GetInverse()
float* GetMatrix()
Transform& Rotate(float)
Transform& Rotate(float, float, float)
Transform& Rotate(float, Vector2f&)
Transform& Scale(float, float)
Transform& Scale(float, float, float, float)
Transform& Scale(Vector2f&)
Transform& Scale(Vector2f&, Vector2f&)
Vector2f TransformPoint(float, float)
Vector2f TransformPoint(Vector2f&)
FloatRect TransformRect(FloatRect&)
Transform& Translate(float, float)
Transform& Translate(Vector2f&)
Transform operator*(Transform&)
Vector2f operator*(Vector2f&)
# Transform operator*=(Transform&, Transform&)
cdef cppclass Time:
Time()
Time(Time)
float AsSeconds()
Uint32 AsMilliseconds()
Int64 AsMicroseconds()
bint operator==(Time&)
bint operator!=(Time&)
bint operator<(Time&)
bint operator>(Time&)
bint operator<=(Time&)
bint operator>=(Time&)
Time operator+(Time&, Time&)
Time operator-(Time&, Time&)
Time operator*(float)
Time operator*(Int64)
Time operator/(float)
Time operator/(Int64)
cdef cppclass Clock:
Clock()
Time GetElapsedTime()
Time Restart()
cdef cppclass Color:
Color()
Color(unsigned int r, unsigned int g, unsigned b)
Color(unsigned int r, unsigned int g, unsigned b, unsigned int a)
Color(Color&)
unsigned int r
unsigned int g
unsigned int b
unsigned int a
cdef cppclass Event:
Event()
int Type
SizeEvent Size
KeyEvent Key
MouseMoveEvent MouseMove
MouseButtonEvent MouseButton
TextEvent Text
MouseWheelEvent MouseWheel
JoystickMoveEvent JoystickMove
JoystickButtonEvent JoystickButton
JoystickConnectEvent JoystickConnect
cdef cppclass VideoMode:
VideoMode()
VideoMode(unsigned int width, unsigned int height)
VideoMode(unsigned int width, unsigned int height,
unsigned int bits_per_pixel)
bint IsValid()
unsigned int Width
unsigned int Height
unsigned int BitsPerPixel
cdef cppclass Image:
Image()
Image(Image&)
void Copy(Image&, unsigned int, unsigned int)
void Copy(Image&, unsigned int, unsigned int, IntRect&)
void Copy(Image&, unsigned int, unsigned int, IntRect&, bint)
bint Create(unsigned int, unsigned int)
bint Create(unsigned int, unsigned int, Color&)
bint Create(unsigned int, unsigned int, Uint8*)
void CreateMaskFromColor(Color&)
void CreateMaskFromColor(Color&, unsigned char)
unsigned int GetHeight()
Color& GetPixel(unsigned int, unsigned int)
unsigned char* GetPixelsPtr()
unsigned int GetWidth()
bint LoadFromFile(char*)
bint LoadFromMemory(void*, size_t)
bint SaveToFile(string&)
bint SaveToFile(char*)
void SetPixel(unsigned int, unsigned int, Color&)
cdef cppclass Texture:
Texture()
Texture(Texture&)
void Bind()
Image CopyToImage()
bint Create(unsigned int, unsigned int)
unsigned int GetHeight()
unsigned int GetWidth()
bint IsRepeated()
bint IsSmooth()
bint LoadFromFile(char*)
bint LoadFromFile(char*, IntRect&)
bint LoadFromImage(Image&)
bint LoadFromImage(Image&, IntRect&)
bint LoadFromMemory(void*, size_t)
bint LoadFromMemory(void*, size_t, IntRect&)
# bint LoadFromStream(InputStream&)
# bint LoadFromStream(InputStream&, IntRect&)
void SetRepeated(bint)
void SetSmooth(bint)
void Update(Uint8*)
void Update(Uint8*, unsigned int, unsigned int, unsigned int,
unsigned int)
void Update(Image&)
void Update(Image&, unsigned int, unsigned int)
void Update(RenderWindow&)
void Update(RenderWindow&, unsigned int, unsigned int)
cdef cppclass String:
String()
String(Uint32*)
Uint32* GetData()
size_t GetSize()
string ToAnsiString()
cdef cppclass Glyph:
Glyph()
int Advance
IntRect Bounds
IntRect TextureRect
cdef cppclass Font:
Font()
Font(Font&)
Glyph& GetGlyph(Uint32, unsigned int, bint)
Texture& GetTexture(unsigned int)
int GetKerning(Uint32, Uint32, unsigned int)
int GetLineSpacing(unsigned int)
bint LoadFromFile(char*)
bint LoadFromMemory(void*, size_t)
cdef cppclass Drawable:
pass
cdef cppclass Transformable:
Transformable()
Vector2f& GetOrigin()
Vector2f& GetPosition()
float GetRotation()
Vector2f& GetScale()
Transform& GetTransform()
Transform& GetInverseTransform()
void Move(float, float)
void Move(Vector2f&)
void Rotate(float)
void Scale(float, float)
void Scale(Vector2f&)
void SetOrigin(float, float)
void SetOrigin(Vector2f&)
void SetPosition(float, float)
void SetPosition(Vector2f&)
void SetRotation(float)
void SetScale(float, float)
void SetScale(Vector2f&)
cdef cppclass Text:
Text()
Text(char*)
Text(char*, Font&)
Text(char*, Font&, unsigned int)
Text(String&)
Text(String&, Font&)
Text(String&, Font&, unsigned int)
Vector2f FindCharacterPos(size_t)
unsigned int GetCharacterSize()
Color& GetColor()
Font& GetFont()
FloatRect GetLocalBounds()
String& GetString()
unsigned long GetStyle()
void SetCharacterSize(unsigned int)
void SetColor(Color&)
void SetFont(Font&)
void SetString(char*)
void SetString(String&)
void SetStyle(unsigned long)
cdef cppclass Sprite:
Sprite()
Sprite(Texture&)
Sprite(Texture&, IntRect&)
Color& GetColor()
FloatRect GetGlobalBounds()
FloatRect GetLocalBounds()
Texture* GetTexture()
IntRect& GetTextureRect()
void SetColor(Color&)
void SetTexture(Texture&)
void SetTexture(Texture&, bint)
void SetTextureRect(IntRect&)
cdef cppclass View:
View()
View(FloatRect&)
View(Vector2f&, Vector2f&)
Vector2f& GetCenter()
Transform& GetInverseTransform()
Transform& GetTransform()
float GetRotation()
FloatRect& GetViewport()
Vector2f& GetSize()
void Move(float, float)
void Move(Vector2f&)
void Reset(FloatRect&)
void Rotate(float)
void SetCenter(float, float)
void SetCenter(Vector2f&)
void SetFromRect(FloatRect&)
void SetRotation(float)
void SetSize(float, float)
void SetSize(Vector2f&)
void SetViewport(FloatRect&)
void Zoom(float)
cdef cppclass Shader:
Shader()
void Bind()
bint LoadFromFile(char*, declshader.Type)
bint LoadFromFile(char*, char*)
bint LoadFromMemory(char*, declshader.Type)
bint LoadFromMemory(char*, char*)
# bint LoadFromStream(InputStream&, declshader.Type)
# bint LoadFromStream(InputStream&, InputStream&)
void SetCurrentTexture(char*)
void SetParameter(char*, float)
void SetParameter(char*, float, float)
void SetParameter(char*, float, float, float)
void SetParameter(char*, float, float, float, float)
void SetParameter(char*, Vector2f&)
void SetParameter(char*, Vector3f&)
void SetParameter(char*, Color&)
void SetParameter(char*, Transform&)
void SetParameter(char*, Texture&)
void SetParameter(char*, declshader.CurrentTexture)
void Unbind()
cdef cppclass ContextSettings:
ContextSettings()
ContextSettings(unsigned int)
ContextSettings(unsigned int, unsigned int)
ContextSettings(unsigned int, unsigned int, unsigned int)
ContextSettings(unsigned int, unsigned int, unsigned int, unsigned int)
ContextSettings(unsigned int, unsigned int, unsigned int, unsigned int,
unsigned int)
unsigned int AntialiasingLevel
unsigned int DepthBits
unsigned int MajorVersion
unsigned int MinorVersion
unsigned int StencilBits
cdef cppclass WindowHandle:
pass
cdef cppclass RenderStates:
RenderStates()
RenderStates(RenderStates&)
BlendMode BlendMode
Shader* Shader
Texture* Texture
Transform Transform
cdef cppclass Vertex:
Vertex()
Vertex(Vector2f&)
Vertex(Vector2f&, Color&)
Vertex(Vector2f&, Vector2f&)
Vertex(Vector2f&, Color&, Vector2f&)
Vector2f Position
Color Color
Vector2f TexCoords
cdef cppclass VertexArray:
VertexArray()
VertexArray(PrimitiveType, unsigned int)
Vertex& operator[](unsigned int)
void Append(Vertex&)
void Clear()
FloatRect GetBounds()
PrimitiveType GetPrimitiveType()
unsigned int GetVertexCount()
void Resize(unsigned int)
void SetPrimitiveType(PrimitiveType)
cdef cppclass RenderTarget:
void Clear()
void Clear(Color&)
void Draw(Drawable&)
void Draw(Drawable&, Shader*)
void Draw(Drawable&, RenderStates&)
void Draw(Vertex*, unsigned int, PrimitiveType)
void Draw(Vertex*, unsigned int, PrimitiveType, RenderStates&)
unsigned int GetHeight()
unsigned int GetWidth()
void SetView(View&)
View& GetView()
View& GetDefaultView()
IntRect GetViewport(View&)
Vector2f ConvertCoords(unsigned int, unsigned int)
Vector2f ConvertCoords(unsigned int, unsigned int, View&)
void PopGLStates()
void PushGLStates()
void ResetGLStates()
cdef cppclass RenderWindow:
RenderWindow()
RenderWindow(VideoMode, char*)
RenderWindow(VideoMode, char*, unsigned long)
RenderWindow(VideoMode, char*, unsigned long, ContextSettings&)
RenderWindow(WindowHandle window_handle)
RenderWindow(WindowHandle window_handle, ContextSettings&)
void Close()
void Create(VideoMode, char*)
void Create(VideoMode, char*, unsigned long)
void Create(VideoMode, char*, unsigned long, ContextSettings&)
void Display()
void EnableKeyRepeat(bint)
void EnableVerticalSync(bint)
ContextSettings& GetSettings()
unsigned long GetSystemHandle()
bint IsOpen()
bint PollEvent(Event&)
void SetActive()
void SetActive(bint)
void SetIcon(unsigned int, unsigned int, Uint8*)
void SetJoystickThreshold(float)
void SetFramerateLimit(unsigned int)
void SetPosition(int, int)
void SetSize(unsigned int, unsigned int)
void SetTitle(char*)
void Show(bint)
void ShowMouseCursor(bint)
void UseVerticalSync(bint)
bint WaitEvent(Event&)
cdef cppclass RenderTexture:
RenderTexture()
bint Create(unsigned int, unsigned int)
bint Create(unsigned int, unsigned int, bint depth)
void SetSmooth(bint)
bint IsSmooth()
bint SetActive()
bint SetActive(bint)
void Display()
Texture& GetTexture()
bint IsAvailable()
cdef cppclass Shape:
Shape()
Color& GetFillColor()
FloatRect GetLocalBounds()
FloatRect GetGlobalBounds()
Transform& GetInverseTransform()
Vector2f& GetOrigin()
Color& GetOutlineColor()
float GetOutlineThickness()
Vector2f GetPoint(unsigned int)
unsigned int GetPointCount()
Vector2f& GetPosition()
float GetRotation()
Vector2f& GetScale()
Texture* GetTexture()
IntRect& GetTextureRect()
Transform& GetTransform()
void Move(float, float)
void Move(Vector2f&)
void Rotate(float)
void SetFillColor(Color&)
void Scale(float, float)
void Scale(Vector2f&)
void SetOrigin(float, float)
void SetOrigin(Vector2f&)
void SetOutlineColor(Color&)
void SetOutlineThickness(float)
void SetPosition(float, float)
void SetPosition(Vector2f&)
void SetRotation(float)
void SetScale(float, float)
void SetScale(Vector2f&)
void SetTexture(Texture*)
void SetTexture(Texture*, bint)
void SetTextureRect(IntRect&)
cdef cppclass RectangleShape:
RectangleShape()
RectangleShape(Vector2f&)
Vector2f& GetSize()
void SetSize(Vector2f&)
cdef cppclass CircleShape:
CircleShape()
CircleShape(float)
CircleShape(float, unsigned int)
unsigned int GetPointCount()
float GetRadius()
void SetPointCount(unsigned int)
void SetRadius(float)
cdef cppclass ConvexShape:
ConvexShape()
ConvexShape(unsigned int)
unsigned int GetPointCount()
void SetPointCount(unsigned int)
# Hacks for static methods and attributes. Some similar hacks are
# created in seperate files, mainly for enums, e.g. declevents.pxd
cdef extern from "SFML/Graphics.hpp":
cdef Time Time_Zero "sf::Time::Zero"
cdef extern from "SFML/Graphics.hpp" namespace "sf":
cdef Time Seconds(float)
cdef Time Milliseconds(Int32)
cdef Time Microseconds(Int64)
cdef extern from "SFML/Graphics.hpp":
RenderStates RenderStates_Default "sf::RenderStates::Default"
cdef extern from "SFML/Graphics.hpp" namespace "sf::VideoMode":
cdef VideoMode& GetDesktopMode()
cdef vector[VideoMode]& GetFullscreenModes()
cdef extern from "SFML/Graphics.hpp" namespace "sf::Transform":
cdef Transform Identity
cdef extern from "SFML/Graphics.hpp":
cdef unsigned int Texture_GetMaximumSize "sf::Texture::GetMaximumSize"()
cdef extern from "SFML/Graphics.hpp" namespace "sf::Font":
cdef Font& GetDefaultFont()
cdef extern from "SFML/Graphics.hpp" namespace "sf::Shader":
cdef bint IsAvailable()