Page 1 of 1

FFGL - custom shader need to gl_enable(GL_TEXTURE_2D)

Posted: Tue Jan 11, 2011 17:15
by Rene
Hi,

I have a plugin with custom shaders. I thought I don't have to gl_enable the texture when I use custom shaders. As I had problems with a plugin (black output) I tried to add gl_enable(GL_TEXTURE_2D) and now it works :? Is there an OpenGL expert who can explain that, please?

Re: FFGL - custom shader need to gl_enable(GL_TEXTURE_2D)

Posted: Wed Jan 12, 2011 12:25
by Joris
Hmmm. That's the normal way to enable texturing, so it makes sense there'd be black output without it. Is there any particular reason you thought it wasn't necessary?

Re: FFGL - custom shader need to gl_enable(GL_TEXTURE_2D)

Posted: Wed Jan 12, 2011 12:35
by Rene
Hi Joris,
thanks for your answer!!

Yepp, there is. In the example code of the FFGL SDK (FFGLTile.cpp - line 121) says

Code: Select all

//activate rendering with the input texture
 //note that when using shaders, no glEnable(Texture.Target) is required
 glBindTexture(GL_TEXTURE_2D, Texture.Handle);
and also this example does not use the glEnable command :?:

Re: FFGL - custom shader need to gl_enable(GL_TEXTURE_2D)

Posted: Wed Jan 12, 2011 12:47
by Joris
....


Ehm...


Yeah...


That's just.... weird....

Re: FFGL - custom shader need to gl_enable(GL_TEXTURE_2D)

Posted: Wed Jan 12, 2011 12:49
by drand48
I usually call glEnable( GL_TEXTURE_2D ) also when using shaders...
but it seems like it is really not necessary, found this link maybe it can be useful
http://www.opengl.org/wiki/GLSL_:_common_mistakes
perhaps you are not calling glEnable before creating the texture?

Re: FFGL - custom shader need to gl_enable(GL_TEXTURE_2D)

Posted: Wed Jan 12, 2011 13:47
by Rene
drand48 wrote:I usually call glEnable( GL_TEXTURE_2D ) also when using shaders...
From now on, me too ;)
drand48 wrote:perhaps you are not calling glEnable before creating the texture?
What do you mean here? - Before binding the input texture coming from the host application, or before calling glCopyTexSubImage2D?

Re: FFGL - custom shader need to gl_enable(GL_TEXTURE_2D)

Posted: Wed Jan 12, 2011 15:21
by drand48
just once before you do any calls related to a 2d texture.
so in the case of glCopyTexSubImage2D you would do something like

Code: Select all

glEnable(GL_TEXTURE2D);
glBindTexture(GL_TEXTURE_2D, Texture.Handle);
glCopyTexSubImage( ... )