Hi all, I'm back again! I'm trying to follow Lesson 05 of Lazy Foo's C++ sdl2 tutorial. Right now in the tutorial the C++ code looks like:
SDL_Rect stretchRect;
stretchRect.x = 0;
stretchRect.y = 0;
stretchRect.w = SCREEN_WIDTH;
stretchRect.h = SCREEN_HEIGHT;
SDL_BlitScaled( gStretchedSurface, NULL, gScreenSurface, &stretchRect );
And my Nim code looks (roughly) like this:
var stretchRect: Rect
stretchRect.x = 0;
stretchRect.y = 0;
stretchRect.w = screenWidth
stretchRect.h = screenHeight
blitScaled(stretchedSurface, nil, surface, stretchRect)
but it doesn't like that because blitScaled last value takes a ptr Rect:
proc blitScaled*(src: SurfacePtr; srcrect: ptr Rect; dst: SurfacePtr;
dstrect: ptr Rect): SDL_Return {.inline, discardable.} = upperBlitScaled(src, srcrect, dst, dstrect)
However, if I change my
var stretchRect: Rect
to
var stretchRect: ptr Rect
I get SIGSEGV: Illegal storage access. (Attempt to read from nil?) with the most recent call being on the following line:
stretchRect.x = 0;
Help? The tutorial uses &stretchRect in the BlitScaled function, but I don't how to do that in Nim. Thanks, hcorion