Gradients?
BlitzMax Forums/BlitzMax Programming/Gradients?
| ||
Hi, Anyone knows why Fredborgs old Gradient sample doesn't work anymore? Or, Does anyone have a better way of doing gradients in Max2D using OpenGL? ^^ Thanks :) |
| ||
Oh, Using the correct GraphicsDriver could be good :P Now I have another issue though, Using DrawText in the same loop as this function has some strange effects, the Gradient just disappears.. Any thoughts on why? :S |
| ||
Drawing text probably enables texturemapping which `hides` the smooth shading that you'd see in the quads you're drawing. glDisable GL_TEXTURE_2D ? Trying to use some gl commands mixed with Max2d is in many cases a conflict of interests. |
| ||
I came up with a better way of doing Gradients now I think :P Just create an image 1x2 pixels, One white and one Black or Dark Grey, Load the image and use DrawImageRect() and OpenGL with smooth the image to a Gradient :P (And the best thing is that you can just use SetColor before to get the color you want if you just want a fading color) I wonder how fast this is though.. |
| ||
That's a good way to do it. It does use more computation because each pixel still has to do a texture lookup, but the texture is very small and there are caches which help speedup accesses which surely will be helping in this case. You don't really need the texture to do such a gradient but it's probably not much slower. |
| ||
[EDIT] I'm a dork and need to read. Why not just use OpenGL commands? Something like: glBegin(GL_QUAD) glColor4f(1.0, 0.0, 0.0, 1.0) glVertex2f(0.0, 0.0) glColor4f(0.0, 1.0, 0.0, 1.0) glVertex2f(0.0, GraphicsHeight()) glColor4f(0,0, 0.0, 1.0, 1.0) glVertex2f(GraphicsWidth(), GraphicsHeight()) glColor4f(1.0, 1.0, 1.0, 1.0) glVertex2f(GraphicsWidth(), 0.0) glEnd() |