buffer problem?

The CAD app I am working displays meshes in 3 ways,

  1. wireframe
  2. with metallic shading
  3. color countour map with smooth shading

I use vertex arrays for vertex and normal coordinates for all three (and color coordinates for 3)

My trackball rotation, panning and zooming all work fine with 1 and 2, but with 3 the part sometimes jerks back to the previous position in between each movement. So if you rotate, then click to rotate again right after, the part somtimes jerks back to the original position. But if you wait a few seconds before clicking to rotate the second time, it’s fine. The same happens with panning. It’s like I have to give it time to refresh or something. Also, the larger the part the more frequently the jerking happens. And it gets worse on my collegues computer who has less RAM. Therefore, I think it may be related to buffers but I am not sure.

I’m looking for general tips, but I can give more details of the code if anyone needs…

[This message has been edited by mandyV (edited 03-06-2002).]

I reackon you need to store the position of your mouse when you click the button. Bear in mind that only passive motion gets updated when there are no buttons pressed, and chances are you’ve moved it a long way between the last registered mouse movement when you next click!!

Rob could be right. Or it could be that your drawing and moving functions take too long and your mouse move data is accumulating in the mean time. So when you think it’s jerking back, it might be doing a near 360 rotation before it can be drawn again. The fact that it gets worse with larger/more complex images suggests that drawing time is increasing, leading to larger accumulation of a move. Less RAM means your image data may be swapping to the hard disk leading to even longer draw times (I’ve encountered that before). This will show by hard disk activity during drawing.

Okay, I think it is the latter…that my drawing operations are taking too long for this mode…because my mouse operations are as follows:

OnLButtonDown

  • Store the mouse position

OnMouseMove

  • Calculate the new angle/pan value based on the current mouse movement and the clicked point
  • Draw the new scene with the given values

OnLButtonUp - forget the last mouse point

Let me stress that my manipulations work when drawing wireframe meshes and shaded meshes. They only act up when drawing this high color smooth shaded mode. So I think it may be the accumulation thing as Furrage mentioned.

Sincerely,
Still Strugglin’

[This message has been edited by mandyV (edited 03-07-2002).]

You can test this by reducing scene complexity in that mode (to < 100 tris). If it works fine for small scenes but becomes more jerky with increasing complexity then you know your drawing code is taking too long for complex images. If so, start trying Vertex Arrays, Display Lists and other optimisation techniques. Otherwise your only going to be able to target machines with better specs.

yes the jerkiness is less with smaller models…I do use vertex normal and color arrays, however, I don’t use display lists…I thought it may be some gl calls that i make in the draw function but am not sure which ones I can move out of the function to only be called once. I tried moving the clear color buffer bit and depth buffer bit call, but that didn’t seem to make a difference.

Look for any information you can preprocess as opposed to calculating in your drawing code. If you have a lot of calculations in your drawing function that can also slow it down. With display lists, you can draw portions of your scene to the display list then call it, instead of drawing code. When you need to change a specific portion just update it.

Another thought. When doing transforms make it automatically switch to wireframe mode. Once the transform is complete switch back to rendering mode and draw the transformed image. It’s an age old trick that everone used to do when computers were too slow to handle moving images properly.

I will look further into the preprocessing stuff…

The funny thing about your second suggestion is that the app we are doing now is supposed to be an improved windows version of one of our old apps. The wireframe approach is the way our old apps handled transformations…We are basically two developers trying to pull off what has been done in larger apps like CATIA and SolidWorks. We didn’t think it would be this hard, but I guess it is with our level of experience.

Thanks for your help!

I was just browsing through the advanced section and saw this very interesting post. You might want to check it out, especially the solutions.
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/005755.html

FIXED IT!

It had nothing to do with buffers or optimization! There was a call to a conflicting method being called in OnMouseMove method that was throwing off the picking data. I didn’t realize this method was being called during transformations, so I disabled it during transformations and it works!!!

Thanks everyone for your help. At least now I know that there is nothing much more should have been doing, optimization-wise.

[This message has been edited by mandyV (edited 03-07-2002).]