第二《Introduction to 3D Game Programming with DirectX 11》介绍

《Introduction to 3D Game Programming with DirectX 11》说完了一些大概及开发者应具备的条件等,给与出一个第六章才学到的box让大家过过瘾,但这个瘾不是好过的;

   先处理简单的事:

   1.下载VS2010并安装;

   2.下载适合学习VS2010及DIRECTX的SDK;

    书中地址是:http://msdn.microsoft.com/en-us/directx/,但不好用,给个好用的:    

       VS2010链接:https://pan.baidu.com/s/1htV2lNI 密码:sm4r;

      DXSDK_Jun10.exe链接:https://pan.baidu.com/s/1o9g5dH4 密码:nqqg

      书链接:https://pan.baidu.com/s/1jJhtjhG 密码:1unp 

      代码链接:https://pan.baidu.com/s/1o9AXmm2 密码:asfv

  3.创建开发环境:不建议直接打开下载的代码,要自己动手学习

     (1)建立win32的空项目,名为:Project,自己可以改,简单;

     (2)link 库文件,按书上说的即可,d3dll.lib;d3dxlld.lib;D3DCompiler.lib;Effectslld.lib;dxerr.lib;dxgi.lib;dxguid.lib;把以上代码复制进去,但编译时会出现问题,d3dll等后边ll改为11,书上错了,正确为:d3d11.lib;d3dx11d.lib;D3DCompiler.lib;Effects11d.lib;dxerr.lib;dxgi.lib;dxguid.lib;注意分号用英文,不能在中文下编写。

       (3)包含头文件与库文件,按书上操作,注意要包含2组头文件及库文件,头文件为 SDK下的include,common, SDK下的lib\X86,common;

      也可以用一劳永逸的办法,但第一个困难来了,书上这样说的:In Visual Studio 2010, the directory paths are per project settings (this differs from Visual Studio 2008 behavior). This means you need to set the search paths for every project when you make a new project. If you make many demo projects, this can be annoying.However, there is a way to make these settings permanent for a user. Under the Visual Studio menu, select View > Other Windows >
Property Manager.  Expand the property manager as in Figure 9, and double-click the Microsoft. Cpp. Win32, user item. You get a dialog box similar to the one in Figure 8, except that the paths you set here will persist across projects, so that you do not need to add them every time. More specifically, every new project you make will inherit the values set here.

大致意思为:“ 2010版的VS需要为每个项目设置目录路径(这和2008版不同)。这意味着你需要为每一个新建的项目设置搜索路径。假如你制作很多演示项目,会非常烦恼的。然而,这里有一种方法可以为开发者做永久性设置。在VS菜单下,视图》其他窗口》属性管理器。就像图9一样展开属性管理器......”

     说是去除烦恼,但带来了烦恼、头大,给努力学好directx的人当头一棒,当你打开视图、其他窗口后,根本找不到属性管理器。可能作者版本排列与中文版不一样,我这版直接点开视图倒数第二就是了,不知你们的也是这样吗?

 然后剩下就解决了,选择属性管理器》左上角就出现了》展开》看到debug|win32》双击》就能修改了。

  2.然后,第二个困难来了,怎么退回文件视图,以增加源文件、头文件等,跟VC++6.0不一样,选择视图》解决方案资源管理器 即可。

  3. 将书上说的文件导入:1. Right-click on the project name under the Solution Explorer and select Add > Existing Item... from the dropdown menu, andadd BoxDemo.cpp to the project.
2. Right-click on the project name under the Solution Explorer and select Add > New Filter, and name the filter FX. Right-click on the FX filter and select Add > Existing Item... from the dropdown menu, and add FX\color.fx to the project.
3. Right-click on the project name under the Solution Explorer and select Add > New Filter, and name the filter Common. Right-click on the Common filter and select Add > Existing Item... from the dropdown menu, navigate to where you placed the book'sCommon directory code, and add all the .h/.cpp files from that directory to the project.
4. The source code files are now part of the project, and your Solution Explorer should look like Figure 11. You can now go to themain menu, and select Debug > Start Debugging to compile, link, and execute the demo. The application in Figure 12 shouldappear.F

     COMMON和FX文件夹可右击项目,添加新建筛选器即可,然后右击文件,添加现有项。

显示:第二《Introduction to 3D Game Programming with DirectX 11》介绍_第1张图片

但通常结果不是这样的:第三个困难来了。如:跳出一个对话框:

第二《Introduction to 3D Game Programming with DirectX 11》介绍_第2张图片

问题可能出在着色器文件:"FX/color.fx"身上,CompileFromfile时没找到,到文件里一查,果然没有FX,自己到项目名里,再进入相同项目名,不知道为什么是两个,建立FX,拷贝color.fx进去,编译就成功了。

 自己建立的工程,一条.cpp或.h都没有,都是导入的别的文件夹的东西进行编译,为什么对于.fx,需要用自己的?请大侠指点

      

 

你可能感兴趣的:(第二《Introduction to 3D Game Programming with DirectX 11》介绍)