Difference between revisions of "Horde3D Wiki:HOWTO"

From Horde3D Wiki
Jump to: navigation, search
Line 12: Line 12:
 
== How to get the size of a loaded texture ==
 
== How to get the size of a loaded texture ==
  
To query the dimensions of a loaded texture you can call
+
The following code queries the dimensions of the base mipmap of a loaded texture:
 
{{CppSourceCode|
 
{{CppSourceCode|
 
description= C++ Code|
 
description= C++ Code|
 
code=
 
code=
 
<source lang="cpp" line="1">
 
<source lang="cpp" line="1">
int width = Horde3D::getResourceParami( texResHandle, TextureResParams::Width );
+
int width = h3dGetResParamI( texResHandle, H3DTexRes::ImageElem, 0, H3DTexRes::ImgWidthI );
int height = Horde3D::getResourceParami( texResHandle, TextureResParams::Height );
+
int height = h3dGetResParamI( texResHandle, H3DTexRes::ImageElem, 0, H3DTexRes::ImgHeightI );
 
</source>}}
 
</source>}}
 +
If you want to get the dimensions of mipmap level ''n'', change the elemIdx parameter which is 0 above to ''n''.

Revision as of 20:41, 27 August 2009

The HOWTO contains quick answers for smaller problems.



How to enable anti-aliasing (MSAA)

Anti-aliasing can only be enabled for render targets. The RenderTarget element used in Pipeline resources has an attribute maxSamples which defines the maximum number of samples used for MSAA. The actual number of samples is controlled by the engine option SampleCount. This makes it possible to control the anti-aliasing quality from the application. If SampleCount is set to zero, MSAA is disabled. Note that the hardware needs to support the EXT_framebuffer_multisample extension in order for the MSAA to work.

How to get the size of a loaded texture

The following code queries the dimensions of the base mipmap of a loaded texture:

C++ Code
int width = h3dGetResParamI( texResHandle, H3DTexRes::ImageElem, 0, H3DTexRes::ImgWidthI );
int height = h3dGetResParamI( texResHandle, H3DTexRes::ImageElem, 0, H3DTexRes::ImgHeightI );

If you want to get the dimensions of mipmap level n, change the elemIdx parameter which is 0 above to n.