Giter Club home page Giter Club logo

androidimgui's Introduction

AndroidImgui

介绍

Dear ImGuiopenglesvulkan为后端在android平台上的封装,支持加载图片纹理等,两个后端可以无缝切换,可以开箱即用

使用

set(CMAKE_CXX_STANDARD 20)

include(FetchContent)

FetchContent_Declare(
        AndroidImgui  # 你的库名
        GIT_REPOSITORY https://github.com/enenH/AndroidImgui.git  # GitHub库的URL
        GIT_TAG v1.4 # 你想要的分支或标签
)

FetchContent_MakeAvailable(AndroidImgui)  # 下载并使库可用


target_link_libraries(your_lib_name AndroidImgui)  # 链接库

示例

#include "ANativeWindowCreator.h"
#include "GraphicsManager.h"
#include "my_imgui.h"
#include "TouchHelperA.h"

int main() {
    auto display = android::ANativeWindowCreator::GetDisplayInfo();
    if (display.height > display.width) {
        std::swap(display.height, display.width);
    }
    auto window = android::ANativeWindowCreator::Create("test", display.width, display.width);
    auto graphics = GraphicsManager::getGraphicsInterface(GraphicsManager::VULKAN);

    graphics->Init(window, display.width, display.width);
    ImGui::Android_LoadSystemFont(26);
    Touch::Init({(float) display.width, (float) display.height}, true);

    auto image = graphics->LoadTextureFromFile("/sdcard/1.png");

    static bool flag = true;
    while (flag) {
        graphics->NewFrame();
        Touch::setOrientation(android::ANativeWindowCreator::GetDisplayInfo().orientation);
        ImGui::SetNextWindowSize({500, 500}, ImGuiCond_Once);
        if (ImGui::Begin("test", &flag)) {
            ImGui::Text("Hello, world!");
            ImGui::Image(image->DS, {100, 100});
        }
        ImGui::End();

        graphics->EndFrame();
    }
    graphics->DeleteTexture(image);
    graphics->Shutdown();
    return 0;
}

androidimgui's People

Contributors

enenh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.