Sign in to follow this  
Oris

Works in tutorial, but not for me..

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this