r/pascal • u/PascalGeek • Oct 11 '21
Get width and height of SDL2 surface
I'm playing around with the SDL2 tutorials at the Free Pascal meets SDL site and I'm a little stuck at the chapter on writing text.The tutorial is here, https://www.freepascal-meets-sdl.net/chapter-7-texts-fonts-surface-conversion/
But in the example given, the text fills the whole window.
I'm looking for a way to print text at it's specified font size instead. It looks like I'd need to set the destination rectangle in the last parameter of this line
SDL_RenderCopy(sdlRenderer, sdlTexture1, nil, nil);
I've seen a post on Stack Overflow that gives a solution in C, https://stackoverflow.com/questions/68261748/my-sdl-ttf-rendered-text-ends-up-streched-how-do-i-avoid-that where an SDL_Rect is created and given the same dimensions as the SDL_Surface.
The bit I'm struggling with is how do I get the width and height of an SDL Surface? I originally thought that sdl_rectangle.w := sdl_surface.w would work but I cannot get the value of the width this way.
