mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-03-20 10:09:26 +08:00
ggwave-gui : minor
This commit is contained in:
@@ -1,5 +1,44 @@
|
||||
#include "common.h"
|
||||
|
||||
#include <imgui-extra/imgui_impl.h>
|
||||
|
||||
#include <SDL_opengl.h>
|
||||
|
||||
// ImGui helpers
|
||||
|
||||
bool ImGui_beginFrame(SDL_Window * window);
|
||||
bool ImGui_endFrame(SDL_Window * window);
|
||||
|
||||
bool ImGui_beginFrame(SDL_Window * window) {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
ImGui_ProcessEvent(&event);
|
||||
if (event.type == SDL_QUIT) return false;
|
||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) return false;
|
||||
}
|
||||
|
||||
ImGui_NewFrame(window);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImGui_endFrame(SDL_Window * window) {
|
||||
// Rendering
|
||||
int display_w, display_h;
|
||||
SDL_GetWindowSize(window, &display_w, &display_h);
|
||||
glViewport(0, 0, display_w, display_h);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
ImGui::Render();
|
||||
ImGui_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_Window * g_window;
|
||||
static void * g_gl_context;
|
||||
|
||||
@@ -49,6 +88,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
deinitMain(worker);
|
||||
|
||||
GGWave_deinit();
|
||||
|
||||
SDL_GL_DeleteContext(g_gl_context);
|
||||
SDL_DestroyWindow(g_window);
|
||||
SDL_Quit();
|
||||
|
||||
Reference in New Issue
Block a user