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