PDA

View Full Version : rendering



RandyU
04-26-2001, 07:39 PM
I want to know what is the right way to draw scene. I do in such way:

if firsttimeflag then begin
//initialization
DC := GetDC(Handle);
//then I fill pfd and call such functions:
ChoosePixelFormat(DC, @pfd);
SetPixelFormat(DC, nPixelFormat, @pfd)
DescribePixelFormat(DC, nPixelFormat, sizeof(TPixelFormatDescriptor), pfd)
end;

DrawScene;
if not SwapBuffers(DC) then begin
//my DC is no longer valid
ReleaseDC(DC); DC := GetDC;
end;


I do it on timer event.
On WM_PAINT event I only do SwapBuffers - it makes picture valid when moving.

04-26-2001, 11:10 PM
RandyU try to break your code into distinct procedures where certain tasks must be performed.
Initiating the Opengl environmet is one thing and drawing your scene is another.
So for start:

Try to add a procedure called InitOpenGl where you create and bind the rendering context to your program..

Add a procedure to choose the pixelformat from within InitOpenGl.

Remember to add WS_CLIPSIBLINGS and WS_CLIPCHILDREN to your OpenGL window styles

Trap WM_DESTROY to unbind the rendering context before the window is closed.

So after you have set up your window so it starts and ends succesfuly you have to set up your 3d World. This can be done in WM_PAINT or to a seperate procedure.

You can keep WM_PAINT strictly for rendering purposes.

You seem a bit confused.
A nice place to start is to download the OpenGL redbook and start looking for tutorials on the net. Nehes tutorials are very good and ofcourse this very site we are communicating from.
There are many sources for begginers....(More than me)

I hope i gave you some hint.