Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: multiple viewports

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2001
    Location
    wrwrqwrqw
    Posts
    13

    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.
    Thanx

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 1969
    Location
    Munich,Germany
    Posts
    227

    Re: multiple viewports

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

    Chris
    yes

  3. #3
    Member Newbie
    Join Date
    Aug 2000
    Posts
    32

    Re: multiple viewports

    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

    ...

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2001
    Location
    wrwrqwrqw
    Posts
    13

    Re: multiple viewports

    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.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Dec 1969
    Location
    Munich,Germany
    Posts
    227

    Re: multiple viewports

    I don't think I get it.

    Why don't you just make

    OnLeftMouseButtonDown
    make viewport1
    draw in viewport1

    Chris
    yes

  6. #6
    Junior Member Newbie
    Join Date
    Sep 2001
    Location
    wrwrqwrqw
    Posts
    13

    Re: multiple viewports

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

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: multiple viewports

    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.

  8. #8
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: multiple viewports

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

  9. #9
    Junior Member Newbie
    Join Date
    Sep 2001
    Location
    wrwrqwrqw
    Posts
    13

    Re: multiple viewports

    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.

  10. #10
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: multiple viewports

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

Page 1 of 2 12 LastLast

Similar Threads

  1. Multiple viewports
    By EugChriss in forum Vulkan
    Replies: 2
    Last Post: 03-29-2018, 06:54 PM
  2. Multiple Viewports, Multiple Textures - 3D
    By Cyndy in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 04-08-2010, 04:47 PM
  3. multiple viewports
    By jra3084 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-29-2003, 08:52 AM
  4. Multiple ViewPorts
    By PlayBoy in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-08-2003, 02:02 PM
  5. Multiple viewports?
    By spdow in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-16-2001, 04:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean