Change vertex colours on a call to DrawImage?
BlitzMax Forums/BlitzMax Programming/Change vertex colours on a call to DrawImage?
| ||
I'd like to be able to change vertex colours on a call to DrawImage... Can this be done simply? Thanks, Sonic |
| ||
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. |
| ||
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? |
| ||
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 |
| ||
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. |
| ||
Oh right - thanks sswift! |