GL_TEXTURE_RECTANGLE_ARB vs GL_TEXTURE_2D

Hi Zach & Theo,

I’m using gluSphere for texturing a sphere but since v0.04 I’ve got problems with the textures. I think it’s because of the GLEE_ARB_texture_rectangle check in ofTexture.cpp which makes the textureTarget = GL_TEXTURE_RECTANGLE_ARB instead of GL_TEXTURE_2D. The texture width and height are not between 0…1 anymore but have the real dimensions of the texture. When I create my own sphere routine and use the real texture dimensions in glTexCoord2f things go fine.

Is there an other solution I can use? For example, force the system to use GL_TEXTURE_2D? Of is there a way to pass the real texture dimensions to the glu function?

Thanks
Rick

ah!! ok that’s an interesting problem - it’s actually one that comes up too with GLSL, since you need to know what kind of texture you have as well in order for the glsl code to work (And even, likely, avoid the ARB extension, just like you are). I will take a look at some user control.

an option now might be to extend ofTexture, and add your own constructor:

  
  
class myNonArbTexture : public ofTexture {  
  
}  
  

and in myNonArbTexture, rewrite the constructor:

  
  
myNonArbTexture::myNonArbTexture(){  
	textureName[0] = 0;  
	bFlipTexture = false;  
	textureTarget = GL_TEXTURE_2D;  
  
	//if (GLEE_ARB_texture_rectangle){  
	//	textureTarget = GL_TEXTURE_RECTANGLE_ARB;  
	//} else {  
	//	textureTarget = GL_TEXTURE_2D;  
	//}  
}  
  

then you myNonArbTexture should have access to all the other fucntions (draw, loadData, etc) and not use ARB at all…

another option, might work is this hack:

// in the h file:
ofTexture blah;

blah = new ofTexture(); /// here we might have ARB
blah.textureTarget = GL_TEXTURE_2D; // no more ARB :slight_smile:

I think you will have to make the variable textureTarget public… it’s not the nicest thing (the extending the class above is nicer) but it’s a simple hack and should work.

hope the helps!!
zach

Thanks, I’ll try that and let you know.