![]() ![]() It just does what you expect and transforms the SDL2 surface into a SDL2 texture with the help of the given renderer. SDL_CreateTextureFromSurface(renderer: PSDL_Renderer surface: PSDL_Surface): PSDL_Texture The function to use is SDL_CreateTextureFromSurface(renderer, surface). Step 2: Creating a SDL2 Texture from the SDL2 Surface The function is declared as SDL_LoadBMP(_file: PAnsiChar): PSDL_SurfaceĪnd return nil on error, e.g. in Windows something like ‘C:\MyImages\fpsdl.bmp’. Optionally you can also give a full file path, e.g. Attention though, if you just give a file name, it is assumed that the file is found in the same folder as the executing application. SDL_LoadBMP(name of bmp image file) does what you expect, it loads the image file and generates a SDL2 surface from it. Step 1: Loading the BMP file to a SDL2 Surface If SDL_RenderCopy(sdlRenderer, sdlTexture1, nil, nil) 0 thenĬontains two new variables, namely “sdlSurface1” and “sdlTexture1” of the pointer types PSDL_Surface and PSDL_Texture, respecitvely.Īfter setting up SDL2, a window and a renderer as known, we find this. ![]() ![]() SdlTexture1 := SDL_CreateTextureFromSurface(sdlRenderer, sdlSurface1) And finally this texture is rendered by SDL_RenderPresent, this function we know already.Īnd now let’s see how it is done in code. This SDL2 surface is then transformed into a SDL2 texture by SDL_CreateTextureFromSurface function (whose name is just explaining what is does). The bmp image file is stored on your hard drive and can be loaded by SDL_LoadBMP function to a SDL2 surface. The original image is 200×200 pixels wide. This image by is licensed under a Creative Commons Attribution 4.0 International License. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |