OpenGL rendering optimization

I draw squares in openGL. My question is whether there are additional benefits to this:

// Method #1

glBegin(GL_QUADS);
// Define vertices for 10 quads
glEnd();

... for this, for each of the 10 quads:

// Method #2

glBegin(GL_QUADS);
// Define vertices for first quad
glEnd();

glBegin(GL_QUADS);
// Define vertices for second quad
glEnd();

//etc...

In this case, all the squares use the same texture.

+3
source share
6 answers

I decided to go ahead and compare it using a loop of 10,000 quads.

Results:

Method 1: 0.0128 seconds

Method 2: 0.0132 seconds

Method No. 1 has some improvement, but the improvement is very slight (3%). This is probably nothing more than overhead, just calling more features. Thus, it is likely that OpenGL itself does not receive additional optimization from method # 1.

3 Windows XP OpenGL 2.0 visual studio 2005.

+3

, , glBegin glEnd OpenGL.

, glBegin glEnd ( ), glVertexPointer ( ), glDrawArrays glDrawElements. GPU , , glVertex3f .

+9

. . glBegin/glEnd , .

, glBegin/glEnd OpenGL 3.0 OpenGL ES.

, , glDrawArrays. NeHe.

+4

, "", . -, 100- , . :)

schnaader: , , , , gl, glBegin glEnd. , , .

+2

, . , .

0

, , .

, 3D-. .

0

Source: https://habr.com/ru/post/1712418/


All Articles