Search code examples
openglopengl-3

How should I implement sub-windows in my OpenGL viewport?


How should I implement sub-windows in my OpenGL viewport? Inside my viewport, I want to reserve some space on the left for labels, and some space around the edges as a border. I've got all the coordinates figured out and everything is displaying properly. My problem is clipping the things in one subwindow that are spilling over into the others. I can't seem to figure out what the OpenGL 3.3, core context way of doing things is. Is it to

  • use per-vertex clipping?
  • a scissor test?
  • a stencil test?
  • associate a framebuffer with different parts of my window?

Which commands should I be looking at?


Solution

  • Before I spend time writing a full answer, I would like you to confirm that this is what you were describing in your original question:

    *---------------------------------------*
    | ------------------------------------- |
    | |   |                               | |
    | |   |                               | |
    | |   |                               | |
    |C| A |              B                |C|
    | |   |                               | |
    | |   |                               | |
    | |___|_______________________________| |
    *---------------------------------------*
    
    A = Labels
    B = Main Window
    C = Border