DECLARE SUB DQBfttri (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
Works exactly like normal DQBttri, but applies bilinear filtering during the texturing process. This function is slower than DQBttri, but it draws better looking triangles; anyway you need a gradient palette in order to achieve good results.
As this function has been coded thinking about speed, it isn't too accurate with its calculations; this means that to be sure your triangle will be drawn correctly, you should use a gradient palette set in the way that at least 4 or 5 colors are NOT used by your texture before and after its colors range. I mean that if your texture uses only color 5 to 100, you also need to set colors 0-4 and 101-105; this way you'll avoid boring problems... See also DQBsetTextureSize, DQBtri, DQBbtri, DQBgtri, DQBttri
*****************************************************************************
' All integers for speed
DEFINT A-Z
'$INCLUDE:'DIRECTQB.BI'
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
' Creates a red gradient palette
FOR i = 0 TO 63
DQBsetCol i, i, 0, 0
DQBsetCol 64 + i, 63, i, i
NEXT i
' Creates a texture filled with random red pixels
FOR x = 0 TO 63
FOR y = 0 TO 63
DQBpset VIDEO, x, y, 5 + (RND * 118)
NEXT y
NEXT x
DQBbox VIDEO, 0, 0, 63, 63, 127
DQBline VIDEO, 63, 0, 0, 63, 127
' Gets the texture
DQBget VIDEO, 0, 0, 63, 63, VARSEG(texture(0)), VARPTR(texture(0))
' Clears the screen
DQBclearLayer VIDEO
' Draws 500 random triangles
FOR i = 1 TO 500
RANDOMIZE TIMER
DQBfttri 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
END
*****************************************************************************