# HG changeset patch # User Michael Pavone # Date 1405995075 25200 # Node ID eb83863fd33ec404e3019e00a7a86b4a298857b3 # Parent 1205c7a43cb42581019d0b10177ebee3f1f83207 Store renderer pointer in texture object since the texture can only be used with the renderer it was created with diff -r 1205c7a43cb4 -r eb83863fd33e modules/sdl.tp --- a/modules/sdl.tp Mon Jul 21 12:51:38 2014 -0700 +++ b/modules/sdl.tp Mon Jul 21 19:11:15 2014 -0700 @@ -105,7 +105,7 @@ texOpaque <- make_object: (addr_of: cpointer_meta) NULL 0 texOpaque val!: (SDL_CreateTextureFromSurface: (rendOpaque val) (surfOpaque val)) if: (texOpaque val) { - tex <- ccall: makeTexture 1 (texOpaque castTo: (object ptr)) + tex <- ccall: makeTexture 1 (rendOpaque castTo: (object ptr)) (texOpaque castTo: (object ptr)) mcall: value 2 option tex } else: { mcall: none 1 option @@ -113,9 +113,10 @@ } } - _makeTexture <- :ptr { + _makeTexture <- :rendptr texptr { #{ includeSystemHeader: "SDL.h" + llProperty: renderer withType: (SDL_Renderer ptr) llProperty: texture withType: (SDL_Texture ptr) llMessage: opaque withVars: { ptr <- cpointer ptr @@ -125,20 +126,19 @@ ptr } llMessage: _ptr_init withVars: { - ptr <- cpointer ptr - } andCode: :ptr{ - texture <- ptr val + rendptr <- cpointer ptr + texptr <- cpointer ptr + } andCode: :rendptr texptr{ + renderer <- rendptr val + texture <- texptr val self } - llMessage: copyTo withVars: { - renderer <- object ptr - rendOpaque <- cpointer ptr + llMessage: copy withVars: { intret <- obj_int32 ptr - } andCode: :renderer { - rendOpaque <- (mcall: opaque 1 renderer) castTo: (cpointer ptr) + } andCode: { intret <- make_object: (addr_of: obj_int32_meta) NULL 0 - intret num!: (SDL_RenderCopy: (rendOpaque val) texture NULL NULL) + intret num!: (SDL_RenderCopy: renderer texture NULL NULL) intret } @@ -146,7 +146,7 @@ SDL_DestroyTexture: texture true } - } _ptr_init: ptr + } _ptr_init: rendptr texptr } _makeSurface <- :ptr { diff -r 1205c7a43cb4 -r eb83863fd33e samples/sdl.tp --- a/samples/sdl.tp Mon Jul 21 12:51:38 2014 -0700 +++ b/samples/sdl.tp Mon Jul 21 19:11:15 2014 -0700 @@ -12,7 +12,7 @@ (sdl loadBMP: "944.bmp") value: :surf { (surf asTexture: render) value: :tex { sdl clearError - if: (tex copyTo: render) != 0 { + if: (tex copy) != 0 { print: "Failed to copy texture to renderer: " . (sdl getError) . "\n" } surf free