Skip to content

Commit

Permalink
Examples: SDL3: Updated for latest WIP SDL3 branch. (#6243)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Mar 15, 2023
1 parent 0d60696 commit ae4dad0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


-----------------------------------------------------------------------
Expand Down
13 changes: 10 additions & 3 deletions examples/example_sdl3_opengl3/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ae4dad0

Please sign in to comment.