Welcome
 Top Next

OpenGL Library for Delphi, maintained by Eric Grange, based on Mike Lischke's GLScene. Tutorials designed and written by Paul van Dinther

GLScene is an OpenGL based 3D library for Delphi . It provides visual components and objects allowing description and rendering of 3D scenes in an easy, no-hassle, yet powerfull manner.

GLScene is not just an OpenGL wrapper or utility library, it has grown to become a set of founding classes for a generic 3D engine with Rapid Application Development in mind. GLScene allows you to quickly design and render 3D scenes without having to learn the intricacies of OpenGL, if you know how to design a TForm, you'll easily master the basic operations of TGLScene. The library comes with a large collections of demos showcasing the ease of use, and demonstrating RAD wasn't done at the expense of CPU/GPU horsepower.

GLScene is released to the public as open-source under Mozilla Public Licence .

This document is a GLScene training manual. GLScene is a very powerful OpenGL library designed for Delphi. The library allows you to build applications using the 3D capability of modern computers. Unfortunately with power comes some complexity. In the past many beginning users have struggled to get to grips with the basic principles. This tutorial is designed to help you understand the building blocks that form GLScene. No prior knowledge of OpenGL or indeed any 3D programming is required to work through this tutorial. We do assume however that you are familiar with the use of Delphi and OpenGL.

(This document is under construction )


Software and Hardware requirements
 Previous Top Next

Although GLScene supported Older versions of Delphi in the past, Nowadays you really need Delphi 5 or newer in order to run the current GLScene software.

This tutorial is created using Delphi 6 and GLScene version 1.0.0.0622

It is advisable that you use a PC that has a 3D graphics card installed that supports at least OpenGL 1.0

The PC on which the tutorial was created runs Windows XP Home edition and made use of an ATI Radeon 9600 graphics card.


Library installation

It is advisable that you install the entire GLScene library. This provides you with the benefits of having access to a wide range of demo applications showcasing the various features of GLScene.

There are two ways to obtain the library code. You can go and download a the latest release code here or you can access the Sourceforge CVS repository directly and have all the very latest source code at your finger tips.

See the chapter on CVS later in the manual if you wish to use the latter option.

We will assume for the purpose of this installation guide that you have the GLScene stored in
C:\library\GLScene and that you use Delphi 6

Installation of GLScene

Step 1
  • Start Delphi
  • Select Tools - Environment Options - Library

  • Click on the ellipsis button behind "Library Path" and make sure at least the following paths are there

  • Click on OK once you are done
  • Click OK again for the previous dialog

Now we are going to prepare your system so it can find the various third party DLL's that are shipped with GLScene.

(In the screen shots following you will see little green tags on the file icons. Don't worry about these. They are a feature of CVS Tortoise that I use)
  • Copy the files listed below to your Windows\system32 folder

Now we are going to compile the design-time parts of the library and get those wonderful VCL controls installed. Most people allow Delphi to create a blank project by default as Delphi starts up. We don't need it so Close everything.
  • Click in Delphi on File - Close All

In this case we are going to assume you are using Delphi 6. Adjust the instructions for the appropriate Delphi versions.
  • Click File - Open and open GLScene6.dpk

  • Compile and install the package

Now do the same with the following packages in the following order:

GLS_ODE6.dpk
GLS_SDL6.dpk
GLS_BASS6.dpk
GLS_FMOD6.dpk

If you have the cg or dws library then you can also compile those packages.

Your GLScene library should now be completely installed. The VCL palette should look like this


Compile your first demo application

Now GLScene is installed I am sure you want to see this library in action. The library comes with a lot of demo applications. Each showcasing GLScene features.

The purpose of this topic is to let you compile and run a GLScene demo application in order to confirm that the library is correctly installed.
  • Start Delphi
  • Load C:\library\GLScene\Demos\behaviours\torque\torque.dpr

Compile and run it.

The application should look like this

If you move your mouse over the shapes they should start spinning.

If they do: congratulations, if they don't then it is time to hit the any of the following:

  • FAQ,'s
  • Google
  • GLScene General newsgroup
  • GLScene Support newsgroup


The first steps

We are ready to take our first steps into the 3D openGL universe. In GLScene the universe or 3D world is called a scene. Hence the name. We are going to create our first application that will contain a 3D cube. We will learn how to start a basic GLScene application and how to control the layout by manipulating the design time properties.
  • Start a new application in Delphi
  • Set the form width to 640 and the height to 480

  • Go to the GLScene tab on the VCL palette

  • Place a TGLScene [image] and a TGLSceneViewer [image] viewer on the form

The TGLSceneViewer is the window which will give us a view into the 3D scene we are about to build. The TGLSene is the master of the scene. Everything that happens is managed through the TGLScene control.

Let’s introduce you to the most important dialog in GLScene. The scene editor.
  • Right click on the TGLScene [image] icon on the form and select “Show scene editor”

As a result the scene editor dialog will appear.

The world managed by TGLScene is still a blank canvas. You can add objects such as shapes, camera’s and lights to build your world in this editor.

Let’s start by adding a 3D cube to the scene.
  • Right click on [image] “Scene Objects” and select a “Cube” from “Basic geometry”

You can see there are a lot of objects you can choose from. Leave those for what they are for now. We will visit other objects later in the tutorial.

The popup menu will collapse once you click on the [image] Cube object. The cube is now added to the scene.

Let’s close the scene editor and check out wat we see.

???? Nothing! Why can’t you see the cube? Well that would be correct. There is a whole bunch of things that need to be considered before you will see anything.

Check out the next topic to sort out the issues.


Make it all work

In the previous topics you build an application but so far you could not see any results. Why can’t you see the cube? Well in order for you to see anything at all you will need to create a way to view the scene. This is done using a camera. We are now going to add a camera to the scene.

Need to know:
The scene editor doesn’t always know where you click on. A work around is to select any other node in the editor and then select the node you want. Only then will the object inspector (F10) and the context popup menu be correct.
  • Left click on [image] “Scene objects” to make that option active
  • Left click on [image] “Cameras” to make that option active

This weird toggle action will sort out the Scene editor if it get’s confused. Use this trick whenever the object inspector or context menu fails to show the correct information.
  • Open the scene editor again. Right click on the TGLScene [image] icon on the form and select “Show scene editor”
  • Right click on [image] “Cameras” and select “Add camera”

You now have a camera but don’t bother to go and check out your creation on the form. There is still nothing there!

Need to know:
Every new object that is created is always placed in the center of the scene by default.

So you can see that the camera occupies the same space as the cube. Besides the camera points at some default direction and chances are that it is not pointing to the cube anyway.

Well that is easy to fix. We are going to tell the camera to look at the cube
  • Select [image] GLCamera1 and press F10 to bring up the object inspector.

In the object inspector you will see the camera properties.
  • Set the “TargetObject” to GLCube1

From now on the camera will always point at GLCube no matter where the Cube or camera is located.

Still the GLSceneViewer won’t show anything. The main reason for this is that the viewer has not yet been told for which camera it should display a view. In GLScene you can have multiple camera’s and you can switch your view from one camera to another.
  • Close the Scene editor
  • Select the TGLSceneviewer control
  • Press F10 to bring up the object inspector

One of the properties of a tGLSceneViewer is the Camera property. This property defined wich camera should be used to render the 3D view for the viewer.
  • Set the “Camera” property to GLCamera1

Still nothing to see. Let’s summarize what we have done and see if we can identify what we have missed.

We created a cube and a camera. We told the camera to look at the cube. We told the viewer to use camera1. However, we never told the camera and cube where to go!

For now let’s just get this thing working. After that we need to spend some time to talk about 3D coordinates.
  • Right click on the TGLScene [image] icon on the form and select “Show scene editor”
  • Select [image] GLCamera1 and press F10 to bring up the object inspector.
  • Set the position coordinates to X=1, Y=1 and Z=1

Finally, something appears on the screen. It looks pretty bad but at least it’s something right?

What you see is the silhouette of a 3D cube as seen from an angle. It is all black because… There are no lights! Every scene needs lights. Without lights you can’t see anything. So let’s add a light.
  • Right click on the TGLScene [image] icon on the form and select “Show scene editor”
  • Right click on [image] “Scene Objects” and select a “Lightsource”

Nothing changed. The new light is added to the center of the scene and in our case the light would end up in the inside of the cube. We need to move the light up to get it out of the cube.
  • Select the new light in the scene editor and press F10 to bring up the object inspector
  • Change the position of the light as shown below

And finally the cube is shown in all it’s glory.

Congratulations you have mastered the very basics of GLScene. We have created an application containing a TGLScene [image] and a TGLSceneViewer [image] We have added a cube, a camera and a light. We told the viewer to use our new camera. We made the camera look at the cube and placed the camera away from the cube so it can look at it. We added a light and placed it above the cube and presto we are done! So the minimum requirements in order for you to see anything in GLScene are:
  • TGLScene component (The scene master object)
  • TGLSceneViewer (To see stuff)
  • TGLCamera (were to see stuff from)
  • TGLLight (So we can see stuff)
  • TGLCube (Stuff to see)

Obviously these objects need to be configured in such a way that the camera can actually see the cube and the light can shine on the outside of the cube.

Although we have achieved to display a 3D object in Delphi, we need to be able to manipulate the object in 3D space. Gain control so to speak. the next topic will help you to get started.


Managing object positions

So we know how to move thing around in 3D space but we still need to learn how to manage their orientation. This topic will explain the do's and don't of Object orientation.

Object orientation is basically the art of rotating an object around it's X, Y and Z axis.

So far we have explained every step in detail. Before we continue we will list knowledge we assume from now on. We assume you know how to:
  • Open the scene editor
  • Add objects to the scene
  • How to select objects
  • How to access the objects properties.

Now we have a 3D cube in a viewer we can start messing around with the cubes position. The coordinate system in GLScene uses three axis that are perpendicular to each other. The manage placement in X, Y and Z direction.

Let’s illustrate this by turning on the “Show Axis property of the cube.
  • Select the cube in the object inspector and set the “Show axis” property to True

A 3 colored axis system is now shown.

The three axis you see here are the X, Y and Z axis.

X axis is Red
Y axis is Green
Z axis is Blue

The intersection of these three axis is coordinate X=0.0, Y=0.0 and Z=0.0 which is where the cube is currently placed. We call this system of coordinates a coordinate system. Now here is where things may become confusing:

Every object has it’s own coordinate system!

For now just accept this as a fact. Later you will find out the incredible power that can be gained from having this feature.

By default objects created in GLScene have a size of 1 unit. Therefore the cube is 1 unit wide, 1 unit height and 1 unit deep.

Let’s move the cube along the x axis by changing the position.x property of the cube from 0 to 1. This should move the cube along the red X axis by exactly the width of the cube.
  • Set the Position.X property of GLCube1 to 1

The result won’t be what you expected:

What happened? Well the cube moved along the X axis as intended but the camera is programmed to keep looking at GLCube1. So the camera turned to follow GLCube1 and the above image is the result.

We need to give the camera a fixed reference that does not move. A quick and easy way is to use another object that stays in place while the cube moves around.

Introducing the “Dummy cube”. This cube can be seen during design-time as a wireframe cube but is not rendered during run-time. The cube however is still very much part of the object structure. Let’s try this
  • Open the scene editor and add a dummy cube
  • Select the camera and set its “Target” property to GLdummyCube1

Have a look at the form now.

The camera orientation has gone back to what it was before we changed the GLCube1 position.X coordinate. The white dashed wireframe shows the position of the GLDummyCube1. That is where the GLCube1 used to be.

Now play with the coordinates of GLCube1 a little. Change Position.X Y and Z and see if you can place the cube in the lower left corner of the viewer.
Coordinates in GLScene are of type Single. You can therefore enter fractions such as 0.43 and so on. Try both positive values and negative values

Need to know:
The default values for a camera define a “NearPlaneBias” with a value of 1. When object come close to the camera they get clipped by this plane. This is the reason that the Cube in the above picture has a corner missing.

You can make this artifact go away by decreasing the “NearPlaneBias” from 1 to say 0.1

Once you feel familiar with the position coordinates you can go-ahead and move the cube to it’s final position:
  • Set the GLCube1.position.x to 0
  • Set the GLCube1.position.y to -0.5
  • Set the GLCube1.position.z to 0

We are now going to do some more work with coordinates. This time we will use a TGLLines object. TGLLines can draw a polyline in 3D space. The final line drawn can be made up of straight line segments or a spline can be drawn through its points.
  • Open the Scene editor and add a “Lines” object.
The form will look like this:

As you can see the GLCube1 has moved down half a unit but there is no line anywhere in sight. This makes sense because we have yet to define the points that make up the line.

We are going to create the outline of a simple house shape. The points of a TGLLines object are called nodes. Let’s add a few nodes and keep an eye on the form to see where they end up.

To make identification of the node points easier we will set a few properties first.
  • Select the GLLines1 object in the scene editor and press F10 to get the object inspector.
  • Set the Linecolor to clrAquamarine
  • Set LineWidth to 4
  • Set NodesAspect to lnaCube
  • Set NodeSize to 0.1

We have now told GLLines1 to draw it’s lines in aqua marine color 4 pixels wide and mark every node in the polyline with a cube with a size of 0.1 units wide, high and deep.

Let’s get to work and add some nodes.
  • In the above object inspector click on Nodes to bring up the nodes collection dialog

Click on the familiar “Add” button to add a node. Each node can be given a color and an X,Y,Z coordinate. Lets start with the top of the roof of our house shape:
  • Enter 0.5 for the Z coordinate

Add nodes until you have the following collection:

Try not to look and figure out the coordinates for yourself to obtain this shape:

Need to know:
Note how all Y values have been left to 0. In GLScene the Y axis is going “up”. The above GLLines1 object is flat with all it’s Y coordinates set to zero.

Can you create a set of nodes that allows the house to stand upright? I bet you are bored about coordinates. Same here, let’s see if we achieve this upright house in a different way.

There are two things that define an object in space. Position and Orientation. We know about position now. the next topic will teach you how to manage an objects orientation.


Using vectors in orientation

Ok, if it is late now then you want to save your project and go to sleep. Understanding vectors is no trivial feat and needs to be understood properly.

Let’s hide the GLCube1 we created earlier so we can concentrate on the GLLines1 object.
  • Select GLCube1 in the scene editor and set the visible property to False

The GLCube1 has now disappeared from view.

Before we can play with vectors we first need to understand what a vector is.

A vector is a direction

That’s all. Just stretch your arm out and point somewhere. Your arm now forms a vector defining a precise direction. If we were to measure the X,Y and Z coordinate of the tip of your finger relative to your shoulder then we would have an exact definition of the direction your arm is pointing.

Therefore a vector is defined by an X,Y and Z value in a similar way as the position is defined by X,Y and Z

To stick with the hand pointing example, That vector could define a compass heading (TurnAngle) and how much up or down the direction is (Pitch)

However to perfectly define the orientation of a 3D object in space we need to define the objects angle relative to all three axis. Rather than managing three indiscriminate angles GLScene uses two vectors to define the orientation of an object.

The Direction vector defines where the object is pointing at. By default the direction of an object is in the Z axis. The direction vector manages the TurnAngle of the object and the PitchAngle.

The Up vector defines where “up” is. By default the Up vector is aligned with the Y axis. The Up vector manages the RollAngle and PitchAngle.

Enough talk. Let’s try to visualize this.
  • Select GLLines1 in the SceneEditor and press F10 to bring up the object inspector
  • Set “Show axis” to True in order to see the axis of the coordinate system
  • Select the GLDummyCube in the Scene editor and set it’s “ShowAxis” property to True.

As you can see the default Direction vector points into the screen being the Blue Z axis in our example you can assume the roof of the house shape to be the arrow pointing in the the same direction as the Direction vector.

Before we change anything, check out the Up vector values as well.

As suggested earlier, the Up vector points along the Y axis.

Ok, now bear with me. Earlier on in the tutorial I suggested that every object has it’s own coordinate system. I even dared to claim that this is a good idea. Let’s explore this concept now.

The master of the scene (universe) is the Scene Root object. We can assume this to contain it’s own absolute world coordinate system. Within this scene we have a Light, a camera, a cube, a dummy cube and a Lines object. Each with it’s own coordinate system.

But!!! We haven’t messed with the orientation if the individual coordinate systems yet so they are all nicely aligned with each other. For all intense and purposes they are the same.

All coordinate values defined for an objects position direction vector or Up vector are defined in the objects parents coordinate system. So all the coordinates used for GLLines1 are relative to the “Scene root” master coordinate system because GLLines1 is a direct child of Scene root.

Changing the direction vector of an object causes the orientation of that objects coordinate system to change. The nodes, vertexes or points of any 3D object in GLScene are relative to that objects coordinate system. But we define the direction vector in terms of X,Y and Z! so do they change too?

The answer here is NO. Because Position, direction and Up vector are defined relative to the parents coordinate system.

Don’t fully understand this? Not unexpected. Try the following exercise. It may shed some light on this matter.
  • Select GLLines1 in the scene editor and press F10 to bring up the object inspector
  • Change the Direction.Y value to -1

Although you entered -1, they value instantly changes to -0.7071068

Why is that? The absolute value of a direction vector does not matter since all we care about is the direction in which it points. GLScene makes use of “Normalized” vectors. These vectors are automatically resized to be exactly 1 unit long.

We have turned the direction vector downwards (relative to it’s parents coordinate system) by entering -1 as an Y value. The Z value of 1 and Y value of -1 were recalculated to normalize the length of the vector back to 1 and the result is that Y = - 0.7071068 and Z = 0.7071068

As you can see the Blue Z axis from the GLLines1 object is now pointing down. Now, make a guess. If you change the Position.Y coordinate. Where is the GLLines1 shape going? Straight up along the parents coordinate system (As shown by the dummy cube axis) or Up and forward along it’s own Y axis?

Why not just try it.
  • Select GLLines1 in the scene editor and press F10 to bring up the object inspector
  • Change the position.Y value to 0.5

Indeed, the shape went straight up because the GLLines1 position coordinates are expressed relative to it’s parents coordinate system. Let’s go one step further and see what happens when we add a Cube as a child of the GLLines object.
  • Select GLLines1 in the scene editor and add a Cube object

Make sure that the GLCube2 is a child of the GLLines1 as shown

You can drag and drop object in the scene editor to redefine Parent child relationships.

Wow, see this? The GLcube2 automatically aligned with the GLLines coordinate system.

Let’s have a look at the Up vector which should have a default value of Y=1.
  • Select GLLines1 in the scene editor and press F10 to bring up the object inspector

Indeed, the Up vector points straight up. This value is relative to the cubes parent coordinate system which is owned by GLLines1.

Now enough wow stuff. We are going to delete GLCube2 from the scene.
  • Open the scene editor, select GLCube2 and delete it

We set out to re-orient the house shape so it would point up. You should now posses the knowledge to do this.

Indeed. Set the direction vector of GLLines1 as shown below and while you are at it. Set the Position Y value back to 0

The result is a GLLines with a direction vector pointing up along the Y axis

This brings us to the end of this tutorial. In this tutorial we have learned to place objects in a coordinate system, manage their orientation and get some appreciation of the concepts of parent and child coordinate systems.

At this point you should be able to build applications that use basic geometry, do basic lighting of the scene and manage position and orientation of your objects in design-time and of course at run-time.

You may have noticed the PitchAngle, RollAngle and TurnAngle properties on GLLines1. This is another way to manage an objects orientation but as you will see in the next topic it is not the best way.


Dangers of Pitch, Roll and Turn angles

You may have noticed the PitchAngle, RollAngle and TurnAngle properties on GLLines1.

and wondered why there are not used instead of the rather confusing Direction and Up vectors. Some rather complex 3D math comes into play here but I’ll attempt to explain when you should and when you should not use these properties.

First thing to note is the fact that any of the three angles (Pitch, roll and turn) are defined relative to the objects own coordinate system and not against the coordinate system of the parent like is the case with the Position, direction and Up vector.

This is a confusing situation because if you change the PitchAngle from 0 to 30 degrees then the object will pitch 30 degrees from it’s current pitch angle. The objects coordinate system, direction vector and Up vector are all updated. Let’s try it.

  • Select GLLines1 in the scene editor and press F10 to bring up the object inspector
  • Set the PitchAngle to 30

The result is that the GLLines1 object pitches 30 degrees like so:

Did you notice in the above object inspector how the Direction Vector has changed? So if the Pitch is relative to the objects coordinate system. How come that the pitch still shows 30 while the GLLines1 object has a pitch of 0 relative to it’s own coordinate system.

Indeed, confusing. The way GLScene implements these angles is that behind the scenes the library is simply instruction to pitch the coordinate system around the X axis by the change of the PitchAngle. In our example the old PitchAngle was 0, the new one was 30 therefore the pitch change was 30.

So if you now enter PitchAngle = 20 you will find that the delta pitch is -10 and the coordinate system will come back in pitch by 10 degrees.

  • Set GLLines1.PitchAngle to 20

Now, let’s take control of this object and align the Direction vector back with the Y axis as it was before.

  • Set GLLines1.direction.Y to 1 and GLLines1.Direction.Z to 0

Have a good look at the Form and object inspector. The direction vector corresponds with what you see on the form but the PitchAngle still shows 20!

Yeah, have a coffee at this point and a little cry. It just isn’t fair. What is happening is that within the objects coordinate system the object was told to pitch 20 degrees. After that we re-aligned the coordinate system with the Y axis and thus the GLLines1 object points up again. Guess what happens if you set PitchAngle to 0? Right.

Conclusion: Using Pitch, Roll or turn is useful as long as you don’t mix it’s use with the Direction and Up vector. Another important limitation is that you should not manipulate the object around more than one axis.

Let’s prove this with another example.

  • Set GLLines1.PitchAngle to 0
  • Set GLLines1.TurnAngle to 0
  • Set GLLines1.RollAngle to 0
  • Set GLLines1.Direction.X = 0, GLLines1.Direction.Y to 0 and GLLines1.Direction.Z to 1
  • Set GLLines1.Up.X = 0, GLLines1.Up.Y to 1 and GLLines1.Up.Z to 0

You should see this again:

Now let’s pitch this object up by a 60 degrees, around by 135 degrees and back down to a pitch of 0. You would expect this right?

But that is NOT what you are going to see. Try it now and observe the form after each step.

  • Set GLLines1.PitchAngle = 60
  • Set GLLines1.TurnAngle = 135
  • Set GLLines1.PitchAngle = 0

As you could see. After each step the objects coordinate system changes and therefore subsequent steps are performed in a different coordinate system that has a different orientation.

The best thing to do is go back and re-read the topic about vectors if not fully understood. Or refrain from manipulating more than one angle on an object.


More about Lights

Several aspects control an objects appearance. There is of course the objects color and material settings which are very versatile and powerful. But there is also the lighting that makes things appear. Remember.

Vision is reflected light

In a Previous tutorial we found out that we don't see much unless we create a light source. Once the light was in place we could see the object. Let's continue on this and start to do some basic experiments with light first.
  • Set the Visible property for GLLines1 to False
  • Set the Visible property for GLCube1 to True
  • Set Position.Y property for GLcube1 to 0

You should see this now

Let's also visualize the light source by placing a sphere at the same location as the light. We are going to re-arrange our scene so everything fit's into the view nicely.
  • Change the value of Position.Y from GLLightSource1 to 2 to move it close to the cube
  • Change all Position.X, Y and Z values from 2 to 3 to move the camera further away
  • Add a sphere object and make sure it is a child object from GLLightSource1
  • Ensure that the position of GLSphere is all 0. Because it lives in the coordinate system of the GLLightSource1 we want it to be zero so it is co-located with the light.
  • Set Radius of GLSphere1 to 0.1 to make it smaller

You should now see this on the main form:

The stage is now set for our next series of experiments. Now we can see the light we can appreciate how it will affect the way the cube looks. Let's move the light around a bit and study the effects.

Move the light smack in the middle over the cube. Remember the coordinate system?

The X and Z axis form the ground plane while the Y axis goes up.

You can see in the scene editor that both the Cube and the light live in the same coordinate system so you need to match the X and Z coordinate with the values found for the cube.
  • Set Position.X and Z to 0 for GLLightSource1

The light moved right above the cube. you can now see how there is no light reaching the sides of the cube while the top is evenly lit.
  • Set Position.X and Z to 1 for GLLightSource1

You have now placed the light right above the front corner. You can see how the front corner of the cube is brighter than the far corner.

Play around with the light a little. Move it closer, further away and study the effects. Just like in real life, light placement is critical for properly lit scenes and lights can make objects with the same material look very different.

So you may ask the question. Why is the cube gray? Well there are two reasons for this. The default material for the cube is gray and the lightsource emits a nice clean white light. So the color you see is the true color of the cube's material.

Let's play with the light color a little. Set the light color to Red
  • Set the GLCamera1.position values all to 2 to move the camera closer
  • Set Diffuse color of GLLightSource to clrRed

The cube's appearance changed to red because the gray material reflects the red light to the camera thus causing the red appearance.

You may have noticed the other color properties on the TGLLightSource Ambient and Specular. Ambient is the surrounding light that is bouncing around the place. Unlit surfaces still receive some amount of ambient light.

Specular light color defines the light color for the highlight spots on objects. For example a shiny plastic ball would have a small but bright spot where the light bounces directly to the camera. It is in fact this bright spot that gives a surface a shiny appearance. Hence the word "shiny"


Basic object material options

The single most important property controlling an objects appearance is the Material property. There is a lot to be said about materials but this tutorial will take you through the basic steps.

First prepare the scene and change the GLLightSource1 diffuse color back to White.
  • Set the diffuse color property of GLLightSource1 to clrWhite
  • Set the position property of GLLightSource1 to X=2, Y=3 Z=1 to move the light back into position

The cube appears in it's natural gray color again. Now we are ready to play around with the objects material. You should see this again:

  • Select GLCube1 from the scene editor and click on the + in the object inspector before the "Material" property.
  • Click on the + in the object inspector before the "FrontProperties" to expand it

You should see this:

Again you can see the three colors we saw earlier in the light properties. Ambient, Diffuse and Specular. The object can also emit light. The color of this light is defined by the Emission color property. (Note that emitted light does not illuminate other objects.)

You may have noticed that besides the FrontProperties, there is also a BackProperties section. The 3D triangles that make up everything in the 3D OpenGL world have two sides. A front and a back. Normally the back of a 3D face is not rendered but you can choose to have two sides rendered. In that case the BackProperties become important.


About CVS
 Previous Top
The GLScene open source library is hosted by http://sourceforge.net/projects/glscene Although it is recommended to work with the release versions of GLScene, for some it may be nessesary to access the latest files directly from the version control system CVS.

If you wonder what CVS means you should probably move on but basically developers contributing to GLScene use access to CVS to get the latest code to fix bugs, add new features and so on.

Anyone can have read access to CVS. Only authorised opensource GLScene members have write access.

The progam I use to access the latest GLScene source code is called TortoiseCVS . This program integrates very nicely in your file explorer in windows and makes file access very simple indeed. You can download TortoiseCVS here: http://www.tortoisecvs.org/

The procedure below has been written based on version 1.8.22 of TortoiseCVS

Once you have installed TortoiseCVS you need to configure it for read access to the GLScene CVS repository in SourceForge.

Step 1

Create the GLScene folder where you want to store the GLScene library. Call it whatever you want but "GLScene" seems to make sense to me. Next you right click on the GLScene folder

Select "Make New Module" on the popup menu and enter the details as they appear on the dialog below:

A quick way to enter the details is to paste this text into the CVSROOT field:
:pserver:anonymous@glscene.cvs.sourceforge.net:/cvsroot/glscene. Click on "OK" and the CVS will be files will be donwloaded from CVS.

Developer access

For developer access to CVS you need to be authorized by the GLScene administrator. You will need to use your SourceForge username and password to access CVS.

You may need to select a different protocl in TortoiseCVS.

Try "Secure shell (:ext)" or "Secure shell (:ssh)

Enter your SourceForge user name in the username field. When TortoiseCVS connects to CVS you will need to provide the password.