PDA

View Full Version : unable to load GL_RGBA16F in opengl



satya jeetu
07-20-2017, 12:31 PM
Please help!
my Frame buffer:


unsigned int hdrFBO;
glGenFramebuffers(1, &hdrFBO);
// create floating point color buffer
unsigned int colorBuffer;
glGenTextures(1, &colorBuffer);
glBindTexture(GL_TEXTURE_2D, colorBuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, SCREEN_WIDTH, SCREEN_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// create depth buffer (renderbuffer)
unsigned int rboDepth;
glGenRenderbuffers(1, &rboDepth);
glBindRenderbuffer(GL_RENDERBUFFER, rboDepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, SCREEN_WIDTH, SCREEN_HEIGHT);
// attach buffers
glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBuffer, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
std::cout << "Framebuffer not complete!" << std::endl;
glBindFramebuffer(GL_FRAMEBUFFER, 0);


my Code in the Loop:


`glm::mat4 view = camera.GetViewMatrix();

shader.Use();
glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

GLint texLoc = glGetUniformLocation(shader.Program, "diffuseTexture");
glUniform1i(texLoc, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, diffuseMap);



GLint modelLoc = glGetUniformLocation(shader.Program, "model");
GLint viewLoc = glGetUniformLocation(shader.Program, "view");
GLint projLoc = glGetUniformLocation(shader.Program, "projection");

glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));
glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection));

GLint viewPosLoc = glGetUniformLocation(shader.Program, "viewPos");

glUniform3f(viewPosLoc, camera.GetPosition().x, camera.GetPosition().y, camera.GetPosition().z);

glm::mat4 model = glm::mat4();
model = glm::translate(model, glm::vec3(0.0f, 0.0f, 25.0));
model = glm::scale(model, glm::vec3(2.5f, 2.5f, 27.5f));
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));

renderCube();
glBindFramebuffer(GL_FRAMEBUFFER, 0);







glBindTexture(GL_TEXTURE_2D, 0);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
hdrShader.Use();

GLint texLoc1 = glGetUniformLocation(hdrShader.Program, "hdrBuffer");
glUniform1i(texLoc1, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, colorBuffer);

renderQuad();

Silence
07-20-2017, 12:59 PM
First of all, your code does not look bad, at least for the FBO creation, which I focused on.
What is your clear color ?
Is your FBO valid ? You have the code to check, but the story does not tell anything about it.
Any other OpenGL error maybe ?
Also try to remove your depth RBO and replace it with a depth texture.

Dark Photon
07-20-2017, 05:37 PM
To maximize your chance of getting help, you should tell us:

1) What is the problem, and what evidence do you have of it?
2) What have you done to try and diagnose the root cause?
3) What's your question?

Also useful:

4) What GPU and OpenGL drivers do you have installed?

Have you tried Checking for GL errors (https://www.khronos.org/opengl/wiki/OpenGL_Error)?

(Also, don't cross-post. I've deleted your other duplicate posts on these forums.)