Hard Light Productions Forums
Off-Topic Discussion => General Discussion => Topic started by: Aardwolf on May 10, 2008, 09:31:22 pm
-
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.
-
If a function designed to check for errors is returning 0, isn't that a good thing? :doubt:
-
I thought so, but no, apparently there is some non-zero error code that it should return.
-
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?
-
Google got me this:
#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
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.
-
According to that, if it returns 0, it'll fail on everything no matter what.
-
It looks like GL_FRAMEBUFFER_COMPLETE_EXT is a success. At least according to what those code bits say.
-
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).
-
If your getting 0 it means your doing something else wrong.
-
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.
-
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)
-
what is your video card