This section describes the build action.
Build action is the process of executing the files registered in a project at the time of a build.
The following build actions can be set to a file with PSM Studio.
Build Action Description Compile Compiles the files as the source code. Content Changes cannot be added to the file, but they can be transferred to the actual device. ShaderProgram Compiles the files as a shader program. None Nothing is done for the file. Nothing is transferred to the actual device. EmbeddedResource Files are embedded in the assembly. EmbeddedShaderProgram Complies the files as a shader program and embeds them in the assembly. PsmMetadata Performs app.xml settings.
When registering the following files to a project, build action will automatically be set as follows.
File with the filename "osc.cfg" or with one of the extensions "*.png, *.jpg, *.bmp, *.gif, *.dds, *.wav, *.mp3, *.mdx".
"Content" will be set to the build action.File with one of the extensions "*.fcg, *.vcg, *.fp.cg, *.vp.cg".
"ShaderProgram" will be set to the build action.File with the filename "app.xml".
"ShaderProgram" will be set to the build action.
When embedding (EmbeddedResource or EmbeddedShaderProgram) is set for the build action, the embedded files are used as follows.
sample/Tutorial/TutoLib/SimpleSprite.cs
private static ShaderProgram CreateSimpleSpriteShader()
{
//@j 埋め込まれたファイル名。
//@e Embedded file name.
string resourceName = "TutoLib.shaders.SimpleSprite.cgx";
Assembly resourceAssembly = Assembly.GetExecutingAssembly();
if (resourceAssembly.GetManifestResourceInfo(resourceName) == null)
{
throw new FileNotFoundException("File not found.", resourceName);
}
//@j ファイルストリームの取得とメモリの確保。
//@e Get filestream and allocate dataBuffer.
Stream fileStream = resourceAssembly.GetManifestResourceStream(resourceName);
Byte[] dataBuffer = new Byte[fileStream.Length];
//@j ファイルをメモリに読み込む。
//@e Read files into the dataBuffer.
fileStream.Read(dataBuffer, 0, dataBuffer.Length);
//@j メモリに配置されたデータを利用する。
//@e use data.
var shaderProgram = new ShaderProgram(dataBuffer);
shaderProgram.SetUniformBinding(0, "u_WorldMatrix");
return shaderProgram;
}
Here, files embedded in the assembly with EmbeddedShaderProgram are read.