Click to See Complete Forum and Search --> : Drawing lines & mouse output
braveheartkenya
February 12th, 2007, 08:20 PM
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...
blueday54555
February 13th, 2007, 12:25 AM
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/Programming/Game_Development/Game_Graphics/OpenGL/Q_20702231.html
Zachm
February 13th, 2007, 12:32 AM
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 (http://www.lighthouse3d.com/opengl/glut/index.php?1) 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 !
braveheartkenya
February 13th, 2007, 01:37 PM
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
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.