• Advertisement

#### Archived

This topic is now archived and is closed to further replies.

# For anyone who ever used this book

This topic is 6434 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Ive been using Andre LaMothe''s "Tricks of the Windows Game Programming Gurus" to learn how to use DirectX to make a game. Ive posted many times about this book and some people are probably sick of me but I was wondering if anyone else who read ran into the same problems I have and could offer any advice. Right now Im on chapter 7 and trying to load a bitmap, just one, on my screen. I decided to use his libraries he gives to do this and a lot of the code has errors in it and stuff and I run into a lot of linking errors, when I try to use the Load_Bitmap_File function for example I get an unresolved external symbol error. Part of that probably is my lack of knowledge on including headers and stuff into my projects in correct orders. I remembering reading in a post that he put changes to the files on his web site but I dont remember the address or anything about it. So if anyone could give me any insight or advice on this subject at all I would be happy. Thanks

#### Share this post

##### Share on other sites
Advertisement
hey,
could you post some of your errors please? I had a LOT of problems with his code too. Maybe I, or someone else could help you if you gave something more specific.

skitzo_smurf

#### Share this post

##### Share on other sites
My biggest problem is using the t3dlib1.h and t3dlib1.cpp files
I include t3dlib1.h in my main and make a call to the Load_Bitmap_File function and get "unresolved external symbol" error. I was thinking it could be because Im not including the t3dlib1.cpp file. For kicks I added that to my project and compiled it and it had many error and warnings in the code alone.
So I took one of his example programs (demo7_10) that loaded a bitmap on the screen with the function declared in the main source file and it works, but when I put my own bitmap in the function call I dont get anything but that could simply be due to his being a full screen bitmap and mine being much smaller and my not changing the code. Thanks for replying and hopefully I gave enough to give me a little help thanks

#### Share this post

##### Share on other sites
Unresolved external error means your compiler can''t find the library.
If you''re using vc++, go to project->settings on the menu bar.On the settings dialog, change the drop-down list box to ''all configurations'', then choose the ''link'' tab.In the text box labeled ''Object/library'' type the file name of the lib file (including the path), then hit the ok button.Recompile.
If you''re using a different compiler package, take a look at the documentation for linking; that''s waht its there for.

Good luck

----------
meh

#### Share this post

##### Share on other sites
Its not a lib file, its a .cpp file with a header, ?

#### Share this post

##### Share on other sites
Its not a lib file, its a .cpp file with a header, ?

#### Share this post

##### Share on other sites
Heh, forgot a few things...make sure the header file you''re using has all the function prototypes your application is using in it.If not, just add them to the header file.This would give you an undefinde reference error during compile time
Also, sometimes libraries are a pain in the cheese-wheel and won''t load even if you link them correctly (I''m not very interested in the problem, and I don''t use a whole lot of extra libraries, so I just work around it).This wouldn''t give you an error at link or compile time, but all the functions in the library will fail.Call LoadLibrary() and load the dll, you don''t have to worry about unloading it, when all processes are finished with it, windows will unload it for you.If you end up having to do this, make sure you update your configuration so that when it links, its not linking with that library anymore (because your application is already linking it).
Don''t know if any of that will help, never used this library before.

----------
meh

#### Share this post

##### Share on other sites
Didn''t know that...sorry.Did you add the cpp file to your project? It doesn''t matter which order you compile in; your compiler will compile all the files, then the linker links all the modules.

#### Share this post

##### Share on other sites
well I included the t3dlib1.cpp file, it has some errors in it but I think if they are fixed I can put this problem behind me

\t3dlib1.cpp(160) : error C2664: ''CreateSurface'' : cannot convert parameter 1 from ''struct _DDSURFACEDESC2 *'' to ''struct _DDSURFACEDESC *''

>>>> here, this error occurs three times
if (FAILED(lpdd->CreateSurface(&ddsd,&(bob->images[index]),NULL)))
return(0);

\t3dlib1.cpp(754) : error C2660: ''SetDisplayMode'' : function does not take 5 parameters

>>>>> I use this in my main and I use 5 params no problem, no clue on this

#### Share this post

##### Share on other sites
I heard that the files on the disc were corrupted. A LOT of people posted here complaining about that. I too, could not get his code to compile right off of the disc(and YES I removed the "read only" attribute). I had to take what I wanted to use and basically paste it into my own utility header file to get it to work. I only use his Load_Bitmap_File function so this is not a problem. ANyhow, if that doesnt work make sure you have the following lib''s included:

dxgiud.lib and ddraw.lib

To include them just click on Project->Settings. THen click on the link tab and enter those lib''s in the text field and click "ok".

keep complaining if this doesnt work for you,
skitzo_smurf

#### Share this post

##### Share on other sites
thanks Skitzo, right now my only errors are

\t3dlib1.cpp(160) : error C2664: ''CreateSurface'' : cannot convert parameter 1 from ''struct _DDSURFACEDESC2 *'' to ''struct _DDSURFACEDESC *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

and

t3dlib1.cpp(754) : error C2660: ''SetDisplayMode'' : function does not take 5 parameters

but it does
if you use his load_bitmap_file dont you need the flip and unload functions too? thanks for the help!

#### Share this post

##### Share on other sites
Im not too familiar with making my own libraries, so that might not be the best route for me, ?

#### Share this post

##### Share on other sites
Ah...the linker gives you an unresolved external because it can''t link the module (because it won''t compile with errors).The errors sound like its using a weird version of directx.Check the top of t3dlib1.cpp and make sure its including ddraw.h like this:

#include

and not doing something really dumb, like declaring the prototypes itself.This error:

\t3dlib1.cpp(160) : error C2664: ''CreateSurface'' : cannot convert parameter 1 from ''struct _DDSURFACEDESC2 *'' to ''struct _DDSURFACEDESC *''

is because the function is expecting a DDSURFACEDESC, not the newer DDSURFACEDESC2, or the other way around.At least one of the files is trying to do thing the old way, and the other way, which could possibly explain the 5 parameter error (but I though directx was backwards compatible as far as functions go).

#### Share this post

##### Share on other sites
Argh...html

make sure its including ddraw like this:

  #include

Edited by - Bulbasaur on July 16, 2000 2:16:46 AM

#### Share this post

##### Share on other sites
that sounds good bulbasaur, but the t3dlib file does include ddraw.h, I even tried replacing the ddraw.h file in the vis studio includes with the directx one, so I cant figure out how to change the file so it doesnt use an old function like you suggest. Thanks (this stinks )

#### Share this post

##### Share on other sites
Well, rather then debug a ''library'' thats supposed to work when you get it, my advice (not that I''m good enough to give advice) to you is to ditch it and use DirectDraw without it; its not at all difficult to use...link ddraw.lib and use the various well-documented methods.
Sorry I couldn''t help

#### Share this post

##### Share on other sites
Hey thanks for trying! I went to LaMothes web site (xgames3d.com) and there is a way to get a replacement cd that works, but I cant figure out how? so theres still hope

#### Share this post

##### Share on other sites
ok,
I have that disc, and ill try to help. I am creating an app right now. But if you want to get the Load_Bitmap_File function to work in the meantime heres some code for you to cut and paste.

In your project make a new header file and name it whatever you want. Im calling mine "utility.h". Now in your application make sure you say include "utility.h" or whatever you named it

heres the code
  //---utility.h---#ifndef _UTILITY_H_#define _UTILITY_H_// MACROS - DEFINES/////////////////////////////////////////////////#define BITMAP_ID 0x4D42#define DD_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct);}// TYPES ///////////////////////////////////////////////////////////typedef unsigned short USHORT;typedef unsigned short WORD;typedef unsigned char UCHAR;typedef unsigned char BYTE;// STRUCTURES //////////////////////////////////////////////////////typedef struct BITMAP_FILE_TAG{ BITMAPFILEHEADER bitmapFileHeader; BITMAPINFOHEADER bitmapInfoHeader; PALETTEENTRY palette[256]; UCHAR *buffer;} BITMAP_FILE, *BITMAP_FILE_PTR;int Load_Bitmap_File(HWND hwnd,BITMAP_FILE_PTR bitmap, char* filename);/*load a bitmap off of disk into a BITMAP_FILE structure*/int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height);/* this function is used to flip bottom-up .BMP images */int Scan_Image_Bitmap(BITMAP_FILE_PTR bitmap, LPDIRECTDRAWSURFACE7 lpdds); /* Load A bitmap onto a surface */ #endif

//now make a new source file called "utility.cpp" and add the actual function definitions right from the book. The first line of utility.cpp will be to include "utility.h"

hope this helps

Edited by - skitzo_smurf on July 16, 2000 2:42:47 AM

#### Share this post

##### Share on other sites
Well I can solve your problem in a few easy steps.

First open up visual c++.

Open up the workspace you were just trying to compile.

Now goto the TOOLS option.

Choose OPTIONS in that menu.

Select the DIRECTORIES tab on the list

Now you''ll notice that over in the box on the right hand side of the screen it says "INCLUDE FILES". (this will be needed for a later step).

Anyway. Add in your c:\mssdk\include\(or where ever you installed the SDK to) directory onto that list. Then highlight that directory and click on the up arrow icon until it''s at the top of the list.

Next you need to go up to the box where it says "INCLUDE FILES" click on that box, and choose "LIBRARY FILES".

Now add your c:\mssdk\lib\ (or where ever you installed the SDK to) directory onto that list. Highlight this, and hit the up arrow icon until it''s on the top of that list.

Now click OK and exit.

The last thing you need to do to get the project working correctly is the following.

Goto the PROJECT menu.

Select the SETTINGS option.

Choose the LINK tab.

goto the OBJECT/LIBRARY MODULES text box, and hit the END key.(this will take you to the end of the list).

Add in dxguid.lib (this is needed everytime you want to make a program which uses any part of direct x). And then add in any other libraries that direct x may use (Example: ddraw.lib, dsound.lib, dinput.lib).

Click OK.

Now compile your project with the REBUILD ALL option and it''ll execute if you did the above correct.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### Popular Tags

• Advertisement
• ### Popular Now

• 9
• 50
• 11
• 17
• 11
• Advertisement