Hello,
I am new to this forum. I just started using OpenGL extensions about 3 months ago.
I am trying to render to both a color and a depth texture(GL_TEXTURE_RECTANGLE_ARB) that are attached to an FBO. I am using Cg shaders to do per-vertex and per-fragment operations. After I render I use those textures again in a different render (using a different Cg shader), but it’s either not rendering to the texture the first time, or the second shader is not capturing the values. Howerver, when I use a query to check how many fragments made it to the frame buffer the first time, and it returns many fragments, so i don’t know if and why the texture is not capturing the values.
I need to berify which exact card Im using at the lab ( it’s something like Ge Force 79… something), but i’ll post it up when i have the info.
Here’s where i initialize the FBO and textures:
glGenTextures(2, g_dirLayerDepthTexId);
glGenTextures(2, g_dirLayerColorTexId);
glGenFramebuffersEXT(2, g_depthPeelingFboId);
for (int i = 0; i < 2; i++)
{
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, g_dirLayerDepthTexId[i]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_DEPTH_COMPONENT24_ARB,
sampling.g_imageWidth, sampling.g_imageHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, g_dirLayerColorTexId[i]);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, sampling.g_imageWidth, sampling.g_imageHeight,
0, GL_RGBA, GL_FLOAT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_depthPeelingFboId[i]);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_RECTANGLE_ARB, g_dirLayerDepthTexId[i], 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_RECTANGLE_ARB, g_dirLayerColorTexId[i], 0);
}
Here’s where I bind and try to render to the first FBO
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_depthPeelingFboId[currLayer]);
glDrawBuffer(g_drawBuffers[0]);
glMatrixMode(GL_PROJECTION);
glViewport(0, 0, sampling.g_imageWidth, sampling.g_imageHeight);
glMatrixMode(GL_MODELVIEW);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glBeginQuery(GL_SAMPLES_PASSED_ARB, g_peelingQuery);
//LAYER RENDER
cgGLBindProgram(cgVProgram_DirPeel); checkForCgError("Binding DirPeel Vertex Shader");
cgGLBindProgram(cgFProgram_DirPeel); checkForCgError("Binding DirPeel Fragment Shader");
cgSetMatrixParameterfr ( cgVParam_DirPeel_dirViewProjMat, dirView.viewProjMat ); checkForCgError("Setting DirPeel Vertex Shader Param 'dirViewProjMat'");
cgSetMatrixParameterfr ( cgVParam_DirPeel_dirTextCoordMat, dirTextCoordMat ); checkForCgError("Setting DirPeel Vertex Shader Param 'dirTextCoordMat'");
cgSetParameter3fv ( cgFParam_DirPeel_lNormal, lights[0]->normals+3 ); checkForCgError("Setting DirPeel Fragment Shader Param 'lNormal'");
cgSetParameter3fv ( cgFParam_DirPeel_gAmbient, lights[0]->materials[1].ambient ); checkForCgError("Setting DirPeel Fragment Shader Param 'gAmbient'");
cgSetParameter3fv ( cgFParam_DirPeel_Id, lights[0]->materials[1].diffuse ); checkForCgError("Setting DirPeel Fragment Shader Param 'Id'");
cgSetParameter3fv ( cgFParam_DirPeel_Is, lights[0]->materials[1].specular ); checkForCgError("Setting DirPeel Fragment Shader Param 'Is'");
cgSetParameter3fv ( cgFParam_DirPeel_objSpaceLPos, lights[0]->position ); checkForCgError("Setting DirPeel Fragment Shader Param 'objSpaceLPos'");
cgSetParameter3fv ( cgFParam_DirPeel_objSpaceEPos, dirView.eye ); checkForCgError("Setting DirPeel Fragment Shader Param 'objSpaceEPos'");
cgGLSetTextureParameter( cgFParam_DirPeel_pervDepthLayer, g_dirLayerDepthTexId[prevLayer] ); checkForCgError("Setting DirPeel Fragment Shader Param 'pervDepthLayer'");
lightPass = 2;
DrawScene();
cgGLUnbindProgram(cgVProfile); checkForCgError("Binding DirPeel Vertex Shader");
cgGLUnbindProgram(cgFProfile); checkForCgError("Binding DirPeel Fragment Shader");
Any suggestions?