Can’t seem to get this working. Trying to convert from GL_TEXTURE_2D. I’ve enabled it, and created all my test texture stuff, but I get only blackscreen.
I keep reading in the posts that the gurus remind us beginners to use texture coordinates, and not normalized coordinates. What exactly does that mean programatically? The shader examples I see still use glTexCoord[0].st in the texture2dRect() access funtion, which is the same as for normalized textures.
Here is my relevant SETUP CODE for this texture:
OpenGL Code:
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(1,&m_sourceTextureBlackOffset);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB,m_sourceTextureBlackOffset);
glTexParameterf(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_WRAP_T,GL_CLAMP);
glPixelStorei(GL_UNPACK_SWAP_BYTES,GL_TRUE);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,0,GL_LUMINANCE32F_ARB,m_maxTextureSize,m_maxTextureSize,0,GL_RED,GL_UNSIGNED_BYTE,m_blackBuffer);
//Fragment Shader Relevant Code (Render To FBO Texture):
#version 110
#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect BlackSampler;
float black = texture2DRect(BlackSampler, gl_TexCoord[0].st).r;
Everything seems to compile fine, just black image.
Do I have to modify my drawing code also? Presently, I use the following drawing code:
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0);
glVertex2f(-1.0,-1.0);
glTexCoord2f(1.0,0.0);
glVertex2f( 1.0,-1.0);
glTexCoord2f(1.0,1.0);
glVertex2f( 1.0, 1.0);
glTexCoord2f(0.0,1.0);
glVertex2f(-1.0, 1.0);
glEnd();
Do these need to be modified to reference texture coodinates?
what about the use of glTranslate(), glRotate() and glScale()?
Also, can I mix GL_TEXTURE_2D textures in a Fragment Shader with GL_TEXTURE_RECANGLE_ARB textures?
What about the FBO target texture?
Right now, all my textures are GL_TEXTURE_2D, and I’m just testing one rectangle source texture inside a fragment shade that uses 10 textures.
I appreciate your help.