triangle and imgui
This commit is contained in:
@@ -90,6 +90,10 @@
|
|||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
glfw
|
glfw
|
||||||
glew
|
glew
|
||||||
|
|
||||||
|
glm
|
||||||
|
nlohmann_json
|
||||||
|
curl
|
||||||
];
|
];
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
@@ -102,10 +106,12 @@
|
|||||||
$imgui/backends/imgui_impl_opengl3.cpp \
|
$imgui/backends/imgui_impl_opengl3.cpp \
|
||||||
$imgui/misc/cpp/*.cpp \
|
$imgui/misc/cpp/*.cpp \
|
||||||
$imgui/*.cpp \
|
$imgui/*.cpp \
|
||||||
-DRENDERER=1 \
|
-DRENDERER_OPENGL=1 \
|
||||||
-DWINDOW=1 \
|
-DWINDOW_GLFW=1 \
|
||||||
-I include -I $imgui -I . \
|
-I include -I $imgui -I . \
|
||||||
-lEGL -lGL -lglfw -lGLEW \
|
-lEGL -lGL -lglfw -lGLEW \
|
||||||
|
$(curl-config --cflags) \
|
||||||
|
$(curl-config --libs) \
|
||||||
-Wall \
|
-Wall \
|
||||||
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
|
-o $name -DIMGUI_IMPL_GLFW_DISABLE_X11
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Archimedes {
|
|||||||
public:
|
public:
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
glm::vec4 clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
glm::vec4 clearColor = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
|
||||||
Renderer() : w(0), h(0) {}
|
Renderer() : w(0), h(0) {}
|
||||||
|
|
||||||
|
|||||||
@@ -57,10 +57,7 @@ void TestTriangle::onLoad() {
|
|||||||
|
|
||||||
void TestTriangle::run() {
|
void TestTriangle::run() {
|
||||||
|
|
||||||
window->getRenderer()->render();
|
|
||||||
window->getRenderer()->draw(rt);
|
window->getRenderer()->draw(rt);
|
||||||
window->swapBuffers();
|
|
||||||
window->pollEvents();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ void ImguiModule::onLoad() {
|
|||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
window = wm->aquireWindow();
|
window = (Archimedes::WindowGLFW*) wm->aquireWindow();
|
||||||
|
|
||||||
#ifdef RENDERER_SDL3
|
#ifdef RENDERER_SDL3
|
||||||
renderer = window->getRenderer()->getRendererImpl()->renderer;
|
renderer = window->getRenderer()->getRendererImpl()->renderer;
|
||||||
@@ -78,7 +78,7 @@ void ImguiModule::onLoad() {
|
|||||||
std::cout << "rendererInit failed!\n" << std::endl;
|
std::cout << "rendererInit failed!\n" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WINDOW == 2
|
#ifdef WINDOW_SDL3
|
||||||
ecmd_it = wm->addEventFn([](Archimedes::Event* e){
|
ecmd_it = wm->addEventFn([](Archimedes::Event* e){
|
||||||
if(e->userData.type() == typeid(SDL_Event*)) {
|
if(e->userData.type() == typeid(SDL_Event*)) {
|
||||||
ImGui_ImplSDL3_ProcessEvent(std::any_cast<SDL_Event*>(e->userData));
|
ImGui_ImplSDL3_ProcessEvent(std::any_cast<SDL_Event*>(e->userData));
|
||||||
@@ -93,9 +93,6 @@ void ImguiModule::onLoad() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ImguiModule::run() {
|
void ImguiModule::run() {
|
||||||
rendererNewFrame();
|
|
||||||
windowNewFrame();
|
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
@@ -107,6 +104,10 @@ void ImguiModule::run() {
|
|||||||
|
|
||||||
window->getWindowImpl()->restoreContext();
|
window->getWindowImpl()->restoreContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rendererNewFrame();
|
||||||
|
windowNewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ImguiModule::onEvent(const Archimedes::Event &e) {
|
bool ImguiModule::onEvent(const Archimedes::Event &e) {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class ImguiModule : public Archimedes::Module {
|
|||||||
|
|
||||||
ImGuiContext* context;
|
ImGuiContext* context;
|
||||||
|
|
||||||
Archimedes::Window* window;
|
Archimedes::WindowGLFW* window;
|
||||||
|
|
||||||
std::list<std::function<void()>>::iterator rcmd_it;
|
std::list<std::function<void()>>::iterator rcmd_it;
|
||||||
|
|
||||||
@@ -99,10 +99,10 @@ class ImguiModule : public Archimedes::Module {
|
|||||||
|
|
||||||
#ifdef WINDOW_SDL3
|
#ifdef WINDOW_SDL3
|
||||||
#ifdef RENDERER_OPENGL
|
#ifdef RENDERER_OPENGL
|
||||||
auto windowInit() { return ImGui_ImplSDL3_InitForOpenGL(window->getWindowImpl().getWindow(), window->getWindowImpl().getContext()); }
|
auto windowInit() { return ImGui_ImplSDL3_InitForOpenGL(window->getWindowImpl()->getWindow(), window->getWindowImpl()->getContext()); }
|
||||||
#endif
|
#endif
|
||||||
#ifdef RENDERER_SDL3
|
#ifdef RENDERER_SDL3
|
||||||
auto windowInit() { return ImGui_ImplSDL3_InitForSDLRenderer(window->getWindowImpl().getWindow(), renderer); }
|
auto windowInit() { return ImGui_ImplSDL3_InitForSDLRenderer(window->getWindowImpl()->getWindow(), renderer); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void windowShutdown() { ImGui_ImplSDL3_Shutdown(); }
|
void windowShutdown() { ImGui_ImplSDL3_Shutdown(); }
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void WindowModule::onLoad() {
|
|||||||
void WindowModule::run() {
|
void WindowModule::run() {
|
||||||
|
|
||||||
if(window) {
|
if(window) {
|
||||||
//window->doFrame();
|
window->doFrame();
|
||||||
} else {
|
} else {
|
||||||
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user