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

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

## 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

That's my problem...figure 1.2 cuts off the command in "Command Line." Plus the project in the figure isn't the same as the first project Ambient, so it makes it hard for me to correlate what I put where. So can you tell me exactly what goes in "Command Line" and "Outputs" for the Ambient project? For instance, what is the PS.txt in the figure? Do I type the $(InputName).fx exactly or do I have to replace that with the input .fx file name? Is that the end of the command line? Do I put "vs.fxo" in the Outputs every time or does that correspond to something? The only sentence I can find that says anything about the "Outputs" field is page 7: "The entry field labeled Output stores the name of the output file." So what is the name of the output file supposed to be? Plus, just telling the reader to check the SDK and here's a list of options without explaining any of them or how to use them or when to use them doesn't help the noob at debugging shaders (i.e. me). Having at least one very noob literal step by step "type this exactly here and there," would help a ton. After I see how it works once, I can apply that to the rest of the projects... Thanks for the help guys :) [Edited by - SAE Superman on April 18, 2006 12:01:31 PM] #### Share this post ##### Link to post ##### Share on other sites ... this is a general problem I can see more and more. I assumed that people who want to program vertex and pixel shaderes are working usually for some time in the industry or at least with DirectX. After you programmed DirectX for some time, all these things are not an issue for you, because you are used to the IDE ... the question is how far would you like to explain the usage of Visual C++ in a book on shader programming. The next version of the book will be clearly marked for intermediate programmers. I am sorry about the confusion here. I would like to suggest you look into a tutorial on how to use the Visual C++ IDE first. Ok here is an example command line that should work fxc.exe /T ps_2_0 /E PSProjTexture /Fc$(InputName).txt \$(InputName).fx

This one compiles a pixel shader with the name PSProjTexture for ps_2_0 and outputs an assembly listing.

If you write that into your command line, it should work. I hope this helps.

Have a great day,
- Wolf

• 40
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631371
• Total Posts
2999603
×