Blitz3D+ Command Reference

TextureHeight ( texture )

Parameters

texture - texture handle

Description

Returns the height of a texture, in pixels.

The companion to TextureWidth: use the pair to size drawing operations to a texture you did not create yourself, or to work out the aspect ratio of a loaded image before you stretch a quad to match it.

For a multi-frame texture made by LoadAnimTexture this is the height of one frame, not of the source image.

See also: TextureWidth, TextureBuffer, CreateTexture, LoadTexture.

Example

; TextureHeight Example
; ---------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()

light=CreateLight()
RotateEntity light,45,45,0

; Load a 400x197 image. The engine may resize a texture to dimensions
; the graphics card prefers (usually powers of 2).
tex=LoadTexture("media/b3dlogo.jpg")

crate=CreateCube()
PositionEntity crate,0,0,5
EntityTexture crate,tex

While Not KeyDown(1)

    TurnEntity crate,0,1,0

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Arrows: camera   Esc: exit"
    Text 0,20,"b3dlogo.jpg is 197 pixels high"
    ; TextureHeight reports the height actually used in memory
    Text 0,40,"TextureHeight(tex) = "+TextureHeight(tex)

    Flip

Wend

End

Index