View Full Version : multiple viewports
09-04-2001, 12:44 AM
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.
09-04-2001, 01:02 AM
you always draw into the last viewport you created, so you have to recreate the others to draw into those.
09-04-2001, 05:15 AM
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
09-05-2001, 04:55 AM
i do :
*draw in viewport1
*draw in viewport2
*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.
09-05-2001, 05:32 AM
I don't think I get it.
Why don't you just make
draw in viewport1
09-05-2001, 05:51 AM
the first viewport must redraw constantly. In the onleftmousedownbutton, i wanna draw some extra stuff in the first viewport.
09-05-2001, 05:56 AM
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.
09-05-2001, 05:57 AM
Please repost an EXACT description of the problem you are facing.
09-05-2001, 06:12 AM
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.
09-05-2001, 06:22 AM
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...
09-05-2001, 06:24 AM
oops just wanted to post about the same thing Micheal said. He was faster http://www.opengl.org/discussion_boards/ubb/smile.gif)
09-05-2001, 06:28 AM
thanx both http://www.opengl.org/discussion_boards/ubb/smile.gif
09-05-2001, 06:29 AM
Sorry dude... http://www.opengl.org/discussion_boards/ubb/smile.gif
Strange. I'm currently eating cookies, and everytime I crunch, my monitor seems to flicker... hmm... well, anyway.
09-05-2001, 08:34 PM
Michael, My problem exactly... seems like too much strain on my eyes is doing this.... or is it the monitor refresh rate???
09-05-2001, 11:12 PM
I thnin it has something to do with the weather forecast.... http://www.opengl.org/discussion_boards/ubb/wink.gif
but i think we are straining a little bit OT
09-06-2001, 02:22 PM
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
09-07-2001, 06:40 AM
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... http://www.opengl.org/discussion_boards/ubb/smile.gif
Uhm... ZeeBoy... Did you create multiple windows each with a opengl context applied? That shouldn't cause any problems.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.