Dynamic Image Masking

BlitzMax Forums/BlitzMax Programming/Dynamic Image Masking

Gehhilfe(Posted 2005) [#1]
Hi Guys!

I am drawing with DrawPoly,
then i want Draw a Image only over the White Poly.

How can i do that ?

My Code:
Type TVektor

	Field x#, y#
	
	Method Set ( x#, y# )
		Self.x# = x#
		Self.y# = y#
	End Method
	
End Type

Type TPoly

	Field Point:TVektor[3]
	
	Function Create:TPoly ( x#[], y#[] )
		Local t:TPoly = New TPoly
		For Local i=0 To 2
			t.Point[i] = New TVektor
			t.Point[i].Set ( x#[i], y#[i] )
		Next
		Return t
	End Function
	
	Method Draw()
		Local tri#[]=[ Self.Point[0].x#, Self.Point[0].y#, Self.Point[1].x#, Self.Point[1].y#, Self.Point[2].x#, Self.Point[2].y# ]
		DrawPoly tri
	End Method

End Type



Graphics 800, 600, 0

Global Test:TPoly = TPoly.Create ( [ 100.0, 100.0, 200.0 ] , [ 100.0, 200.0, 200.0 ] )

While Not KeyHit ( KEY_ESCAPE )
	Cls
	
	SetBlend SolidBlend
	SetColor 0,0,255
	DrawRect 0, 0, 800, 600
	
	SetBlend SHADEBLEND
	SetColor 0, 0, 0
	DrawRect 0,0,800,600
	SetBlend LIGHTBLEND
	SetColor 255,255,255
	Test.Draw()
	
	Flip
	
	FlushMem()
Wend

Sorry my English isnt god.

Greatings, Tim


TartanTangerine (was Indiepath)(Posted 2005) [#2]
I'm working on a function to let you texture a polygon, I'll share the code when I've started and even finished it.


Gehhilfe(Posted 2005) [#3]
I am happy to hear that.

Have a nice Day, Tim


ImaginaryHuman(Posted 2005) [#4]
You can either texture the polygon, or if you want to use OpenGL commands you can set the stencil buffer to activate in the areas where the polygon is drawn, and then subsequently draw your 2d shape so that it is only drawn where the bits are marked in the stencil. Frankly the texturing is probably easier and faster.