I’m trying to draw cube in open gl by mouse pointer. But I dont know how to get co-ordinates for cube. Can anybody give me help or little code snip-it.
Thank you.
I’m trying to draw cube in open gl by mouse pointer. But I dont know how to get co-ordinates for cube. Can anybody give me help or little code snip-it.
Thank you.
I don’t get what you are trying to do exactly. Are you trying to set each point of the cube using the mouse or move it using the mouse?
I want to draw cube by mouse in open gl.
If you have a library near you or it’s on the internet Ed Angels’ Computer Graphics a top down aproach has some nice examples of using the mouse to draw stuff.
The problem is that the x and y coordinates of the mouse are in the window coordinates–And so there’s no the z coordinate for mouse. Projection in OpenGL projects the 3D scene to the 2D plan.projecting the 2D scene-the mouse coordinate-to the 3D scene is impossible–Or is difficult to do.As i have studied the book A top down…, it uses from the mouse to only draw the 2D polygons.
-Ehsan-
Note that it’s not a robust example. The examples of this book use from the GLUT mouse functions-glutMouseFunc,glutPassiveMotionFunc, glutMotionFunc- to draw the objects. As you know, GLUT isn’t so useful. You should use from the other APIs-Like DirectInput-To interact with the mouse.
-Ehsan-
Ehsan thanx for your help.
if you have code in MFC not using glut. that will be great. even drawing a single line is ok.
You’re welcome.I have no experience about the MFC. I use from the win32 app to write my programs. you should search in google to find some sample codes written with MFC.
-Ehsan-