annotate modules/sdl.tp @ 304:dcb495cf2b97

Add fd method to file objects for accessing file descriptor
author Michael Pavone <pavone@retrodev.com>
date Sat, 26 Jul 2014 15:01:38 -0700
parents 2b045d5b673b
children 4c669942c30d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 _helper <- #{
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 llMessage: createWindow withVars: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 title <- string ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 x <- obj_int32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 y <- obj_int32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 w <- obj_int32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 h <- obj_int32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 flags <- obj_uint32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 makeWindow <- lambda ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 windowOpaque <- cpointer ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 win <- object ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 } andCode: :title x y w h flags makeWindow {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 windowOpaque <- make_object: (addr_of: cpointer_meta) NULL 0
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 windowOpaque val!: (SDL_CreateWindow: (title data) (x num) (y num) (w num) (h num) (flags num))
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 if: (windowOpaque val) {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 win <- ccall: makeWindow 1 (windowOpaque castTo: (object ptr))
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 mcall: value 2 option win
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 } else: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 mcall: none 1 option
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
23
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
24 llMessage: createRenderer withVars: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
25 window <- cpointer ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
26 index <- obj_int32 ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
27 flags <- obj_uint32 ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
28 rendOpaque <- cpointer ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
29 rend <- object ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
30 makeRender <- lambda ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
31 } andCode: :window index flags makeRender {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
32 rendOpaque <- make_object: (addr_of: cpointer_meta) NULL 0
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
33 rendOpaque val!: (SDL_CreateRenderer: (window val) (index num) (flags num))
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
34 if: (rendOpaque val) {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
35 rend <- ccall: makeRender 1 (rendOpaque castTo: (object ptr))
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
36 mcall: value 2 option rend
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
37 } else: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
38 mcall: none 1 option
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
39 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
40 }
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
41
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
42 llMessage: loadBMP withVars: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
43 filename <- string ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
44 makeSurface <- lambda ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
45 surfOpaque <- cpointer ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
46 surf <- object ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
47 } andCode: :filename makeSurface{
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
48 surfOpaque <- make_object: (addr_of: cpointer_meta) NULL 0
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
49 surfOpaque val!: (SDL_LoadBMP: (filename data))
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
50 if: (surfOpaque val) {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
51 surf <- ccall: makeSurface 1 (surfOpaque castTo: (object ptr))
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
52 mcall: value 2 option surf
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
53 } else: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
54 mcall: none 1 option
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
55 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
56 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
57
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
58 llMessage: createTextureFromSurface withVars: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
59 rendOpaque <- cpointer ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
60 surfOpaque <- cpointer ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
61 makeTexture <- lambda ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
62 texOpaque <- cpointer ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
63 tex <- object ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
64 } andCode: :rendOpaque surfOpaque makeTexture {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
65 texOpaque <- make_object: (addr_of: cpointer_meta) NULL 0
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
66 texOpaque val!: (SDL_CreateTextureFromSurface: (rendOpaque val) (surfOpaque val))
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
67 if: (texOpaque val) {
291
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
68 tex <- ccall: makeTexture 2 (rendOpaque castTo: (object ptr)) (texOpaque castTo: (object ptr))
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
69 mcall: value 2 option tex
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
70 } else: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
71 mcall: none 1 option
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
72 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
73 }
291
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
74
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
75 llMessage: pollEvent withVars: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
76 constructor <- lambda ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
77 event <- SDL_Event
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
78 eventPtr <- cpointer ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
79 eventType <- obj_uint32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
80 timeStampO <- obj_uint32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
81 } andCode: :constructor {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
82 if: (SDL_PollEvent: (addr_of: event)) {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
83 eventType <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
84 timeStampO <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
85 eventType num!: ((addr_of: event) type)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
86 timeStampO num!: ((addr_of: ((addr_of: event) common)) timestamp)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
87 eventPtr <- make_object: (addr_of: cpointer_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
88 eventPtr val!: (addr_of: event)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
89 mcall: value 2 option (ccall: constructor 3 (eventType castTo: (object ptr)) (
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
90 timeStampO castTo: (object ptr)) (eventPtr castTo: (object ptr)))
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
91 } else: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
92 mcall: none 1 option
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
93 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
94 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
95
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
96 llMessage: populateWindowEvent withVars: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
97 eventPtr <- cpointer ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
98 empty <- object ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
99 winEvent <- SDL_WindowEvent ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
100 ou32 <- obj_uint32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
101 ou8 <- obj_uint8 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
102 oi32 <- obj_int32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
103 } andCode: :eventPtr empty {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
104 winEvent <- eventPtr val
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
105 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
106 ou32 num!: (winEvent windowID)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
107 mcall: windowID! 2 empty ou32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
108 ou8 <- make_object: (addr_of: obj_uint8_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
109 ou8 num!: (winEvent event)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
110 mcall: event! 2 empty ou8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
111 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
112 oi32 num!: (winEvent data1)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
113 mcall: data1! 2 empty oi32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
114 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
115 oi32 num!: (winEvent data2)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
116 mcall: data2! 2 empty oi32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
117 empty
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
118 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
119
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
120 llMessage: populateKeyEvent withVars: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
121 eventPtr <- cpointer ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
122 empty <- object ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
123 keyEvent <- SDL_KeyboardEvent ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
124 ou32 <- obj_uint32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
125 ou16 <- obj_uint32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
126 ou8 <- obj_uint8 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
127 } andCode: :eventPtr empty {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
128 keyEvent <- eventPtr val
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
129 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
130 ou32 num!: (keyEvent windowID)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
131 mcall: windowID! 2 empty ou32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
132 if: (keyEvent state) = SDL_PRESSED {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
133 mcall: pressed?! 2 empty true
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
134 } else: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
135 mcall: pressed?! 2 empty false
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
136 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
137 ou8 <- make_object: (addr_of: obj_uint8_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
138 ou8 num!: (keyEvent repeat)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
139 mcall: repeat! 2 empty ou8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
140 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
141 ou32 num!: ((addr_of: (keyEvent keysym)) scancode)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
142 mcall: scanCode! 2 empty ou32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
143 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
144 ou32 num!: ((addr_of: (keyEvent keysym)) sym)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
145 mcall: keyCode! 2 empty ou32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
146 ou16 <- make_object: (addr_of: obj_uint16_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
147 ou16 num!: ((addr_of: (keyEvent keysym)) mod)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
148 mcall: mod! 2 empty ou16
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
149 empty
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
150 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
151
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
152 llMessage: populateMouseButtonEvent withVars: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
153 eventPtr <- cpointer ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
154 empty <- object ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
155 mouseButEvent <- SDL_MouseButtonEvent ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
156 ou32 <- obj_uint32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
157 ou8 <- obj_uint8 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
158 oi32 <- obj_int32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
159 } andCode: :eventPtr empty {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
160 mouseButEvent <- eventPtr val
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
161 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
162 ou32 num!: (mouseButEvent windowID)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
163 mcall: windowID! 2 empty ou32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
164 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
165 ou32 num!: (mouseButEvent which)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
166 mcall: mouseID! 2 empty ou32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
167 ou8 <- make_object: (addr_of: obj_uint8_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
168 ou8 num!: (mouseButEvent button)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
169 mcall: button! 2 empty ou8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
170 if: (mouseButEvent state) = SDL_PRESSED {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
171 mcall: pressed?! 2 empty true
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
172 } else: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
173 mcall: pressed?! 2 empty false
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
174 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
175 ou8 <- make_object: (addr_of: obj_uint8_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
176 ou8 num!: (mouseButEvent clicks)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
177 mcall: clicks! 2 empty ou8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
178 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
179 oi32 num!: (mouseButEvent x)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
180 mcall: x! 2 empty oi32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
181 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
182 oi32 num!: (mouseButEvent y)
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
183 mcall: y! 2 empty oi32
293
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
184 empty
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
185 }
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
186
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
187 llMessage: populateMouseMotionEvent withVars: {
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
188 eventPtr <- cpointer ptr
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
189 empty <- object ptr
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
190 mouseMotEvent <- SDL_MouseMotionEvent ptr
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
191 ou32 <- obj_uint32 ptr
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
192 oi32 <- obj_int32 ptr
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
193 } andCode: :eventPtr empty {
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
194 mouseMotEvent <- eventPtr val
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
195 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
196 ou32 num!: (mouseMotEvent windowID)
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
197 mcall: windowID! 2 empty ou32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
198 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
199 ou32 num!: (mouseMotEvent which)
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
200 mcall: mouseID! 2 empty ou32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
201 ou32 <- make_object: (addr_of: obj_uint32_meta) NULL 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
202 ou32 num!: (mouseMotEvent state)
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
203 mcall: buttonState! 2 empty ou32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
204 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
205 oi32 num!: (mouseMotEvent x)
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
206 mcall: x! 2 empty oi32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
207 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
208 oi32 num!: (mouseMotEvent y)
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
209 mcall: y! 2 empty oi32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
210 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
211 oi32 num!: (mouseMotEvent xrel)
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
212 mcall: xRel! 2 empty oi32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
213 oi32 <- make_object: (addr_of: obj_int32_meta) NULL 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
214 oi32 num!: (mouseMotEvent yrel)
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
215 mcall: yRel! 2 empty oi32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
216 empty
291
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
217 }
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
218 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
219
291
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
220 _constant <- macro: :name cname {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
221 quote: (llMessage: name withVars: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
222 uintret <- obj_uint32 ptr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
223 } andCode: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
224 uintret <- make_object: (addr_of: obj_uint32_meta) NULL 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
225 uintret num!: cname
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
226 uintret
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
227 })
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
228 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
229 _subsystems <- #{
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
230 _constant: timer SDL_INIT_TIMER
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
231 _constant: audio SDL_INIT_AUDIO
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
232 _constant: video SDL_INIT_VIDEO
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
233 _constant: joystick SDL_INIT_JOYSTICK
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
234 _constant: haptic SDL_INIT_HAPTIC
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
235 _constant: gameController SDL_INIT_GAMECONTROLLER
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
236 _constant: events SDL_INIT_EVENTS
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
237 _constant: everything SDL_INIT_EVERYTHING
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
238 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
239
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
240 _windowOpts <- #{
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
241 _constant: fullscreen SDL_WINDOW_FULLSCREEN
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
242 _constant: fullscreenDesktop SDL_WINDOW_FULLSCREEN_DESKTOP
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
243 _constant: opengl SDL_WINDOW_OPENGL
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
244 _constant: hidden SDL_WINDOW_HIDDEN
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
245 _constant: borderless SDL_WINDOW_BORDERLESS
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
246 _constant: minimized SDL_WINDOW_MINIMIZED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
247 _constant: maximized SDL_WINDOW_MAXIMIZED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
248 _constant: inputGrabbed SDL_WINDOW_INPUT_GRABBED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
249 _constant: allowHighDPI SDL_WINDOW_ALLOW_HIGHDPI
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
250 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
251
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
252 _renderOpts <- #{
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
253 _constant: software SDL_RENDERER_SOFTWARE
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
254 _constant: accelerated SDL_RENDERER_ACCELERATED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
255 _constant: presentVSYNC SDL_RENDERER_PRESENTVSYNC
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
256 _constant: targetTexture SDL_RENDERER_TARGETTEXTURE
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
257
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
258 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
259
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
260 _events <- #{
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
261 _constant: quit SDL_QUIT
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
262 _constant: window SDL_WINDOWEVENT
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
263 _constant: sysWM SDL_SYSWMEVENT
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
264 _constant: keyDown SDL_KEYDOWN
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
265 _constant: keyUp SDL_KEYUP
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
266 _constant: textEditing SDL_TEXTEDITING
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
267 _constant: textInput SDL_TEXTINPUT
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
268 _constant: mouseMotion SDL_MOUSEMOTION
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
269 _constant: mouseDown SDL_MOUSEBUTTONDOWN
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
270 _constant: mouseUp SDL_MOUSEBUTTONUP
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
271 _constant: mouseWheel SDL_MOUSEWHEEL
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
272 _constant: joyAxis SDL_JOYAXISMOTION
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
273 _constant: joyBall SDL_JOYBALLMOTION
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
274 _constant: joyHat SDL_JOYHATMOTION
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
275 _constant: joyDown SDL_JOYBUTTONDOWN
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
276 _constant: joyUp SDL_JOYBUTTONUP
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
277 _constant: joyDeviceAdded SDL_JOYDEVICEADDED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
278 _constant: joyDeviceRemoved SDL_JOYDEVICEREMOVED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
279 _constant: controllerAxis SDL_CONTROLLERAXISMOTION
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
280 _constant: controllerDown SDL_CONTROLLERBUTTONDOWN
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
281 _constant: controllerUp SDL_CONTROLLERBUTTONUP
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
282 _constant: controllerDeviceAdded SDL_CONTROLLERDEVICEADDED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
283 _constant: controllerDeviceRemoved SDL_CONTROLLERDEVICEREMOVED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
284 _constant: controllerDeviceRemapped SDL_CONTROLLERDEVICEREMAPPED
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
285 _constant: dropFile SDL_DROPFILE
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
286 //TODO: Add mobile/touch/gesture events
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
287 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
288
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
289 _eventConstructors <- dict hash
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
290 _eventConstructors set: (_events window) :typ tstamp eventPtr {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
291 _helper populateWindowEvent: eventPtr #{
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
292 type <- typ
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
293 timeStamp <- tstamp
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
294 windowID <- 0u32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
295 event <- 0u8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
296 data1 <- 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
297 data2 <- 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
298 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
299 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
300 keyEvent <- :typ tstamp eventPtr {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
301 _helper populateKeyEvent: eventPtr #{
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
302 type <- typ
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
303 timeStamp <- tstamp
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
304 windowID <- 0u32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
305 pressed? <- false
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
306 repeat <- 0u8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
307 scanCode <- 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
308 keyCode <- 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
309 mod <- 0u16
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
310 _constant: scanCodeMask SDLK_SCANCODE_MASK
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
311 keyChar <- {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
312 if: (keyCode and (self scanCodeMask)) = 0 {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
313 keyCode utf8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
314 } else: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
315 ""
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
316 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
317 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
318 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
319 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
320 _eventConstructors set: (_events keyDown) keyEvent
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
321 _eventConstructors set: (_events keyUp) keyEvent
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
322
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
323 mouseButtonEvent <- :typ tstamp eventPtr {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
324 _helper populateMouseButtonEvent: eventPtr #{
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
325 type <- typ
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
326 timeStamp <- tstamp
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
327 windowID <- 0u32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
328 mouseID <- 0u32
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
329 button <- 0u8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
330 pressed? <- false
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
331 clicks <- 0u8
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
332 x <- 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
333 y <- 0
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
334 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
335 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
336 _eventConstructors set: (_events mouseDown) mouseButtonEvent
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
337 _eventConstructors set: (_events mouseUp) mouseButtonEvent
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
338
293
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
339 _eventConstructors set: (_events mouseMotion) :typ tstamp eventPtr {
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
340 _helper populateMouseMotionEvent: eventPtr #{
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
341 type <- typ
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
342 timeStamp <- tstamp
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
343 windowID <- 0u32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
344 mouseID <- 0u32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
345 buttonState <- 0u32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
346 x <- 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
347 y <- 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
348 xRel <- 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
349 yRel <- 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
350 }
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
351 }
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
352
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
353 /*
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
354 _eventConstructors set: (_events mouseWheel) :type tstamp eventPtr {
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
355 _helper populateMouseWheelEvent: eventPtr #{
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
356 type <- typ
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
357 timeStamp <- tstamp
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
358 windowID <- 0u32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
359 mouseID <- 0u32
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
360 x <- 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
361 y <- 0
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
362 }
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
363 }
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
364 */
2b045d5b673b Add binding for sdl mouse motion event
Michael Pavone <pavone@retrodev.com>
parents: 291
diff changeset
365
279
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
366 _makeTexture <- :rendptr texptr {
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
367 #{
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
368 includeSystemHeader: "SDL.h"
279
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
369 llProperty: renderer withType: (SDL_Renderer ptr)
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
370 llProperty: texture withType: (SDL_Texture ptr)
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
371 llMessage: opaque withVars: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
372 ptr <- cpointer ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
373 } andCode: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
374 ptr <- make_object: (addr_of: cpointer_meta) NULL 0
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
375 ptr val!: texture
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
376 ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
377 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
378 llMessage: _ptr_init withVars: {
279
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
379 rendptr <- cpointer ptr
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
380 texptr <- cpointer ptr
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
381 } andCode: :rendptr texptr{
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
382 renderer <- rendptr val
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
383 texture <- texptr val
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
384 self
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
385 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
386
279
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
387 llMessage: copy withVars: {
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
388 intret <- obj_int32 ptr
279
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
389 } andCode: {
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
390 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
279
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
391 intret num!: (SDL_RenderCopy: renderer texture NULL NULL)
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
392 intret
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
393 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
394
283
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
395 llMessage: copyTo withVars: {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
396 dst <- object ptr
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
397 dstOpaque <- cpointer ptr
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
398 intret <- obj_int32 ptr
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
399 } andCode: :dst {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
400 dstOpaque <- (mcall: _rectPointer 1 dst) castTo: (cpointer ptr)
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
401 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
402 intret num!: (SDL_RenderCopy: renderer texture NULL (dstOpaque val))
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
403 intret
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
404 }
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
405
284
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
406 llMessage: copyRect:To withVars: {
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
407 src <- object ptr
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
408 dst <- object ptr
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
409 srcOpaque <- cpointer ptr
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
410 dstOpaque <- cpointer ptr
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
411 intret <- obj_int32 ptr
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
412 } andCode: :src :dst {
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
413 srcOpaque <- (mcall: _rectPointer 1 src) castTo: (cpointer ptr)
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
414 dstOpaque <- (mcall: _rectPointer 1 dst) castTo: (cpointer ptr)
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
415 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
416 intret num!: (SDL_RenderCopy: renderer texture (srcOpaque val) (dstOpaque val))
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
417 intret
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
418 }
99c18127da04 Add another SDL_RenderCopy binding in the form of copyRect:To
Michael Pavone <pavone@retrodev.com>
parents: 283
diff changeset
419
287
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
420 llMessage: copyTo:rotated withVars: {
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
421 dst <- object ptr
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
422 angle <- object ptr
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
423 dstOpaque <- cpointer ptr
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
424 anglef <- obj_float32 ptr
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
425 intret <- obj_int32 ptr
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
426 } andCode: :dst :angle {
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
427 anglef <- (mcall: f32 1 angle) castTo: (obj_float32 ptr)
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
428 dstOpaque <- (mcall: _rectPointer 1 dst) castTo: (cpointer ptr)
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
429 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
430 intret num!: (SDL_RenderCopyEx: renderer texture NULL (dstOpaque val) (anglef num) NULL SDL_FLIP_NONE)
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
431 intret
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
432 }
b01d7c1b4edd Add binding for simple form of SDL_RenderCopyEx
Michael Pavone <pavone@retrodev.com>
parents: 285
diff changeset
433
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
434 llMessage: destroy withVars: {} andCode: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
435 SDL_DestroyTexture: texture
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
436 true
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
437 }
279
eb83863fd33e Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
Michael Pavone <pavone@retrodev.com>
parents: 278
diff changeset
438 } _ptr_init: rendptr texptr
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
439 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
440
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
441 _makeSurface <- :ptr {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
442 #{
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
443 includeSystemHeader: "SDL.h"
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
444 llProperty: surface withType: (SDL_Surface ptr)
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
445 llMessage: opaque withVars: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
446 ptr <- cpointer ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
447 } andCode: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
448 ptr <- make_object: (addr_of: cpointer_meta) NULL 0
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
449 ptr val!: surface
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
450 ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
451 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
452 llMessage: _ptr_init withVars: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
453 ptr <- cpointer ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
454 } andCode: :ptr{
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
455 surface <- ptr val
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
456 self
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
457 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
458
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
459 asTexture <- :renderer {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
460 _helper createTextureFromSurface: (renderer opaque) opaque _makeTexture
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
461 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
462
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
463 llMessage: free withVars: {} andCode: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
464 SDL_FreeSurface: surface
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
465 true
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
466 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
467 } _ptr_init: ptr
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
468 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
469
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
470 #{
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
471 includeSystemHeader: "SDL.h"
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
472 includeSystemHeader: "stdlib.h"
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
473
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
474 llMessage: init withVars: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
475 flags <- obj_uint32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
476 intret <- obj_int32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
477 } andCode: :flags {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
478 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
479 intret num!: (SDL_Init: (flags num))
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
480 if: (intret num) {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
481 atexit: SDL_Quit
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
482 }
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
483 intret
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
484 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
485
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
486 llMessage: initSubSystem withVars: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
487 flags <- obj_uint32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
488 intret <- obj_int32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
489 } andCode: :flags {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
490 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
491 intret num!: (SDL_InitSubSystem: (flags num))
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
492 intret
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
493 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
494
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
495 llMessage: quitSubSystem withVars: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
496 flags <- obj_uint32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
497 } andCode: :flags {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
498 SDL_QuitSubSystem: (flags num)
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
499 true
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
500 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
501
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
502 r:g:b:a <- :rc :gc :bc :ac {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
503 #{
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
504 r <- rc
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
505 g <- gc
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
506 b <- bc
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
507 a <- ac
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
508 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
509 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
510
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
511 r:g:b <- :r :g :b {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
512 r: r g: g b: b a: 255u8
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
513 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
514
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
515 createWindow:pos:size:flags <- :title :x y :w h :flags{
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
516 _helper createWindow: title x y w h flags :ptr {
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
517 print: (string: ptr) . "\n"
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
518 #{
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
519 includeSystemHeader: "SDL.h"
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
520 llProperty: window withType: (SDL_Window ptr)
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
521 llMessage: opaque withVars: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
522 op <- cpointer ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
523 } andCode: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
524 op <- make_object: (addr_of: cpointer_meta) NULL 0
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
525 op val!: window
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
526 op
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
527 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
528
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
529 llMessage: _ptr_init withVars: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
530 ptr <- cpointer ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
531 } andCode: :ptr {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
532 window <- ptr val
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
533 self
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
534 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
535
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
536 renderOpts <- { _renderOpts }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
537
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
538 createRenderer:flags <- :index :flags {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
539 _helper createRenderer: (self opaque) index flags :ptr {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
540 #{
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
541 includeSystemHeader: "SDL.h"
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
542 llProperty: renderer withType: (SDL_Renderer ptr)
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
543 llMessage: opaque withVars: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
544 op <- cpointer ptr
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
545 } andCode: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
546 op <- make_object: (addr_of: cpointer_meta) NULL 0
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
547 op val!: renderer
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
548 op
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
549 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
550 llMessage: _ptr_init withVars: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
551 ptr <- cpointer ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
552 } andCode: :ptr {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
553 renderer <- ptr val
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
554 self
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
555 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
556
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
557 llMessage: drawColor! withVars: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
558 color <- object ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
559 rc <- obj_uint8 ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
560 gc <- obj_uint8 ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
561 bc <- obj_uint8 ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
562 ac <- obj_uint8 ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
563 intret <- obj_int32 ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
564 } andCode: :color {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
565 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
566 rc <- (mcall: r 1 color) castTo: (obj_uint8 ptr)
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
567 gc <- (mcall: g 1 color) castTo: (obj_uint8 ptr)
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
568 bc <- (mcall: b 1 color) castTo: (obj_uint8 ptr)
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
569 ac <- (mcall: a 1 color) castTo: (obj_uint8 ptr)
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
570 intret num!: (SDL_SetRenderDrawColor: renderer (rc num) (gc num) (bc num) (ac num))
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
571 intret
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
572 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
573
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
574 llMessage: clear withVars: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
575 intret <- obj_int32 ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
576 } andCode: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
577 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
578 intret num!: (SDL_RenderClear: renderer)
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
579 intret
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
580 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
581
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
582 llMessage: present withVars: {} andCode: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
583 SDL_RenderPresent: renderer
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
584 true
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
585 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
586
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
587 llMessage: destroy withVars: {} andCode: {
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
588 SDL_DestroyRenderer: renderer
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
589 true
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
590 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
591 } _ptr_init: ptr
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
592 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
593 }
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
594
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
595 llMessage: destroy withVars: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
596 } andCode: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
597 SDL_DestroyWindow: window
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
598 true
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
599 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
600 } _ptr_init: ptr
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
601 }
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
602 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
603
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
604 loadBMP <- :filename {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
605 _helper loadBMP: filename _makeSurface
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
606 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
607
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
608 llMessage: delay withVars: {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
609 ms <- obj_uint32 ptr
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
610 } andCode: :ms {
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
611 SDL_Delay: (ms num)
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
612 true
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
613 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
614
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
615 llMessage: clearError withVars: {} andCode: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
616 SDL_ClearError:
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
617 true
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
618 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
619
283
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
620 rect:size <- :x y :w h {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
621 getter <- macro: :propName {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
622 quote: (llMessage: propName withVars: {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
623 intret <- obj_int32 ptr
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
624 } andCode: {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
625 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
626 intret num!: ((addr_of: rect) propName)
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
627 intret
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
628 })
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
629 }
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
630 setter <- macro: :propName {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
631 quote: (llMessage: propName withVars: {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
632 v <- obj_int32 ptr
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
633 } andCode: :v {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
634 (addr_of: rect) propName: (v num)
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
635 self
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
636 })
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
637 }
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
638 (((#{
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
639 llProperty: rect withType: SDL_Rect
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
640 getter: x
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
641 setter: x!
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
642 getter: y
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
643 setter: y!
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
644 getter: w
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
645 setter: w!
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
646 getter: h
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
647 setter: h!
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
648 llMessage: _rectPointer withVars: {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
649 retptr <- cpointer ptr
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
650 } andCode: {
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
651 retptr <- make_object: (addr_of: cpointer_meta) NULL 0
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
652 retptr val!: (addr_of: (self rect))
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
653 retptr
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
654 }
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
655 } x!: x) y!: y) w!: w) h!: h
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
656 }
0ec4f1b68a38 Add copyTo method to texture that allows copying to a rectangular region on the renderer rather than stretching to fit the entire renderer
Michael Pavone <pavone@retrodev.com>
parents: 279
diff changeset
657
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
658 llMessage: getError withVars: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
659 str <- string ptr
285
bb1539decd62 Fix const warning in sdl module
Michael Pavone <pavone@retrodev.com>
parents: 284
diff changeset
660 rawstr <- const: (char ptr)
278
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
661 } andCode: {
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
662 rawstr <- SDL_GetError:
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
663 str <- make_object: (addr_of: string_meta) NULL 0
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
664 str bytes!: (strlen: rawstr)
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
665 str len!: (str bytes)
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
666 str data!: (GC_MALLOC: (str bytes) + 1)
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
667 memcpy: (str data) rawstr (str bytes) + 1
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
668 str
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
669 }
1205c7a43cb4 Add bindings for SDL_ClearError, SDL_GetError, SDL_LoadBMP, SDL_CreateTextureFromSurface and a partial binding for SDL_RendererCopy
Michael Pavone <pavone@retrodev.com>
parents: 277
diff changeset
670
291
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
671 pollEvent <- {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
672 _helper pollEvent: :typ tstamp eventPtr {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
673 _eventConstructors ifget: typ :handler {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
674 handler: typ tstamp eventPtr
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
675 } else: {
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
676 //fallback event
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
677 #{
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
678 type <- typ
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
679 timeStamp <- tstamp
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
680 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
681 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
682 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
683 }
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
684
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
685 subsystems <- { _subsystems }
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
686 windowOpts <- { _windowOpts }
291
38bbbf74b735 Initial work on event support in SDL module
Michael Pavone <pavone@retrodev.com>
parents: 287
diff changeset
687 eventTypes <- { _events }
274
a923b5b7da3d Initial work on an SDL2 binding
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
688 }
277
2b58eafa360b Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
Michael Pavone <pavone@retrodev.com>
parents: 274
diff changeset
689 }