PDA

View Full Version : OpenGL without glut



snupinokyo
11-20-2003, 12:56 AM
I wrote a program presenting 3D objects in prespective projection. The program uses selection and feedback to allow the user to click & drag an objcet. Each object has its own display method, and build of some primitive objects. I wrote the program at VC++ 6.0 with glut. When two objects are intersecting each other, the program presents them one in the other, as it should be.

Now I have to translate the program to MFC, without glut. At the MFC version, When I presents the scene, using the same methods as at the without glut program, each object is displayed as in its own space. When two objects intersects one the other, they aren't displayed one peneterating the other's surface, but the object which its display method is called first is displayed in front of the other, even if they are defined on the same spot at the world coordinate.

I used the VC++ application wizard to build the interface, and the methods are the same as the program using glut, but instead of each call to glutPostRedisplay I call Invalidate, the same for glutMotionFunc and every other glut func.
The intersection of two objects is very important to my program, since I uses selection & feedback in order to calculate the object's intersection.
Please help me.

I think i must bypass the glut usage.
I guess the Coordinate of MFC (or Win32, this is the same) are different from the glut translated coordinats.

Thanx

Relic
11-20-2003, 01:08 AM
If you do the same things in the drawing routine as you did ion your glut program this shouldn't happen.
Sounds like depth buffer problems.
Things to check:
- Number of depth bits (GL_DEPTH_BITS or DescribePixelFormat) should be the same, Request 24 bits.
- glClear(GL_DEPTH_BUFFER_BIT)
- glEnable(GL_DEPTH_TEST)
- glDepthFunc
- Projection matrix: glFrustum, glOrtho or gluPerspective, what is the zNear/zFar ratio? Make it as big as possible to get most of the depth buffer precision from the available bits.

zeckensack
11-20-2003, 08:53 AM
edit: Whoops, no, please ignore
zFar/zNear should be as small as possible. Relic reversed it.
/edit


Originally posted by Relic:
<...>what is the zNear/zFar ratio? Make it as big as possible to get most of the depth buffer precision from the available bits.That should read "make it as small as possible" methinks http://www.opengl.org/discussion_boards/ubb/smile.gif



[This message has been edited by zeckensack (edited 11-20-2003).]