OpenGL

OpenGL

Post by Tomaz Kori » Wed, 07 Apr 2004 06:46:18


Hi

I'm just learning OpenGL and I made a simple example. It works, but the
problem is double buffering. With single buffering redrawing is super fast
but with double-buffering, it's really slow (1000 fps - single buf., 70
fps - double buf.). If back-buffer is managed by graphics hardware and is
located in VRAM then speeds should be almost identical. This smells like
memory bitmaps has something to do with it. Paint function has "for" loop to
test the speed. Why is double-buffering slow?

The code is simple:

procedure TForm1.FormCreate(Sender: TObject);
var
pfd: TPixelFormatDescriptor;
FormatIndex: integer;
begin
FillChar(pfd, SizeOf(pfd),0);
with pfd do
begin
nSize := SizeOf(pfd);
nVersion := 1; {The current version of the desccriptor is 1}
dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
iPixelType := PFD_TYPE_RGBA;
cColorBits := 32;
cDepthBits := 32; {depth of z-axis}
iLayerType := PFD_MAIN_PLANE;
end; {with}
FormatIndex := ChoosePixelFormat(Canvas.Handle, @pfd);
SetPixelFormat(Canvas.Handle, FormatIndex, @pfd);
GLContext := wglCreateContext(Canvas.Handle);
wglMakeCurrent(Canvas.Handle, GLContext);
end;

procedure TForm1.FormResize(Sender: TObject);
begin
glViewPort(0, 0, ClientWidth, ClientHeight);
glLoadIdentity;
glOrtho(0, ClientWidth, ClientHeight, 0, 1.0, -1.0);
PostMessage(Handle, WM_PAINT, 0, 0);
end;

procedure TForm1.FormPaint(Sender: TObject);
var
i: Integer;
begin
for i := 1 to 10 do
begin
glClearColor(1.0, 1.0, 1.0, 0);
glClear(GL_COLOR_BUFFER_BIT);

glColor(1.0, 0.0, 0.0, 0.0);
glRectF(0, 0, 200, 250);

glFlush;
SwapBuffers(Canvas.Handle);
end;
end;

..........................

regards
Tomaz
 
 
 

OpenGL

Post by Tomaz Kori » Wed, 07 Apr 2004 06:51:37

I forgot to mentione that I own a GF FX 5200 128MB DDR.

regards
Tomaz

 
 
 

OpenGL

Post by Eric Grang » Wed, 07 Apr 2004 14:18:24


> [...] 70 fps [...]

Wouldn't that be your screen refresh rate? If so, you might want
to turn VSync off in the driver control panel or via the
WGL_EXT_swap_control extension with f.i. a

wglSwapIntervalEXT(0)

after activating the context.

Eric
 
 
 

OpenGL

Post by Tomaz Kori » Wed, 07 Apr 2004 17:38:01

Hi

O yes, of course, it is my screen refresh rate :). In driver settings
(Control panel->display settings....) I can't find anything regarding VSync,
or is it located somewhere else. Though I would prefer to switch it on/off
programatically. Where is wglSwapIntervalEXT defined since I can't find it.
Also, how are GL extentions, that are implemented by graphics card, used?
Also where could I find tutorial for OpenGL that describes such things. I
have many pdf files, but it only shown the basics and then goes rith away to
3D. I would like to know the details about double-buffering, GL extentions,
etc.... (I don't know what elsethere is).

Regards
Tomaz
 
 
 

OpenGL

Post by Eric Grang » Wed, 07 Apr 2004 18:15:02

> O yes, of course, it is my screen refresh rate :). In driver settings

It's usually in the "advanced" tab for nVidia & ATI drivers, somewhere around
the perfomance and quality options.

> wglSwapIntervalEXT defined since I can't find it.

It's an extension, you'll need a more complete OpenGL unit than the one
provided by Borland, you can find a big (but complete) one at

http://www.yqcomputer.com/

a leaner one in

http://www.yqcomputer.com/

and another variation (more C-like) at

http://www.yqcomputer.com/

And I guess there is yet another in the Jedi project (better than
Borland's default one, but still outdated when compared to the ones
previously mentionned).


The import unit should take care of that during context activation
(you'll need to their context activation function though, and not
activate manually).


I found it in the nVidia OpenGL extensions PDF a few years ago.
You should also check tutorials sites like

http://www.yqcomputer.com/

There is also the "OpenGL Red Book"

http://www.yqcomputer.com/ ~unreal/theredbook/

(first link from google, there may be more recent versions around, but for
starting up, that's plenty enough)

Eric
 
 
 

OpenGL

Post by Tomaz Kori » Wed, 07 Apr 2004 19:38:36

Hi

Thanks for help.

regards
Tomaz




settings
VSync,
around
used?
 
 
 

OpenGL

Post by Rene Tscha » Wed, 07 Apr 2004 20:17:23


You're right to track this detail.
Having a graphics card doing OpenGL natively doesn't mean
it actually happens this way. By calling a 'wrong' function or
parameter, some module may decide that the software OpenGL is
to be loaded.

As to your problem, memory moves are not infinitely fast.
The 1000fps are possible without erase_background, wheras
the 70fps include an erase_background.

Assume a screen having 1000x1000 pixels. That makes
moving 1Mpixel per frame.

IMO, 70fps is not that bad depending on the complexity of the
scenery. Try drawing an additional million triangles
and compare.


Rene
--
Ing.Buro R.Tschaggelar http://www.yqcomputer.com/
Your newsgroups @ http://www.yqcomputer.com/
 
 
 

OpenGL

Post by Peter S » Fri, 09 Dec 2005 23:15:16

Hello all,

I use Delphi 6.0 and I wish to learn OpenGL. Can you give me any advice on
how to begin (e.g. some links to sites with OpenGL examples for Delphi)?

Thank you all for your time

Regards

Peter
 
 
 

OpenGL

Post by Andrew Jam » Sat, 10 Dec 2005 00:10:40

There are two sites that are an absolute goldmine of tips and examples :

http://www.yqcomputer.com/
http://www.yqcomputer.com/

The first site features all Delphi code most by the late Jan Horn and his
work is excellent and well documented. The second is by NeHe and he has a
wealth of tutorials ... most support Delphi but you'll soon appreciate
that's there little language dependency when working in OpenGL so don't be
put off by a lot of C ! Also C code is not any faster than Delphi, so don't
get lost in that debate unless you want portability for other platforms and
then C is the way to go.

http://www.yqcomputer.com/

The definitive site for developers and you must join the forums ... you'll
get better feedback too ... don't post to the advanced group at first,
you'll get flamed !


http://www.yqcomputer.com/

For component suites, you can't find better than GLScene but I'd strongly
suggest that you learn the basics at this stage.


And some more sites :

http://www.yqcomputer.com/
http://www.yqcomputer.com/
http://www.yqcomputer.com/
http://www.yqcomputer.com/
http://www.yqcomputer.com/


Books :
OpenGL Programming Guide: The Official Guide to Learning OpenGL

Finally a tip ... you'll find that Delphi's IDE can blow up on you whilst
debugging ... that can prove costly when you've not saved your code ! I
tend to run my program from outside the IDE during development then at least
you can terminate it. My own OpenGL work doesn't seem to cause many IDE
crashes but some examples that you'll come across certainly do !

Best of luck ...

Andrew
 
 
 

OpenGL

Post by Peter S » Sat, 10 Dec 2005 00:17:54

Andrew,

Thank you very much for your answer. It seems to me that I have lots of
reading to do :o)

Regards
Peter

"Andrew Jameson"<< XXXX@XXXXX.COM >>

don't> > get lost in that debate unless you want portability for other platforms
and> > then C is the way to go.> >> > http://www.yqcomputer.com/ ; >> > The definitive site for developers and you must join the forums ... you'll> > get better feedback too ... don't post to the advanced group at first,> > you'll get flamed !> >> >> > http://www.yqcomputer.com/ ; >> > For component suites, you can't find better than GLScene but I'd strongly> > suggest that you learn the basics at this stage.> >> >> > And some more sites :> >> > http://www.yqcomputer.com/ ; > http://www.yqcomputer.com/ ; > http://www.yqcomputer.com/ ; > http://www.yqcomputer.com/ ; > http://www.yqcomputer.com/ ; >> >> > Books :> > OpenGL Programming Guide: The Official Guide to Learning OpenGL> >> > Finally a tip ... you'll find that Delphi's IDE can blow up on you whilst> > debugging ... that can prove costly when you've not saved your code ! I> > tend to run my program from outside the IDE during development then at
least> > you can terminate it. My own OpenGL work doesn't seem to cause many IDE> > crashes but some examples that you'll come across certainly do !> >> > Best of luck ...> >> > Andrew> >> >
 
 
 

OpenGL

Post by Felipe Mon » Mon, 12 Dec 2005 06:04:20


Or Lazarus
 
 
 

OpenGL

Post by Tanju » Wed, 08 Feb 2006 18:05:38

Hi folk !

1.) In OpenGL, what can I do to fix the problem at the attached file, edges
rendering doesn't satisfy me and also when I'm rotating objects (or
translating) edges seem very ragged.

Thnx!
 
 
 

OpenGL

Post by Andrew Jam » Wed, 08 Feb 2006 19:14:01

You might consider using ARB_MULTISAMPLE, there's an example at :

http://www.yqcomputer.com/

You could also turn on the card's anti-aliasing (if supported) but this can
be difficult to control from an application. I recollect some examples that
do this and I think that they're available from the above link.

Anti-aliasing and multi-pass rendering can introduce a significant
performance hit and another suggestion (if you're running in fullscreen) is
simply to increase the screen resolution which is what we do with our OpenGL
product.

There are a few other techniques for edge blurring and I would strongly
suggest posting this question on the OpenGL forum at www.opengl.org.

Andrew
 
 
 

OpenGL

Post by Andrew Jam » Wed, 08 Feb 2006 19:21:10

Just refreshing my memory - I gave up fighting the jaggies but there's lots
of ideas around :

http://www.yqcomputer.com/

Try Googling !

Andrew
 
 
 

OpenGL

Post by Tanju » Wed, 08 Feb 2006 21:06:50

Thnxs helping me,

It doesn't sound like a good idea to turn on anti-aliasing which doesn't
eliminate the jaggy edges but blurr them with nearby pixels. It seems to me
that I didn't specify the front and back surface of objects so that, drawing
for back and front surface is made randomly. First front surface is drawn
and then back surface is drawn on top of the front surface or vice versa.

Could this be a thing that I'm missing in my program ?


"Andrew Jameson" < XXXX@XXXXX.COM >, haber iletisinde
nlaryazd XXXX@XXXXX.COM ...> > Just refreshing my memory - I gave up fighting the jaggies but there's > > lots of ideas around :> >> > http://www.yqcomputer.com/ ; >> > Try Googling !> >> > Andrew> >>>>>> 1.) In OpenGL, what can I do to fix the problem at the attached file, >>>>> edges rendering doesn't satisfy me and also when I'm rotating objects >>>>> (or translating) edges seem very ragged.>>>>>>>>>> Thnx!> >> >