Monday 9 February 2015

Building WadExplorer in Delphi XE7 Starter

WadExplorer is a program written by IceBerg to investigate Tomb Raider Level Editor (TRLE) *.wad files.

Delphi XE7 Starter [link] is the latest low cost version of Delphi for hobbyists and beginners.

If purchasing Delphi Starter Edition be sure to purchase the Upgrade edition which is the cheapest.

You are eligible for the Upgrade version if you have any other IDE installed.

If you don’t have an IDE installed don’t worry the Delphi installer doesn’t check but if you want to be safe just download and install a free IDE like CodeBlocks or ZinjaI or Lazarus or Visual Studio Community Edition.

You could use the 30 day trial version of Delphi XE7 to build WadExplorer instead.

[UPDATE 26May2017: Delphi Starter is now free, see [link].]

Since WadExplorer was written in Delphi 7 it will probably need some changes to compile in Delphi XE7 so use Delphi 7 if you have it.

IceBerg’s website is no longer available but has been preserved at the Internet Archive at this [link].

Download the WadExplorer source code from the site by clicking the dot next to “Source Code (Delphi 7)”.

You will also need to download the IceDataGrid Component source code.

Download Source Code

WadExplorer uses the GLScene library [link].

Clicking the GLScene link on IceBerg’s WadExplorer page shows that IceBerg used GLScene 1.0.0.0714.

GLScene version

This version of GLScene is still available at SourceForge but is not suitable for Delphi XE7 so download it only if you are using Delphi 7.

GLScene available versions

Download GLScene_v1.3_December_2014_VCL.7z.

Download GLscene version 1_3

To build WadExplorer you will need to install the IceDataGrid component into Delphi XE7.

If I remember correctly all I did was open IceControls.dpk in Delphi XE7, right click on IceControls.bpl in the Project Manager window and select Install from the menu.

Install IceControls component

Close the IceControls project and install GLScene into Delphi XE7 by following the installation instructions included with the GLScene download.

GLScene installation

Start at step 3, and ignore steps 5, 6, 7 and 9. GLS_DWS_VCL and GLS_Python_VCL will not build until you install additional libraries but these packages are not needed for WadExplorer so I didn’t bother building and installing them.

Test that GLScene installed correctly by building and running some of the GLScene demo projects included with the GLScene download.

Test GLScene demos

Open the WadExplorer project file, WadExplorer11.DPR, in Delphi XE7.

If IceControls and GLScene are not installed correctly Delphi XE7 will report errors loading the project.

Open WadExplorer in Delphi

Clicking the green arrow button to build and run WadExplorer fails as expected.

The first error reported is that unit GLMisc listed in the interface uses section is not found.

This unit was removed from GLScene and its contents were split between GLUtils and GLState.

Delete GLMisc from the uses section.

When MainUnit is saved, Delphi adds the following units to the uses section automatically.

  • GLCoordinates
  • GLCrossPlatform
  • GLBaseClasses

Running WadExplorer again shows that units VectorGeometry and VectorTypes are also not found.

These units have been renamed and now begin with the prefix “GL”, so add the “GL” prefix to these units in the uses section of MainUnit.

The unit Keyboard in the uses section must also have the “GL” prefix added since the GLScene Keyboard unit was also renamed.

No error was reported for the Keyboard unit because Delphi has its own unit named Keyboard.

The next error reported is that the type TFaceCulling is undeclared.

This was previously declared in GLTexture but now is declared in GLMaterial so we must add the GLMaterial unit to the uses section.

The next error is another undeclared identifier, TColorVector.

This type was previously declared in GLTexture but is now declared in GLColor so add the GLColor unit to the uses section.

The modified uses clause is shown in the code snippet below.


The next error is about incompatible types TMouseButton and TGLMouseButton in Wad2Textures.pas.

Delphi is using GLScene’s identifier, mbLeft,  from the GLCrossPlatform unit instead of the one from the System unit.

The usual fix is to fully qualify the identifier by prepending the unit name but I cannot get that to work so I cast the identifier to a TMouseButton type instead as shown in the code snippet below.



The next several errors report an undeclared identifier, PolygonMode.

PolygonMode is now a property of TGLMaterial and not TGLFaceProperties so we need to remove the TGLFaceProperties reference for the PolygonMode property.

IceBerg does sometime use different PolygonModes for front and back faces but I do not know if that is still possible in GLScene.

I will set the PolygonMode to whatever IceBerg uses for front faces as shown in the code snippet below.



After fixing all the references to PolygonMode we get another incompatible types TMouseButton and TGLMouseButton error which is fixed as we did before.



Now WadExplorer builds successfully but running WadExplorer and loading a *.wad file results in access violation errors and other assorted errors.

These may be caused by changes in Delphi between versions 7 and XE7 or changes between GLScene versions 1.0.0.0714 and 1.3.

WadExplorer builds successfully but has runtime errors


Debugging is required to get WadExplorer functioning correctly which I will leave for another day.

Well another day came sooner than expected.

All I had to do to fix the errors, which I think had something to do with the repainting of the TreeView, is disable Runtime Themes.

Disabling Runtime Themes also corrected the graphical differences between the original WadExplorer and this one.

In Delphi go to Project>Options...>Application and change the Runtime Themes setting in the drop down from "Enable runtime themes" to "None" and click OK.

Disable runtime themes

There is a new problem however.

Some buttons and other controls aren't visible on the 3D viewer panels.

I'll look into this later.

OK.

Form Main's Position property was originally set to poDesktopCenter and I had changed this because of my extended desktop over two monitors.

I had changed it to poDefault which caused the problem.

Changing it to anything other than poDefault or poDefaultSizeOnly fixes the problem.

I have noticed that the meshes are not rendered correctly in the Meshes tab GLViewer.

I do not know if this is due to the changes we made for TGLMaterial.PolygonMode or something else but will investigate later.

The problems with rendering may be caused by the following pre-Unicode function.



Replacing the code as follows fixes the rendering problem.



One more bug is that the mesh line width increases for some reason in wireframe mode on the second click.

The only way I found to fix this is to comment out setting of the line width for the facetmark in the BuildTheFacetMark procedure.

Setting the line width for a TGLLines object must set the OpenGL line width property.

No idea why the original WadExplorer can have a different line width for the facetMark?



Here is WadExplorer modified to accept v130 wads. [link removed due buggy program]


EDIT: 16 May 2018.

There are still some problems I noticed on Windows 10. Getting access violation errors on tabs that have the 3D views of the meshes and moveables. Will study later.




No comments:

Post a Comment