Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
# ls -l

Linux:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -76,16 +76,16 @@ jobs:
zip -r sql-gui-linux.zip sql-gui fonts

- name: Archive Product
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: sql-gui-linux.zip
name: sql-gui-linux
path: sql-gui-linux.zip


MacOS:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -104,9 +104,9 @@ jobs:
zip -r sql-gui-mac.zip sql-gui fonts

- name: Archive Product
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: sql-gui-mac.zip
name: sql-gui-mac
path: sql-gui-mac.zip

# Emscripten:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "imgui"]
path = imgui
url = https://github.com/corentin-plouet/imgui.git
url = https://github.com/ocornut/imgui.git
[submodule "ImGuiColorTextEdit"]
path = ImGuiColorTextEdit
url = https://github.com/BalazsJako/ImGuiColorTextEdit.git
2 changes: 1 addition & 1 deletion ImGuiColorTextEdit
20 changes: 5 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,25 @@

EXE = sql-gui
SOURCES = main.cpp
SOURCES += imgui/examples/imgui_impl_sdl.cpp imgui/examples/imgui_impl_opengl3.cpp
SOURCES += imgui/backends/imgui_impl_sdl2.cpp imgui/backends/imgui_impl_opengl3.cpp
SOURCES += imgui/imgui.cpp imgui/imgui_demo.cpp imgui/imgui_draw.cpp imgui/imgui_widgets.cpp imgui/imgui_tables.cpp
SOURCES += ImGuiColorTextEdit/TextEditor.cpp
SOURCES += sqlite/sqlite3.c
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)

CFLAGS = -I./imgui/examples/ -I./imgui/ -I./imgui/backends -I./sqlite
CFLAGS = -I./imgui/ -I./imgui/backends -I./sqlite
CFLAGS += -g -Wall -Wformat
LIBS =

CXXFLAGS = -std=c++11 $(CFLAGS)
CXXFLAGS = -std=c++17 $(CFLAGS)

##---------------------------------------------------------------------
## OPENGL LOADER
##---------------------------------------------------------------------

## Using OpenGL loader: gl3w [default]
SOURCES += imgui/examples/libs/gl3w/GL/gl3w.c
CFLAGS += -Iimgui/examples/libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W
## Using OpenGL loader: imgui's built-in loader (default since 1.91+)
## No external loader needed - imgui_impl_opengl3.cpp includes its own loader.

## Using OpenGL loader: glew
## (This assumes a system-wide installation)
Expand Down Expand Up @@ -89,21 +88,12 @@ endif
%.o:ImGuiColorTextEdit/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

%.o:imgui/examples/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

%.o:imgui/backends/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

%.o:imgui/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

%.o:imgui/examples/libs/gl3w/GL/%.c
$(CC) $(CFLAGS) -c -o $@ $<

%.o:imgui/examples/libs/glad/src/%.c
$(CC) $(CFLAGS) -c -o $@ $<

%.o:sqlite/%.c
$(CC) $(CFLAGS) -c -o $@ $<

Expand Down
2 changes: 1 addition & 1 deletion imgui
Submodule imgui updated 261 files
70 changes: 20 additions & 50 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,38 +1,20 @@
// dear imgui: standalone example application for SDL2 + OpenGL
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)

#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_sdl2.h"
#include "imgui_impl_opengl3.h"
#include <stdio.h>
#include <SDL.h>
#include <sqlite3.h>
#include "ImGuiColorTextEdit/TextEditor.h"

// About Desktop OpenGL function loaders:
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
#include <GL/gl3w.h> // Initialize with gl3wInit()
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
#include <GL/glew.h> // Initialize with glewInit()
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
#include <glad/glad.h> // Initialize with gladLoadGL()
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
#include <glbinding/Binding.h> // Initialize with glbinding::Binding::initialize()
#include <glbinding/gl/gl.h>
using namespace gl;
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
#include <glbinding/glbinding.h>// Initialize with glbinding::initialize()
#include <glbinding/gl/gl.h>
using namespace gl;
// GL includes are handled by imgui_impl_opengl3_loader.h
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <SDL_opengles2.h>
#else
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
#include <SDL_opengl.h>
#endif

void DisplayTable(char **result, int rows, int cols)
Expand Down Expand Up @@ -109,36 +91,13 @@ int main(int argc, char**argv)
SDL_GL_MakeCurrent(window, gl_context);
SDL_GL_SetSwapInterval(1); // Enable vsync

// Initialize OpenGL loader
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
bool err = gl3wInit() != 0;
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
bool err = glewInit() != GLEW_OK;
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
bool err = gladLoadGL() == 0;
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
bool err = false;
glbinding::Binding::initialize();
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
bool err = false;
glbinding::initialize([](const char* name) { return (glbinding::ProcAddress)SDL_GL_GetProcAddress(name); });
#else
bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
#endif
if (err)
{
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
return 1;
}

// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io.ConfigFlags |= ImGuiConfigFlags_EnablePowerSavingMode;

// Setup Dear ImGui style
ImGui::StyleColorsLight();
Expand Down Expand Up @@ -214,7 +173,6 @@ int main(int argc, char**argv)
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
ImGui_ImplSDL2_WaitForEvent();
SDL_Event event;
while (SDL_PollEvent(&event))
{
Expand All @@ -227,7 +185,7 @@ int main(int argc, char**argv)

// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame(window);
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();

if (show_demo_window)
Expand Down Expand Up @@ -267,7 +225,7 @@ int main(int argc, char**argv)
auto shift = io.KeyShift;
auto ctrl = io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl;
auto alt = io.ConfigMacOSXBehaviors ? io.KeyCtrl : io.KeyAlt;
if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Enter), false)) {
if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Enter, false)) {
do_query = true;
}

Expand Down Expand Up @@ -529,9 +487,21 @@ int main(int argc, char**argv)
// Rendering
ImGui::Render();
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

// Update and Render additional Platform Windows
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
}

SDL_GL_SwapWindow(window);
}

Expand Down