DxCreateTexture: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
element dxCreateTexture ( string filepath [, string textureFormat = "argb", bool mipmaps = true ] ) | element dxCreateTexture ( string filepath [, string textureFormat = "argb", bool mipmaps = true ] ) | ||
element dxCreateTexture ( string pixels [, string textureFormat = "argb", bool mipmaps = true ] ) | element dxCreateTexture ( string pixels [, string textureFormat = "argb", bool mipmaps = true ] ) | ||
element dxCreateTexture ( int width, int height [, string textureFormat ] ) | element dxCreateTexture ( int width, int height [, string textureFormat, string textureType, int depth ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 26: | Line 26: | ||
**''''dxt5'''' : DXT5 compressed - Can take a fraction of a second longer to load (unless the file is already a DXT3 .dds). Uses 4 times less video memory than ARGB and can speed up drawing. Quality slightly better than DXT1 and supports crisp alpha blending. | **''''dxt5'''' : DXT5 compressed - Can take a fraction of a second longer to load (unless the file is already a DXT3 .dds). Uses 4 times less video memory than ARGB and can speed up drawing. Quality slightly better than DXT1 and supports crisp alpha blending. | ||
*'''mipmaps :''' True to create a mip-map chain so the texture looks good when drawn at various sizes. | *'''mipmaps :''' True to create a mip-map chain so the texture looks good when drawn at various sizes. | ||
{{New feature/item|4.0130|1.3|4021| | |||
*'''textureType :''' Desired texture type | |||
**''''2d'''' : Standard texture (default) | |||
**''''3d'''' : Volume texture | |||
**''''cube'''' : Cube map | |||
*'''depth:''' Desired number of slices when creating a volume texture | |||
}} | |||
==Returns== | ==Returns== | ||
Returns a [[texture]] if successful, ''false'' if invalid arguments were passed to the function. | Returns a [[texture]] if successful, ''false'' if invalid arguments were passed to the function. | ||
Line 52: | Line 58: | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Changelog== | |||
{{ChangelogHeader}} | |||
{{ChangelogItem|1.3.0-9.04021|Added textureType and depth argument}} | |||
==See Also== | ==See Also== | ||
{{Drawing_functions}} | {{Drawing_functions}} |
Revision as of 02:37, 22 April 2012
This function creates a texture element that can be used in the dxDraw functions.
It is possible to use dxCreateTexture to load cubemaps and volume textures, but these will only be useable as inputs for a shader. The Microsoft utility DxTex can view and change cubemaps and volume textures. DxTex can also convert standard textures into DXT1/3/5 compressed .dds which should reduce file sizes.
Syntax
element dxCreateTexture ( string filepath [, string textureFormat = "argb", bool mipmaps = true ] ) element dxCreateTexture ( string pixels [, string textureFormat = "argb", bool mipmaps = true ] ) element dxCreateTexture ( int width, int height [, string textureFormat, string textureType, int depth ] )
Required Arguments
- filepath: The filepath of the image. (.bmp, .dds, .jpg, .png, and .tga images are supported). Image files should ideally have dimensions that are a power of two, to prevent possible blurring.
or
- pixels: Pixels containing image data. ('plain', 'jpeg' or 'png' pixels can be used here)
or
- width: Desired width (Must be a power of two. e.g. 128, 256)
- height : Desired height (Must be a power of two. e.g. 128, 256)
Optional Arguments
- textureFormat : Desired texture format
- 'argb' : ARGB uncompressed 32 bit color (default)
- 'dxt1' : DXT1 compressed - Can take a fraction of a second longer to load (unless the file is already a DXT1 .dds). Uses 8 times less video memory than ARGB and can speed up drawing. Quality not as good as ARGB and does not support alpha blending.
- 'dxt3' : DXT3 compressed - Can take a fraction of a second longer to load (unless the file is already a DXT3 .dds). Uses 4 times less video memory than ARGB and can speed up drawing. Quality slightly better than DXT1 and supports smooth alpha blending.
- 'dxt5' : DXT5 compressed - Can take a fraction of a second longer to load (unless the file is already a DXT3 .dds). Uses 4 times less video memory than ARGB and can speed up drawing. Quality slightly better than DXT1 and supports crisp alpha blending.
- mipmaps : True to create a mip-map chain so the texture looks good when drawn at various sizes.
Returns
Returns a texture if successful, false if invalid arguments were passed to the function.
Example
addEventHandler( "onClientRender", root, function() if myImage then dxDrawImage( 100, 350, 300, 350, myImage ) end end ) -- Use 'toggle' command to switch image on and off addCommandHandler( "toggle", function() if not myImage then myImage = dxCreateTexture( "moonpig.png" ) -- Create texture else destroyElement( myImage ) -- Destroy texture myImage = nil end end )
Changelog
Version | Description |
---|
1.3.0-9.04021 | Added textureType and depth argument |
See Also
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsSize
- dxGetPixelsFormat
- dxGetStatus
- dxGetTextSize
- dxGetTextWidth
- dxGetTexturePixels
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderValue
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource