Started with the DirectX 8 Library
This document is organized
into the following topics:
The DirectX 8 Library
consists of a set of frameworks, COM interfaces, and sample code that allow
you to build powerful DirectX 8 applications interactively.
Step 1: is to install Smalltalk MT (STMT) using stmt41.exe. (Assumption
here is that you will install in the default directory C:\Program
Files\Smalltalk MT 4). Choose complete to include all samples.
Step 2: copy Microsoft DirectX 8.1 media
files (Media.zip) into C:\Program Files\Smalltalk MT 4\DirectX 8
Library\Media. These files are used for demonstration purposes in the
samples and are not an integral part of the framework.
You will be presented with the
Transcript. All other windows can be launched from the Transcript (STMT is an
What's New in this Release
This version of the library is based on
|Particle parameters are completely
encapsulated in a structure, making it much easier to work with presets. The
new Particle demo displays a UI that allows you to interactively control the
parameters. The number of particles is now defined as the number of
particles per second. |
|When a DirectX frame window looses focus,
it automatically inserts wait states to yield to other windows and
Loading the DirectX 8 project
The DirectX framework projects and DirectX 8
DLLs now need to be bound in to the image, which is accomplished in the
- Open the Project Browser using Tools
Menu -> Browsers -> Project Browser
- This window can be sized and preferences
saved using Option Menu -> Save Preferences. The next time you open a
new Project Browser it will use the preferences you saved.
- Use the File Menu -> Open … and
navigate to C:\Program Files\Smalltalk MT 4\DirectX 8 Library\Samples
- Select the Dx8 samples.spx project and
choose Open. The package contents will display in the PB. To load this
package choose Project Menu -> File In
- STMT will now advise that there are
libraries (DLLs) that are not linked with the current image (these are the
DX8 DLLs). Choose Yes to load the libraries.
- You will now be presented with three
dialogs indicating the location of the DEF files for the DLLs (DINPUT8.def,
STD3DX8.def and D3D8.def). Choose OK for all three dialogs.
- STMT will now recreate the development
environment with the DirectX 8 DLLs bound in and restart the image.
- When the image restarts, the DirectX8
Application and all the samples will be loaded.
To ‘File In’ in Smalltalk means to compile and load the code into the
currently running development environment.
|In the Project Browser, select the project
Triangle in the left hand pane. Next select the class DX::Triangle in the
middle pane. Click right and select Test |
The DX::Triangle application will start and
display a spinning yellow triangle.
|To see the class, click right onto
DX::Triangle and select Browse Class.
A Class Hierarchy Browser will open on
the DX::Triangle class. |
|Again this window can be sized and saved
using Tools Menu -> Save Preferences. |
|To test this application from the Class
Hierarchy Browser, right click on the DX::Triangle class and choose
Test. The application will open a
window and display a rotating yellow triangle (rotating around the Y axis).
It is important to note that unlike Visual
Studio, the application is running in the same process as the development
environment. To further demonstrate this, let us change the running program.
|Select the method (right hand pane)
On the third line from the bottom you will
see a line:
matspin rotationY: m_fTime.
which calculates the Y rotation from the time
the application has been running. Change this line to:
matspin rotationY: m_fTime/2.
|Save the new method by right clicking in
the text pane and choosing Accept. |
The triangle will now immediately begin to
rotate at half the previous speed. Try
to speed up rotation.
We have just modified a running program which
is one of the greatest strengths of Smalltalk.
Now let’s debug this application.
|After the line above (and before the line
containing SetTransform) insert the following line (don’t forget the period
at the end of the line): |
When you save the new method this time, a
debugger window will display. First choose Window Menu -> Arrange windows
and then save this with Options Menu -> Save Preferences.
The debugger window displays the call stack
(top left), the locals (top right) and the current position (bottom).
In the locals window, you can expand out
matSpin to see all of its values and by pressing the Resume toolbar
button (far left), you can see the matspin matrix changing. Thus the debugger
gives you ways of tracking complex changes.
To dismiss the debugger while leaving the
application running, remove the self
halt line in the debugger text and right
click to accept. Choose resume to continue the application and close the
debugger window. You will see the application continue to run.
|Exit the application by closing the
Modifying a running application
Another example might be to test out
different materials. To do this:
|Go to the method renderScene and insert as
the first line: |
|Now go to the method createMaterial and
change the first float (currently 1.0) to 0.0 after the initMaterial:.
The triangle immediately goes green.
Just before we go into workspaces, we
need to briefly review the Smalltalk syntax. All Smalltalk statements
are of the form “receiver message” or “receiver message: param1” or “receiver
message: param1 with: param2”. There are no exceptions to this rule. In
addition, the Smalltalk standard does not define operator precedence.
1*3 + 3*4 will execute as (((1*3)+3)*4)
1*4<3*6 will execute as (((1*4)<3)*6)
unless of course you provide parenthesis
Note: Optionally, Smalltalk MT
supports operator precedence. To enable operator precedence, open the Image
Properties (in the Transcript, Tools Menu -> Image Properties), click
on the Compiler Tab, and check the box labeled “Enable Operator
Precedence”. Doing this makes your code incompatible with other Smalltalks.
|From the Class Hierarchy Browser choose
Tools Menu -> New Workspace. Let’s call a DLL entry point by typing in:
WINAPI MessageBeep: -1
|Execute this line by choosing Smalltalk
Menu -> Execute (Note: The cursor must be somewhere on the line you
typed). The system bell will ring. You have just executed a DLL call
(statically called) by executing this line as though it was a script!
Smalltalk code can be executed anywhere in a
text pane which provides the ability to easily prototype and test. Workspaces
also have the ability to create variables to hold onto values. For example,
let us test out the PerformanceTimer.
|In a workspace enter: |
a := PerformanceTimer new.
If you execute this line, you will be
prompted that “a” is not defined. Do you wish to declare it as a workspace
variable. Select Yes.
|Now enter the line: |
|This time instead of executing this line,
display this line using Smalltalk Menu -> Display. A float will be
displayed showing the current tick value. Execute: |
|To set the timer back to zero and then
display the tick value again. |
As you can see, it is simple to test out
classes in a workspace for use in your code.
Exit Smalltalk MT
Exit Smalltalk by closing the Transcript.
Choose Exit (not Save & Exit) to maintain a ‘clean’ image
(choosing Save & Exit will save the image in its current state with all
This simple introduction introduces some of
the rich features of Smalltalk MT. Smalltalk is extremely capable of handling
complex and large applications. The image can be saved with all project code
and then can be reloaded without the need to recompile.
Unit testing is part of Smalltalk development
and is accomplished by calling methods from a workspace or in the running
Whole structures can be debugged and
inspected and the developer can navigate through these.
Copyright © 2001 Genify
Corporation. All Rights Reserved.
If the samples
don't run the cause is probably a faulty media path or missing media files.
The media path is a registry entry that points to the location of media files.
If the registry entry is missing, or if it points to a non-existing location,
the framework tries to load media files from a media subdirectory,
under the folder from which the program started.
installation program sets the media path to c:\Program Files\Smalltalk MT
4\DirectX 8 Library\Media.
Make sure that
you have the required media files in the directory above. DirectX 8 samples
use the media files from the Microsoft DirectX 8 SDK, so you can simply copy
the whole media folder from the SDK to the location above, or alternatively
you can the media path in the registry:
HKEY_CURRENT_USER\Software\Object Connect\Smalltalk MT\DirectX8 SDK
HKEY_CURRENT_USER with HKEY_CURRENT_MACHINE if you installed for all users).
Some of the
samples (more precisely, the dialog-based ones) require custom resource DLLs.
All other samples use DX8Res.DLL, which contains standard resources. The
development image requires access to these DLLs in order to run the samples.
You may not be
able to run all samples, depending on your graphics hardware. If you installed
the DirectX 8 SDK you should at least be able to run in the reference
rasterizer mode. The retail mode doesn't offer this mode; in that case a
sample that uses unsupported features will not run.
hardware support can be enabled by installing a newer graphics driver.
requires a minimum level of compiler optimization, otherwise inline structure
accesses may fault or return unexpected results. The minimum settings are met
by the level 'Debug', in the image properties. By default, the image is
shipped with a predefined setting of 'Full' (or 'Debug', depending on the
version), however any predefined setting except 'Disable Optimizations' is