PDA

View Full Version : OpenGL interoperability with mouse under Ms Windows & X-win systems



pascal
09-29-2002, 11:36 AM
I want to know if objects rendered with opengl in a window system are clickable ???

ie: I draw a line & a cube, can i click on
the line, the faces'textures of the cube
& the cubes lines to call more OpenGL
events and objects ?

Its surely an easy question but i've got to
code a clickable visualisation window and
i dont know what graphic renderer to choose.

Thanks.

Pascal

tinak
09-29-2002, 02:43 PM
Windows has its own mouse operations from what I understand but I haven't used them that much myself to explain them well.. although you may well know those more than me anyway...

GLUT has a set or callback functions that allow you to work with mouse operations so you may want to investigate that avenue.

And then finally a look through gametutorials.com and nehe.gamedev.net may point you into a set of picking tutorials that may help you.

Basically, you click on a pixel and your program is told what to do based on that pixel position. Either locate which object is nearest to that pixel and thus was clicked or create an object and place at that position.. and perhaps other similar actions can be carried out.

Tina

aldo657
09-30-2002, 07:49 AM
Originally posted by tinak:
Windows has its own mouse operations from what I understand but I haven't used them that much myself to explain them well.. although you may well know those more than me anyway...

GLUT has a set or callback functions that allow you to work with mouse operations so you may want to investigate that avenue.

And then finally a look through gametutorials.com and nehe.gamedev.net may point you into a set of picking tutorials that may help you.

Basically, you click on a pixel and your program is told what to do based on that pixel position. Either locate which object is nearest to that pixel and thus was clicked or create an object and place at that position.. and perhaps other similar actions can be carried out.

Tina

nexusone
09-30-2002, 09:31 AM
Anything beyond clickable things like buttons, you have to write extra code to do it.

There is a tutor on nehe.gamedev.net, on how to use openGL functions to select objects with a mouse.

I think that even with direct x, you also would have to write addtional code to do 3D object selection.


Originally posted by pascal:
I want to know if objects rendered with opengl in a window system are clickable ???

ie: I draw a line & a cube, can i click on
the line, the faces'textures of the cube
& the cubes lines to call more OpenGL
events and objects ?

Its surely an easy question but i've got to
code a clickable visualisation window and
i dont know what graphic renderer to choose.

Thanks.

Pascal

cwc36
09-30-2002, 03:55 PM
It have 2 way to select the 3d object with your mouse.

The gluPickMatrix() can help u to select the objects with your mouse. U can find the examples in red book and internet.

The second method is gluUnPorject(). It also help u to find out the coordinates object in the window from projection matrix and modelview matrix base on your viewport matrix. If u use the gluUnProject(). U can get the x and y coordinates with window function. Then u draw a line to negative z axis . Then u have to check the intersection point of the line. Then u will get the exact x,y,z value...
I hope it can help u ....