From: Wolfgang.Draxinger on
Am Thu, 29 Jul 2010 11:47:59 +0200
schrieb "Skybuck Flying" <IntoTheFuture(a)hotmail.com>:

> It's is often said that opengl is a big state machine.

Yes. It's been defined that way.

> The question is does this extend/apply to user provided data as well,
> like verteces for example ?!?

If those vertices are stored in an OpenGL object (Display List, Vertex
Buffer Object), then yes.

> // rendering loop:
> while true do
> begin
> glClear; // perhaps... clear could be skipped as well.

Why could you skip it? There's still the content of the previous frame
here.

>
> if mFirst then
> begin
> // supply vertex data to opengl state machine only on first
> frame glVertexPointer
> end;

Not the vertex data is supplied here, but the information, where the
vertex data can be found. I think the function suffix -Pointer should
make this pretty clear.

> // supply color information for each frame.
> glColorPointer
>
> // draw vertex array.
>
> // flush.
> end;
>
> So far the theory...
>
> The question is... will this work in practice ?!?

Not this way. Well, you can of course use vertex arrays, and adjust the
data in the color pointer array continously. Since
gl{Color,Vertex,Normal,Attrib}Pointer don't upload you can do this even
on the fly, while the pointer is set.

If you want to upload stuff to the GPU use Vertex Buffer Objects. To
replace a portion of the VBO you can use glBufferSubData just like
you'd to with glTexSubImage.

> Or will it not work and will opengl become confused ?!?

The only one confused here, is you.

> Is the call to glVertexPointer necessary for each frame (static
> data) ? hmmm.

gl{Vertex,Color,Normal,Attrib}Pointer isn't uploading stuff. It doesn't
work like glTexImage. It's just setting a variable in OpenGL to where to
find the vertex data when instanciated by glDrawElements/glDrawArrays.
In the case VBOs are used instead of a pointer into process memory it
sets an offset in the buffer data. There's example code at the end of
http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt

> Time will tell, since sometime it will make an example or
> implementation of these idea's ;)

For god's sake: Just read the documentation. It's all written down
there in very clear form. It's not archeology or historic research,
where you've to develop theories. Everything has been exactly specified.


Wolfgang
--
CIP-Rechnerbetriebsgruppe
Fakultät für Physik - LMU München
Schellingstrasse 4, 80799 München