Can be made an MDI application in OpenGL

As I said in the title can be made an application in OpenGL that uses the MDI of VC++ ? I’m curious because I see some topics about this. How does the main frame talk with the child frame (the main frame is a MFC window and the child frame is a OpenGL window). I’m curious. IF someone can explain it to me I’ll appreciate.

NewROmancer

Thats no problem, because the child frame is a DC (maybe CDC in MFC?). This way you could reach place it in the child frame. Then you make a render context from the dc and you can render on it with openGL. You just need an render context for each child window (supposing you want to render different views…).

Kilam.

You can actually have only ONE rendering context per document and then use the several DCs for each view with wglMakeCurrent…

Basically, for each view :
wglMakeCurrent(m_pDC->GetSafeHdc(),GetDocument()->m_hRC);

Easy, isn’t it ?

Eric

Yep, right. Views was the wrong word in my comment, I meant different objects, display lists… Then you need a second render context.

So I can combine MFC with OpenGL. This sucks! You see, I can define in MFC an object derived from CMDIChildWnd and paint in it whatever i want. And I can theoretically make 4,5 of this objects and to have multiple instances of it. I don’t know if this is good - anyway I don’t see the computer that can make all this run smoothly. The possibility as an idea is good but it only confuses the programmer. And personally I didn’t ever see a program that has simultaneously two opengl Windows.

NewROmancer

I am developing several professional applications (3) that are using MDI and OpenGL… I could send you snapshots if you want to see an MDI application with more than two OpenGL windows…

The thing is, using MDI and OpenGL is useless for games… As far as other types of applications are concerned, it is a good solution…

The biggest problem when using MDI and OpenGL is animation : you need to use timers to refresh your views at fixed intervals. If you use the same techniques than in games (refresh as much as you can !), the interface is never updated (menus, toolbars, …, coz’ these updates take place during the Idle time of the application (OnIdle in your CWinApp). If you spend your time refreshing, there is no Idle time and no message processing…

Well, if you need further info, just ask…

Regards.

Eric

You can SetFocus to another window on a SetTimer basis so all the window can process their message queue. I’m sure that this thing can be done. And I learn OpenGL to make games. Any other things I make with MFC (DC) aso. And trust me I know a lot of Win programming. What I don’t know is how to bound the OpenGL window to the client area of the parent window. When I make generally Win programming I derive a class from CMDI ChildWindow and I paint in it. So can I paint an OpenGL Window in a MDI Child Window?
In fact that was my question.

NewROmancer.

I stick this in my GL viewports OnSize() and OnPaint():
HDC hDC = ::GetDC(this->m_hWnd);
wglMakeCurrent(hDC,m_hGLContext);

This works well when your shuffling and resizing the child frames around or tiling them. You could have multiple GL frames within your child frame as well using static splitters.

I’ve been trying to create a certain configuration. My child frame has one vertical static splitter. The left pane is a CTreeView. The right is a CView used for my GL context. Ok I have that and it works well. Now what I would like to do is nest a 2x2 Dynamic splitter within the right pane. So when I drag the dynamic splitter up from the bottom, a new GL CView would be created. When I drag the dynamic splitter back down the GL CView would be destroyed. Same for the vertical dynamic splitter. Drag “open” create, drag “shut” destroy. Havent figured this one out just yet. Solidworks www.solidworks.com has this look.

Wow, didn’t know by now that SolidWorks got that feature… Maybe I should do the same in my App :wink:

Ok, my idea for this problem: Just generate all 4 dc’s and let them be active everytime. When the splitter is completely on the left/top, then the dc size is simply zero and you dont have to render (don’t try to render then, some gfx-cards will crash…).
So you don’t have to new them all the time.

Are you doing some kind of feature modeller (sounds like… tree on the left, model on the right :wink:

Regards,

Kilam.

Hi Kilam
Ive worked with SW98 SW98Plus & SW99, they all had the same look. Its a very comfortable gui for Windows people. That’s why Id like to use that style of gui.

Yes Im attempting to create a modler. Im not a professional programmer by any stretch of the word. Its just a hobby I guess.

I like your idea of not having to create/destroy the CViews. You can set a min height or width for the dynamic pane. Once it gets to this point it snaps shut. I could set a flag in each CView telling it to render based on CSplitterWnd::GetRowInfo, GetColumnInfo. Or I have world height and width member variables I could test.
This way each CView could regulate itself instead of the Child frame policing the CViews.

Static and dynamic splitters aren’t too bad to code. I just cant figure out how to nest a dynamic within a static or if that’s even what Im looking for. I could nest statics within statics all day, but a static splitter is always visible. Not what Im after. Also Dynamic splitters come with free hscrolls & vscrolls by default I believe. This would be
simple to link them with my Projection matrix to perform panning in each pane.

Do you or anyone else in this thread know of some example code for this style? Ive asked the guys/gals on the MFC group 4 different times with no luck. Im pretty sure Id need 4 CView instances connected to the same
Doc Template. This way actions performed on geometry in one pane would be reflected in all panes. But each CView would have its own Modleview and Projection matrixes. This way I could pan. zoom, rotate each CView independently.

Sean

So you wanna say that for making an OpenGL window I need the DC from an registered window? Then how I can access directly the video card if I make it through an DC. I can paint on the DC by myself.
Please explain me the architecture…

NewROmancer