This page groups the most frequently asked questions and their answers. A few things before you ask in the newsgroup:
- Get the latest CVS version (from this site or CVS)
- Check the new detailed beginner tutorial in the glscene\help folder. It will help you through install, first application and CVS setup.
- Check out the demos, they demonstrate the use of many components/functions as well as ways around common issues
- Search the newsgroups whether you question was asked some time ago
Extra resources, modelers and editors
GLScene should be installed like a Delphi package, by opening the relevant ".dpk" file (GLScene5.dpk for Delphi5, GLScene6.dpk for Delphi6, etc.) and then clicking "Install" (check your Delphi manual for more details).
The sound-support and other optional packages install in a similar fashion, but make sure the underlying sound API/DLLs have been properly installed before attempting to install a package.
- Samples run ok, but compile/design does not: recompile the dpk and make sure you do not have multiple version of the files
- Samples don't run, compile/design does: make sure an up-to-date bpl is accessible to the exe (like in the Delphi\Bin directory)
- Errors with ODE, check the DLL you're using is the good one (just copy it from the Physics directory)
GLScene is currently distributed under Mozilla Public License, see http://www.mozilla.org/∞
for details. In short, this means it is not public domain and the agreement consists in what is stated in the MPL, that is:
- can use freely, in free or commercial software, can redistribute freely the packages (source, exe, bpl etc.)
- remains copyrighted software, you must place/leave a notice whenever you use/distribute it, with proper credit/link to author/site
- any alterations/modifications to the code must be made public (to owner and users)
- additions, libraries or code that just uses GLScene do not fall under MPL, and can be private/commercial
The help is in the "Help" subdirectory, in HTMLHelp format (check the "download" section if you are using Win95 and need HTMLHelp support). It is regularly updated, but GLScene is currently growing faster than the help file.
A beginner tutorial is included in the GLScene\help folder. alternatively you can check out the on-line tutorials
The only 'core' tutorials available are the samples/demos. Check them from first to last, read the comments in the header of their "unit1.pas", play with them, and you should get a fair understanding of GLScene.
- Johan Rabie is maintaining the GLScene Documentation project at http://CapeRaven.co.za∞, the site also includes tutorials, demos and links sections.
- Rene Tschaggelar has written a QuickStart guide here
- Charlie Calvert has a "first tutorial" for GLScene in his OpenGL Notes
All 3D objects, from sphere to camera to light are edited from the TGLScene editor, double-click on a TGLScene component and a hierarchical scene editor will popup, allowing to compose most of your scenes at design-time.
Make sure you added all the GLScene source paths to your Delphi library paths (Tools / Environment Options / Library). All the source paths must be added (Source, Base, FileFormats, etc.).
First, install the package, new components will be added to your palette.
Drop a TSceneViewer and a TGLScene on your form, then double-click the TGLScene or use the context menu (right mouse button), this will bring up the scene editor.
The very first objects you will probably want to add are a Camera, a Light and an object (f.i. a sphere).
You now have to pick the camera in the sceneviewer's Camera property, the viewer will no render from the camera point of view.
All new objects are positioned at coordinates (0, 0, 0) by default, so you need to arrange them if you want to see something, f.i. move the light by setting its position to (10, 10, 10) and the camera at (5, 0, 0) away by giving.
The camera will most likely not be pointing at the object, so either orient it with its "direction" property, or just pick your object in the camera's TargetObject.
GLScene uses OpenGL for rendering, if you have an hardware-accelerated graphics card that supports OpenGL, hardware acceleration will be automatically used.
However, some 3D cards do not accelerate all resolution/pixel depth, and if acceleration is unavailable, OpenGL will fallback to software rendering, you may query the "Acceleration" property of a Viewer's Buffer to check if this viewer is hardware accelerated or not.
Check the "Info" form to know at design-time which OpenGL driver is used: just double-click on a TGLSceneViewer.
There are various 3D resources I found on the web :
- FlipCode has a nice series of article introducing 3D math, and other categories that deal with more complex aspects. Quite a complete site.
- Wolfram Research stores a fair set of material, but be warned this is mathematical stuff, not code. If it's math related, you'll find it here.
- Gamasutra's Features contains a series of articles (with C code most of the time) on various game programming issues, including 3D math. Do not expect primers here though, but rather "advanced" documentation.
- GameDev Developer resources similar to Gamasutra, but seems less thorough and definetely less structured. Worth a look.
- Delphi 3D, not exactly primers, but Tom Nuydens maintains a collection of articles on 3D rendering techniques that may help you understand how things work.
If none of these suits you, check the sites in the "Links" section, they maintain their own list of interesting links and you may well find the hidden gem here.
(adapted from a post by Robert Hayes)
Here's a quick run-down if anybody wants to use it (and they're not behind a firewall):
This is the new directory structure for GLScene... broken down by Delphi version. When you download code, it will be from one of these directories (f.i. Delphi5 and Source).
I tried WinCVS but had more success with TortoiseCVS: http://www.tortoisecvs.org/∞
Once Tortoise is installed, pick the *highest* level directory where you want all your GLScene subfolders to go (for me for example it's Delphi/Lib), and right-click on it. Then choose the CVS checkout option. A "checkout" is when you first download all the folders and files from a directory off the server onto your local machine. Tortoise will ask you for some info and the answers are:
Protocol: Internet (Unix pserver)
Repository directory: /cvsroot/glscene
User name: anonymous
you can also simply copy this string into the CVSROOT string whose value is:
Note: When you use TortoiseCVS on GLScene for the first time it will enter the module name "GLScene" at the Module field. Replace this name with a dot "." otherwise the CVS checkout will fail because CVS can not find the GLScene module because there is no module named like that. The module name "." checks out everything in the GLScene repository including the advanced demos. If you only want to update the source you can enter "Source" as a module name and note the capital "S"
When you hit OK it will pull all the files and subfolders in the Source "module" on the server to a new folder called Source on your computer. Then you can do the same thing for any other folders you want (Delphi5, demos etc.), or use '.' to check out everything (be aware this will also include AdvDemos, which can be heavy to download).
Once you've checked out everything you want, you'll notice these folders have a green highlight to them. If you right click them again, you can now update them whenever you want. The only think left to do is change your Delphi environment options to point to the new directories :)
The DummyCube is a (usually) non-visible objects that exists in the scene hierarchy.
GLScene objects can be arranged as sub-objects of other GLScene objects and can be set to have relative position to their parent. If the parent moves, all children are moved along, this works with all GLScene objects.
A dummy cube can be used when you have no "physical" parent for objects that must be moved together, it can also come in handy when you have complex sorting or rendering needs (depth-sorting for transparency, mirrors, etc.). It can also be used to decompose rotations axis by axis (and allow "reversable" relative rotations f.i.), several of the "movements" demo use DummyCubes to that purpose.
Finally the DummyCube is also commonly used as Camera Target (with the Camera a child of its target dummy cube or vice-versa).
The VfW.pas unit is used/referred by both GLScene and the JvMM package, to resolve the incompatibility, either add the GLScene package to the requires of JvMM, or add JvMM to the requires of GLScene. Rebuild the packages.
Make sure OpenGL is properly installed and that you have the latest drivers, which can typically be found at your hardware manufacturers website. The drivers auto-installed by WinXP/2k/2k3 don't support hardware acceleration by default, make sure you always update them after installing or reinstalling the OS. You can also use MESA for Software OpenGL support.
Delphi built-in math functions (like Trunc() or Frac) are not all compatible with a non-standard 8087 Control Word (See Set8087CW in Delphi's help - Nota: Delphi 6/7 do not have this issue, but the implementation is significantly slower).
Replacement functions are provided in the VectoryGeometry.pas unit, these functions are also faster than their VCL equivalents, so make sure you are NOT using "math", but "geometry" instead.
Texture mapping requires 2 things to work:
- A properly loaded, enabled, texture map
- Texture coordinates
Texture coordinates are provided for all standard GLScene objects, but for TGLMesh, TGLFreeForm and TGLActor, they must be either provided in the 3D file or given by the programmer during the mesh compositing phase.
If the texture map is not loaded or enabled, the color of the object will not change at all. If the coordinates are not right, but the texture is loaded, the object will most likely be given a uniform color.
Here is a quick reminder, if not compressed:
RGB, RGBA -> 16 millions colors RGB16 -> 65536 colors RGBA16 -> 4096 colors The '16' modes use less memory but are of low quality. Texture compression must be supported by hardware. The other common limitations are:
- 3Dfx Voodoo3 boards are limited to RGB16 and RGBA16 (even if you require RGB or RGBA)
- some ATI drivers limit textures to RGB16 (you have to uncheck something somewhere in the display properties, this is a trick to get more FPS commonly found in "branded" systems)
- texture resolution is also usually limited by desktop resolution
So switch your desktop to highest color setting, and stick to RGB & RGBA if you want high-quality, to save memory, try texture compression or the 16bits mode (texture compression is almost always preferable if available).
Make sure the image management class are included in the compiled executable. For instance, this will happen if you use Jpeg textures, and did not add "Jpeg" to any of your uses clause : TJpegImage is not compiled in the compiled exe.
To solve this, add "Jpeg" or any relevant unit to one of your uses clause.
Transparency requires depth-sorting (back to front) for the objects to be rendered correctly when ZBuffering is active. This can be automatically handled by GLScene to some extent with the ObjectSorting property.
See the materials/transparency for explanation and illustration.
You can print a scene by rendering first to bitmap with the TGLSceneViewer.RenderToBitmap method (and specify printer dpi resolution), then draw the bitmap on the printer Canvas.
Make sure you defined the bitmap's size as well as pixel depth (f.i with "PixelFormat:=pf24Bit") before invoking RenderToBitmap, if not, drawing on the printer Canvas will fail.
See the rendering/tobitmap demo of GLScene.
Several options, from fastest to simplest:
- Design a textured cube in a 3D modeler, and map your faces as suits you best
- Build a cube from planes in a TFreeForm
- Use 6 TPlane objects
You can't, this is a common hardware limitation, and anyway, having more than 3-4 lights is not recommended performance-wise. Common alternatives are:
- Switch-off lights that are far away
- Use pre-lit textures
- use lightmaps/shadowsmaps (a luminance texture modulated with your primary texture)
- Use custom vertex lighting (not recommended, but you may then do anything you want)
You need the CVS version of DWSII for this demo to work. See section "CVS : Setting up access" in this FAQ for a quick guide on how to use CVS. To access DWS's CVS just use CVSROOT=:pserver:firstname.lastname@example.org:/cvsroot/dws
This may occur on some systems when you have copied a glscene control like the TGLSceneViewer into the clipboard. To get rid of this error all you need to do is to copy a piece of code into your clipboard to make the error go away
Following instructions assume that you have TortoiseCVS (version is 1.8.*)
1 - Create a directory named GLScene
2 - Go in this directory
3 - Right click on it, and do CVS Checkout...
4 - You must have in the windows that appear:
5 - Click the OK button. The download will begin and you will get the complete GLScene directory
6 - Until now, you are (implicitly) on the Main (HEAD) branch. You can verify this point with a right click on any file and in the sub-menu of CVS, select "Revision Graph..."
7 - Now, we must take the GLScene_BCB6 branch. To do that, Right clich on the "Source" directory and in the sub-menu of CVS, select "Update Special...".
On the windows that appear, check "Get tag/branch/revision" and select on the list GLScene_BCB6. If this branch is not present click on the button "Update list...". Don't change the other default params. Then click OK.
8 - Repeat this operation for the directories "Demos" and "AdvDemos"
That's it. Your version of GLScene are now compatible with Delphi/BCB/Kylix Now, you can install GLScene (be sure that you have eradicate all older files)
1. Open GLSceneBCB*.bpg project group that are in BCB*
2. First install GLSceneBCB*.bpl
3. Install the others you need
If you need some *.lib, you can found them on the Library directory of BCBDemos.
For cgShader, you can find dll at :
- NVidia Cg Toolkit page (whole package, with demos and docs)
- CPPBuilder Cg libraries by Alexey Barkovoy.
If you need to re-create lib file, use the instruction "implib.exe *.lib *.dll", where implib.exe are in the bin directory of your BCB. Be careful that you have no different version of *.dll in your PATH constant
Kylix compatibility is under way, not all of GLScene's features will be available in Kylix, but one step at a time, GLScene is being "abstracted" to allow cross-platform support without messing with ifdefs everywhere - I hate ifdefs ;)
Upgrade your display drivers. This has been reported to solve the problem with at least nVidia GeForce MX2 chipset, Win2K itself is not the problem.
Be aware that some vendors have a tendency to lag in driver compatibility, and downloading directly from the hardware manufacturer of the chipset is often preferable.
Make sure you properly installed and compiled GLScene.
If the error shouts about a missing GLScene5 or VCL50 package, go to project/options/packages, and uncheck "use runtime packages" or translate to Delphi4 (by using GLScene5 and VCL40).
Be aware that GLScene's main development now occurs on Delphi5 and Delphi6, Delphi4 compatibility and testing comes only through user reports...
There is a known problem with GLScene under Delphi 4 and Windows NT, DirectX exceptions get triggered from somewhere within Delphi 4 (DirectX is NOT used in GLScene), while the compiled applications work fine under NT.
There is no known solution nor service pack that seems to solve this issue. Help and suggestions welcome.
Yes, development currently occurs on Delphi 6/7, so CVS versions are Delphi 6/7 compatible.
No, and no support of Delphi 8 for Dot Net is planned.
No official one since no one with D2005 has yet volunteered to support it. Early reports indicate that getting GLScene to work in D2005 is straightforward, but there may be design-time stability issues (how much comes from the D2005 IDE itself is still unclear).
No official one since no one with D2006 has yet voluntereed to support it. Early reports indicate that getting GLScene to work in D2006 is straightforward, but there may be design-time stability issues (how much comes from the D2006 IDE itself is still unclear). More stable than Delphi 2005
Extra resources, modelers and editors:
The following software may or may not suit your need or your style, but they should get you started:
- OpenFX: generic mesh/CAD editor with quality rendering and animation capabilities
- Blender: generic mesh/level editor, unix-style interface
- GMAX: stripped-down version of 3DSMax, powerful, may have some legal limitations
- Milkshape: simple but efficient editor for actors and simple meshes, supports many formats.
- QuArK: "Quake Army Knife", quake-formats oriented editing tools, quite capable
Severale projects are more or less under way:
If you are interested in these, the simplest way is to get in touch with the authors directly or via the newsgroups.
The following formats are currently supported:
- 3DS (3DStudio, and many others)
- MD2, MD3 (Quake2/3, animated)
- OBJ (WaveFront, and many others)
- SMD (Half-Life, skeletal animation, obtained from a decompiled MDL, f.i. with MilkShape)
- NMF (Normal Mapper File, ATI tool)
- GTS (GNU Triangulated Surface)
- GL2 (Ghoul2, aka MDX)
- OCT (FSRad)
And Partial support is available for:
- BSP (Quake3 BSP)
- PLY (Stanford)
- LWO (LightWave)
- MS3D (MilkShape)
- STL, TIN
Daniel Guldkrans maintains a huge bitmap fonts archive, almost ready-to use in GLScene:
A TFreeForm or TActor can automatically setup the materials and load the textures from a 3DS files. You must first add a material library component (which will store the materials, once the 3DS is loaded), then link the FreeForm to this material library and set UseMeshMaterials to True.
After doing this, when loading the 3DS mesh, the importer will add new materials to the material library (using the names defined in the 3DS file), which you can later alter if you so wish.
Be aware that the image formats must be supported, for instance if your textures are JPeg files, you must add 'JPeg' to your uses.
(by Renaud Ghia, adapted from french version)
This entry explains how to use 3DSMax/Character Studio models into GLScene (with skeletal animation).
As GLScene supports the SMD format (Half-Life), you only need to export your scene and characters from 3DSMax to SMD via the Valve plugin, which can be found at the following urls:
Once downloaded and unzipped, copy the files to the "plugins" directory of 3DSMAX.
An HalfLife character is made of multiple files, the first, or "reference", stores the description, geometry and skeleton of a character, while the others are used for animations of this character
After creating and animating your character in 3DSMax and the Character Studio plugin/expansion, go to FILE->EXPORT, select the "smd" format and check "reference" for the first export.
Repeat the procedure and check "skeletal animation" for each of the animations of your character (if you change your character, you'll have to export everything again, if you only change an animation, you may just re-export that single animation).
That's all, you've now exported your 3DSMax characters to SMD.
Notes and comments:
- Some Character Studio meshes/skeleton have a particular structure, and may not get exported well
- All texture maps must be made available to GLScene, by playing them in the same folder as the SMD, or by specifying the path in the MaterialLibrary (make sure all images formats can be read by Delphi)
The TActor object is uses for SMDs in GLScene, the reference file must be loaded first:
Also suggested by Thomas Mager is the "modeling" document part of the HalfLife SDK, available here, which introduces modeling actors in SMD format and many related dos/donts.
The 3DS importer currently does not properly support clones and duplicates defined in 3DSMax or previous versions. "Pivot" points are reportedly not taken into account either.
Since I don't own 3DSMax, any contribution on this subject from someone with good knowledge of 3DSMax & Delphi would be welcome.