PDA

View Full Version : why is there a glBegin/glEnd limitation?



Theo
12-23-2000, 07:55 PM
It would be nice to do things like

glBegin GL_QUADS
glBindTexture GL_TEXTURE_2d, Tex1
DrawSomeTextureQuadVertixs
glBindTexture GL_TEXTURE_2d, Tex2
DrawOtherTextureQuadVertixs
glEnd

at the moment I need to call glEnd to do glBindTexture. Is there really such a need to only have so few calls allowed in a glBegin block? Its annoyed me other times too. Also, my implementation (Mac OpenGL) doesn't give you an error from glGetError if you call things in a glBegin block that shouldn't be called.

j
12-23-2000, 08:59 PM
It seems to me that switching textures in the middle of drawing a batch of primitives might mess up the graphics pipeline pretty bad.

Why would you not want to put in two batches of primitive drawing in that code? If you are drawing any amount of triangles greater than, say, a hundred or so, the savings in function overhead from two less glBegin/glEnd calls would be unnoticeable.

j

mcraighead
12-23-2000, 09:12 PM
The amount of per-vertex state must be _strictly_ limited to ensure that rendering is efficient.

OpenGL made a big mistake in allowing Material commands inside Begin/End. Under no conditions should you EVER use this feature.

The first problem, one of many, is: if you change the texture inside a triangle strip, which triangles use which textures?

There are solutions to these problems, but they involve crippling the efficiency of the API.

Immediate mode itself, in my opinion, was a mistake. OpenGL should have just had vertex arrays from the start. There should have been two drawing commands: DrawArrays and DrawRangeElements.

- Matt