Change vertex colours on a call to DrawImage?

BlitzMax Forums/BlitzMax Programming/Change vertex colours on a call to DrawImage?

Sonic(Posted 2007) [#1]
I'd like to be able to change vertex colours on a call to DrawImage... Can this be done simply?

Thanks,
Sonic


tonyg(Posted 2007) [#2]
Quite simply.
The vertex colours are held in m2x2ddriver.cverts array at indexes 3,7,11,15.
Here's something VERY quick:
Graphics 800 , 600
Local red:Int , green:Int , blut:Int
red = 255
blue = 0
green = 0
color=($ff000000)|(red Shl 16)|(green Shl 8)|blue		
D3D7Max2DDriver().cverts[11] = color
DrawRect 0 , 0 , 100 , 100
Flip
WaitKey()


<edit> Having said that Drawimage seems to take it's colours from the xyzuv array which is a bit more difficult to get at. However, search for setuv and you should find some code on these forums which will give you access.


SebHoll(Posted 2007) [#3]
Excuse my ignorance, but what are vertex colours? I tried Googling it and searching on Wikipedia but it's talking about graphs and stuff.

Judging by tonyg's example, it seems to produce a kind of gradient effect, but other than that I don't know.

Could someone please explain?


xMicky(Posted 2007) [#4]
you can see how to take effect on vertex colors in the code archive here:
Click here!

Just replace
c[ii+3] = Driver.DrawColor
with
c[ii+3] = Alpha Shl 24 | Red Shl 16 | Green Shl 8 | Blue


sswift(Posted 2007) [#5]
Seb:
Draw a triangle.

Draw a dot at each corner of the triangle.

Those dots are vertices.

All 3D objects are made of a list of vertices, (dots in 3D space) and a list of triangles which is really a list of the three vertices in the previous list that define each one.

BlitzMax is 3D accelerated, so all the 2D looking stuff you see is really 3D stuff. 3D acceleration makes effects like changing colors and transparency much faster.

It also means that each of those square images you draw on the screen is really printed on two triangles. You need two triangles to make a square. And that means there's four vertices, one at each corner of the square.

Each vertex there can have a different color and alpha (transparency) set for it. And changing that allows you to do these simple gradient effects.


SebHoll(Posted 2007) [#6]
Oh right - thanks sswift!