PDA

View Full Version : how to disable doublebuffering ?



supercoollee
05-09-2010, 10:30 PM
i found in my OPENGL app, a rotating object is constantly rotating back and forth for a small angle at high frequency.
is that caused by double-buffering? - one of the buffer contains previous status of the object.

should i disable double-buffering to solve this problem?
and how to disable it?
i tried removing PFD_DOUBLEBUFFER in pixelformat flags, then it doesn't render at all.
currently i am using
PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER

i assembler is MASM32.

ZbuffeR
05-09-2010, 10:58 PM
Do not try to use single buffer.
You error is most likely elsewhere ; do you glClear each frame ?

supercoollee
05-09-2010, 11:04 PM
yes, i have these before any rendering:

glClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glLoadIdentity

Yomboprime
05-09-2010, 11:09 PM
Couldn't it be a number precision problem instead of a high frequency rotation?

supercoollee
05-09-2010, 11:31 PM
i am not sure.

i use: glRotatef,rollratef,0,0,3f800000h
to rotate it along Z axis.

"rollratef" contains a real4 value, it is calculated by a integer value multiplied by a real8 value. the integer value is added or subtracted.


PS: my app has a timeGetTime delay procedure with makes the whole physics and graphics system work 50 times per second. my screen refresh rate is 60HZ.

Yomboprime
05-10-2010, 12:10 AM
i use: glRotatef,rollratef,0,0,3f800000h
to rotate it along Z axis.
What are you trying to do with that 3f800000h? It doesn't have sense, it should be just 1.0 to rotate in the z axis.

What values does rollratef? (i.e. what's the integer and the real8 values you mention?) You could post the code that sets the values.



PS: my app has a timeGetTime delay procedure with makes the whole physics and graphics system work 50 times per second. my screen refresh rate is 60HZ.
This is a bad approach. You should make no delay, and run your program in a loop. Use a time function to measure the time DT between frames (I don't know what language you are coding in so I can't tell you wich function to use), and use 1.0 / DT instead of the delay to animate your rotation.

If the time measuring function gives you milliseconds for example, then use 1000.0 / DT and you will have a time frame in seconds.

ZbuffeR
05-10-2010, 12:32 AM
PS: my app has a timeGetTime delay procedure with makes the whole physics and graphics system work 50 times per second. my screen refresh rate is 60HZ.
This is a bad approach. You should make no delay, and run your program in a loop. Use a time function to measure the time DT between frames (I don't know what language you are coding in so I can't tell you wich function to use), and use 1.0 / DT instead of the delay to animate your rotation.
Having a physics at 50hz and graphcis at 60hz is indeed a bad idea. But a simple function of time will not be easy for complex physics.

A better idea is to run both physics and graphics at the same rate. (an even better idea is to run physics at a much higher rate than graphics if possible)
And when graphics and physics are out of sync, then graphics will look at the 2 most recent physics steps, and interpolate between those to show very smooth physics (at the cost of a small latency).

supercoollee
05-10-2010, 12:32 AM
i am using ASM language.
3f800000h is the HEX form of float value 1 (real4).
ASM can't directly intepret "1.0" in function calls. 3f800000h is the most direct way.

i will consider the timing procedure later.

supercoollee
05-10-2010, 12:36 AM
i don't mean the program update physics and graphics at different rates. they both update roughly 50 times per second in my program.
screen refresh rate is another thing. it's the graphic card setting. such as 1024x768,32bit,60hz .

Yomboprime
05-10-2010, 02:40 AM
ASM??? :eek: :p


i assembler is MASM32.
Sorry i missed that line

Well, if the glRotate is ok, then it must be the angle value that is getting odd values...