DECLARE SUB DQBttri (BYVAL Layer, BYVAL x1, BYVAL y1, BYVAL x2, BYVAL y2,
BYVAL x3, BYVAL y3, BYVAL u1, BYVAL v1, BYVAL u2,
BYVAL v2, BYVAL u3, BYVAL v3, BYVAL TextureSeg,
BYVAL TextureOff)
Layer - Layer where to draw the triangle
x1 - x coordinate of the first vertex
y1 - y coordinate of the first vertex
x2 - x coordinate of the second vertex
y2 - y coordinate of the second vertex
x3 - x coordinate of the third vertex
y3 - y coordinate of the third vertex
u1 - x coordinate of first vertex on texture
v1 - y coordinate of first vertex on texture
u2 - x coordinate of second vertex on texture
v2 - y coordinate of second vertex on texture
u3 - x coordinate of third vertex on texture
v3 - y coordinate of third vertex on texture
TextureSeg - Array segment holding the texture (use VARSEG)
TextureOff - Array offset holding the texture (use VARPTR)
none
Draws a texture-mapped triangle with (x1,y1), (x2,y2) and (x3,y3) as vertexes. The texture used must be stored into specified array with GET or DQBget, and its width must be a power of 2, equal to the one specified by calling DQBsetTextureSize (the default texture width is 64 pixels). Each vertex of the triangle has also its own texture coordinates, that can be anywhere on the texture itself, as well as out of it; if the distance between two texture vertexes is greater than the texture size, the texture is wrapped while drawing. DQBttri supports transparency (color 0 on the texture is *always* handled as transparent color) and clipping.
See also DQBsetTextureSize, DQBtri, DQBbtri, DQBgtri
*****************************************************************************
' All integers for speed
DEFINT A-Z
'$INCLUDE:'DIRECTQB.BI'
' Dimension our 64x64 pixels texture array
DIM Texture(2049)
' Let's initialize the library with no extra layers nor sounds nor EMS
IF DQBinit(0, 0, 0) THEN DQBclose: PRINT DQBerror$: END
DQBinitVGA
' Let's build our sample texture
FOR i = 0 TO 15
DQBbox VIDEO, i, i, 63 - i, 63 - i, 31 - i
DQBbox VIDEO, 16 + i, 16 + i, 47 - i, 47 - i, 16 + i
NEXT i
DQBbox VIDEO, 0, 0, 63, 63, 40
DQBline VIDEO, 0, 0, 63, 63, 4
DQBellipse VIDEO, 32, 32, 24, 24, 43
' Gets our texture and clears the screen
DQBget VIDEO, 0, 0, 63, 63, VARSEG(Texture(0)), VARPTR(Texture(0))
DQBclearLayer VIDEO
' Draws 500 textured triangles
FOR i = 1 TO 500
DQBttri VIDEO, (RND * 320), (RND * 200), (RND * 320), (RND * 200), (RND * 320), (RND * 200), 0, 0, 63, 0, 0, 63, VARSEG(Texture(0)), VARPTR(Texture(0))
NEXT i
' Waits for the user to press a key
WHILE INKEY$ = "": WEND
' Ends program
DQBclose
*****************************************************************************