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