multiple views, split screen

Hello everyone, I’m having some trouble rendering the bottom half of my split screen using glViewports. I also want to implement each screen to have its own control but it seems like the entire scene only have one control and not 2 separate control of its own. Here is a snippet of the code:

   GL.LoadIdentity();
            GL.Enable(EnableCap.ScissorTest);
            GL.MatrixMode(MatrixMode.Projection);
            GL.Viewport(0, 0, sceneView.Width, sceneView.Height);
            GL.Scissor(0, 0, sceneView.Width, sceneView.Height);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.Ortho(0, 0, sceneView.Width, sceneView.Height, -1, 1);
            GL.PushMatrix();
            GL.Flush();

    
            GL.LoadIdentity();
            GL.Enable(EnableCap.ScissorTest);
            GL.MatrixMode(MatrixMode.Projection);
            GL.Viewport(0, sceneView.Height / 2, sceneView.Width, sceneView.Height / 2);
            GL.Scissor(0, sceneView.Height / 2, sceneView.Width, sceneView.Height / 2);
          Maths.ZAXIS);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.Disable(EnableCap.ScissorTest);
            GL.Flush();

Here is an image of what it looks like:

I’m using OpenTK and iCarus Scene Engine 3 for this project.

Any help would GREATLY be appreciated!

It looks like you’re trying to render on top of something that has already been drawn.
In the top half of your code snippet viewport is set to the whole Sceneview-width and height. In the bottom half only to half of that.
Not sure if this is really what you want to do… nonetheless: this can be done but maybe you have to clear the depth-buffer before rendering over the other half of the scene.
When looking at those halves as controls/widgets I’d expect each control to only render into it’s own area - hence setting the viewport in the top-half of the code to sceneview-width/-height halves also.

[QUOTE=hlewin;1253498]It looks like you’re trying to render on top of something that has already been drawn.
In the top half of your code snippet viewport is set to the whole Sceneview-width and height. In the bottom half only to half of that.
Not sure if this is really what you want to do… nonetheless: this can be done but maybe you have to clear the depth-buffer before rendering over the other half of the scene.
When looking at those halves as controls/widgets I’d expect each control to only render into it’s own area - hence setting the viewport in the top-half of the code to sceneview-width/-height halves also.[/QUOTE]

Thanks for replying. I tried clearing the depth buffer but it didn’t make any different, I still only have the top half rendered while the bottom half is still blue. I can’t seem to get a split-screen view with each screen having its own camera and controls.

Just read your source again:
In the top half of the source, you set your viewport to the whole Scene-view’s height. This should be halved I guess.
And another Thing: glOrtho is typically used as projection-matrix and not as modelview.


            GL.MatrixMode(MatrixMode.Projection);

This is redundant. Neither glViewport() nor glScissor() are affected by the matrix mode. The viewport transformation is distinct from the projection and model-view transformations.


            GL.Viewport(0, 0, sceneView.Width, sceneView.Height);
            GL.Scissor(0, 0, sceneView.Width, sceneView.Height);

This sets the viewport to the entire window


            GL.Viewport(0, sceneView.Height / 2, sceneView.Width, sceneView.Height / 2);
            GL.Scissor(0, sceneView.Height / 2, sceneView.Width, sceneView.Height / 2);

This sets the viewport to the top half of the window ((0,0) is the lower left corner).

The portion of the code which you show doesn’t include any drawing commands. The placement of those commands will affect what actually gets drawn.

thanks for the reply! I just realized that when I compiled my program, that the top half of the code doesn’t even execute, only the bottom half gets executed, any ideas as to why it’s doing that?

Try posting more complete code. Like, showing where stuff actually gets drawn.

All the stuff are drawn in a separate class, I just wanted to focus on how splitting the screen and having its own control. I know I’m suppose to draw something between each viewports but all the rendering are happening in another class.