GL_REPEAT with ofFbo


im trying to port a video feedback sketch to openFrameworks. the setup is very simple, 2 FBO’s drawing into each other, one also draws to the screen. there is a third shader which is used to seed the system with noise.

(note that i’m using the programmable pipeline renderer, i have no desire to spend any time with the ancient openGL versions, also my existing glsl code is written for the newer style of openGL.)

the problem i’m running into is that i need the textures being bound to the FBOs to be in GL_REPEAT wrap mode. i get an openGL error (invalid enumerant) when I try to set this mode on any texture, unless I add a call to ofDisableArbTex() however, adding this call unfortunately breaks the texture sampling in my shaders (i did notice that ofDisableArbTex causes normalized texture coordinates to be used, and adjusted for it.) I can get a gradient across the screen but I can’t sample from textures! I tried changing sampler2DRect to sampler2D also.

im totally lost on this and i’ve probably spent more time trying to figure it out than it would take to write the code from scratch. any help would be greatly appreciated. i have uploaded a simple version of the project that only does noise through a blur, using FBOs:


I think ofFbo::getTexture().setTextureWrap(GL_REPEAT, GL_REPEAT); would do the job. I haven’t tested this myself though.


i’ve tried that call and the openGL call directly, both give the same error, invalid enumerant, when i remove the ofDisableArbTex call. i think it has something to do with the FBO textures being created as GL_TEXTURE_RECTANGLE unless i call ofDisableArbTex, because openGL doesnt allow setting the wrap mode to GL_REPEAT with those. however, i cant figure out why my texture sampling wont work when using GL_TEXTURE_2D (as a result of ofDisableArbTex)


yes i think you can’t use GL_REPEAT with rectangle textures. when using 2D textures you have to use normalized texture coordinates (between 0…1 instead of 0…width/height) perhaps that’s the problem?


Not sure if this is of any help but since you’re already using shaders isn’t it easier to use mod() inside the texture2D call to get a repeat effect? For example; texture2DRect(fboTexture, mod(texcoord0.xy, fboTextureSize)).


that’s a really good call. i tend to want to figure out why things dont work, and i wanted to duplicate my previous setup so that I could avoid modifying my shader code. not to hard to add this though, plus that makes it portable to webgl. thank you


i always get a black screen when i try to sample from a GL_TEXTURE_2D texture, and i know i have the right texture coordinates because im able to draw a gradient by setting the output color to the texcoords