Binary resources are loaded from their files as ResGraphicsFile objects. You must run Setup before creating instances of the Model or other items from the loaded ResGraphicsFile. For the setup, use the Setup for ResGraphicsFile, or the Setup for ResModel. The main setup processes are as follows.
After a properly setup binary resource is no longer needed, you must run Cleanup and then release it.
Running Setup on a binary resource returns a Result. The Result from Setup is a ResourceResult object. Error handling would look like the following.
RESOURCE_RESULT_NOT_FOUND_TEXTURERESOURCE_RESULT_NOT_FOUND_SHADERRESOURCE_RESULT_NOT_FOUND_LUTSetup again, passing ResGraphicsFile as an argument.
Setup
RESOURCE_RESULT_IRRELEVANT_LOCATION_LUTRESOURCE_RESULT_IRRELEVANT_TEXTURE_MAPPING_METHOD
You can change binary resource values via the Res* class accessor. However, when changing values, you must also set the hash to 0. The following table shows how class and variable names correspond to hashes.
| Class / Var Name | Hash |
|---|---|
ResMaterial::m_Flags |
ShadingParameterHash |
ResShaderParameter |
ShaderParametersHash |
ResTextureCoordinator |
TextureCoordinatorsHash |
ResPixelBasedTextureMapper, ResStandardTextureSampler |
TextureMappersHash |
ResMaterialColor |
MaterialColorHash |
ResRasterization |
RasterizationHash |
ResFragmentLighting |
FragmentLightingHash |
ResFragmentLightingTable |
FragmentLightingTableHash |
ResAlphaTest |
AlphaTestHash |
ResTextureCombiner |
TextureCombinersHash |
ResFragmentOperation |
FragmentOperationHash |
When running Setup using multiple threads, the user must handle VRAM transfers. Handling all VRAM transfers at once is also more efficient than dealing with VRAM transfers within Setup. The process is as follows.
nw::gfx::ResGraphicsFile resFile = resourceSet->resource;
void* imageData = resFile.GetImageBlockData();
s32 size = resFile.GetImageBlockDataSize();
void* vramAddr = nw::demo::AllocateGraphicsMemory(NN_GX_MEM_VRAMA, NN_GX_MEM_TEXTURE, 0, size);
// Flush the data cache and transfer to VRAM.
nngxUpdateBuffer( imageData, size );
nngxAddVramDmaCommand( imageData, vramAddr, size );
Setup.
nw::gfx::TransferedVramAddressSetter locationSetter( imageData, vramAddr );
resFile.ForeachTexture(locationSetter);
resFile.ForeachIndexStream(locationSetter);
resFile.ForeachVertexStream(locationSetter);
CONFIDENTIAL