Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: passing coordinates from mouse clicks

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2011
    Posts
    16

    passing coordinates from mouse clicks

    so I have this mouse(click,state,x,y) function that generates coordinates for each click, and I want to pass some clicks to another function that for example draws a polygon using those coordinates. how do I do this ? create new points in the mouse function, or is there some other way to pass along these click coordinates ?

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2011
    Posts
    11

    Re: passing coordinates from mouse clicks

    Quote Originally Posted by Jaymz
    so I have this mouse(click,state,x,y) function that generates coordinates for each click, and I want to pass some clicks to another function that for example draws a polygon using those coordinates. how do I do this ? create new points in the mouse function, or is there some other way to pass along these click coordinates ?
    Draws the polygon where?

    If you were just looking to draw in the top-down view, you have to derive OpenGL coordinates from your mouse coordinates.

    So, if you have a 640x480 viewport, where the origin is at the top left corner of the screen, you have to create a function that maps 0:640 to -1.0:1.0 and 0:480 to 1.0:-1.0:

    Code :
    gl_vert = toGlVert(mouse_xy); // You write this function
    // gl_vert: [mouse.x, mouse.y, 0.0f, 1.0f]

    And then you just send a collection of those verts to the GPU, in a VBO, as you usually would.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •