Mercurial > repos > tabletprog
comparison modules/sdl.tp @ 279:eb83863fd33e
Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 21 Jul 2014 19:11:15 -0700 |
parents | 1205c7a43cb4 |
children | 0ec4f1b68a38 |
comparison
equal
deleted
inserted
replaced
278:1205c7a43cb4 | 279:eb83863fd33e |
---|---|
103 tex <- object ptr | 103 tex <- object ptr |
104 } andCode: :rendOpaque surfOpaque makeTexture { | 104 } andCode: :rendOpaque surfOpaque makeTexture { |
105 texOpaque <- make_object: (addr_of: cpointer_meta) NULL 0 | 105 texOpaque <- make_object: (addr_of: cpointer_meta) NULL 0 |
106 texOpaque val!: (SDL_CreateTextureFromSurface: (rendOpaque val) (surfOpaque val)) | 106 texOpaque val!: (SDL_CreateTextureFromSurface: (rendOpaque val) (surfOpaque val)) |
107 if: (texOpaque val) { | 107 if: (texOpaque val) { |
108 tex <- ccall: makeTexture 1 (texOpaque castTo: (object ptr)) | 108 tex <- ccall: makeTexture 1 (rendOpaque castTo: (object ptr)) (texOpaque castTo: (object ptr)) |
109 mcall: value 2 option tex | 109 mcall: value 2 option tex |
110 } else: { | 110 } else: { |
111 mcall: none 1 option | 111 mcall: none 1 option |
112 } | 112 } |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 _makeTexture <- :ptr { | 116 _makeTexture <- :rendptr texptr { |
117 #{ | 117 #{ |
118 includeSystemHeader: "SDL.h" | 118 includeSystemHeader: "SDL.h" |
119 llProperty: renderer withType: (SDL_Renderer ptr) | |
119 llProperty: texture withType: (SDL_Texture ptr) | 120 llProperty: texture withType: (SDL_Texture ptr) |
120 llMessage: opaque withVars: { | 121 llMessage: opaque withVars: { |
121 ptr <- cpointer ptr | 122 ptr <- cpointer ptr |
122 } andCode: { | 123 } andCode: { |
123 ptr <- make_object: (addr_of: cpointer_meta) NULL 0 | 124 ptr <- make_object: (addr_of: cpointer_meta) NULL 0 |
124 ptr val!: texture | 125 ptr val!: texture |
125 ptr | 126 ptr |
126 } | 127 } |
127 llMessage: _ptr_init withVars: { | 128 llMessage: _ptr_init withVars: { |
128 ptr <- cpointer ptr | 129 rendptr <- cpointer ptr |
129 } andCode: :ptr{ | 130 texptr <- cpointer ptr |
130 texture <- ptr val | 131 } andCode: :rendptr texptr{ |
132 renderer <- rendptr val | |
133 texture <- texptr val | |
131 self | 134 self |
132 } | 135 } |
133 | 136 |
134 llMessage: copyTo withVars: { | 137 llMessage: copy withVars: { |
135 renderer <- object ptr | |
136 rendOpaque <- cpointer ptr | |
137 intret <- obj_int32 ptr | 138 intret <- obj_int32 ptr |
138 } andCode: :renderer { | 139 } andCode: { |
139 rendOpaque <- (mcall: opaque 1 renderer) castTo: (cpointer ptr) | |
140 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 | 140 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
141 intret num!: (SDL_RenderCopy: (rendOpaque val) texture NULL NULL) | 141 intret num!: (SDL_RenderCopy: renderer texture NULL NULL) |
142 intret | 142 intret |
143 } | 143 } |
144 | 144 |
145 llMessage: destroy withVars: {} andCode: { | 145 llMessage: destroy withVars: {} andCode: { |
146 SDL_DestroyTexture: texture | 146 SDL_DestroyTexture: texture |
147 true | 147 true |
148 } | 148 } |
149 } _ptr_init: ptr | 149 } _ptr_init: rendptr texptr |
150 } | 150 } |
151 | 151 |
152 _makeSurface <- :ptr { | 152 _makeSurface <- :ptr { |
153 #{ | 153 #{ |
154 includeSystemHeader: "SDL.h" | 154 includeSystemHeader: "SDL.h" |