Jump to content

  • Log In with Google      Sign In   
  • Create Account

Weton

Member Since 27 Mar 2013
Offline Last Active Aug 15 2014 12:21 PM

Topics I've Started

Cannot Clear/Draw to Framebuffer

12 August 2014 - 02:43 PM

Hi,

 

I'm trying to clear/draw to a framebuffer but I don't get the expected result. Instead of the clear color/expected object the framebuffer stays black with some white pixels. After running the application multiple times the white pixel pattern changes slightly (=> due to uninitialized memory?).

glGetError returns NO_ERROR and glCheckFramebufferStatus returns FRAMEBUFFER_COMPLETE.

Does anybody know what's going wrong?

 

This is the content of the framebuffer taken from apitrace after the glClear

Color0:

Attached File  Color0.png   20.35KB   1 downloads

Depth:

Attached File  Depth.png   22.1KB   1 downloads

Stencil:

Attached File  Stencil.png   51.77KB   1 downloads

 

This are the opengl calls duped by apitrace

glGenVertexArrays(n = 1, arrays = &1)
glGenFramebuffers(n = 1, framebuffers = &1)
glGenTextures(n = 1, textures = &1)
glBindTexture(target = GL_TEXTURE_2D, texture = 1)
glTexStorage2D(target = GL_TEXTURE_2D, levels = 1, internalformat = GL_RGBA16F, width = 640, height = 480)
glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_BASE_LEVEL, param = 0)
glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_MAX_LEVEL, param = 1)
glGenTextures(n = 1, textures = &2)
glBindTexture(target = GL_TEXTURE_2D, texture = 2)
glTexStorage2D(target = GL_TEXTURE_2D, levels = 1, internalformat = GL_RGBA16F, width = 640, height = 480)
glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_BASE_LEVEL, param = 0)
glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_MAX_LEVEL, param = 1)
glGenTextures(n = 1, textures = &3)
glBindTexture(target = GL_TEXTURE_2D, texture = 3)
glTexStorage2D(target = GL_TEXTURE_2D, levels = 1, internalformat = GL_DEPTH24_STENCIL8, width = 640, height = 480)
glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_BASE_LEVEL, param = 0)
glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_MAX_LEVEL, param = 1)
glGenTextures(n = 1, textures = &4)
glBindTexture(target = GL_TEXTURE_2D, texture = 4)
glTexStorage2D(target = GL_TEXTURE_2D, levels = 1, internalformat = GL_DEPTH24_STENCIL8, width = 640, height = 480)
glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_BASE_LEVEL, param = 0)
glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_MAX_LEVEL, param = 1)
//compiling shders genBuffers... no framebuffer operations
glViewport(x = 0, y = 0, width = 640, height = 480)
glBindFramebuffer(target = GL_DRAW_FRAMEBUFFER, framebuffer = 1)
glFramebufferTexture(target = GL_DRAW_FRAMEBUFFER, attachment = GL_COLOR_ATTACHMENT0, texture = 1, level = 0)
glFramebufferTexture(target = GL_DRAW_FRAMEBUFFER, attachment = GL_COLOR_ATTACHMENT1, texture = 2, level = 0)
glFramebufferTexture(target = GL_DRAW_FRAMEBUFFER, attachment = GL_DEPTH_STENCIL_ATTACHMENT, texture = 3, level = 0)
glClearColor(red = 0.3, green = 0.3, blue = 0.3, alpha = 1)
glDepthMask(flag = GL_TRUE)
glClearDepth(depth = 1)
glClear(mask = GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)

Thank you for your help!


PARTNERS