CHAI3DCHAI3D

normal Multiple display contexts

More
04 Feb 2016 08:59 #1

Is it possible to have multiple OpenGL windows running in the same application?

In the multiframes example, there are multiple views of the same interaction on one window. There isn't an example of having the haptic device cursor interacting with a model in one window, while having another window showing some analytics or incoming data. Is it possible to do something like this?

I'm running my application on a windows 8.1 64 bit machine, updated OpenGL version and using VS2013. I'm not familiar with using multiple OpenGL contexts and I thought I'd ask you first.

Please Log in or Create an account to join the conversation.

More
04 Feb 2016 09:34 #2

Supporting multiple windows (or display contexts) in a single application is possible. The challenge comes when you want these windows to render the same CHAI3D world as both both displays may need to share display lists, texture objects, shaders, etc... stored in GPU memory. The solution is platform specific and therefore additional code will need to be called depending on which developement framework you are using.


  1. If you are using GLUT and wish to create two or more windows, take a look at example 18-endoscope. GLUT does provide any way to share data between display contexts, but CHAI3D is capable on managing different texture IDs and display lists for each object. This approach is not recommended, but will do the trick if you want to do some quick prototyping.

  2. If you want to render numerical information or data, we suggest using the Qt framework (www.qt.io/developers/). A template can be found in the CHAI3D directory ./templates/Qt. More information about sharing data between display contexts in Qt can be found here>: doc.qt.io/qt-5/qopenglcontext.html

  3. Another option is to use frames to split a single display context into smaller windows as illustrated in example 27-multiframes. You could very easily modify that example to display text and graphs using the CHAI3D widgets.

Attachment frames.jpg not found

Attachments:

Please Log in or Create an account to join the conversation.

More
04 Feb 2016 17:49 #3

I hadn't tried the endoscope example. Thank you. In regards to your suggestions,

1. Why is this approach not recommended? Is there a chance of the data being corrupted when sharing across multiple windows? What are the problems with this method?

2. I more familiar with VS so I'd prefer to use it over Qt if I can. What makes Qt better for rendering numerical information or data?

What I'm looking to do is have a command center in one window (1), prompting the operator of potential areas of interest using text or graphs. This data comes from another source, not from the haptics interaction model on the other window (2). I hope to have command window working seperately from the haptics window, and the only information that may be shared between the two is a running simulation clock. Is this fine using the same approach used in endoscope, or is Qt will preferred?

Thanks in advance

Please Log in or Create an account to join the conversation.

More
04 Feb 2016 18:24 #4

The limitation with the dual GLUT window example comes from the fact that 3D objects are stored twice in the GPU memory (once for each display context, or GLUT window). CHAI3D manages to handle different object IDs for different display contexts so you can still render them, but it is not the most efficient way to proceed in particular if you are rendering very large scenes.

This said, the application you are describing seems to only share information that remains on the CPU, and therefore rendering models and data on different window displays should not be a problem.

Regarding Qt, you can run it without problem under Visual Studio. Qt also offers an elegant plugin that will allow you to easily adjust project settings for Qt from VS. More information can be found here: doc.qt.io/vs-addin/ The Qt templates which come with CHAI3D are designed for Visual Studio.

If you prefer to remain purely VS, you can also use the .NET framework which also allows you to develop application with forms and widgets, however .NET is much more finicky and we would not recommend it if you still need to learn about it from scratch. In that case you are doing a better investment by studying Qt for a few evenings!

Please Log in or Create an account to join the conversation.

More
09 Feb 2016 20:39 #5

Thanks for your help. I will look into installing the Qt framework and try to move my application over to a Qt application inside VS if I need to. I recently have got a separate window working and have a live data feed using cScope objects. They might work decently well for what I'm trying to do, but I can see how you might suggest using Qt now.

Please Log in or Create an account to join the conversation.

More
10 Feb 2016 01:06 #6

I installed Qt and tried to run the example template application chai3d provides. It builds fine, but the screen is always black. I'm sure my graphics drivers are up to date and opengl works on my machine because my other OpenGL applications still run correctly. Where should I look to fix a black screen when running Qt in Visual Studio?

Please Log in or Create an account to join the conversation.