How do i build a application which looks like OpenGL but
not with a Paint method of thousands of lines?
OpenGL
applications with MNOgl component collection
Nothing is easier than this!
Use the brand new component collection from minais (www.minais.at).
This collection comes along with a lot of sample files which can
be downloaded from www.minais.at. Build your own games with key
and mouse interactions or improve and facelift your existing applications
with OpenGL output. We made very good experiences with pupils
who were fascinated how interesting 3D world can be.
Don't hesitate to check our site www.minais.at. MNOgl Version
1.0 is completly FREE.
Let me show you a first example:
When you use MNOgl component collection from minais you have two
different ways to build such an application.
First i want to describe the easy way:
First of all be sure to install the MNOgl package file mnogl.bpl
under
Delphi (Component menu - Install packages - Add button - search
for
MNOgl.bpl and say Open). The result is you have a new component
folder called MNOgl. Within you will find a lot of handy components
to
design an OpenGL application.
Let us start with a new project. Select a TMNOglControl component
and drop it on to the form. Resize the control as you want it
or let it
align. Then select a TMNOglCanvas component and drop it on the
form. Assign the MNOglControl1 to the property named WinControl.
NOW an OpenGL rendering context will be generated (the
MNOglControl changes to black backgroundcolor).
Let us now look how we can draw a box in this canvas. Pick a
TMNOglScene component from the MNOgl folder and drop it on the
form. Assign the MNOglCanvas1 to the property MNOglCanvas. Now
let us select a TMNOglBox component and drop it on the form. Assign
MNOglScene1 to the property Scene. Now you see the shape alread
in design mode. Try to change the size of the box by changing
the
properties length, width and height. If you want to have your
shape
centered then set the TransformBy property to
(-length/2, -width/2, -height/2).
TForm1 = class(TForm)
private
{ Private declarations }
MNOglControl1:TMNOglControl;
MNOglCanvas1:TMNOglCanvas;
MNOglScene1:TMNOglScene;
MNOglBox1:TMNOglBox;
public
{ Public declarations }
end;
Then enter the FormShow method and we will create the components
we will need:
procedure TForm1.FormShow(Sender: TObject);
begin
// create the WinControl for the OpenGL render context
// herein your shapes will be played
MNOglControl1 := TMNOglControl.Create(self);
MNOglControl1.Align := alClient;
MNOglControl1.Parent := self;
// create the MNOglCanvas
MNOglCanvas1 := TMNOglCanvas.Create (self);
// assign the WinControl --> and the render
// context will be created
MNOglCanvas1.WinControl := MNOglControl1;
// create the scene (OpenGL calls it DisplayList)
MNOglScene1 := TMNOglScene.Create (self);
// and tell the scene in which Canvas it will be played
MNOglScene1.MnOglCanvas := MNOglCanvas1;
// create the box
MNOglBox1 := TMNOglBox.Create (self);
// ant tell the box to which scene it will belong
MNOglBox1.Scene := MNOglScene1;
// change properties of the box
with MNOglBox1 do begin
Length := 4;
Width := 3;
Height := 2;
end;
end;
If you want the scene to rotate then just add a TMNOglNav (a navigator)
to your form and set the property MNOglCanvas to MNOglCanvas1.
When you start the program you can then press the
left mouse button on the MNOglNav component and move the mouse.
With left double click the view will be reset.