Results 1 to 2 of 2

Thread: Drawing a rectangle using two mouse clicks

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2006
    Location
    UK
    Posts
    6

    Drawing a rectangle using two mouse clicks

    Hi,

    I'm trying to draw a rectangle using two mouse clicks, over an existing BMP image.

    So what I would like to happen is that the first click designates where the top-left of the rectangle will be, and then the second click designates where the bottom-right of the triangle would be.

    Any and all help is very welcome and appreciated!

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: Drawing a rectangle using two mouse clicks

    grab both points screen x,y positions from the user input

    then setup a 2d orthogonal projection, so the window corresponds to a 1pixel == 1 unit mapping ( check the faq or red book or wiki )

    + then its just drawing a quad with
    Ax,Ay
    Ax,By
    Bx,By
    Bx,Ay

Similar Threads

  1. Drawing rectangle by mouse shows weird shape
    By michaelpiano in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-17-2016, 07:49 AM
  2. Mouse Clicks
    By Erin C. in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-28-2008, 07:32 AM
  3. How to get 3d coords from mouse clicks - drawing a curve...
    By BigShooter in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-31-2003, 01:38 AM
  4. About Mouse clicks and rectangles
    By DeSeis in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-01-2001, 09:46 AM
  5. Testing for Mouse Clicks
    By jeremyp in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 04-14-2001, 10:23 AM

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