请问如何在visual studio 2013中设置custom build tool?

虚空梦影 2014-10-10 10:49:29
现在正在自学DX 11编程,就是《Introduction to 3D Game with DirectX 11》那本书。书上第6.8.5节讲到Compiling an Effect at Build Time,就是利用DirectX自带的fxc程序来在程序编译时顺便编译effect文件。这就需要对编译器进行设置了。总体来说有如下三个步骤:
1、把fxc所在的文件夹添加到项目的VC++ Directories的Executable Directories目录中。
2、把需要在运行时编译的effect文件添加到项目中。具体就是新建一个Filter,然后在此Filter下添加effect文件。
3、右击effect文件,然后在Properties中进行如下图的设置:


书中使用的是Visual Studio 2010。不过在Visual Studio 2013中右击effect文件并没有出现这样比较简单的一个Custom Build Tool目录,而是出现了一个比较复杂的HLSL Compiler目录。然后我试了各种方法,但是不管怎么设置,包括在最后添加命令行,也没法成功地编译,总是会报错(当然都跟这个设置有关)。请问应该怎么做呢?如何设置VS 2013中的custom build tool?或者,在HLSL Compiler中怎么样设置才能够让项目正常运行?

多谢啦!
...全文
1002 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
虚空梦影 2014-10-11
  • 打赏
  • 举报
回复
为了方便,还是把代码放上来吧! http://download.csdn.net/detail/supersayess/8026527 希望有大神能够解决一下那个AssemblerOutput的问题。貌似是生成汇编语言文件的时候出错?不过这个简单的.fx文件不可能会出错的呀!
虚空梦影 2014-10-11
  • 打赏
  • 举报
回复
好啦,基本上解决啦!就是这样设置:


具体就是这样子:entry point不要设置;object file name要合理设置,与程序中的路径一致。

不过还有个问题:如果设置AssemblerOutput参数的话,编译的时候就会报告
error : Element <AssemblerOutput> has an invalid value of "AssemblyCode".
的错误。这个怎么解决呢?这个是用来输出.fx 文件的汇编代码的,还是比较有用的。
哈利_蜘蛛侠 2014-10-11
  • 打赏
  • 举报
回复
这个不太清楚啊,没用过,看上去貌似很高端的样子
赵4老师 2014-10-11
  • 打赏
  • 举报
回复
要不我怎么说:“VC6最好,不解释”呢?
虚空梦影 2014-10-11
  • 打赏
  • 举报
回复
我觉得可能有这么两个原因: 1、VS 2013的这个属性设置里并没有添加fxc为编译器的功能,而这个HLSL Compiler是vs 2013内置的一个编译器,用法与fxc 有点不同; 2、入口点(entry point)的设置问题。不过我改了好多次,也没法改对。我的这个.fx 文件是这样的,请问怎么设置入口点呢?

//***************************************************************************************
// color.fx by Frank Luna (C) 2011 All Rights Reserved.
//
// Transforms and colors geometry.
//***************************************************************************************

cbuffer cbPerObject
{
	float4x4 gWorldViewProj; 
};

struct VertexIn
{
	float3 Pos   : POSITION;
    float4 Color : COLOR;
};

struct VertexOut
{
	float4 PosH  : SV_POSITION;
    float4 Color : COLOR;
};

VertexOut VS(VertexIn vin)
{
	VertexOut vout;
	
	// Transform to homogeneous clip space.
	vout.PosH = mul(float4(vin.Pos, 1.0f), gWorldViewProj);
	
	// Just pass vertex color into the pixel shader.
    vout.Color = vin.Color;
    
    return vout;
}

float4 PS(VertexOut pin) : SV_Target
{
    return pin.Color;
}

technique11 ColorTech
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_5_0, VS() ) );
		SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_5_0, PS() ) );
    }
}


https://marketplace.visualstudio.com/items?itemName=DonAirey.ResourceGenerator&ssr=false#qna This package contains a custom tool that can be used to replace the PublicResXFileCodeGenerator that Microsoft uses by default to generate resources. The biggest problem with the Microsoft default code generator is that the generated constructor is protected, which means that it can’t be used to construct strongly-typed resources in Visual Studio in Portable Class Libraries (PCL). Simply replace the PublicResXFileCodeGenerator custom tool on all the resources with ResourceGenerator and a portable version of the resources will be generated. To create portable resources, start with a Portable Class Library project. Create a directory for your resources (e.g. Strings, this step is optional). The right click on the project, select “Add…” and select Resources File from the options. Name the file whatever you want (e.g. Resources, Errors, etc.) and hit Add. Select the .RESX file from the Solution Explorer window and hit F4 to get to the properties. In the Custom Tools property, remove ResXFileCodeGenerator or PublicResXFileCodeGenerator and type in ResourceGenerator. Now your solution can use these strings from code or XAML, in WPF, Windows 8 or UWP projects. To add localization, create a copy of the resource file and add extensions for the cultures you want to support, such as en-GB, fr-FR or any other combination. After adding the resource file, updating the extension, and translating the text (I’m a big fan of Google Translate for this part), you will need to remove the ‘Custom Tool’ property and make sure that each of the culture files has an Embedded Resource as a Build Action. The directory should look like this:

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧