Skip to main content
gamedev.net
🔒 Locked

4 viewports

Started by rkoostber 2 replies 250+ views
Original Post
rkoostber
rkoostber
Hello, I''m working on a 3d editor which someone asked me to make to design levels for his 3d engine. Now I have a question. I have now come to the point where I want 4 viewports (3 ortho, 1 persp.) instead of only one. My questions are: 1) How do I get 4 OpenGl viewports? 2) Is it possible to have more Opengl viewports on one windows window? P.S. I know how to make an opengl window, just not how to make four. P.P.S. I used an MFC Splitter window before, but could only get one screen to work in opengl, the rest just didn''t drw what I wanted it to draw. Also, I couldn''t update the frame on any other time than when a WM_PAINT message arrived (not often). Some help on this would be very pleasent too. Thanks in advance
real_man
real_man
No one has replied so I will give your question a try...

The first thought that comes to mind is to directly edit hWnd and render into only that section of the screen. This means you must change the viewport 4 times and hWnd 4 times every frame.

The other thought that comes to mind is to use DirectX. I am pretty sure you can do it in DirectDraw or D3D or something...

This will take some research. I would recomend whiping out the dissassembler and dissassembling someting like 3dsmax or Worldcraft and seeing how they do it.
Gorg
Gorg
You just call glViewPort 4 times with different sizes. ex :

you have a 800 x 600 screens :

//lower left
glViewport(0,400,0,300);
//draw lower left

//upper left
glViewPort(0, 400,300,600);
//draw upper left

//upper right
glViewPort(400, 800,300,600);
//draw upper right

//lower left
glViewport(400,800,0,300);
//draw lower left

swapbuffers();

When you change the viewport, you need to reset your Matrices, which is probably what you want anyway, because the object will be probably be viewed from different angle.

Julien
Julien
You can also use splitters like you said, but you have to make sure that your current OpenGL context from the current view is active, I mean you should call glmakecurrent (or something like that) at the begenning of your rendering function. Be sure you''ve shared textures between all your OpenGL rendering context.

Give a look at my site, you should see a screenshot of splitters with 4 differents OpenGL views

My Web Page

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.