kunitoki / yup

YUP is an open-source library dedicated to empowering developers with advanced tools for cross-platform application development.
Other
55 stars 6 forks source link

how to use opengl render on windows? #23

Closed iomeone closed 15 hours ago

iomeone commented 6 days ago

How can I enable OpenGL rendering on the Windows platform? I've been trying for a long time without success, and I hope you can provide some suggestions.

kunitoki commented 5 days ago

Haven't tried yet, but should definately be possible.

kunitoki commented 4 days ago

Let's keep it open, going to have a look

kunitoki commented 4 days ago

I've started doing some changes but unluckily my windows VM only supports GL up to 3.3 and Rive needs at least 4.2 so i'm unable to validate that the changes work. Can try to open a PR and you can try tomorrow.

kunitoki commented 3 days ago

I started working on https://github.com/kunitoki/yup/pull/24 which should allow better rendering backend selection. Still not perfect, but should be possible to enable opengl on windows.

You will have to define YUP_RIVE_USE_OPENGL=1 when configuring your application (in cmake as PUBLIC definition), then when you create a yup::DocumentWindow, you can pass opengl as context api to use:

struct MyWindow : public yup::DocumentWindow
{
    MyWindow()
        : yup::DocumentWindow(yup::ComponentNative::Options()
            .withGraphicsApi(yup::GraphicsContext::OpenGL))
    {}
};

Beware i haven't tested it for running.

iomeone commented 2 days ago

I was able to build it for the opengl branch on windows 10 with vs2022, but when I ran it, nothing appeared. Then, I investigated further. In the function: void GLFWComponentNative::renderContext() I added:
glfwSwapBuffers (window); right after: context->tick();

After making this change, the animation started to display!

kunitoki commented 2 days ago

Nice! Will give it a spin and update the PR

kunitoki commented 2 days ago

I have updated the PR with the changes you suggested. Please let me know if it's working for you, it would be nice if you could send here some screenshots of your app running !

iomeone commented 17 hours ago

Yes, the current code on the main branch can run using OpenGL. Thank you!