using textured and non-textured faces

  • Follow


Hello

I am an OpenGL beginner, and I'm trying to use both textured and
non-textured faces in the same scene. Is that possible ?
I took the following code from a tutorial (www.gametutorials.com) that draw
a textured square.
I'd like to draw another square right after this one but using no texture
(only a color set by glColor())
I trying to simply put glColor() followed by vertex creation but I had no
visible square on the screen.
How can I acheive that ?

Thank you in advance for you help.

// Bind the texture stored at the zero index of g_Texture[]
glBindTexture(GL_TEXTURE_2D, g_Texture[0]);

// Display a quad texture to the screen
glBegin(GL_QUADS);

// Display the top left vertice
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1, 1, 0);

// Display the bottom left vertice
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-1, -1, 0);

// Display the bottom right vertice
glTexCoord2f(1.0f, 1.0f);
glVertex3f(1, -1, 0);

// Display the top right vertice
glTexCoord2f(1.0f, 0.0f);
glVertex3f(1, 1, 0);

// What if I wanna draw a non-textured QUAD here ?

glEnd();


0
Reply Stab 10/28/2004 4:48:25 PM

Stab wrote:
> Hello
> 
> I am an OpenGL beginner, and I'm trying to use both textured and
> non-textured faces in the same scene. Is that possible ?

Of course.

> // What if I wanna draw a non-textured QUAD here ?
> 

glEnd();
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);


-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    The Cheat is not dead!


0
Reply fungus 10/28/2004 5:12:03 PM


"Stab" <stabrico@yahoo.fr> wrote in message
news:41812283$0$13810$636a15ce@news.free.fr...

snip

> // What if I wanna draw a non-textured QUAD here ?
>
> glEnd();
>

Either glDisable(GL_TEXTURE_2D) or glBind to texture id 0 (the default)
before you draw your next quad.

Roger


0
Reply Roger 10/28/2004 5:33:37 PM

Roger Rowland wrote:

> Either glDisable(GL_TEXTURE_2D) or glBind to texture id 0 (the default)
> before you draw your next quad.

Of course, you might have a texture bound to texture ID 0. :-)

--
Andy V

0
Reply Andy 10/30/2004 11:20:43 PM

"Andy V" <noone@nowhere.togo> wrote in message
news:flVgd.704$Zx3.28379@petpeeve.ziplink.net...
> Roger Rowland wrote:
>
> > Either glDisable(GL_TEXTURE_2D) or glBind to texture id 0 (the default)
> > before you draw your next quad.
>
> Of course, you might have a texture bound to texture ID 0. :-)
>
> --
> Andy V
>

True :-)

But if not (who would do such a thing?!), is it not preferable to do that
rather than turning texturing on and off?

(I'm sure someone will correct me if I'm wrong, but it would be nice to have
confirmation if I'm not!)

Rog


0
Reply Roger 11/1/2004 12:58:19 PM

Roger Rowland wrote:
 > >> glBind to texture id 0
 >
 > is it not preferable to do that
 > rather than turning texturing on and off?
 >

Are you asking "Is it better to use another
function to turn texture off rather than
the function designed to turn it off?"



-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    The Cheat is not dead!


0
Reply fungus 11/1/2004 2:13:43 PM

Thank you, it works :)
In fact I tried this but it wouldn't work because I did it in the same
glBegin / glEnd block.

"Roger Rowland" <see.sig@bottomof.message> a �crit dans le message de news:
1099313903.85278.0@despina.uk.clara.net...
> "Andy V" <noone@nowhere.togo> wrote in message
> news:flVgd.704$Zx3.28379@petpeeve.ziplink.net...
> > Roger Rowland wrote:
> >
> > > Either glDisable(GL_TEXTURE_2D) or glBind to texture id 0 (the
default)
> > > before you draw your next quad.
> >
> > Of course, you might have a texture bound to texture ID 0. :-)
> >
> > --
> > Andy V
> >
>
> True :-)
>
> But if not (who would do such a thing?!), is it not preferable to do that
> rather than turning texturing on and off?
>
> (I'm sure someone will correct me if I'm wrong, but it would be nice to
have
> confirmation if I'm not!)
>
> Rog
>
>


0
Reply Stab 11/1/2004 2:16:49 PM

"fungus" <openglMY@SOCKSartlum.com> wrote in message
news:swrhd.1465$f85.188@news.ono.com...
> Roger Rowland wrote:
>  > >> glBind to texture id 0
>  >
>  > is it not preferable to do that
>  > rather than turning texturing on and off?
>  >
>
> Are you asking "Is it better to use another
> function to turn texture off rather than
> the function designed to turn it off?"
>

Not really.

I was asking, is it better performance-wise to bind to texture 0 (with no
texture loaded) rather than glDisable(GL_TEXTURE_2D)? Would there be any
difference in the end result (visually), and would the former involve (I'm
guessing) no state change in the pipeline and (I'm still guessing) better
performance?

I suppose I could try it, but if you know anything in theory, I'd be
interested in your comments.

Roger


0
Reply Roger 11/1/2004 4:22:46 PM

> 
> Not really.
> 
> I was asking, is it better performance-wise to bind to texture 0 (with no
> texture loaded) rather than glDisable(GL_TEXTURE_2D)? Would there be any
> difference in the end result (visually), and would the former involve (I'm
> guessing) no state change in the pipeline and (I'm still guessing) better
> performance?
> 
> I suppose I could try it, but if you know anything in theory, I'd be
> interested in your comments.
> 
> Roger
> 
> 

If there's a speed differerence, glDisable should be faster:
The drivers should be optimized for binding existing textures,
since this is the normal case. Binding a new texture involves more
changes (texture image size, number of mipmaps, lod bias, etc) than just
disabling texturing. It could be that drivers do some calculations
for that stuff before checking if texture 0 is a valid texture.

Philipp
0
Reply Philipp 11/1/2004 5:37:25 PM

Roger Rowland wrote:
> 
> I suppose I could try it, but if you know anything
> in theory, I'd be interested in your comments.
> 

I know that all documentation says that glBindTexture
is usually the most expensive OpenGL operation of all.



-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    The Cheat is not dead!


0
Reply fungus 11/1/2004 5:51:28 PM

9 Replies
122 Views

(page loaded in 0.713 seconds)

Similiar Articles:













7/17/2012 9:15:41 AM


Reply: