#include "imgui.h" #include "application/application.h" #include "rhi/renderer.h" #include "rhi/texture.h" #include "ShaderWriter/ShaderWriterPrerequisites.hpp" #include "ShaderWriter/VertexWriter.hpp" #include "ShaderWriter/CompositeTypes/MixedStructHelper.hpp" #include "ShaderWriter/CompositeTypes/IOStructInstanceHelper.hpp" template< sdw::var::Flag FlagT > using PosColStructT = sdw::IOStructInstanceHelperT , sdw::IOStructFieldT< sdw::Vec4, "colour", 1u>>; template< sdw::var::Flag FlagT > struct PosColT : public PosColStructT { PosColT(sdw::ShaderWriter& writer, sdw::expr::ExprPtr expr, bool enabled = true) : PosColStructT{ writer, std::move(expr), enabled } { } auto position()const { return this->getMember<"position">(); } auto colour()const { return this->getMember<"colour">(); } }; class arona_application : public application { public: ~arona_application() override { delete texture_; } void draw_gui() override { ImGuiIO& io = ImGui::GetIO(); { static float f = 0.0f; static int counter = 0; ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) ImGui::Checkbox("Another Window", &show_another_window_); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f if (ImGui::Button("按钮")) // Buttons return true when clicked (most widgets return true when edited/activated) counter++; ImGui::SameLine(); ImGui::Text("counter = %d", counter); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); texture_->draw(); ImGui::End(); } } void init_imgui(ImGuiContext* in_context) override { ImGui::SetCurrentContext(in_context); } void post_init() { texture_ = load_texture(R"(\\192.168.1.104\nas\NanakoDisk\可爱二次元\61280855_p9_waifu2x_art_noise2_scale.png)"); using namespace sdw; VertexWriter writer; writer.implementMainT( [&](VertexInT in, VertexOutT out) { out.colour() = in.colour(); out.position() = in.position(); out.vtx.position = in.position(); } ); renderer_->compile_shader(&writer); } private: bool show_another_window_ = true; texture* texture_ = nullptr; }; int main(int argc, char* argv[]) { arona_application app; window_params params = {}; params.title = "Hello World"; params.width = 1280; params.height = 720; params.hi_dpi = true; params.resizable = true; app.init(params, argc, argv); app.post_init(); return app.run(); }