If you want to avoid recalculating the positions of all elements on the screen every…
Jump to turn (11)
- 1If you want to avoid recalculating the positions of all elements on the screen e
- 2i can't use sdl's renderlogicsize function because it does not work with sdl vie
- 3how can i offset where the render is drawn in sdl2 c++
- 4if i move the viewport then do i have to move all of the objects so that they ma
- 5does sdl2 use mipmaps?
- 6i'm trying to find out why i encounter subpixels when my textures are not scaled
- 7SDLSetHint(SDLHINTRENDERSCALEQUALITY, “0”); what is this?
- 8tell me more about my options when using sdlsethint
- 9thanks for all your help. i may need more
- 10what do you know about roguelite deckbuilders
- 11what makes opening trading card packets addictive?
- User
If you want to avoid recalculating the positions of all elements on the screen every time you adjust the virtual window area, you can use a different approach. Instead of modifying the rendering area, you can modify the rendering transformation using a combination of the SDL_RenderSetLogicalSize() and SDL_RenderSetScale() functions.
Here’s an alternative method to create a virtual window in SDL2 C++ that can be moved and affects the rendered screen as well as the input handling:
SDL_Init(SDL_INIT_VIDEO); SDL_Window* window = SDL_CreateWindow(“Virtual Window”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN); SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
int virtualWindowWidth = 400; // Example virtual window width int virtualWindowHeight = 300; // Example virtual window height int virtualWindowX = 200; // Example virtual window X position within the main window int virtualWindowY = 150; // Example virtual window Y position within the main window