Board index » cppbuilder » OpenGL and VCL

OpenGL and VCL

Is it possible to use any of the VCL controls to set up an OpenGL rendering
context into? I am thinking it will be necessary to write a custom control
to use OpenGL with VCL. I don't like the ActiveX controls. My preference is
to just use an existing control to set up with OpenGL.

Jon

 

Re:OpenGL and VCL


On Fri, 29 Jan 1999 15:21:20 -0600, "Jon Berndt" <j...@hal-pc.org>

Quote
> Is it possible to use any of the VCL controls to set up an OpenGL rendering
> context into? I am thinking it will be necessary to write a custom control
> to use OpenGL with VCL. I don't like the ActiveX controls. My preference is
> to just use an existing control to set up with OpenGL.

I've written an OpenGL component myself.
  http://www.wischik.com/lu/programmer.html#opengl
It's free, including source code, and comes with examples.

In answer to your actual question, it's not necessary to write a
custom control. OpenGL will work fine with any component as long as it
has the CS_OWNDC style. (and, luckily for us, all VCL encapsulations
of the standard controls have precisely that style!) You can use a
TPanel if you want. Or you can even use the TForm.

One thing to bear in mind: an OpenGL context is associated with an
HDC, and an HDC is associated with a HWND. The VCL controls feel
perfectly at liberty to destroy and recreate their HWNDs at will
(although, of course, they only do it at opportune moments... the
TForm will create an HWND before your construct has even started, and
then destroy it, and then create it again. And if you subsequently
change the FormStyle or BorderStyle it will destroy and recreate the
HWND. And if anyone else happens to come along and destroy the HWND, a
VCL control will happily recreate it.)

The reasons for using a ready-made custom control are that
 - saves work setting up pixel format and stuff
 - handles this problem with HWNDs being recreated
 - my component has additional features to make it work well with
  3dfx cards (which can only start OpenGL in their own
  separate full-screen), and it allows you to dynamically
  choose which OpenGL implementation to link to
  (3dfxgl.dll, 3dfxquake.dll, mesa.dll, opengl32.dll)

--
Lucian Wischik, Queens' College, Cambridge CB3 9ET. www.wischik.com/lu

Re:OpenGL and VCL


No disrespect to Lucian, but...

Personally, I don't like using a special component for OpenGL output - I send the
output to a standard TPanel.  I'm not sure about the phenomenon he descibed re:
destruction of the component's handle - I've never had that problem. Of course,
the panel is placed on the form at design time; it isn't created or altered once
the program is running.

Other reasons for not using a special component -

1) Unnecessary 'wrapping' around the GL interface can reduce your flexibility in
creating/presenting an image;

2) Personally, I think it's a good thing to learn about the details of using the
API. This makes it possible to do much more than draw to a component - render to
a bitmap in ram, for instance...

3) Using a standard TPanel means you have access to all the normal event handlers
associated w/ a TPanel,without having to create your own message map, etc.

4) In Lucian's case this isn't an issue, but you don't have to pay someone any
more cash to use a standard TPanel.

I started w/ John Thomas' tutorial at TheBits. This demonstrates rendering to the
canvas of a form. You can easily modify this to render to the canvas of a TPanel
by sending to the device context of a panel (GL->hDC = GetDC(Panel1->Handle);.

Experiment - you'll see what I mean.

See ya

Dave R|

Re:OpenGL and VCL


Quote
>>> 1) Unnecessary 'wrapping' around the GL interface can reduce your

flexibility in
creating/presenting an image;

Quote
>>> 2) Personally, I think it's a good thing to learn about the details of

using the
API. This makes it possible to do much more than draw to a component -
render to
a bitmap in ram, for instance...

Quote
>>> 3) Using a standard TPanel means you have access to all the normal

event handlers
associated w/ a TPanel,without having to create your own message map, etc.

Quote
>>> 4) In Lucian's case this isn't an issue, but you don't have to pay

someone any
more cash to use a standard TPanel.

While these points are mainly true, and I have sometimes said similar
things myself,
you could make the same or similar arguments against the use of almost any
third
party tools. More importantly, why are you using OpenGL when you should
be implementing your own (superior for similar reasons) graphics library?
;-)
I know someone whose idea of Heaven is writing drivers for graphics
cards...

I had a look at Lucian's comprehensive component recently. It's all very
nice but
way over the top for my needs. I have implemented a simple, small, thin
component
based on TCustomPanel (a lot of the code comes from the OpenGL SuperBible).
It
might serve as a first tutorial if Jon wants to roll his own component. The
source is free
at http://www.foxholly.demon.co.uk/Programming.html.

Arnold the Aardvark

Re:OpenGL and VCL


Quote
<moria...@inreach.com> wrote:
> No disrespect to Lucian, but...
> Personally, I don't like using a special component for OpenGL output - I send the
> output to a standard TPanel.  I'm not sure about the phenomenon he descibed re:
> destruction of the component's handle - I've never had that problem.

I agree totally!

[it was simply that in my case that I needed 3dfx OpenGL acceleration,
and I needed an OpenGL that could dynamically link either to
3dfxgl.dll rather than opengl32.dll: it takes masses masses too much
code to do this with a TPanel]

--
Lucian Wischik, Queens' College, Cambridge CB3 9ET. www.wischik.com/lu

Re:OpenGL and VCL


Quote
>I had a look at Lucian's comprehensive component recently. It's all very
>nice but
>way over the top for my needs. I have implemented a simple, small, thin
>component
>based on TCustomPanel (a lot of the code comes from the OpenGL SuperBible).
>It
>might serve as a first tutorial if Jon wants to roll his own component. The
>source is free
>at http://www.foxholly.demon.co.uk/Programming.html.

Yes. I agree with David and the Aardvark (where does that name come from??),
I really want a simple OpenGL introduction. I did a considerable amount of
Iris GL years ago, but I would like to build a simple component myself based
on a TPanel, or something. I have the SuperBible, so I am referring to that
a lot. I'll check out the address above. Also, thanks to Lucian for
replying. I may eventually have need for something like that, too.

Jon

Re:OpenGL and VCL


Quote
> I really want a simple OpenGL introduction. I did a considerable amount of

http://www.cbuilder.dthomas.co.uk/tutorials/gfx_hardware.htm//jt

Re:OpenGL and VCL


Quote
>Yes. I agree with David and the Aardvark (where does that name come

from??),

I don't know. When I first lurked on newsgroups I saw that lots of people
used
pseudonyms, and "Arnold the Aardvark" surfaced from my memory. I keep
thinking I ought to use my real name but I'm quite fond of ol' Arnold now.

If you have the SuperBible you will quickly realise that my component is no
more
than what you would create if the authors had included an "OpenGL with the
VCL"
appendix to go with the ones about MFC and OWL.

Alan Chambers

Re:OpenGL and VCL


In article <796tln$ft...@forums.borland.com>, Arnold the Aardvark
wrote:

Quote
> "Arnold the Aardvark" surfaced from my memory.

For some reason I can instantly think of the same 26 names.  So anytime
a need to test some software that needs names I'm never stuck.  They
start with Aaron Aardvark, and go on to Zaphod Zzyck, with Jean-Jaques
Jeans 'n' Jumpsuits there in the middle.

Colin

Re:OpenGL and VCL


Please follow newsgroup guidelines and refrain from cross-posting.

Quote
> Is it possible to use any of the VCL controls to set up an OpenGL rendering

Check out the following web sites for more OpenGL help:

http://www.cgsoftware.com/opengl/opengl.html
http://pc-heartbreak.physiol.ox.ac.uk/Programming/OpenGL/
http://www.danbbs.dk/~allmette/software.htm

And a freeware OpenGL component:

http://www.cobweb.net/~dplakosh/

+===================================================+
| Jonathan Arnold (mailto:jdarn...@buddydog.org)    |
| Engineering Manager       Roger Wagner Publishing |
| http://people.ne.mediaone.net/jdarnold            |
+===================================================+

"The Wizard of Oz": Transported to a surreal landscape, a
young girl kills the first woman she meets, then teams up
with three complete strangers to kill again.

Other Threads