Texture Flags

Blitz3D Forums/Blitz3D Programming/Texture Flags

Fry Crayola(Posted 2004) [#1]
I've been experimenting with single surface systems (as you might guess from my recent topics), and now I'm trying to display overlapping quads.

I believe the way to do this when creating the texture, to include the Mask flag (4). This is after I have used ClearTextureFilters.

However, when doing this, nothing appears on my screen. If I apply no mask, everything's fine except the graphics overlap horribly, as you'd expect. After experimentation I found out that setting any texture flag makes my graphics disappear.

Any help? It's a basic quad system, nothing too complex. I'm in a hurry (sadly), I'll get the code up later if necessary. Thanks.


Fry Crayola(Posted 2004) [#2]
here is my code. This is really bugging me.

;this is a program to demonstrate the use of single surface quads

Graphics3D 800,600
ClearTextureFilters

Type sprite
Field width			;width of sprite in pixels
Field height		;height of sprite in pixels
Field u1#,v1#		;top left texture coords
Field u2#,v2#		;bottom right texture coords
Field tile			;tile number of sprite (for use in deleting tiles)
End Type

;create array of seven sprites
Dim image.sprite(6)

;globals
Global texture, surf, brush, camera, light, mesh


;create texture to be used
;this creates a 1024*1024 texture, allowing for 4*4 tiles
texture = CreateTexture(256,256,1)

;load in sample graphics tile, add to texture at first tile position
textureImage = LoadImage ("sample graphics.bmp")
SetBuffer TextureBuffer(texture)
DrawImage textureImage,0,0
SetBuffer BackBuffer()

;create the brush
brush = CreateBrush()
BrushTexture brush,texture

;okay! That works! Mwahahahahahah!
;Now, the aim is to load in the image information contained in "sample graphics.dat"
file = ReadFile("sample graphics.dat")
sprites = ReadInt(file)

For a = 1 To sprites
	x = ReadInt(file)
	y = ReadInt(file)
	width = ReadInt(file)
	height = ReadInt(file)
	
	image(a-1) = New sprite
	image(a-1)\width = width
	image(a-1)\height = height
	image(a-1)\u1 = (x/255.0)
	image(a-1)\v1 = (y/255.0)
	image(a-1)\u2 = ((x+width-1)/255.0)
	image(a-1)\v2 = ((y+height-1)/255.0)
	image(a-1)\tile = 1
Next
CloseFile (file)


camera=CreateCamera()
CameraZoom camera,1


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

; Create blank mesh
mesh=CreateMesh()

; Create blank surface which is attached to mesh (surfaces must always be attached to a mesh)
surf=CreateSurface(mesh)


;call draw3DImage function, drawing an object on screen
draw3DImage(image(0),0,200,1,1)
draw3DImage(image(2),0,400,1,1)

;position mesh so it can be seen
PositionEntity mesh,-400,-300,400
PositionEntity camera,0,0,0

;paint the surface with the brush
WireFrame False
PaintSurface surf,brush

; main loop
While Not KeyDown(1)

If KeyDown(200)	MoveEntity camera,0,-1,0
If KeyDown(203) MoveEntity camera,1,0,0
If KeyDown(205) MoveEntity camera,-1,0,0
If KeyDown(208) MoveEntity camera,0,1,0
If KeyDown(44) MoveEntity camera,0,0,1
If KeyDown(45) MoveEntity camera,0,0,-1

UpdateNormals mesh
RenderWorld
Flip

Wend

End



;function draw3DImage(image, xpos, ypos, xscale, yscale)
Function draw3DImage(this.sprite, xpos#, ypos#, xscale#, yscale#)
	;first, create the four vertices as part of the quad.
	v1 = AddVertex(surf, xpos, ypos, 0, this\u1, this\v1)
	v2 = AddVertex(surf, (xpos+this\width-1), ypos, 0, this\u2, this\v1)
	v3 = AddVertex(surf, (xpos+this\width-1), (ypos-this\height+1), 0, this\u2, this\v2)
	v4 = AddVertex(surf, xpos, (ypos-this\height+1), 0, this\u1, this\v2)
	
	;add two triangles
	t1 = AddTriangle(surf, v1, v2, v4)
	t2 = AddTriangle(surf, v2, v3, v4)
End Function



Fry Crayola(Posted 2004) [#3]
Ok, I solved the problem by loading in a texture rather than creating it. Seeing as I need a blank texture, it's a shame that I have this overhead.

I understand this bug was supposed to have been fixed in 1.87?