PDA

View Full Version : drawing by mouse



05-16-2005, 05:53 PM
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.

05-17-2005, 05:40 AM
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?

05-17-2005, 08:18 AM
I want to draw cube by mouse in open gl.

dvm
05-17-2005, 01:48 PM
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.

Ehsan Kamrani
05-17-2005, 08:43 PM
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-

05-18-2005, 02:28 AM
can you provide me that 2D drawing code.
email: newasun@gmail.com
Thank you

Ehsan Kamrani
05-18-2005, 06:01 AM
Sure. see this link:
http://www.cse.nd.edu/courses/cse566/www/code/BOOK_PROGRAMS/square.c
-Ehsan-

Ehsan Kamrani
05-18-2005, 01:16 PM
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-

newasun
05-18-2005, 05:40 PM
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.

Ehsan Kamrani
05-18-2005, 10:37 PM
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-