New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing SDL_WINDOW_RESIZABLE when creating the window, instead of calling SDL_SetWindowResizable #6324
Comments
That's odd, I copied your program and removed the glad OpenGL code (since I don't have that installed) and it worked for me: #include <stdlib.h>
#include <SDL.h>
#include "SDL_opengl.h"
SDL_Window *window;
const float maxFPS = 5.f;
void
fatalError(const char *message)
{
SDL_Log("%s", message);
if (window) {
SDL_DestroyWindow(window);
}
SDL_Quit();
exit(-1);
}
int
main()
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fatalError("Failed to initialize");
}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
const int winW = 300;
const int winH = 300;
window = SDL_CreateWindow("OpenGL, SDL2, C++",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
winW,
winH,
SDL_WINDOW_OPENGL);
if (!window) {
fatalError("Failed to create the SDL window");
}
SDL_SetWindowResizable(window, SDL_TRUE);
SDL_GLContext glContext = SDL_GL_CreateContext(window);
if (!glContext) {
fatalError("Failed to create the SDL_GL context");
}
glViewport(0, 0, winW, winH);
glClearColor(0.5f, 0.5f, 1.f, 1.f);
SDL_Event event;
int running = 1;
while (running) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
running = 0;
break;
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_RESIZED:
glViewport(0, 0, event.window.data1, event.window.data2);
break;
}
break;
}
}
float startTicks = SDL_GetTicks();
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(window);
// Limit FPS to the max FPS
float frameTicks = SDL_GetTicks() - startTicks;
if (1000.f / maxFPS > frameTicks) {
SDL_Delay(1000.f / maxFPS - frameTicks);
}
}
SDL_GL_DeleteContext(glContext);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
} |
HolyBlackCat wrote here:
Whoever reads this, please, test it on your computer too. It would be nice if my example tested at least 2-3 people. I use Windows 10 64-bit. |
SDL 2.0 is now in maintenance mode, and all inactive issues are being closed. If this issue is impacting you, please feel free to reopen it with additional information. |
It works:
But
SDL_SetWindowResizable
does not work:The text was updated successfully, but these errors were encountered: