This tutorial was designed for Visual C++ Express which is the free version of Visual C++.
This tutorial will be divided in two parts:
- the first part will have like subject the installation of
PTK in a VC++ project ;
- the second part will see the creation of a small program to
practise and see what PTK can offer.
You will find the PTK library with the following
address in the section download : Phelios.com.
Download the zip file for Windows and decompress the file in
an easily accessible directory with a name like “ptk”
Before continuing it's important to know that PTK needs other
basic” librarys will say us.
You will have install the following librarys :
- Platform SDK from Microsoft ;
- DirectX SDK, Version 7.0 is recommended if you intend on developping casual games. Download “dx70
min.zip”, then you will have just copy the contents of
lib” in the directory “lib” of your
IDE and make the same way with the directorys “include”
- OpenGL. ( but you probably already have that one )
Go urgently to this url.
Reason? VC++ Express cannot deal with “Wind32 Application”,
it deals with only “Win32 Console Application”.
If it's important to do it now it's because normally you installed
the SDK, essential thing. The modifications are simple.
We can now pass to the installation of PTK on Visual C++. Start
by creating a project, for that made : File > New > Project.
In the type of project select “Win32” and “Win32
Application” like model. In VC++ Express, only “Win32
Console Application” is available but don't worry, if
you read the preceding "warning",
there isn't problem. Enter a name like “TestPTK”,
and validate with “OK”.
In the new window which appears, click on “Next”
then choose “Empty project” which will create a
project without the least line of code. And if you are under
VC++ Express you will be able to choose “Windows Application”,
which you will make (if not that won't go). It any more but
doesn't remain you to validate with “Finish” .
Us here with an empty project, right click on “Source
Files” then made Add > New Element. Selected like model,
on the right, a file C++ (cpp) and choose a name. As it is our
first file and that it will be our main thing, name this “main”.
Now we will configure VC so that it "recognizes" the PTK library. There are two ways of configuring and installing PTK.
The first is to make it as in the tutorial of Platform SDK. You'll have to add in Tool > Option > VC++Directories, the address of the directorys “lib” (libmicrosoftvc)
and “include” (headers) of your library PTK.
Another method, more complicated, makes it possible to configure the project directly. It's this method which i have chosen here. For that one starts by making a right click on the project and selects “properties”.
Y ou should have an identical window :
At the top of the window in “Configuration” selected
All the configurations”. Select “General”
C/C++” and in “Additionnal Include Directories”
put the access path towards the file “headers” which
is in your file “ptk”.
Now click on “Linker” then "General".
Even thing that before, except that you will do that with “Additonnal
Library Directories” and that it's the access path towards
the directory “libmicrosoftvc” which you will have
Always in “Linker”, select “Input”,
and in “Additionnal Indepencies” to copy/paste the
following line: “libptkvc.lib ksoundvcstatic.lib winmm.lib
opengl32.lib dsound.lib dxguid.lib ddraw.lib d3dx.lib wininet.lib
In the file “readme” it's indicated that you can add the files” .lib " in your project. But we don't need to do that since we added the files in the linker directly.. Add their names in “Additionnal
Indepencies” as that is described above.
Here one finished for the “total” configuration,
apply all that. Then in “Configuration” select “Debug”.
Always in Linker > Input, in "Ignore Specific Library"
copy/paste the following line : libcmt; libc.
Pass in “Release” in “Configuration”
(in top) and return in “C/C++”, but this time in
Code Generation”. In “Runtime Library”
selected “Multi-threaded (/MT)”.
Lastly, pass again in “Debug” in the configuration
and select “Multi-threaded Debug (/MTd)” in “Runtime
Library”. Apply and quit.
Here a small fast code to test the configuration. This last
allows the posting of an image in a window. You willn't certainly
see something, but it's before testing :
KWindow *ourWindow = NULL ;
KGraphic *ourPicture = NULL ;
//according to your operating sytem the entry
point is slightly different
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPreInst, LPSTR
lpszCmdLine, int nCmdShow )
int main( void )
ourWindow = KPTK::createKWindow( K_OPENGL);
if( ourWindow == NULL ) return 0 ;
ourPicture = KPTK::createKGraphic( ) ;
ourPicture->loadPicture( KMiscTools::makeFilePath( "image.tga"
) , true, true ) ;
ourWindow->setDefaultWorldView( ) ;
ourPicture->blitAlphaRect(0,0,640,480,0,0 ) ;
ourWindow->flipBackBuffer( ) ;
}while( ourWindow->isQuit() == false );
delete ourWindow ;
return 0 ;
If you don't have any error message, you're ready to pass to