memononen / nanovg

Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.
zlib License
5.06k stars 767 forks source link

Direct opengl render #628

Closed ghost closed 1 year ago

ghost commented 2 years ago

Something that was asked sometimes... if ever it is not yet here, very rough basis, sorry.

memononen commented 2 years ago

Why would you need to do this?

ghost commented 2 years ago

I needed this several times before, and searched forums. Several other persons wanted this, finally I gave up. Now I feel I'll need it soon, so this time, this is here (just the basis).

This is for having for example easy bitmap display, text rendering, easy and beautiful drawing, as well as all you can imagine to do with OpenGL (ambient occlusion on 3d cubes, particle effects or anything).

On Sun, Apr 24, 2022, 22:24 Mikko Mononen @.***> wrote:

Why would you need to do this?

— Reply to this email directly, view it on GitHub https://github.com/memononen/nanovg/pull/628#issuecomment-1107912102, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYOV4ZPAEUPRFWRXHM2AYELVGWUW5ANCNFSM5UGNQX5Q . You are receiving this because you authored the thread.Message ID: @.***>

mulle-nat commented 2 years ago

This approach has the problem that nanovg caches the draw commands, so the OpenGL calls will appear before previously executed nanovg drawing commands in the same frame. I have no problem mixing OpenGL and nanovg, by using multiple nvgBeginFrame and nvgEndFrame calls in the same screen frame. I execute OpenGL after a nvgEndFrame and then resume my nanovg code with nvgBeginFrame.

ghost commented 2 years ago

I was sure to have made the call of this "direct OpenGL rendering" code after, needs more tests on my side. I will double-check soon, and will try your method.

On Sun, Apr 24, 2022, 23:22 Nat! @.***> wrote:

This approach has the problem that nanovg caches the draw commands, so the OpenGL calls will appear before previously executed nanovg drawing commands in the same frame. I have no problem mixing OpenGL and nanovg, by using multiple nvgBeginFrame and nvgEndFrame calls in the same screen frame. I execute OpenGL after a nvgEndFrame and then resume my nanovg code with nvgBeginFrame.

— Reply to this email directly, view it on GitHub https://github.com/memononen/nanovg/pull/628#issuecomment-1107921027, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYOV4ZLVAG23Q5U6JEWDVBTVGW3TBANCNFSM5UGNQX5Q . You are receiving this because you authored the thread.Message ID: @.***>

ghost commented 2 years ago

mulle-nat:

This approach has the problem that nanovg caches the draw commands, so the OpenGL calls will appear before previously >executed nanovg drawing commands in the same frame. I have no problem mixing OpenGL and nanovg, by using multiple >nvgBeginFrame and nvgEndFrame calls in the same screen frame. I execute OpenGL after a nvgEndFrame and then resume >my nanovg code with nvgBeginFrame.

john-j-h-doe:

I was sure to have made the call of this "direct OpenGL rendering" code after, needs more tests on my side. I will double-check soon, and will try your method.

@mulle-nat:

That was not voluntary on my side at first, this will make my day

mulle-nat commented 2 years ago

Works for me though :man_shrugging: as in this demo, where the teapot is old OpenGL and all the rest is nanovg. opengl-mix The teapot draws over the lower bar and below upper bar. Expect no further help from me though.

memononen commented 2 years ago

Multiple nvgBeginFrame()/nvgEndFrame() pairs or rendering to texture and using that within the nanovg is the way to go.