nn::gd::CTR::Resource::CreateTexture2DResource Member Function

Syntax

static nnResult CreateTexture2DResource(
     const Texture2DResourceDescription * description,
     const void * initialData,
     gdBool autoGenerateMipMapsFromData,
     Texture2DResource ** texture2DResource,
     gdBool copyInitialData = GD_TRUE
);

Parameters

Name Description
in description Specifies the descriptor for creating a 2D texture resource.
in initialData Specifies the initialization data for the texture resource. Specify NULL if there is no initialization data. If there is mipmap data, all of the levels need to be specified, so set autoGenerateMipMapsFromData to GD_FALSE. If you are using automatically created mipmaps, specify only the top level of mipmap data. The initialization data must be created in LAYOUT_BLOCK_8 mode. (Helper::ConvertTextureResourceToNativeFormat orHelper::ConvertCompressedTextureResourceToNativeFormat)
in autoGenerateMipMapsFromData If automatic mipmap generation is enabled, uses the MemoryGene rateMipMaps function to generate them automatically from initialData. MemoryGenerateMipMaps is able to generate mipmaps with a resolution of 32 (sometimes 64) or greater. For more information, see the Memory::GenerateMipMaps function reference. This can be used when the hardware resolution is 8 or higher. If you want to use a mipmap with resolution lower than 32, you must generate the mipmap manually. Specify GD_FALSE for autoGenerateMipMapsFromData.
out texture2DResource Specifies the address storing the created 2D texture resource.
in copyInitialData This parameter is used when initialization data is specified. The default is true. When this parameter is true, a memory area is allocated in the function (either FCRAM or VRAM specified by the descriptor), and then the initialization data is copied to the allocated memory. When this parameter is false, the texture2DResource memory address becomes the one allocated by the user (the address of initialData). In this case, the user must allocate a sufficient memory area with the correct memory alignment. If resources use some mipmaps, sufficient memory area must be allocated to all the mipmaps. Also, the user is responsible for releasing the data memory area after releasing the resource.

Return Values

Returns the result of the operation.
Value Description
Result::IsSuccess Process was successful.
ResultNullParameter NULL was specified for description or texture2DResource.
ResultInvalidTextureResolution 0 was specified for either m_Width or m_Height in Texture2DResourceDescription. The result is also returned if the layout is LAYOUT_BLOCK_32 and the size is not correctly aligned. Also, this result is returned if a mipmap cannot be created for the given size of m_Width or m_Height in Texture2DResourceDescription. The specified size must be a power of 2.
ResultInvalidTextureMipLevel The mipmap level index for Index is invalid.
ResultInvalidMemoryLayout Memory layout is not correct. This result is also returned if initialization data has been specified but the memory layout is not Memory::LAYOUT_BLOCK_8.
ResultInvalidMemoryLocation The memory type is not valid.
ResultInvalidTextureFormat The pixel format is incorrect. This result is also returned if the initialization data is in ETC format and mipmaps cannot be automatically created.
ResultOutOfMemory Cannot obtain memory for the resource
ResultOutOfMemoryExt Cannot obtain memory for the data.
ResultInvalidTextureMipLevelIndexForMipmapAutoGeneration If autoGenerateMipMapsFromData is enabled, the last mipmap level must have a resolution of 8x8 or better. Or, the last mipmap level generated must have a resolution of 32 bits or better if the pixel format is 32 or 24.

Description

Creates a 2D texture resource.

This function adds commands to the command list. Refer to the Programming Manual for details.

See Also

Texture2DResourceDescription
Helper::ConvertTextureResourceToNativeFormat
Helper::ConvertCompressedTextureResourceToNativeFormat

Revision History

2011/02/17
Initial version.

CONFIDENTIAL