I use 7600GT. But if i draw it on screen it works ok…why it wouldnt work if it was drawn on fbo? The code is:
Fragment shader (i deleted most of the stuff and just left it to return the texture5, i checked and the problem again is there)
uniform sampler2D tex;
uniform sampler2D tex2;
uniform sampler2D tex3;
uniform sampler2D tex4;
uniform sampler2D tex5;
uniform float Threshold;
uniform float WashInStart;
uniform float WashInPoints;
varying vec2 TexCoord;
void main(void)
{
float dectimeStart=0.0180;
float dectime=0.0120;
vec3 A = (0.1,0.0,0.0);
float enchant=0.0;
float mVal=0.0;
float LocalWashInStart=0.0;
float Delay=0.0;
float EarlyStart=0.0;
float EarlyFinish=0.0;
float EarlyEnchancementAvg=0.0;
vec3 textureColor1 =texture2D(tex, TexCoord).rgb;
vec3 textureColor2 = texture2D(tex2,TexCoord).rgb;
vec3 textureColor3 = texture2D(tex3,TexCoord).rgb;
vec3 textureColor4 = texture2D(tex4,TexCoord).rgb;
vec3 textureColor5 = texture2D(tex5,TexCoord).rgb;
float tmp=textureColor5.r;
gl_FragColor = vec4 (tmp,0.0,0.0,1.0);
}
The code for FBO is:
(This works for every texture except 5 :()
// Set up the viewport for 1:1 pixel to texel mapping
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, size , 0.0, size);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, size, size);
//FBO creation
GLuint fbo;
glGenFramebuffersEXT(1, &fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
checkGLErrors("FBO creation or Binding");
checkFramebufferStatus();
//Setup output texture
GLuint img;
glGenTextures(1, &img);
glBindTexture(GL_TEXTURE_2D, img);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F_ARB, size, size, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,size,size,GL_RED,GL_FLOAT,data);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, img, 0);
checkFramebufferStatus();
checkGLErrors("Output Texture Creation");
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
checkGLErrors("Frame Buffer binding");
checkFramebufferStatus();
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glPolygonMode(GL_FRONT, GL_FILL);
glBegin( GL_QUADS );
glTexCoord2f(0.0, 1.0);
glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 1.0);
glVertex2f(size, 0.0);
glTexCoord2f(1.0, 0.0);
glVertex2f(size, size);
glTexCoord2f(0.0, 0.0);
glVertex2f(0.0, size);
glEnd();
checkFramebufferStatus();
checkGLErrors("Render to FBO");
//Reading values from frameBuffer to array with flaots
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, size, size,GL_RED,GL_FLOAT,pixels);
writeFile("Output1.dat",data,size);
printVector(data,1024*1024);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
checkGLErrors("Frame Buffer unbinding");
glDeleteTextures(1,&img);
glActiveTexture(GL_TEXTURE0);
glBindTexture( GL_TEXTURE_2D, texture1 );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,size,0.0,size);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0,0,size,size);
glTranslatef(0.0,0.0,-24); // We move the object 24 points forward to fill the window
glBegin( GL_QUADS );
{
glTexCoord2f(0.0, 0.0);
glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 0.0);
glVertex2f(size, 0.0);
glTexCoord2f(1.0, 1.0);
glVertex2f(size, size);
glTexCoord2f(0.0, 1.0);
glVertex2f(0.0, size);
}
glEnd();
glDeleteFramebuffersEXT(1, &fbo);
free(data);
glUseProgram(0);
checkGLErrors("Render on Screen");
exit(1);
You see something that may lead to this? I now that the code may have a lot of problems but i am new to this.