Convert to SDL3 and static link
This commit is contained in:
@@ -112,7 +112,7 @@ Library PrepareIMGUI(S8_String sdl_inc_path) {
|
||||
Library l = {};
|
||||
l.include_paths.add("../src/external/imgui/");
|
||||
l.include_paths.add("../src/external/imgui/backends");
|
||||
l.sources.add("../src/external/imgui/backends/imgui_impl_sdl2.cpp");
|
||||
l.sources.add("../src/external/imgui/backends/imgui_impl_sdl3.cpp");
|
||||
l.sources.add("../src/external/imgui/backends/imgui_impl_opengl3.cpp");
|
||||
l.sources.add("../src/external/imgui/imgui.cpp");
|
||||
l.sources.add("../src/external/imgui/imgui_demo.cpp");
|
||||
@@ -120,7 +120,7 @@ Library PrepareIMGUI(S8_String sdl_inc_path) {
|
||||
l.sources.add("../src/external/imgui/imgui_tables.cpp");
|
||||
l.sources.add("../src/external/imgui/imgui_widgets.cpp");
|
||||
|
||||
l.objects.add("imgui_impl_sdl2.obj");
|
||||
l.objects.add("imgui_impl_sdl3.obj");
|
||||
l.objects.add("imgui_impl_opengl3.obj");
|
||||
l.objects.add("imgui.obj");
|
||||
l.objects.add("imgui_demo.obj");
|
||||
@@ -142,11 +142,8 @@ Library PrepareIMGUI(S8_String sdl_inc_path) {
|
||||
|
||||
Library PrepareSDL() {
|
||||
Library l = {};
|
||||
l.include_paths.add("../src/external/SDL2/include");
|
||||
l.objects.add("../src/external/SDL2/lib/x64/SDL2main.lib");
|
||||
l.objects.add("../src/external/SDL2/lib/x64/SDL2.lib");
|
||||
OS_Result os_result = OS_CopyFile("../src/external/SDL2/lib/x64/SDL2.dll", "SDL2.dll", true);
|
||||
if (os_result != OS_SUCCESS) IO_Printf("failed to copy SDL2.dll\n");
|
||||
l.include_paths.add("../src/external/SDL/include");
|
||||
l.objects.add("../src/external/SDL/VisualC/x64/Release/SDL3.lib");
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -210,7 +207,7 @@ int main() {
|
||||
cmd.add("/link");
|
||||
cmd.add("/incremental:no");
|
||||
cmd.add("/SUBSYSTEM:WINDOWS");
|
||||
cmd.add("opengl32.lib");
|
||||
cmd.add("opengl32.lib gdi32.lib winmm.lib Setupapi.lib ole32.lib oleaut32.lib version.lib");
|
||||
For(libs) For2(o, it.objects) cmd.add(o);
|
||||
|
||||
OS_DeleteFile("transcript_browser.pdb");
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_sdl2.h"
|
||||
#include "imgui_impl_sdl3.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <SDL.h>
|
||||
#include "SDL3/SDL.h"
|
||||
#include "glad.h"
|
||||
|
||||
struct FileLoadResult {
|
||||
@@ -139,7 +139,7 @@ void UILoadedFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char **) {
|
||||
int EntryPoint() {
|
||||
InitOS();
|
||||
InitScratch();
|
||||
InitArena(&Perm);
|
||||
@@ -151,7 +151,7 @@ int main(int, char **) {
|
||||
|
||||
Array<String> filenames = {};
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) {
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
|
||||
printf("Error: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
@@ -161,13 +161,12 @@ int main(int, char **) {
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||
|
||||
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_ALLOW_HIGHDPI);
|
||||
SDL_Window *window = SDL_CreateWindow("Transcript browser", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 600, window_flags);
|
||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
|
||||
SDL_Window *window = SDL_CreateWindow("Transcript browser", 960, 600, window_flags);
|
||||
if (window == nullptr) {
|
||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||
return -1;
|
||||
@@ -195,7 +194,7 @@ int main(int, char **) {
|
||||
ImGui::StyleColorsLight();
|
||||
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||
ImGui_ImplSDL3_InitForOpenGL(window, gl_context);
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18.0f);
|
||||
|
||||
@@ -229,14 +228,15 @@ int main(int, char **) {
|
||||
bool f1_press = false;
|
||||
bool f2_press = false;
|
||||
SDL_Event event;
|
||||
SDL_Event input_event_saved;
|
||||
#if 1
|
||||
while (SDL_PollEvent(&event)) {
|
||||
#else
|
||||
if (SDL_WaitEvent(&event)) {
|
||||
#endif
|
||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||
if (event.type == SDL_KEYDOWN) {
|
||||
switch (event.key.keysym.sym) {
|
||||
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||
if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
switch (event.key.key) {
|
||||
case SDLK_UP:
|
||||
case SDLK_DOWN:
|
||||
case SDLK_PAGEUP:
|
||||
@@ -246,6 +246,7 @@ int main(int, char **) {
|
||||
case SDLK_BACKSPACE:
|
||||
case SDLK_DELETE:
|
||||
set_focus_to_input = true;
|
||||
input_event_saved = event;
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
enter_press = true;
|
||||
@@ -260,22 +261,25 @@ int main(int, char **) {
|
||||
f2_press = true;
|
||||
break;
|
||||
}
|
||||
} else if (event.type == SDL_TEXTINPUT) {
|
||||
} else if (event.type == SDL_EVENT_TEXT_INPUT) {
|
||||
set_focus_to_input = true;
|
||||
} else if (event.type == SDL_QUIT) {
|
||||
input_event_saved = event;
|
||||
} else if (event.type == SDL_EVENT_QUIT) {
|
||||
done = true;
|
||||
} else if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) {
|
||||
} else if (event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED && event.window.windowID == SDL_GetWindowID(window)) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
#if 0
|
||||
ImGui::ShowDemoWindow();
|
||||
#else
|
||||
|
||||
// Query input window
|
||||
{
|
||||
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse;
|
||||
@@ -307,7 +311,9 @@ int main(int, char **) {
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (menu_open != MenuOpen_Query && set_focus_to_input) ImGui::SetKeyboardFocusHere(0);
|
||||
if (menu_open == MenuOpen_Query && set_focus_to_input) {
|
||||
ImGui::SetKeyboardFocusHere(0);
|
||||
}
|
||||
if (tab_press && ImGui::IsWindowFocused()) set_focus_to_list = true;
|
||||
if (ImGui::InputText("Input your query", Prompt, sizeof(Prompt))) {
|
||||
StartSearchingForMatches();
|
||||
@@ -331,6 +337,7 @@ int main(int, char **) {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
{
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse;
|
||||
const ImGuiViewport *main_viewport = ImGui::GetMainViewport();
|
||||
@@ -370,12 +377,22 @@ int main(int, char **) {
|
||||
|
||||
// Cleanup
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
ImGui_ImplSDL3_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
SDL_GL_DeleteContext(gl_context);
|
||||
SDL_GL_DestroyContext(gl_context);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if _WIN32
|
||||
int WinMain(void *hInstance, void *hPrevInstance, const char *cmd, int show_cmd) {
|
||||
return EntryPoint();
|
||||
}
|
||||
#else
|
||||
int main() {
|
||||
return EntryPoint();
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user