views:

66

answers:

2

I'm creating a drawing application with OpenGL. I'v created an algorithm that generates gradient textures. I then map these to my polygons and this works quite well. What I realized is how much memory this requires. Creating 1000 gradients takes about 800MB and that's way too much. Is there an alternative to textures, or a way to compress them, or another way to map gradients to polygons that doesn't use up as much memory?

Thanks

My polygons are concave, I use GLUTesselator, and they are multicolored and point to point

+4  A: 

Yes... gradients are super easy to do in OpenGL; you don't need textures at all. Working from memory here... you'd just do something like this:

glBegin(GL_POLYGON);
glColor3ub(255,0,0); // red
glVertex2f(-1,-1);
glVertex2f(1,-1);
glColor3ub(0,0,255); // blue
glVertex2f(1,1);
glVertex2f(-1,1);
glEnd();
// draws a square that fades from red to blue

If you change the color of a vertex, it just creates a gradient between those two points.

Mark
+2  A: 

You can also try generating gradients procedurally inside a fragment shader.

If you go via the texture compression path, you can use glCompressedTexImage2D, compressed texture formats are provided via GL extensions, a common one is S3TC/DXT1.

Matias Valdenegro