![]() SDL_Surface *pConsoleBackground = IMG_Load( "images/consoleBackground1.png") SDL_Surface *pTripod = IMG_Load( "images/tripod.png") SDL_Surface *pScreen = SDL_GetWindowSurface(pWindow) Other SDL parameters bool quit = false SDL_RenderSetLogicalSize(pRenderer, SCREEN_WIDTH, SCREEN_HEIGHT) SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear") // make the scaled rendering look smoother. PRenderer = SDL_CreateRenderer(pWindow, -1, SDL_RENDERER_TARGETTEXTURE) PWindow = SDL_CreateWindow( "TDPB HMI", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ) tiff files, must go after window has been created //Declare window and renderer IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG | IMG_INIT_TIF) //Initialise SDL_Image to load. SDL_Init( SDL_INIT_VIDEO ) //Initialize SDL Screen attributes const int SCREEN_WIDTH = 1250 Example trying to render texture to another texture #include #include #include #include #include #include #include #include #include #include "SDL.h" #include "SDL_image.h" using namespace std I am aware that the textures created using CreateTextureFromSurface have access SDL_TEXTUREACCESS_STATIC, but I am not using these as the target. After all that I set the render target back to be the window and render the background texture (which should now have all the other textures rendered on to it) to the window. I set the background texture to be the rendering target using SDL_SetRenderTarget, then render my other textures onto it. I load a bunch of images as surfaces and convert them to textures using SDL_CreateTextureFromSurface, these are the textures I want to use to build up sub-texture layers. My approach has been to create a background texture with SDL_CreateTexture setting its access to SDL_TEXTUREACCESS_TARGET. Since my GUI is built up in layers, I would like to be able to render one texture onto another before rendering a final set of built up textures to the window. These sub-surfaces are then blitted to the main background screen before doing a final SDL_Flip().įor my SDL2.0 conversion I have tried to move away from Surfaces and use Textures wherever possible. My GUI uses a bunch of png images loaded from file which are rotated, re-sized and then blitted to various sub-surfaces. I am trying to convert a graphical user interface that I developed using SDL1.2 to SDL2.0.
0 Comments
Leave a Reply. |