Jump to content
  • Advertisement
Sign in to follow this  
Kalthios

VC++ 2010 Express and Directx

This topic is 2946 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

I get an "Error: cannont open source file "d3dx10.h" when i try to "#include <d3dx10.h>".

I went to my project properties and added d3d10.lib to the additional dependencies under Linker, but that doesn't solve the problem.

I confess that I am not very good at understanding how libraries and includes work. I assume there is a directory path i need to input somewhere in the VC++ settings but i have no idea. Help please?

Share this post


Link to post
Share on other sites
Advertisement
You have to add the directx include folder to your project's include dependencies. Although you'll need to add the library files as well for the linking process, your code won't compile as the include files are in the include folder, not the lib folder.

In general, the include files contain the functions/classes/etc definitions while the library files contain the compiled code. Thus, the include files are needed for your compiler to know your functions/classes/etc signatures, but once everything is compiled, it will need the actual code to run, and this is where the libraries come in play.

Share this post


Link to post
Share on other sites
How do I include an Include folder to my project dependencies. Been looking through visual studio documentation to no avail.

Share this post


Link to post
Share on other sites
1. Open one of your projects, any one of them.

2. Select View->Property Manager.

3. In the manager, expand your project.

4. Expand Debug | Win32

5. Now double click the file Microsoft.Cpp.Win32.user

6. Under common properties, choose VC++ Directories

7. Add the folder location for the include and the lib in the right side and save.

NOTE: This will make it permanent for all your projects not just this one.

Share this post


Link to post
Share on other sites
What wicked357 said applies to Visual Studios before 2010. In 2010, the bindings are actually per project (although they did transition for me for some reason between projects).

For VS2010:

Go Project -> Properties (Alt+F7)
Expand Configuration Properties
Choose VC++ Directories
Click the right cell for Include Directories, choose Edit and add your DirectX SDK include folder (which is prolly something like /path-To-DirectX-SDK/June 2010/Include).

Share this post


Link to post
Share on other sites
Quote:
Original post by Ratslayer
What wicked357 said applies to Visual Studios before 2010. In 2010, the bindings are actually per project (although they did transition for me for some reason between projects).

For VS2010:

Go Project -> Properties (Alt+F7)
Expand Configuration Properties
Choose VC++ Directories
Click the right cell for Include Directories, choose Edit and add your DirectX SDK include folder (which is prolly something like /path-To-DirectX-SDK/June 2010/Include).


Actually what I posted is for VS2010 Pro, not before if you follow those steps you will set it up for the entire use of the program not per project as Ratslayer states. If you didn't know now you do Ratslayer, you can set them for all projects not just per.

Share this post


Link to post
Share on other sites
Thanks a lot guys. I actually was able to compile my first directx program! Red letter day! New problem though, program crashes when I press escape to close app but shuts down properly when I click the "x" in the top right. Here is my windows procedure and shutdown function:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
//Check for any available messages from the queue
switch (message)
{
//Allow the user to press the Escape key to end
//the application
case WM_KEYDOWN:
switch(wParam)
{
//Check if user hit Escape key
case VK_ESCAPE:
ShutdownDirect3D();
PostQuitMessage(0);
break;
}
break;

//The user hit the close button, close the app
case WM_DESTROY:
ShutdownDirect3D();
PostQuitMessage(0);
break;
}
//ALways return the message to the default winproc for
//further processing
return DefWindowProc(hWnd, message, wParam, lParam);
}



void ShutdownDirect3D()
{
//Release the rendertarget.
if (pRenderTargetView) pRenderTargetView->Release();
//Release the swapchain.
if (pSwapChain) pSwapChain->Release();
//Release the D3D Device.
if (pD3DDevice) pD3DDevice->Release();
}

Share this post


Link to post
Share on other sites
The problem is that when you press escape, it shuts down d3d twice.

Remove the ShutdownDirect3D() call from your escape key press code and you should be G2G (:

Also you shouldn't need to post your quit message in wm_destroy, i believe at that point, your app is already shutting down and doesn't need to be told again.

Share this post


Link to post
Share on other sites
Oh wait, I think I understand now:

So the app gets a msg that the escape key was pressed. Application does the code for that case, PostQuitMessage(0). So another message gets processed, PostQuitMessage(0), which is interpreted in the message switch as the WM_DESTROY case. WM_DESTROY case automatically ends the window, and you can put extra shutdown code, such as ShutdownDirect3d(), into its case code block.

So just do this:

switch (message)
{
//Allow the user to press the Escape key to end
//the application
case WM_KEYDOWN:
switch(wParam)
{
//Check if user hit Escape key
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
break;

//The user hit the close button, close the app
case WM_DESTROY:
ShutdownDirect3D();
break;

Am I understanding this correctly?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!