Archived

This topic is now archived and is closed to further replies.

Viewports & Splitters

This topic is 5041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

what the best way to create 4 views in mfc 1 3d view and x,y,z views with a grid for designing etc or how can i implement Q3Radiant source in to my app like the splitters and viewports etc [edit: made your title less obnoxious] [edited by - Superpig on February 21, 2004 10:10:46 PM]

Share this post


Link to post
Share on other sites
for pure MFC, obviously, 4 child windows. however, you are using either OpenGL / DirectX with MFC, so I''d have a camera class, with a viewport structure inside, and render each cameras individually. the 4 viewports would be

glViewport(0, 0, w/2, h/2);
glViewport(w/2, 0, w, h/2);
glViewport(0, h/2, w, h);
glViewport(w/2, h/2, w, h);

and the main render loop would be something like


OpenGL::Display()
{
glCLear(GL_COLOR_BUFFER_BITS | GL_DEPTH_BUFFER_BITS | GL_STENCIL_BUFFER_BITS);

for(int i = 0; i < numCameras; i ++)
{
Camera[i].Display()
}
glutSwapBuffers();
}



void Camera::Display()
{
glViewport(vp.x, vp.y, vp.w, vp.h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMulMatrixf(projectionMatrix);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMulMatrixf(modelviewMatrix);

Scene.RenderFromCamera(*this);
}

Share this post


Link to post
Share on other sites
This is the last help I''m giving you on this; I''m not going to write your program for you. Like I said, buy an MFC book, that''s how I learnt all this. To create a splitter window like the one used in q3radiant, you need to declare a CSplitterWnd object in your CMainFrame definition. Put it next to the ones the AppWizard created for the CToolbar and CStatusBar, and call it m_wndSplitter. q3radiant actually uses two splitters, one nested inside the other, depending on which configuration your use, but that''s advanced, and you needn''t worry about it. In your CMainFrame implementation, move to CMainFrame::OnCreate and use the m_wndSplitter.CreateStatic() function to actually instantiate a splitter. Then use m_wndSplitter.CreateView() to create all the views for the splitter. For a q3radiant-style right, top, front and 3D layout, specify three 2D views, and a 3D view. That is by no means all (you have to size the windows appropriately, refresh them when required, etc.) but it''s enough to get you started...


Windows 95 - 32 bit extensions and a graphical shell for a 16 bit patch
to an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can''t stand 1 bit of competition.

Share this post


Link to post
Share on other sites
Ah, my mistake. You need to put the code for the splitter creation in CMainFrame::OnClientCreate, which you need to create from ClassWizard or code on your own...


Windows 95 - 32 bit extensions and a graphical shell for a 16 bit patch
to an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can''t stand 1 bit of competition.

Share this post


Link to post
Share on other sites
you will need to derive a viewport class from CView to use CSplitterWnd. at least, i couldn't find a way around it.

also, use WM_ERASEBKGND, not WM_PAINT to draw the window. I had a lot of issues with WM_PAINT.

[edited by - billybob on February 21, 2004 9:39:50 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by billybob
you will need to derive a viewport class from CView to use CSplitterWnd. at least, i couldn''t find a way around it.

also, use WM_ERASEBKGND, not WM_PAINT to draw the window. I had a lot of issues with WM_PAINT.


1. You don''t need to derive a viewport class from CView. You can just add a CSplitterWnd member to CMainFrame, and create the splitter and add views to it in CMainFrame::OnCreateClient().

2. You shouldn''t use OnPaint to do the drawing in a CView. You should use the default OnDraw handler. It specifically states in the CView documentation that you should not use OnPaint to draw. And you only need to use the OnEraseBkgnd handler if you''re using OpenGL, because there are some issues with overdraw if you allow MFC to process that message...


Windows 95 - 32 bit extensions and a graphical shell for a 16 bit patch
to an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can''t stand 1 bit of competition.

Share this post


Link to post
Share on other sites