Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: multiple views, split screen

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    8

    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:
    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:
    https://www.dropbox.com/s/ibfdpcia6z...glviewport.png

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

    Any help would GREATLY be appreciated!
    Last edited by ducle91; 08-05-2013 at 12:55 PM.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2012
    Location
    Bremen, Germany
    Posts
    167
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    8
    Quote Originally Posted by hlewin View Post
    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.
    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.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Nov 2012
    Location
    Bremen, Germany
    Posts
    167
    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.

  5. #5
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    498
    Quote Originally Posted by ducle91 View Post
    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:
    Code :
                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.
    Code :
                GL.Viewport(0, 0, sceneView.Width, sceneView.Height);
                GL.Scissor(0, 0, sceneView.Width, sceneView.Height);

    This sets the viewport to the entire window

    Code :
                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.

  6. #6
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    8
    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?

  7. #7
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    498
    Quote Originally Posted by ducle91 View Post
    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.

  8. #8
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    8
    Quote Originally Posted by GClements View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •