glBegin() / glEnd()

glBegin() / glEnd()

Post by Poiso » Sat, 29 Jun 2002 16:13:37



hi,

is:

glBegin(GL_QUADS);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);

    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
glEnd();

faster than:

glBegin(GL_QUADS);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
glEnd();

glBegin(GL_QUADS);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
    glVertex3f(x,y,z);
glEnd();

    Poison

 
 
 

glBegin() / glEnd()

Post by Gernot Frisc » Sat, 29 Jun 2002 16:32:55


Yes. You propably won't notice, but you leave some function calls in example
1, so it's less code to evaluate.

Gernot.



Quote:> hi,

> is:

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);

>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

> faster than:

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

>     Poison


 
 
 

glBegin() / glEnd()

Post by ZZ » Sat, 29 Jun 2002 16:52:55


yes, u can improve further by going glVertex3fv( vert ) -> using vertex
arrays -> compiled vertex arrays etc

zed


Quote:> hi,

> is:

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);

>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

> faster than:

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

>     Poison

 
 
 

glBegin() / glEnd()

Post by Jakob Bielin » Sat, 29 Jun 2002 17:37:56




Quote:> hi,

> is:

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);

>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

> faster than:

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

    Most likely, yes.
--
jb

(replace y with x to reply)

 
 
 

glBegin() / glEnd()

Post by César Blecua Udía » Sat, 29 Jun 2002 20:18:16



> hi,

> is:

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);

>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

> faster than:

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

> glBegin(GL_QUADS);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
>     glVertex3f(x,y,z);
> glEnd();

Yes, and most of the times is not just "faster", but "*much* faster",
specially if we're talking about thousands of quads.

Csar

 
 
 

glBegin() / glEnd()

Post by Wolfgang Draxinge » Mon, 01 Jul 2002 02:59:40




>>hi,

>>is:

>>glBegin(GL_QUADS);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);

>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>glEnd();

>>faster than:

>>glBegin(GL_QUADS);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>glEnd();

>>glBegin(GL_QUADS);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>    glVertex3f(x,y,z);
>>glEnd();

> Yes, and most of the times is not just "faster", but "*much* faster",
> specially if we're talking about thousands of quads.

> Csar


And thus it can be sensefull to put a lot of small textures into a
single huge one. There was recently a newbie who wondered, why he wasn't
able to change the texture within glBegin() glEnd(). That behaviour is
very important, since a texture context change means a lot of management
stuff. However putting the 6, say 256x256, textures into a 512x1024
means wasting a bit of memory, but a huge performance gain.

So it's *incredible* faster to collect QUADS and also to collect TEXTURES.
Hey, if we're collecting those performace hints further we'll run out of
superlatives ;-)

 
 
 

glBegin() / glEnd()

Post by Jakob Bielin » Mon, 01 Jul 2002 04:43:58



Newsbeitrag

Quote:> And thus it can be sensefull to put a lot of small textures into a
> single huge one. There was recently a newbie who wondered, why he
wasn't
> able to change the texture within glBegin() glEnd(). That behaviour
is
> very important, since a texture context change means a lot of
management
> stuff. However putting the 6, say 256x256, textures into a 512x1024
> means wasting a bit of memory, but a huge performance gain.

    There's one problem with this, though: your texture might appear
blank or corrupted or whatever, if the card does not support this. To
get arund it, it might be a good idea to leave the textures small and
then merge them at load-time, if the card supports this. To avoid this
procedure every time the application is run, you could also store the
large textures once they have been merged and load those next time,
because then you can be sure that the card will support it. Of course,
this will also involve some more or less complicated texture coords
transformations.

regards
--
jb

(replace y with x to reply)

 
 
 

1. Modelviewtransformation within glbegin/glend ???

Hello,

when I try to do a modelviewtransformation (glrotate,gltranlate,glscale)
within glBegin/glEnd something strange happens.
The following displaylist should draw a part of a "circle" that fades its
color.
Therfore I draw a line ,and then rotate and translate (and change the color)
the matrix before I draw the next vertex (line).
But what happens is that only the fist to vertices (the first line) is drawn
and the Modeltransformation is applied only once.
What can I do to get the desired effect (draw a part of a circle, that
consisis of several straight lines with colorfading?)

glNewList(Strich, GL_COMPILE);
     glColor3f(0.0f,0.0f,0.0f);
     glBegin(GL_LINE_STRIP);
         glVertex2f(0.0f,0.0f);
         glVertex2f(0.0f,10.0f);
         for (i=1;i<=20;i++)
         {
             glColor3f(0.0f,0.0f,i/20);
             glTranslatef(0.0f,10.0f,0.0f);
             glRotatef(10.0f,0.0f,0.0f,1.0f);
             glVertex2f(0.0f,10.0f);
         }
     glEnd();
 glEndList();

thx4hlp

2. Computer Animation Schools FAQ

3. Minimizing glBegin/glEnd not always optimal, was: serious optimization

4. Painter vs ColorIt

5. can i enable/disable GL_Line_Stipple between glbegin/glend?

6. Bad rotation problem Pivot question.

7. glBindTexture and glBegin/glEnd

8. ANN: High dimensional data visualizer VisuMap 1.4 released

9. Disabling texture within glBegin/glEnd

10. glBegin/glEnd

11. SLOOOW glBegin/glEnd

12. Problem with Display Lists, or maybe glBegin()/glEnd() under windows

13. glBegin(), glEnd() and a bit of glBindTexture()