# Problem with book code: "Programming Vertex and Pixel Shaders" : **SOLVED**

## Recommended Posts

I just bought "Programming Vertex and Pixel Shaders" last weekend and I'm having trouble setting up Visual Studio 2003 and compiling and running the first program. Here is a link to another thread started last summer about this from someone else: Other thread I have two problems...problem #1: I can't run the precompiled executables. When I run the programs, I get a dialog box that says something like "Make sure DirectX is installed correctly". I downloaded the latest DirectX SDK (April 2006) and installed it. No change. Do I need to completely uninstall DirectX and then install the latest? Problem #2: The book is horrible about directing you on how to set up Visual Studio to compile and debug shaders. I was wondering if anyone could give me a quick rundown on how to set it up and compile a simple .fx file. I'm not at my home computer right now so I can't give details on how far I get or the exact errors but I'll post them as soon as I can. Any links to resources would be greatly appreciated too since google is no help on this (and I found stuff on gamdev.net about it but it was written by the same author as this book, Wolfgang Engel, and it doesn't explain how to set up VS any better). Thanks in advance... [Edited by - SAE Superman on April 19, 2006 11:56:03 AM]

##### Share on other sites
I have that book too but have not cracked it yet. However, I don't think it is an intro book. To start out take a look at some of the HLSL samples in the DirectX SDK (most of the other samples in the SDK also use HLSL). You can use the D3DXCreateEffectFromFile function to compile an effect (.fx) file at runtime. There are similar functions for doing vertex and pixel shaders separately.

I think the executibles should work though. Since DX uses COM it supports the older interfaces even if you are developing with the later ones. Try uninstalling the current DX SDK and installing the newer ones being sure to install the runtime and debug stuff. The Introduction chapter in the book shows how VS should be setup. You need VS 2002 or later for it to work.

##### Share on other sites
Thanks for replying...here's what I did so far:

Uninstalled every version of DirectX SDK I had installed. Then installed the latest DirectX SDK (April 2006). I then tried to run the precompiled executable and got this message in a dialog box: "Could not find required media. Ensure that the DirectX SDK is correctly installed."

As for the problem #2:
Here's a link to a pdf of the sample first chapter: Sample First Chapter

My problem is page 6 and 7 (I'm new to shaders and custom build steps in VS so bear with me). I can bring up the properties page but what exactly do I type where? You can't read the entire line in the figure on page 6, and page 7 doesn't tell you what to type where. Do I type what page 7 says word for word? I tried typing it in the "Command Line" portion but then I right click on the .fx file and the compile option is greyed out (until I put something into "Outputs", which I'm assuming I have to put something but what?) If I go on and look at the bottom of page 9 "Compile and Debug a Shader", it doesn't tell you everything to get you started in Visual Studio. Also, on page 11, how do I "Confirm that the shaders are compiled with debug information by setting flags..."?

I just need to get this first project to compile and then I can proceed with the learning and the expanding of knowledge [grin]

Thanks for the help!

##### Share on other sites
Hey just came across your post. The best thing you can do is install the same SDK that comes with the CD. Microsoft changed the DirectX framework quite a lot in the last couple of years and only the framework version on the CD should work without hazzle.
Hope this helps,
- Wolf

##### Share on other sites
I had that same dialog box for the precompiled demos. You need to find the UI folder in the Media folder of your installed SDK. Then, place the UI folder in the Media folder provided by the CD. That should let you run the sample programs.

##### Share on other sites
Quote:
 Original post by DirectXFreakI had that same dialog box for the precompiled demos. You need to find the UI folder in the Media folder of your installed SDK. Then, place the UI folder in the Media folder provided by the CD. That should let you run the sample programs.

Thanks, that worked great!!!

Now I just need help compiling in Visual Studio (remember I'm a noob at custom build steps in VS [grin])

Thanks again!

##### Share on other sites
Quote:
 Original post by wolfHey just came across your post. The best thing you can do is install the same SDK that comes with the CD. Microsoft changed the DirectX framework quite a lot in the last couple of years and only the framework version on the CD should work without hazzle.Hope this helps,- Wolf

I'll probably try this if I have any more problems after I get the compiling thing figured out. Can you clarify my issues with the pages I've stated above?

BTW, the precompiled exe's look amazing!

##### Share on other sites
Hey,
check out figure 1.2. It shows you what you need to type in. Verify this with the HLSL compiler command line on page 6 and 7. You can also check out the DirectX SDK documentation to look at some command line parameters.
It is not really necessary to do it this way, but it is quite handy :-)

Have fun,
- Wolf

##### Share on other sites
Quote:
 Original post by wolfHey,check out figure 1.2. It shows you what you need to type in. Verify this with the HLSL compiler command line on page 6 and 7. You can also check out the DirectX SDK documentation to look at some command line parameters.It is not really necessary to do it this way, but it is quite handy :-)Have fun,- Wolf

Hope it helps,
- Wolf

##### Share on other sites
Hey! That works great now :) Thanks a ton! I'm looking forward to going through the book!

It tells me that I can't debug the shaders though :(

##### Share on other sites
You need to compile them with debug data ... I think there is a #define in the example program that just sets this flag.

##### Share on other sites
Haha, I had those uncommented earlier but switched back to what was on the CD [grin] Everything works great now, thanks a ton! One last question about when I turn on the debug...is it supposed to run at 1-2 frames per second? I have a NVidia 6600 GT and I get a dialog that states "Switching to the reference rasterizer, a device that implements the entire Direct3D feature set, but runs very slowly."

Thanks again for all the help Wolf! I'm really looking forward to diving into your book [grin]

##### Share on other sites
that should not happen on most of the examples :-) ... I believe the vertex texture example might have such a behaviour.
Other than this the text should highlight, if an example is hardware specific ... I really can not remember anymore which example might be hardware-specific. It is now more than 2 years ago that I finished the book and I am currently thinking about a re-write with a couple of people.

##### Share on other sites
.... wait a second. It might be that the old SDK did not support a few features the hardware had ...

##### Share on other sites
Alright, thanks again!!!

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627714
• Total Posts
2978773

• 9
• 21
• 14
• 12
• 42