Fullscreen High DPI Hint Issue
unknown
c_cpp
3 months ago
1.3 kB
15
Indexable
#include "SDL3/SDL.h" #include "SDL3_image/SDL_image.h" int main(int argc, char **argv) { SDL_SetHint("SDL_WINDOWS_DPI_AWARENESS", "1"); SDL_Init(SDL_INIT_VIDEO); SDL_Window *w = SDL_CreateWindow("fsbug", 480, 480, SDL_WINDOW_RESIZABLE); SDL_Renderer *r = SDL_CreateRenderer(w, 0); // Optional: If this is on, the pixels look blurry in the test image. If off, the white pixel look almost gone in the test image. SDL_SetRenderLogicalPresentation(r, 480, 480, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE); SDL_Texture *rock = IMG_LoadTexture(r, "dat/T_Obj_Rock0.png"); if (rock == NULL) { return 1; } SDL_SetTextureScaleMode(rock, SDL_SCALEMODE_NEAREST); SDL_Event e; while (1) { while (SDL_PollEvent(&e) > 0) { if (e.type == SDL_EVENT_QUIT) { SDL_Quit(); return 1; } if (e.type == SDL_EVENT_KEY_DOWN) { static bool b_fullscreen; b_fullscreen = !b_fullscreen; SDL_SetWindowFullscreen(w, b_fullscreen); } } SDL_SetRenderDrawColor(r, 255, 255, 233, 255); SDL_RenderClear(r); for (Sint32 i = 0; i < 10; i++) { for (Sint32 j = 0; j < 10; j++) { SDL_RenderTexture(r, rock, NULL, &(SDL_FRect){i * 32.f, j * 32.f, 32.f, 32.f}); } } SDL_RenderPresent(r); } return 0; }
Editor is loading...
Leave a Comment