CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Posts
    41

    Drawing lines & mouse output

    Hi all,

    I would like to draw a line on a GL screen by clicking on the starting point and the ending point within a specified region.

    Being rather new to openGL, i'm a bit confused as to what functions (or events) to use and what the general algorithm of doing this would be. This the general question...

    I have a clue that i would need some form of mouse event/function that returns to me the screen coordinates. Does such a function exist? If it doesn't is there a way of achieving this without too much effort?

    Thanks in advance...

  2. #2
    Join Date
    Aug 2002
    Posts
    879

    Re: Drawing lines & mouse output

    Without to know what type of application you want to program and which framework you want to use here are some useful links.
    For drawing lines with opengl
    http://www.cs.uccs.edu/~semwal/indexGLTutorial.html
    for capturing mouse events
    http://www.lighthouse3d.com/opengl/glut/index.php?9
    http://www.experts-exchange.com/Prog..._20702231.html

  3. #3
    Join Date
    Oct 2006
    Posts
    616

    Re: Drawing lines & mouse output

    OpenGL has to do with graphics and not user interactivity.
    For acheiving this, you can either use WIN32 API to dispatch system events, or use a library that implements the desired interactability with OpenGL. If you want an example of a rather simple library that registers user interaction (keyboard & mouse), you might want to look at GLUT. For a start, you can examine this set of tutorials. Or google for "GLUT" to find endless resources.

    I have a clue that i would need some form of mouse event/function that returns to me the screen coordinates
    Actually. to draw a line in an OpenGL window, you need to do this in "world" coordinates as defined by openGL, and not according to screen x,y coordinates, but you can define your view to be orthographic with the same dimensions as the window - this way it is easy to translate window(x,y) to world(x,y).

    If the only functionality you need is drawing lines in 2D, better use something like GDI+, learning OpenGL / GLUT just for this purpose is a bit too much

    Best of Luck !

  4. #4
    Join Date
    Dec 2005
    Posts
    41

    Re: Drawing lines & mouse output

    Thanks guys, i'll check out the links and advice you've given me ... and i'll get back to you.

    Oh yah, sorry i forgot to mention that i'm developing a small "Cohen-Sutherland" line clipping algorithm thingy .... in Visual C++ with openGL

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured