Author Topic: OpenGL Framebuffer Objects?  (Read 3348 times)

0 Members and 1 Guest are viewing this topic.

Offline Aardwolf

  • 211
  • Posts: 16,384
OpenGL Framebuffer Objects?
So I was trying to figure out how to do render-to-texture in OpenGL. Apparently, the best way is using something called a frame buffer object. I followed instructions in a tutorial only to find that some function designed to check for errors was returning 0. I looked up zero in the table of error codes... but it wasn't there.

In summary,
Does anybody have a clue how to test if FBO's will work on a machine?
Does anybody know what a return value of 0 from glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) means?

And NO,
glCopyTexImage2D will not suffice, it is too slow, as is glReadPixels or whatever the similar function is.

 

Offline blackhole

  • Still not over the rainbow
  • 29
  • Destiny can suck it
    • Black Sphere Studios
Re: OpenGL Framebuffer Objects?
If a function designed to check for errors is returning 0, isn't that a good thing? :doubt:

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: OpenGL Framebuffer Objects?
I thought so, but no, apparently there is some non-zero error code that it should return.

 

Offline blackhole

  • Still not over the rainbow
  • 29
  • Destiny can suck it
    • Black Sphere Studios
Re: OpenGL Framebuffer Objects?
What I want to know is why you actually looked for 0 on an error code table :P

In directX, you use DeviceCaps to figure things like this out. Shouldn't openGL have its own equivelent?

 
Re: OpenGL Framebuffer Objects?
Google got me this:

Code: [Select]
  #define CHECK_FRAMEBUFFER_STATUS()                            \
      {                                                           \
        GLenum status;                                            \
        status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); \
        switch(status) {                                          \
          case GL_FRAMEBUFFER_COMPLETE_EXT:                       \
            break;                                                \
          case GL_FRAMEBUFFER_UNSUPPORTED_EXT:                    \
            /* choose different formats */                        \
            break;                                                \
          default:                                                \
            /* programming error; will fail on all hardware */    \
            assert(0);                                            \
        }
      }

and

Code: [Select]
if (renderToTextureEXT)
{
// create a backbuffer and texture
RTT.gl.glGenFramebuffersEXT(1, &RTT.gl.fb);
RTT.gl.glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, RTT.gl.fb);
RTT.gl.glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, RTT.texture, 0);

GLenum status = RTT.gl.glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status!=GL_FRAMEBUFFER_COMPLETE_EXT) {
renderToTextureEXT= false; // Something went wrong with the FBO approach, default to PBuffer
// if you got GL_FRAMEBUFFER_UNSUPPORTED_EXT then you probably need to choose a different format for glTexImage2D
}
// point it back to normal screen drawing mode
RTT.gl.glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

Couldn't find any real list of valid responses, sorry.
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline blackhole

  • Still not over the rainbow
  • 29
  • Destiny can suck it
    • Black Sphere Studios
Re: OpenGL Framebuffer Objects?
According to that, if it returns 0, it'll fail on everything no matter what.

  
Re: OpenGL Framebuffer Objects?
It looks like GL_FRAMEBUFFER_COMPLETE_EXT is a success.  At least according to what those code bits say.
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: OpenGL Framebuffer Objects?
Yes, but that's not equal to zero, which is what I'm getting. And when I try to continue running the program, the texture shows up as the default texture (that is, the color white).

 

Offline blackhole

  • Still not over the rainbow
  • 29
  • Destiny can suck it
    • Black Sphere Studios
Re: OpenGL Framebuffer Objects?
If your getting 0 it means your doing something else wrong.

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: OpenGL Framebuffer Objects?
Yeah but what? Anyway, I've removed the offending stuff from my program, and am waiting for the coder I plan to work with on my next project to respond to my email.

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: OpenGL Framebuffer Objects?
This could be a problem. There should be in this list of the extensions I have available, with my just-updated-today graphics drivers, something like frame_buffer_object or frame or framebuffer, but there isn't.

GL Extensions:
GL_ARB_depth_texture
GL_ARB_fragment_program
GL_ARB_multitexture
GL_ARB_point_parameters
GL_ARB_shadow
GL_ARB_texture_border_clamp
GL_ARB_texture_compression
GL_ARB_texture_cube_map
GL_ARB_texture_env_add
GL_ARB_texture_env_combine
GL_ARB_texture_env_dot3
GL_ARB_texture_env_crossbar
GL_ARB_transpose_matrix
GL_ARB_vertex_buffer_object
GL_ARB_vertex_program
GL_ARB_window_pos
GL_EXT_abgr
GL_EXT_bgra
GL_EXT_blend_color
GL_EXT_blend_func_separate
GL_EXT_blend_minmax
GL_EXT_blend_subtract
GL_EXT_clip_volume_hint
GL_EXT_compiled_vertex_array
GL_EXT_cull_vertex
GL_EXT_draw_range_elements
GL_EXT_fog_coord
GL_EXT_multi_draw_arrays
GL_EXT_packed_pixels
GL_EXT_rescale_normal
GL_EXT_secondary_color
GL_EXT_separate_specular_color
GL_EXT_shadow_funcs
GL_EXT_stencil_two_side
GL_EXT_stencil_wrap
GL_EXT_texture_compression_s3tc
GL_EXT_texture_env_add
GL_EXT_texture_env_combine
GL_EXT_texture_lod_bias
GL_EXT_texture_filter_anisotropic
GL_EXT_texture3D
GL_3DFX_texture_compression_FXT1
GL_IBM_texture_mirrored_repeat
GL_NV_blend_square
GL_NV_texgen_reflection
GL_SGIS_generate_mipmap
GL_SGIS_texture_edge_clamp
GL_SGIS_texture_lod
GL_WIN_swap_hint

GLU Extensions:
(null)

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Re: OpenGL Framebuffer Objects?
what is your video card
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir