
A target resolution of 640 pixels width x 480 pixels height (4:3 ratio) should be achieved in a device (window) of width x height of 1680 x 1050 pixels (16:10 ratio).īack to the code. This is demonstrated in the example code. Even if the ration of the device is different, for example you are trying to have a 4:3 ratio resolution on a wide screen 16:9 monitor, this function will just put some bars at appropriate places (see screenshot above) and fit the targeted resolution to the device resolution as good as possible. If you want to display a game in VGA (640 x 480) resolution on a XGA (1024 x 768) resolved screen, SDL_RenderSetLogicalSize() will scale up everything as necessary to fill the screen. It will make use of scaling functions internally to fit the target resolution to the actual screen/device resolution.

It sets a device independent resolution for rendering. SDL_RenderSetLogicalSize(renderer: PSDL_Renderer w: SInt32 h: SInt32): SInt32.
FREE PASCAL FILE TIME RESOLUTION CODE
The function SDL_RenderSetLogicalSize() is used to achieve a logical resolution and returns 0 on success and the negative error code on failure. 1680×1050 px) than what your program is expecting (640×480 px), SDL2 will scale everything up or down just to fit your real resolution the best! How does SDL2 achieve a Logical Resolution?Īlthough your monitor resolution may be much larger (e.g. Notice the black border (letter boxing) to the left and right of the red rectangle, because of the different aspect ratios, 16:10 (monitor) and 4:3 (640×480 target resolution). This is the result on a 1680×1050 px monitor resolution, if a logical size of 640×480 px is used. This is the expected result if your monitor has a resolution of 1680×1050 px, and you render a red rectangle at position (0/0) width dimension 640×480 px, and a green rectangle at position (320/240) with dimension 320×240 px.īut since we introduced a logical resolution in the program, we really get something like this: This image by is licensed under a Creative Commons Attribution 4.0 International License. You would expect a result to be something like this: This image by is licensed under a Creative Commons Attribution 4.0 International License. Let’s assume you have a modern monitor and render these two rectangles fullscreen at a typical resolution of 1680×1050 or even higher. “Quarter” is located at (320/240) and has a width of 320 px and a height of 240. The const “Border” is located at (0/0) and has a width of 640 px and a height of 480 px. This program basically draws two rectangles, a red one and a green one. SDL_RenderDrawRect(sdlRenderer, render to window for 3 seconds SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, SDL_ALPHA_OPAQUE) SDL_RenderDrawRect(sdlRenderer, draw green quarter SDL_SetRenderDrawColor(sdlRenderer, 255, 0, 0, SDL_ALPHA_OPAQUE) If SDL_RenderSetLogicalSize(sdlRenderer, 640, 480) 0 then

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, 'linear') program SDL_LogicalResolution īorder: TSDL_Rect = (x: 0 y: 0 w: 640 h: 480) SDL 2.0 provides a solution to circumvent many of the troubles related to resolution settings: the logical resolution. In WSXGA+ resolution the car’s width and height will appear less than half, it will appear to be tiny. This fills a good amount of the screen in VGA resolution. You choose a car image of 64 pixels width and 32 pixels height. Also, even if the system is capable of displaying very high resolutions, there is no guarantee that it will be able to switch down to VGA resolution.įurthermore, if you optimize a game for VGA resolution, you will choose the sprites/images according to fit into a 640 x 480 pixels screen. Unfortunately though, you cannot expect a system whose maximum resolution allows for XGA to display WSXGA+ resolution. The system would just switch to the necessary resolution and voila the game is running and looking like expected. If every monitors/graphic boards would be capable of displaying all possible resolutions, this wouldn’t be much of a problem. If you are going for a target resolution of 640 x 480 (VGA), you will choose less detailed source images as if you go for 1024 x 768 (XGA), or even widescreen 1680 x 1050 (WSXGA+) or any other high detail resolution.

Depending on the answers to these questions you may choose for sprite/image file resolutions. The main question is: What exact resolution are the users going to use to play the game? Do their monitors support the resolution you decide for? Do the user/gamer use a wide screen monitor? And so on. If you create a game, often there are a lot of questions you just can solve partly by planning.

It concerns the resolution of the application or game. Now an awesome feature of SDL 2.0 will be presented which is fixing a big major problem for many programmers.
