multiple viewports

i made a program with 3 different viewports. And now i wanna draw in one of those viewports. What command can i use to tell the program which viewport to use ? By default the last created viewport is selected.

you always draw into the last viewport you created, so you have to recreate the others to draw into those.


One solution to that would be to create viewports in your display routine:

create viewport 1
draw to it

create viewport 2
draw to it

i do :
*make viewport1
*draw in viewport1
*make viewport2
*draw in viewport2
*make viewport3
*draw in viewport3

but now i wanna draw in viewport1 when i push the left mouse button, in the function OnLeftMouseButtonDown. So I want to work with the coordinates in viewport1.

I don’t think I get it.

Why don’t you just make

make viewport1
draw in viewport1


the first viewport must redraw constantly. In the onleftmousedownbutton, i wanna draw some extra stuff in the first viewport.

Why don’t you create 4 windows then?
You want to just update one viewport out of 4 constantly. The problem is, that when you use doublebuffer, you have to redraw all other viewports as well.

Please repost an EXACT description of the problem you are facing.

i have 3 viewports. one rectangle at the upper half of the client area, and 2 squares at the lower half of the client area. In my Ondraw function, those 3 viewports are constantly redrawn, that works fine. I can draw in all viewports seperately and every viewport has its own coordinatesystem.
But now, when i click somewhere in the first viewport(upper half of the window), i have to make calculations with the coordinates of the point where i clicked. The parameters of the Onleftmousebutton are parameters of the whole window, not of 1 viewport. So if my first viewport reaches from -30 to 30 in Y range, i need these coordinates when i click somewhere. I cant calculate these coordinated out of the getClientRect() because these are not the coordinates from my first viewport.

Then store the upper-left coordinate (window coordinate, relative to the whole window) of each window and do:

mouse_relative_x = mouse_x - current_viewport_x;
mouse_relative_y = mouse_y - current_viewport_y;

Then you will have the pixel-coordinates from the upper-left corner of the current viewport (you can also store the center of each viewport, just depends on what you want).
Or is that not your problem? hmm…

oops just wanted to post about the same thing Micheal said. He was faster )

thanx both

Sorry dude…

Strange. I’m currently eating cookies, and everytime I crunch, my monitor seems to flicker… hmm… well, anyway.

Michael, My problem exactly… seems like too much strain on my eyes is doing this… or is it the monitor refresh rate???


I thnin it has something to do with the weather forecast…

but i think we are straining a little bit OT


Hi all

After reading this thread i had a thought. Could multiple view ports be achived using multiple rendering contexts. and using the wglMackeCurrent function to select the view port u want to draw in

Ive just tryed this and have had weird results. does anyone know why this dosnt work


Well, I think it has something to do with that the head crunches too then… So you are moving along the trace for a short period, which reduces the refresh rate relatively to the eyes…

Uhm… ZeeBoy… Did you create multiple windows each with a opengl context applied? That shouldn’t cause any problems.