Drawing a Square vs Loading a Square

Hello.

I was wondering what would be more efficient, loading a generic white square or drawing one instead. I intend on loading several dozens of these squares just to create a simple mosaic, and I’ll be adjusting the opacity of each square individually.

Thanks for your help.

Cheers,
Mark

What do you mean by loading and drawing?

Just a quick heads up, I’m working with the iPhone SDK. So when I use the word “load”, I mean the following procedure (where myTexture is a simple white square):

[_myTexture drawAtPoint:CGPointMake(bounds.size.width / 2, bounds.size.height * 2)];

And when I use the word “draw”, I mean:

glPushMatrix();
glTranslatef(10, 100, 0);
GLshort vertArray[12] = {10,10,0, 10,20,0, 20,20,0, 20,10,0}; 
GLubyte colArray[16] = {0,255,0,0, 255,0,0,0, 0,255,0,0, 0,255,0,0};

//Enable vertices array
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_SHORT, 0, vertArray);

//Enable colour array
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colArray);

//We want to draw triangles, 0=first element(vertices). 3=number of items (vertices) to draw from the array
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colArray);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glPopMatrix();

I hope that clears up the ambiguity. And thanks for the help.

–Mark

Oh I believe I understand. I’d be inclined to think that rendering your squares using 3d primitives (“drawing”) would be much more efficient in this circumstance then rending a texture (“loading”) which contains squares. But this can vary greatly depending on things such as hardware, and complexity of what your trying to render. The more polygons that would be required to render your model, the great chance that using a texture which has been pre-rendered would give you a boost in performance. So I believe it’s quite situational, but I’m no expert on this topic, so others may have some suggestions.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.