Browse Source

Examples: SDL3: Updated for latest WIP SDL3 branch. (#6243)

pull/6247/head
ocornut 2 years ago
parent
commit
ae4dad09b5
  1. 1
      docs/CHANGELOG.txt
  2. 13
      examples/example_sdl3_opengl3/main.cpp

1
docs/CHANGELOG.txt

@ -40,6 +40,7 @@ Breaking Changes:
Other changes:
- Backends: OpenGL3: Fixed GL loader crash when GL_VERSION returns NULL. (#6154, #4445, #3530)
- Examples: SDL3: Updated for latest WIP SDL3 branch. (#6243)
-----------------------------------------------------------------------

13
examples/example_sdl3_opengl3/main.cpp

@ -25,7 +25,7 @@ int main(int, char**)
// Setup SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD) != 0)
{
printf("Error: %s\n", SDL_GetError());
printf("Error: SDL_Init(): %s\n", SDL_GetError());
return -1;
}
@ -60,11 +60,18 @@ int main(int, char**)
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN);
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+OpenGL3 example", 1280, 720, window_flags);
if (window == NULL)
{
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
return -1;
}
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
SDL_GL_MakeCurrent(window, gl_context);
SDL_GL_SetSwapInterval(1); // Enable vsync
SDL_ShowWindow(window);
// Setup Dear ImGui context
IMGUI_CHECKVERSION();

Loading…
Cancel
Save