multi-texturing without FBO

in 007 I can do multitexturing with an FBO, but not without and figured I’d toss this up here to see what advice someone might have for me:

My draw code is dead simple:

  
  
  
void setup() {  
glossImg.loadImage("texturing.png");  
cubeshader.setup("simple.vs", "simple.fs");  
}  
  
void draw() {  
glActiveTexture(GL_TEXTURE0);  
	unsigned int texId1 = permImg.getTextureReference().getTextureData().textureID;  
	unsigned int texTarget1 = permImg.getTextureReference().getTextureData().textureTarget;    
	glBindTexture(texTarget1, texId1);  
	  
	cubeshader.begin();  
	cubeshader.setUniform1f("tex", 0);  
	ofSphere(20, 40, -10, 40);  
	cubeshader.end();  
	cam.end();  
}  
  

as is my shader

  
  
// vert  
void main() {  
   gl_Position = ftransform();  
   gl_TexCoord[0] = gl_MultiTexCoord0;  
}  
  
// frag  
uniform sampler2DRect tex;  
  
void main(void) {    
   gl_FragColor = texture2DRect(tex, gl_TexCoord[0].xy);  
}  

Anyone have any ideas? This is the simplest thing, but I cannot get it to work in OF. In ShaderBuilder it’s a cinch. Super frustrating.

My guess would be that sampler2DRect is causing problems. When using texture rectangle in OpenGL texture coords are expected to be [0…ImgWidth, 0…ImgHeight]. When you say “it works with FBO” I assume you draw fullscreen quad somewhere and it probably has texcoords in screen coordinates while ofSphere has them [0…1, 0…1]. Have you tried using sampler2D insted?

I’ll give using non-ARB a try. By default OF uses RECTANGLE_ARB instead of TEXTURE_2D, which is cool for non-power-of-two textures, but seems to introduce some weirdness in other places, hence the sampler2DRect. sampler2D is for non-ARB, i.e. 512x512, which I’m actually using anyways, but I dunno.

So, with non-ARB, this works fine. Ie

  
  
void setup() {  
ofDisableARB();  
glossImg.loadImage("texturing.png");  
cubeshader.setup("simple.vs", "simple.fs");  
}  
  
void draw() {  
glActiveTexture(GL_TEXTURE0);  
   unsigned int texId1 = permImg.getTextureReference().getTextureData().textureID;  
   unsigned int texTarget1 = permImg.getTextureReference().getTextureData().textureTarget;    
   glBindTexture(texTarget1, texId1);  
     
   cubeshader.begin();  
   cubeshader.setUniform1f("tex", 0);  
   //ofSphere(20, 40, -10, 40); // no spheres?  
   ofBox(100, 100, 1, 100);  
   cubeshader.end();  
   cam.end();  
}  
  

I’m not sure why the rects don’t work though :confused: It’s strange b/c I can make a cube map using ARB textures and use those in my shaders just fine.