修改测试用例

This commit is contained in:
Nanako 2024-02-19 01:29:12 +08:00
parent 580c80d7eb
commit 1bcf313484
2 changed files with 45 additions and 50 deletions

View File

@ -6,102 +6,97 @@
#include "rhi/shader.h"
#include "rhi/texture.h"
struct arona_matrix
{
struct arona_matrix {
ImVec4 m[4];
ImVec4& operator[](int i)
{
ImVec4 &operator[](int i) {
return m[i];
}
};
class arona_application : public application
{
class arona_application : public application {
public:
~arona_application() override = default;
const char* get_entry_model() const override { return "arona"; }
const char* get_draw_ps_vertex_shader_entry() const override { return "defaultDrawPSVertexMain"; }
const char* get_shader_path() override { return R"(E:\Projects\Arona\Arona\shaders)"; }
void draw_gui() override
{
ImGuiIO& io = ImGui::GetIO();
{
const char *get_entry_model() const override { return "arona"; }
const char *get_draw_ps_vertex_shader_entry() const override { return "defaultDrawPSVertexMain"; }
const char *get_shader_path() override { return R"(E:\Projects\Arona\Arona\shaders)"; }
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::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::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
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)
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);
const bool width_changed = ImGui::SliderInt("test_width", &width, 1, 1024);
const bool height_changed = ImGui::SliderInt("test_height", &height, 1, 1024);
if (width_changed || height_changed)
{
drawer_->resize(width, height);
}
drawer_->draw();
texture_->draw();
// const bool width_changed = ImGui::SliderInt("test_width", &width, 1, 1024);
// const bool height_changed = ImGui::SliderInt("test_height", &height, 1, 1024);
// if (width_changed || height_changed) {
// drawer_->resize(width, height);
// }
// drawer_->draw();
// compute_shader_->compute(render_target_->get_width(), render_target_->get_height(), 1);
// render_target_->draw();
compute_shader_->compute(render_target_->get_width(), render_target_->get_height(), 1);
render_target_->draw();
ImGui::End();
}
}
void init_imgui(ImGuiContext* in_context) override
{
void init_imgui(ImGuiContext *in_context) override {
ImGui::SetCurrentContext(in_context);
}
void post_init()
{
texture_ = load_texture(R"(E:\Pictures\21992690_p0.png)");
compute_shader_ = renderer_->load_shader("computeMain");
pixel_shader_ = renderer_->load_shader("fragmentMain");
render_target_ = create_render_target(128, 128, texture_format::RGBA32_FLOAT);
compute_shader_->set_render_target("result", render_target_);
void post_init() {
texture_ = load_texture(R"(\\192.168.1.104\nas\NanakoDisk\可爱二次元\IMG_2745(20230507-020428).JPG)");
// compute_shader_ = renderer_->load_shader("computeMain");
// pixel_shader_ = renderer_->load_shader("fragmentMain");
drawer_ = create_pixel_shader_drawer();
drawer_->init(128, 128, pixel_shader_);
// render_target_ = create_render_target(128, 128, texture_format::RGBA32_FLOAT);
// compute_shader_->set_render_target("result", render_target_);
// drawer_ = create_pixel_shader_drawer();
// drawer_->init(128, 128, pixel_shader_);
}
void shutdown() override
{
void shutdown() override {
texture_ = nullptr;
compute_shader_ = nullptr;
pixel_shader_ = nullptr;
// compute_shader_ = nullptr;
// pixel_shader_ = nullptr;
render_target_ = nullptr;
// render_target_ = nullptr;
application::shutdown();
}
private:
bool show_another_window_ = true;
std::shared_ptr<texture> texture_ = nullptr;
std::shared_ptr<shader> compute_shader_ = nullptr;
std::shared_ptr<shader> pixel_shader_ = nullptr;
std::shared_ptr<pixel_shader_drawer> drawer_ = nullptr;
arona_matrix model_view_projection_ = {};
int width = 512;
int height = 512;
std::shared_ptr<render_target> render_target_ = nullptr;
};
int main(int argc, char* argv[])
{
int main(int argc, char *argv[]) {
arona_application app;
window_params params = {};
params.title = "Hello World";

@ -1 +1 @@
Subproject commit 0be061e3974d6a23bce95adb02f74ccb817fc4f5
Subproject commit e50fcb19924f03e7238bc6ce73a9649d087d1b67