Multiple OpenGL forms

Started by
19 comments, last by Jayce 22 years, 2 months ago
Hi there! I''m writing this leveleditor in Delphi 6 for the 3d engine my team is developing. It''s an MDI application with 4 MDI childs (three 2d views and one 3d view). The 3d view is an OpenGL window and works perfectly but I can''t seem to have more than 1 OpenGL window in this application at the same time. Anyone knows how to solve this one? Jayce http://www15.brinkster.com/jccommandeur
Advertisement
I have Borland Builder, which uses Delphi forms -- and the simple answer is that you can''t use more than one OpenGL context in an application. For my multi-form apps, since the OpenGL instance is created on the form''s creation, I move the

Application->CreateForm(__classID(TOGLWin),&OGLWin);

Line to the point where the form is needed. If you want two forms displayed at the same time, you (as far as I know) cannot do this. The TApplication class holds the device context, and multiple calls to GetDC() to retreive it receive clones, that cause errors.

--Cirian
Hi Cirian,

Thanks for your answer. I''ve suspected this all along and a few little experiments proved it. Glad to see it confirmed on this forum too. Guess I need to think about another sollution now, because I really need 4 seperate views in my program. Any ideas?

Bye,
Jayce
http://www15.brinkster.com/jccommandeur
Well, I''m writing a level editor in VB for my C game engine which both use OpenGL, and have found that you need to set up each of the child windows as a separate OpenGL window. Each must have a hDC and a hRC, which must be set using the wgl* functions before any rendering is done. Also, when you want to render to a particular window, you must first select it''s Rendering Context, with wglMakeCurrent (I think that''s the function, anyway) I don''t know if the wgl* functions apply in Delphi, but this is how I''m doing it in VB, and it''s working perfectly so far (and I''m almost finished). There must be Delphi equivalents...

iNsAn1tY - the place where imagination and the real world merge...
Try http://uk.geocities.com/mentalmantle - Now updated!
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Hi iNsAn1tY,

This is what I thought I should do. I have this OGLform-class which sets up the form to use OpenGL for rendering and each for has its own hDC and hRC but it doesn''t seem to work. You''re saying that it IS possible to have multiple MDI child forms at the same time and set them up for OpenGL? If so, I really need to take another look at my code. Something must be wrong here. :-)

Oh btw, I checked out your website but most screenshots aren''t there?

Bye,
Jayce
Spose im writing some sort of editor, so i put 4 VB pic boxes on a form. Each of them has their own DC, so each of them can get their own RC and get rendered to right? So i use wglMakeCurrent(picX.hDC, picX_hRC) or something to switch targets?

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Well; it all stems to the DC problem -- you can have one OpenGL context per DC, unfortunately, in C++Builder at least, the global TApplication class holds this DC, all children (forms, images, buttons etc) that contain a Canvas property have the same DC as the App. I think the only way around this is:

A) Request another DC from Windows (tricky)
B) Combine the viewports to one form -- it may seem like a bad compromise, but it is guaranteed to work.
Its defintely possible to have multiple OpenGL windows in a single app. Ive done it before and never ran into any troubles. Id say definately check your code
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Maximus,

Care to tell us how you''ve done that? :-)

I have something working here now. Each form has its own DC and RC and in each paint event for each form I activate the current rendering context (using wglMakeCurrent) using this forms DC and RC. This seems to work, meaning that it should be possible to have as many ogl forms as you want. I don''t know if the same applies for pic boxes. I would guess so.

Later,
Jayce
Jayce, it definately possible to create multiple child windows in an MDI Form in Windows. I don''t know how to do it in Delphi (I''m not a Delphi programmer, I specialize in C and VB), but there must be a conversion for the wgl* commands. How are you actually doing the setup of the OpenGL windows? Immediately after they are created? I create all my windows, then call a function which does the setup of the rendering context. I send the child window by value to the function, but I suppose you could just send the hDC...

Oh, and about the images on my site, I know they''re not there. Only complex1 is finished, and I''m getting some nice screenshots together to post. All the other maps are under construction at the moment, because like I said, my level editor isn''t completely finished at the moment...

iNsAn1tY - the place where imagination and the real world merge...
Try http://uk.geocities.com/mentalmantle - Now updated!
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]

This topic is closed to new replies.

Advertisement