ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
57.84k stars 9.92k forks source link

Running ImGui app on Arm Processor (Allwinner H3 with mali 400 -> orangepi one) #7564

Open ismilawd opened 2 months ago

ismilawd commented 2 months ago

Version/Branch of Dear ImGui:

Version 1.90.5, Branch: master

Back-ends:

imgui_impl_glfw + imgui_impl_opengl3

Compiler, OS:

Linux (on armv7)

Full config/build information:

No response

Details:

Hi dear ImGui. Im trying to run C++ ImGui app on arm cpu AllWinenr H3 with mali 400 GPU. It compiles but when I run it screen flashes black once then it gives me this error:

Glfw Error 65544: X11: RandR gamma ramp support seems broken MESA-LOADER: failed to retrieve device information libGL error: unable to load driver: mali_drm_dri.so libGL error: driver pointer missing libGL error: failed to load driver: mali_drm Failed to initialize OpenGL loader!

I have tried:

  1. put "#define IMGUI_IMPL_OPENGL_ES2" inside imconfig.h file
  2. use "#version 100" during init.

I got this when I ran "glxinfo"

OpenGL vendor string: VMware, Inc. OpenGL renderer string: llvmpipe (LLVM 6.0, 128 bits) OpenGL core profile version string: 3.3 (Core Profile) Mesa 18.0.5 OpenGL core profile shading language version string: 3.30 OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile OpenGL core profile extensions: OpenGL version string: 3.0 Mesa 18.0.5 OpenGL shading language version string: 1.30 OpenGL context flags: (none) OpenGL extensions: OpenGL ES profile version string: OpenGL ES 3.0 Mesa 18.0.5 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00 OpenGL ES profile extensions:

and when I run "glxgears" or "glmark2-es2" it works fine and displays 3D objects.

How can I fix it?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

#include <cstdio>
#include <GL/glew.h>
#include "imgui.h"
#include "backends/imgui_impl_glfw.h"
#include "backends/imgui_impl_opengl3.h"
#include <GLFW/glfw3.h> // Include glfw3.h after our OpenGL definitions

static void glfw_error_callback(int error, const char* description) {
    fprintf(stderr, "Glfw Error %d: %s\n", error, description);
}

int main(int, char**) {
    glfwSetErrorCallback(glfw_error_callback);
    if (!glfwInit())
        return 1;

    // Decide GL+GLSL versions
    const char* glsl_version = "#version 100";
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

    // Create window with graphics context
    GLFWwindow* window = glfwCreateWindow(200, 200, "Dear ImGui GLFW+OpenGL3 example", glfwGetPrimaryMonitor(), NULL);
    if (window == NULL)
        return 1;
    glfwMakeContextCurrent(window);
    glfwSwapInterval(1); // Enable vsync

    if (glewInit() != GLEW_OK) {
        fprintf(stderr, "Failed to initialize OpenGL loader!\n");
        return 1;
    }

    // Setup Dear ImGui context
    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    ImGuiIO& io = ImGui::GetIO(); (void)io;

    // Setup Platform/Renderer bindings
    ImGui_ImplGlfw_InitForOpenGL(window, true);
    ImGui_ImplOpenGL3_Init(glsl_version);

    // Main loop
    while (!glfwWindowShouldClose(window)) {
        glfwPollEvents();
        ImGui_ImplOpenGL3_NewFrame();
        ImGui_ImplGlfw_NewFrame();
        ImGui::NewFrame();

        // Here you can build your ImGui interfaces
        ImGui::Begin("Hello, world!");
        ImGui::Text("This is some useful text.");
        ImGui::End();

        // Rendering
        ImGui::Render();
        int display_w, display_h;
        glfwGetFramebufferSize(window, &display_w, &display_h);
        glViewport(0, 0, display_w, display_h);
        glClearColor(0.45f, 0.55f, 0.60f, 1.00f);
        glClear(GL_COLOR_BUFFER_BIT);
        ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

        glfwSwapBuffers(window);
    }

    // Cleanup
    ImGui_ImplOpenGL3_Shutdown();
    ImGui_ImplGlfw_Shutdown();
    ImGui::DestroyContext();

    glfwDestroyWindow(window);
    glfwTerminate();

    return 0;
}
ocornut commented 1 month ago

Can you clarify if the Failed to initialize OpenGL loader! comes from OUR loader displaying this message or from your code in main.cpp displaying this exact same message?

If the earlier: