PDA

View Full Version : doubts about opengl context



ale211734
03-31-2015, 08:34 AM
Hello,
I have some doubts.

I should draw some object in this way:

rendering context 1:
if (visibleA) renderA();
if (visibleB) renderB();
FrontView();

rendering context 2:
if (visibleA) renderA();
if (visibleB) renderB();
SideView();

rendering context 3:
if (visibleA) renderA();
if (visibleB) renderB();
TopView();

Every visibleA and visibleB property is relative to one rendering context so I am able to disable A in the second rendering context and draw A in other rendering context.
Every rendering context have a different view about A and B.
Were possible use a single rendering context to do it?
Now my problem is that vbo should be shared or duplicate in rendering context. I would like know what's the better and simple way to do it.

Alfonse Reinheart
03-31-2015, 09:12 AM
Were possible use a single rendering context to do it?

I'm more perplexed by the fact that you are using multiple OpenGL contexts for this. You shouldn't use multiple contexts just to have different views of a scene.

ale211734
03-31-2015, 12:22 PM
I want to avoid using glViewport and map the screen into different parts. I want to use for each view a GLWidget a component opengl of qt. Maybe I can share the same context between multiple windows and implement my code?

mhagain
03-31-2015, 01:58 PM
I want to avoid using glViewport and map the screen into different parts. I want to use for each view a GLWidget a component opengl of qt. Maybe I can share the same context between multiple windows and implement my code?
Why do you want to avoid using glViewport? glViewport is much more efficient than multiple contexts for this kind of division of the scene.

I'm not personally familiar with qt but I am aware that it can be used for windowing; it would seem much more efficient (not to mention simpler) to use a single window, single context with multiple viewports than using multiple windows with multiple contexts.

GClements
04-01-2015, 12:30 AM
I want to avoid using glViewport and map the screen into different parts. I want to use for each view a GLWidget a component opengl of qt. Maybe I can share the same context between multiple windows and implement my code?

One of the QGLWidget constructors takes a QGLContext* as a parameter, and I can't see anything in the documentation stating that each widget requires a different context.

However: if you just want to be able to share data (buffers, textures), you should let each widget create its own context and use the shareWidget parameter to indicate that the contexts should share data.

GClements
04-01-2015, 12:39 AM
Why do you want to avoid using glViewport? glViewport is much more efficient than multiple contexts for this kind of division of the scene.

Efficiency isn't the only consideration. There are a number of valid reasons for using a separate widget for each view.

ale211734
04-01-2015, 12:45 AM
One of the QGLWidget constructors takes a QGLContext* as a parameter, and I can't see anything in the documentation stating that each widget requires a different context.

Yes I should try to pass the same context at different GLWidget. I want avoid to use glViewport because every view should be resizable. Can widgets that share the same context draw different object?
For example if I have two object A and B and I have three widget (widget1, widget2, widget3) that share the same context can implement this code?

widget1::Paint()
{
DrawA();
}

widget2::Paint()
{
DrawA();
DrawB();
}
widget3::Paint()
{
DrawB();
}