Try Delphi Cannon: A simple OpenGL game integrated with VCL
Everyone knows that the programmers greatest excuse for slacking off is compile time. Next time your waiting for your software to build burn a few minutes playing the Delphi Cannon Demo! It’s a simple VCL/OpenGL app I wrote in a few short afternoons.
By hosting an OpenGL canvas on top of a standard TPanel I was able to easily integrate a simple windows app with basic OpenGL rendering. This allowed me to create the simple game you see here, and encapsulate it in the easy to design UI of VCL. It works for more than just games too. A OpenGL enables TPanel is great for rendering complex graphs and data processed by your Delphi application!
So enjoy playing the demo, and think about what other things could be done with a faster rendering system attached to VCL controls.
Note, since this demo uses OpenGL you will need compatable video card drivers. These can be obtained by your video card manufacturer in MOST cases. Cirtain cards may need to search for OpenGL compatable drivers, as the manufacturers drivers are not always compliant. Also, if anyone has any questions reguarding the TPanel hosting OpenGL, or about the game itself, feel free to reply to this post.
Share This | Email this page to a friend
Posted by David Lock on November 20th, 2007 under Uncategorized |

RSS Feed

November 20th, 2007 at 3:36 pm
Your tank game is very interesting! Thank you for sharing.
November 20th, 2007 at 3:40 pm
3 things surprise me:
1-It is a simple but well constructed game, so my point is: very well to be a "a few short afternoons" demo.
2-The interface is so smooth
3-My video card support it that well!
Pretty good quick-demo David.
November 20th, 2007 at 4:01 pm
"‘-0.8′ is not a valid floating point value"
Well, some of us use ‘,’ as the default decimal separator…
November 20th, 2007 at 4:29 pm
Sorry won’t start on a Swedish XP.
My guess is the decimal separator.
It shows up with ‘-0.8′ is not a valid floating point value.
November 20th, 2007 at 4:32 pm
Nice retro feel. Needs some jarring 80’s midi style polyphonic music to complete it though
November 20th, 2007 at 5:43 pm
Can you put the code up on CodeCentral?
November 20th, 2007 at 6:31 pm
Nice stuff for an application thats barely larger than the smallest of delphi apps.
Is it possible to get the source code ? And a question The underlying panel doesn’t seem to be there ? Is there an opaque layer in there ?
November 20th, 2007 at 9:54 pm
It say " ‘-0.8′ is not a valid floating point value " and doesn’t work
Blank application window opens but new game doesn’t start.
November 21st, 2007 at 12:02 am
Hi,
I wasn’t able to run the program : I’m getting an ‘-0.8 is not a valid floating point value’ (I’m running a French winxp os)
November 21st, 2007 at 1:50 am
Thanks for the ‘game’, David. A _much_ bigger ‘game’ would be if we’ll have a VCL which will leverage the OpenGL as rendering engine. (…also having GLScene around should make things easier, isn’t?). Just a small note, the game doesn’t work if the ‘National Settings’ have other setting than ‘DecimalSeparator=.’ (Point). And at the end the classical question: Source?
November 21st, 2007 at 2:48 am
The Cannon seems to be a bit buggy, at least I can’t run it.
I get this error message on startup:
—————————
Dcannon
—————————
‘-0.8′ is not a valid floating point value.
—————————
OK
—————————
Seems to do with regional settings and you assume everyone uses ‘.’ as decimal symbol in numbers but not say ‘,’ that is popular in Europe and elsewere.
November 21st, 2007 at 7:31 am
Hi David,
I just wanted to check how it looked, but because my culture settings in windows xp are set to Dutch the decimal separator char is an ‘,’. Your program assumes an ‘.’ as separator char, that’s due to the fact you use ‘,’ as data separators for the vgx files. Easiest fix would be:
var
CurrentSeparator: Char;
begin
CurrentSeparator := DecimalSeparator;
try
DecimalSeparator := ‘.’;
{ do the importing.. }
finally
DecimalSeparator := CurrentSeparator;
end;
end;
November 21st, 2007 at 9:04 am
Joliphant: The underlying OpenGL panel is created at runtime, and yes, its actually there :).
Intl Folks: I applied Davy Landman’s fix to the vgx file loader. Hopefully this allows you to waste as much time on this as I have :D.
m. Th.: I have definatly been thinking about that. With Microsoft coming out with things like WPF, which support very rich UI elements its making VCL’s look and feel very antiquated. Hopefully I can convince some of the folks around here that some whiz-bang is needed in our frameworks.
November 21st, 2007 at 9:12 am
Rats, forget to mention, the link in the post now points to the binary with the fixed decimal separator issue.
November 22nd, 2007 at 3:57 am
Now it starts up, but it is tilted 90° (or, rather, my monitors are, and the game doesn’t follow) :-).
It aint easy coding properly with all the different setups your end-users have :-).
November 22nd, 2007 at 12:20 pm
Dear David, game is really rock ! Fun with it much larger than size of the program
Is it possible to get the source code ?
November 22nd, 2007 at 12:27 pm
Dear David, game is really rock ! Fun with it much larger than size of the program
Is it possible to get the source code ? Thank you !
December 2nd, 2007 at 7:52 pm
Hey David,
Awesome game. WOuld be interested in how you did the OpenGL stuff in Delphi.
Are you able to provide the source to see how it all works? Are we expecting a version 2.0???