Comments (2)
Can you post a minimal repro example and steps?
Thanks!
from sdl.
sdl-window-resize.mp4
At the time of posting this I realized I used SDL_GetWindowSizeInPixels in the code below so please let me know if I should provide samples using SDL_GetWindowSize.
#include <SDL3/SDL.h>
#include <cstdio>
#include <windows.h>
void PrintSize(SDL_Window* window, HWND hwnd)
{
int width = 0;
int height = 0;
SDL_GetWindowSizeInPixels(window, &width, &height);
printf("SDL [%i, %i] ", width, height);
RECT clientRect;
GetClientRect(hwnd, &clientRect);
printf("Windows [%li, %li]\n", clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
}
int main(int argc, char** argv)
{
SDL_Init(SDL_INIT_VIDEO);
const int initialWidth = 700;
const int initialHeight = 300;
SDL_Window* window = SDL_CreateWindow
(
"Window size test",
initialWidth,
initialHeight,
SDL_WINDOW_RESIZABLE
);
const HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr, SDL_RENDERER_PRESENTVSYNC);
SDL_SetRenderDrawColor(renderer, 255, 165, 0, 255);
int minWidth = -1;
int minHeight = -1;
SDL_GetWindowMinimumSize(window, &minWidth, &minHeight);
printf("Min window size [%i, %i]\n", minWidth, minHeight);
bool printOnResize = true;
bool open = true;
while(open)
{
SDL_Event e;
while(SDL_PollEvent(&e))
{
if(e.type == SDL_EVENT_KEY_UP && e.key.keysym.sym == SDLK_1)
{
SDL_SetWindowSize(window, initialWidth, 1);
}
else if(e.type == SDL_EVENT_KEY_UP && e.key.keysym.sym == SDLK_2)
{
printOnResize = false;
}
else if(e.type == SDL_EVENT_WINDOW_RESIZED && printOnResize)
{
PrintSize(window, hwnd);
}
else if(e.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED)
{
open = false;
}
}
if(printOnResize == false)
PrintSize(window, hwnd);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return (0);
}
from sdl.
Related Issues (20)
- where is SDL2.lib
- SDL2 memory leak in WSL2 HOT 4
- Documentation warnings HOT 2
- Is SDL3 compatible with SDL2 image? HOT 5
- interval_numerator/denominator of SDL_CameraSpec is opposite for Windows/MediaFoundation implementation HOT 7
- The wait cursors aren't animated on Wayland HOT 1
- Dialog xdg portals broken HOT 1
- Should GUIDs be passed by value or reference? HOT 2
- SDL_GetAudioDeviceName() returns a strdup'd pointer, nothing else does.
- [SDL3] Pen - IOS pen detecting as mouse HOT 3
- windows minimum sdk requirements HOT 11
- `VisualC-GDK/` missing from release tarballs HOT 2
- X11 window opens on the wrong display HOT 40
- [Android] Hardcoding Gamepad hats to buttons [b11; b14] makes no sense
- Trouble with X11_SetWindowMouseGrab() HOT 5
- SDL_CreateWindowFrom handle leak HOT 9
- testyuv bad output on windows? HOT 6
- iOS camera api all formats are unknown HOT 14
- Random Segmentation fault in `SDL_SetRenderTarget_REAL` HOT 6
- PS3 controller visible on windows 10 devices but not seen by SDL2? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdl.