forge icon indicating copy to clipboard operation
forge copied to clipboard

Find if accepting external OpenGL context is viable

Open 9prady9 opened this issue 8 years ago • 10 comments

There are two possible approaches regarding this topic:

  • Find if user created OpenGL context can be used with Forge(glfw/sdl) windows. As of now, some internal state (loading default fonts, color maps etc.) is initialized during window object construction (Window constructor code). The logic in this initialization should be exposed via functions appropriately if external context usage is to be given as an option to the user.
  • Other approach would be to abstract renderable objects such as Image, Chart etc. to be able to render them on user provided OpenGL Window, where forge's window class is not used at all. In this case, just the Image/Chart objects are rendered to which ever viewport is active. The user has to do multiple views in single window by themselves.

9prady9 avatar Sep 01 '16 11:09 9prady9

I have a few questions here. I quickly hacked together an Qt5 window for forge that seems to work, https://github.com/caseymcc/forge/commit/a78f29053b86a39d26db137dccc6f385d4b681b6

But as far as I could tell from the quick overview it to implement this. forge really doesn't care about the window as long as you don't call the window functions. Seems if you created a Chart and just called render making sure the current openGL context is properly setup it would draw.

Ill add a PR later for the Qt5 window (likely need a little info in the manner of how multiple windows are supposed the be handled), need to split it with the hunter functionality (cmake package manager) that I used.

caseymcc avatar Apr 28 '17 21:04 caseymcc

@caseymcc That is true - forge rendering user's can use their own windowing functionality - that was the intention behind the such design. As you said, the user has to take care of GL context. What do you need to know about multiple windows ?

9prady9 avatar Apr 29 '17 01:04 9prady9

Is it intended that the user can open multiple windows? If so in the the case of Qt5 I could make them dockable, dialogs or or split in the same window.

caseymcc avatar Apr 29 '17 04:04 caseymcc

Yes,we wanted to enable multi-window usage. However, this hasn't been tested extensively. You are welcome to try and report any bugs you may find!

9prady9 avatar Apr 29 '17 04:04 9prady9

Any updates here? Is it still possible to just draw into the current context without setting up a window?

beojan avatar Jun 20 '20 09:06 beojan

@beojan Unfortunately, no, there has been much work done in this direction yet.

Currently, fonts are currently set via window object. Thus this needs to be separated from Window so that the they will work out of the box. So basically, except font rendering rest of the stuff should work fine in a user provided OpenGL context even now.

Because fonts won't work, chart won't make sense. Image object's should render fine though.

9prady9 avatar Jun 20 '20 11:06 9prady9

@beojan A quick update. I have looked at the code and as of today font object used by Window object is separate from the font object's created for chart's internal use. Thus, even if Window class from forge isn't used, one should be able to still use rendering logic from other classes in a different OpenGL context.

Note that, a valid OpenGL context should be available to use forge's non-Window classes in that fashion. Hope this helps for your use case.

9prady9 avatar Jul 08 '20 08:07 9prady9

It appears Chart's render member function still requires a reference to a Window. Is there a dummy Window to be passed?

beojan avatar Jul 08 '20 09:07 beojan

Ah right, my bad. Window is being passed, although it can easily worked around since the object is only used to get unique window ID that is in turn used for internal book keeping of VAO objects.

If this object of Windows is replaced with a window identifier variable like int, then it should work out of the box. Unfortunately, that would require an API change and can't be done before 2.0 release.

9prady9 avatar Jul 08 '20 10:07 9prady9