# Thread: Drawing a Square vs Loading a Square

1. ## 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

2. ## Re: Drawing a Square vs Loading a Square

What do you mean by loading and drawing?

3. ## Re: Drawing a Square vs Loading a Square

Originally Posted by jpilon
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):
Code :
`[_myTexture drawAtPoint:CGPointMake(bounds.size.width / 2, bounds.size.height * 2)];`
And when I use the word "draw", I mean:
Code :
```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

4. ## Re: Drawing a Square vs Loading a Square

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.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•