VBOs and normals

  • Follow


I am using display lsits at the moment to compile the objects in my game.  I
am wanting to try out Vertex Buffer objects, and just had a look on
nehe.gamedev.net lesson45.  Things seem quite easy, but I want to clarify
two things.

1) For my display list, I specify my normal then my vertex.  This is done
for each of my quads.  How do I specify the normals of my vertices using
VBOs?

2) For each of my objects, there are several different parts with different
materials, textures etc. e.g. a ship has its body, its engines, its guns and
its cockpit.  Can I use a method to bundle all these together to make
drawing the object use only one call?  i.e. can VBOs do this directly, or
can I use a Display List to call several VBOs?

Thanks
Allan


0
Reply Allan 1/27/2004 11:17:59 AM

> 1) For my display list, I specify my normal then my vertex.  This is
done
> for each of my quads.  How do I specify the normals of my vertices
using
> VBOs?

You must specify a normal pointer list. Same progress as with the
vertex pointers.


> 2) For each of my objects, there are several different parts with
different
> materials, textures etc. e.g. a ship has its body, its engines, its
guns and
> its cockpit.  Can I use a method to bundle all these together to
make
> drawing the object use only one call?  i.e. can VBOs do this
directly, or
> can I use a Display List to call several VBOs?

You should be able to create display lists of VBO calls. The Display
list however will have a copy of the vertices in memory as far as I
know. Correct me anyone if I'm wrong.
You can try it out easily.

HTH,
Gernot


0
Reply Gernot 1/27/2004 11:34:51 AM


Allan Bruce wrote:
> I am using display lsits at the moment to compile the objects in my game.  I
> am wanting to try out Vertex Buffer objects, and just had a look on
> nehe.gamedev.net lesson45.  Things seem quite easy, but I want to clarify
> two things.
> 
> 1) For my display list, I specify my normal then my vertex.  This is done
> for each of my quads.  How do I specify the normals of my vertices using
> VBOs?
> 

glNormalPointer(...);
glEnableClientState(GL_NORMAL_ARRAY);

> 2) For each of my objects, there are several different parts with different
> materials, textures etc. e.g. a ship has its body, its engines, its guns and
> its cockpit.  Can I use a method to bundle all these together to make
> drawing the object use only one call?

No.

Put all the vertices of the parts into a single VBO
then draw each one as needed.

> i.e. can VBOs do this directly, or
> can I use a Display List to call several VBOs?
> 

You could do it with a display list but you probably
won't gain much and it uses up memory.


-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    Why isn't there mouse-flavored cat food?


0
Reply fungus 1/27/2004 11:35:54 AM

"fungus" <openglMY@SOCKSartlum.com> wrote in message
news:u2sRb.2946314$uj6.7539580@telenews.teleline.es...
> Allan Bruce wrote:
> > I am using display lsits at the moment to compile the objects in my
game.  I
> > am wanting to try out Vertex Buffer objects, and just had a look on
> > nehe.gamedev.net lesson45.  Things seem quite easy, but I want to
clarify
> > two things.
> >
> > 1) For my display list, I specify my normal then my vertex.  This is
done
> > for each of my quads.  How do I specify the normals of my vertices using
> > VBOs?
> >
>
> glNormalPointer(...);
> glEnableClientState(GL_NORMAL_ARRAY);
>
> > 2) For each of my objects, there are several different parts with
different
> > materials, textures etc. e.g. a ship has its body, its engines, its guns
and
> > its cockpit.  Can I use a method to bundle all these together to make
> > drawing the object use only one call?
>
> No.
>
> Put all the vertices of the parts into a single VBO
> then draw each one as needed.
>

How do I do this with the different textures?  Ideally I want to use one
call to draw the object, but if this is not a good way, then let me know
Thanks
Allan


0
Reply Allan 1/27/2004 11:41:52 AM

Allan Bruce wrote:
> 
> How do I do this with the different textures?  Ideally I want to use one
> call to draw the object, but if this is not a good way, then let me know
> 

A display list is a bit like a tape recorder. You
start recording, do something, then you can replay
it later. You can put any OpenGL calls in there,
including textures, polygons, whatever.

Obviously you don't create the textures in there
bacause that's slow, you use glBindTexture() in
a display list.

OTOH, don't think that display lists are the answer
to everything. Once you start putting attribute
changes in there (textures, materials, etc.) then
you start losing opportunites for sorting. Real
speed comes from sorting your geometry by texture,
material, etc. Whether you end up doing that will
depend on your program.

-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    Why isn't there mouse-flavored cat food?


0
Reply fungus 1/27/2004 12:02:51 PM

> A display list is a bit like a tape recorder. You
> start recording, do something, then you can replay
> it later. You can put any OpenGL calls in there,
> including textures, polygons, whatever.
>
> Obviously you don't create the textures in there
> bacause that's slow, you use glBindTexture() in
> a display list.
>
> OTOH, don't think that display lists are the answer
> to everything. Once you start putting attribute
> changes in there (textures, materials, etc.) then
> you start losing opportunites for sorting. Real
> speed comes from sorting your geometry by texture,
> material, etc. Whether you end up doing that will
> depend on your program.
>

Unfortunately, this isnt viable for this particular program, unless I was to
start implementing some sort of stack, and then render everything at the end
just before swapping the buffers.


0
Reply Allan 1/27/2004 12:13:10 PM

> A display list is a bit like a tape recorder. You
> start recording, do something, then you can replay
> it later. You can put any OpenGL calls in there,
> including textures, polygons, whatever.
>
> Obviously you don't create the textures in there
> bacause that's slow, you use glBindTexture() in
> a display list.
>

At the moment, I am using display lists to hold my textures aswell, which I
imagine is very slow as I am calling:

glActiveTextureARB()
glEnable()
glTex*() // loads of these

so, if I bind my texture, using
glGenTextures()
glBindTexture()

how do I load up the texture?  MSDN says to use glGet, but not which one.
Thanks
Allan


0
Reply Allan 1/27/2004 12:57:27 PM

Allan Bruce wrote:
>
> Unfortunately, this isnt viable for this particular
 > program, unless I was to start implementing some sort
 > of stack, and then render everything at the end
> just before swapping the buffers.
>

Yes, that's exactly what many programs do...


As usual though, you have to decide if it's worth it.
If this isn't a commercial program or if you only
have half a dozen objects then don't bother, just
use what's easy and works for you.


Aside:

One *big* problem I have with the "display-lists-as
-dumping-grounds" approach is that they're a fertile
source of driver bugs. I've seen dozens and dozens
of rendering bugs appear when display lists are turned
on in my programs[*]. Eventually I gave up and stopped
using them. Maybe it's just old-timer paranoia but I
wouldn't personally use display lists in a commercial
application now that we have VBOs. VBOs and good attribute
sorting will give you about the same frame rates and
are much more reliable.


-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    Why isn't there mouse-flavored cat food?


[*] I bet driver writers get up in the morning and curse
the name of the person who invented display lists.

Historically, they exist because of networked rendering.
When you're rendering across 10 megabit Ethernet then
they ability to store things on the server then render
by sending a single "int" is a *big* speedup. Unfortunately
the word went out that "display lists are *FAST*!!!!" and
driver writers have been dealing with the fallout ever
since.


0
Reply fungus 1/27/2004 1:01:49 PM

Allan Bruce wrote:

> At the moment, I am using display lists to hold my textures aswell, which I
> imagine is very slow as I am calling:
> 
> glActiveTextureARB()
> glEnable()
> glTex*() // loads of these
> 

If you're not sending the image data in the display
list (ie. glTexImage() or equivalent) then you're ok.

> so, if I bind my texture, using
> glGenTextures()
> glBindTexture()
> 
> how do I load up the texture?

glBindTexture() selects a texture.

> MSDN says to use glGet, but not which one.
> 

Huh?


-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    Why isn't there mouse-flavored cat food?


0
Reply fungus 1/27/2004 1:23:33 PM

"fungus" <openglMY@SOCKSartlum.com> wrote in message
news:pDtRb.2948182$uj6.7548892@telenews.teleline.es...
> Allan Bruce wrote:
>
> > At the moment, I am using display lists to hold my textures aswell,
which I
> > imagine is very slow as I am calling:
> >
> > glActiveTextureARB()
> > glEnable()
> > glTex*() // loads of these
> >
>
> If you're not sending the image data in the display
> list (ie. glTexImage() or equivalent) then you're ok.

I am calling glTexImage2D() during compiling the display list.

>
> > so, if I bind my texture, using
> > glGenTextures()
> > glBindTexture()
> >
> > how do I load up the texture?
>
> glBindTexture() selects a texture.

so, I can use glBindTexture() to select a texture, and set all the params,
glTex* etc.
I can do this for all of my textures, then when I need to display one, do I
just use glBindTexture() again?


0
Reply Allan 1/27/2004 1:35:15 PM

Allan Bruce wrote:
> 
>>If you're not sending the image data in the display
>>list (ie. glTexImage() or equivalent) then you're ok.
> 
> 
> I am calling glTexImage2D() during compiling the display list.
> 

Slow - it will be done every time you use the list.

> so, I can use glBindTexture() to select a texture, and set 
 > all the params, glTex* etc.

glTexParameter() - yes.

> I can do this for all of my textures, then when I need to display one, do I
> just use glBindTexture() again?
> 
> 
Yes.


-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    Why isn't there mouse-flavored cat food?


0
Reply fungus 1/27/2004 2:05:23 PM

"fungus" <openglMY@SOCKSartlum.com> wrote in message
news:DeuRb.2948797$uj6.7553812@telenews.teleline.es...
> Allan Bruce wrote:
> >
> >>If you're not sending the image data in the display
> >>list (ie. glTexImage() or equivalent) then you're ok.
> >
> >
> > I am calling glTexImage2D() during compiling the display list.
> >
>
> Slow - it will be done every time you use the list.
>
> > so, I can use glBindTexture() to select a texture, and set
>  > all the params, glTex* etc.
>
> glTexParameter() - yes.
>
> > I can do this for all of my textures, then when I need to display one,
do I
> > just use glBindTexture() again?
> >
> >
> Yes.
>
>

Something isnt quite working, can you have a quick look to see if I`m doing
it right?

Making the texture:

glBindTexture(GL_TEXTURE_2D, mTexID[0]);
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_BLEND);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexImage2D(GL_TEXTURE_2D, ...)

then I do something simlar for:
glBindTexture(GL_TEXTURE_2D, mTexID[1]);
glActiveTextureARB(GL_TEXTURE1_ARB);


then, when I try to use this texture on an object I am trying this:

glBindTexture(GL_TEXTURE_2D, mTexID[0]);
glBindTexture(GL_TEXTURE_2D, mTexID[1]);
gluSphere(...);

I dont get any texture at all.  Where am I going wrong?
Thanks
Allan


0
Reply Allan 1/27/2004 3:15:22 PM

Allan Bruce schrieb:
> Something isnt quite working, can you have a quick look to see if I`m doing
> it right?
> 
> Making the texture:
> 
> glBindTexture(GL_TEXTURE_2D, mTexID[0]);
> glActiveTextureARB(GL_TEXTURE0_ARB);

Try putting "glActiveTextureARB" before "glBindTexture". Where is 
"glGenTextures"?

> then, when I try to use this texture on an object I am trying this:
> glBindTexture(GL_TEXTURE_2D, mTexID[0]);
> glBindTexture(GL_TEXTURE_2D, mTexID[1]);
> gluSphere(...);

Try using:
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mTexID[0]);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mTexID[1]);
gluSphere(...);

Ingo

0
Reply Ingo 1/27/2004 3:28:47 PM

"Ingo Schulz" <i.f.schulz@web.de> wrote in message
news:401683AF.1080003@web.de...
> Allan Bruce schrieb:
> > Something isnt quite working, can you have a quick look to see if I`m
doing
> > it right?
> >
> > Making the texture:
> >
> > glBindTexture(GL_TEXTURE_2D, mTexID[0]);
> > glActiveTextureARB(GL_TEXTURE0_ARB);
>
> Try putting "glActiveTextureARB" before "glBindTexture". Where is
> "glGenTextures"?
>
> > then, when I try to use this texture on an object I am trying this:
> > glBindTexture(GL_TEXTURE_2D, mTexID[0]);
> > glBindTexture(GL_TEXTURE_2D, mTexID[1]);
> > gluSphere(...);
>
> Try using:
> glActiveTextureARB(GL_TEXTURE0_ARB);
> glEnable(GL_TEXTURE_2D);
> glBindTexture(GL_TEXTURE_2D, mTexID[0]);
> glActiveTextureARB(GL_TEXTURE1_ARB);
> glEnable(GL_TEXTURE_2D);
> glBindTexture(GL_TEXTURE_2D, mTexID[1]);
> gluSphere(...);
>
> Ingo
>

Perfect, thats working and MUCH faster than before.
Thanks Ingo, and especially to fungus - I owe you a virtual pint!
Allan


0
Reply Allan 1/27/2004 3:32:40 PM

13 Replies
85 Views

(page loaded in 0.072 seconds)


Reply: