Works in tutorial, but not for me..

Started by
4 comments, last by u235 18 years, 4 months ago
Hey, i was looking at Direct3D tutorials(official ones that go with DXSDK), and what the problem is that if i create a Windows32 empty project, i create .cpp file and copy-paste code from tutorial. And when trying to compile it gives me bunch of errors. LINK2019 mostly and at the end says that there are 4 unresolved externals... :( I can upload the original tutorial(that works) and the one i'm doing with exactly same code but gives me errors :( Can anyone help? Thank you :)
Advertisement
Check your libraries. You're probably not including d3d9.lib in your library path or something. I prefer to add
#pragma comment( lib, "d3d9.lib" )
for extra libraries I use. The exact error messages would help...
I think you forgot to link some some library files (d3dx.lib, d3d9.lib, winmm.lib)

-Zubair-
Yeah you need to add d3d9.lib to the first two tutorials, and d3d9.lib,and d3dx9.lib to any tutorials that deal with matrices, also you need the winmm.lib
the reason you need this is the D3DXMatrix functions that are used in the tutorials, they make translation, rotation , and multiplication easier. Remember this can get tricky.

For a recap their are two types of Vertices, transformed ones and untransformed ones. Transformed vertices, are in screen coordinates, that means that they are already rasterized coordinates and are measured in the pixels on your applications window. Here is an example

// declare a struct

struct CUSTOMVERTEX
{
// variables for the x , y, and z positions
float x,y,z; // each one will tell the position along each axis, x,y,and z
DWORD color;
};

// use the struct
CUSTOMVERTEX cvVertex
{
{350.0f, 100.0f , 0.5, 1.0f,D3DCOLOR_ARGB(1.0f,0.0,0.0f,1.0f),},
}

if I used untransformed vertices they would take up the space in the window based on pixels, so if I declared my window to have a width of 640 pixels, and a height of 480 pixels, if I declared a Vertex buffer with these coordinates
then the first vertex will be located 350 pixels to right of the left side of the window, 100 pixels down from the top of the Window. it is also scaled 0.5, and 1.0f, is the reciprocal of w. Remember something though each element in the struct represents only ONE vertex.

Transformed vertices are in 3d space, You have to set up a virtual camera in order to view them. Setting up a camera is easy , just declare a 3 D3DXVectors and use the D3DXMatrixLookAtLH();
Wow, thank you all guys for fast replies.
Ok, now i know what my problem is - i need to include some libraries. Now i have couple questions:

When i open somebody's project(e.g. official d3d tutorial), where can i see all the libraries included(added) in that project?

#pragma comment( lib, "d3d9.lib" )

- is this the only way to add library to the project, or i can do this some other way?

cellman, thank you for explaining in details :D
Not at my computer at the moment but:

1) You can see all the libraries that will be linked at compile time by clicking, and don't quote me, Project->Options I think, and there will be a text area with this list of all the libraries to be linked to.

2) #pragma comment(lib, "whateverlibyouwanttolinkwith.lib") is not the only way to link with a library. Using the method from #1 above, simply add the library you want to use to the list of libraries.

Hope this helps you out.

-AJ
V/R,-AJThere are 10 kinds of people in the world: Those who understand binary and those who don't...

This topic is closed to new replies.

Advertisement