Jump to content
  • Advertisement
Sign in to follow this  
db123

OpenGL [fixed]what reason can cause pipeline output data to depth buffer but not in color buffer?

This topic is 2061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i want to use render to texture in opengl 2.0.

so i create a very simple mesh, it is a simple wireframe.

if i am not use render to texture(FBO with texture), it works well, like this :

[attachment=20075:1.png]

 

this is the simple shader:

uniform float4   g_DrawColor;
uniform float4x4 g_mWorld;
uniform float4x4 g_mViewProj;

#ifdef GLSL_VERTEXSHADER

attribute float3 InPosition;

void VertexShaderMain()
{	
    float4 WorldPos = MulMatrix( g_mWorld, float4(InPosition,1.0) );
    gl_Position = MulMatrix( g_mViewProj, WorldPos );
}

#endif


#ifdef GLSL_PIXELSHADER

void PixelShaderMain()
{
    // gl_FragColor = float4( g_DrawColor.xyz, 1.0 );
    gl_FragColor = float4( 1.0, 0, 0, 1.0 );
}

#endif

but when i use frame buffer objects, it will not output any thing to the color buffer, but it seems that opengl output the depth info to the depth buffer( i use gdebugger to find this).

this is the screen shot:

[attachment=20076:2.png]

 

this is the color output:

[attachment=20077:3.jpg]

 

this is the api trace log:

[attachment=20078:4.png]

 

this is the context state when that draw call, i copyed from gdebugger:

GL_BLEND: FALSE
GL_BLEND_COLOR: {0, 0, 0, 0}
GL_BLEND_DST: 0
GL_BLEND_DST_ALPHA: 0
GL_BLEND_DST_RGB: 0
GL_BLEND_EQUATION: GL_FUNC_ADD
GL_BLEND_EQUATION_ALPHA: GL_FUNC_ADD
GL_BLEND_EQUATION_EXT: GL_FUNC_ADD
GL_BLEND_EQUATION_RGB: GL_FUNC_ADD
GL_BLEND_SRC: 1
GL_BLEND_SRC_ALPHA: 1
GL_BLEND_SRC_RGB: 1
GL_DEPTH_BIAS: 0
GL_DEPTH_BITS: 24
GL_DEPTH_CLAMP: FALSE
GL_DEPTH_CLEAR_VALUE: 2147482496
GL_DEPTH_FUNC: GL_LESS
GL_DEPTH_RANGE: {0, 1}
GL_DEPTH_SCALE: 1
GL_DEPTH_TEST: TRUE
GL_DEPTH_WRITEMASK: TRUE
GL_STENCIL_BACK_FAIL: GL_KEEP
GL_STENCIL_BACK_FUNC: GL_ALWAYS
GL_STENCIL_BACK_PASS_DEPTH_FAIL: GL_KEEP
GL_STENCIL_BACK_PASS_DEPTH_PASS: GL_KEEP
GL_STENCIL_BACK_REF: 0
GL_STENCIL_BACK_VALUE_MASK: -1
GL_STENCIL_BACK_WRITEMASK: -1
GL_STENCIL_BITS: 0
GL_STENCIL_CLEAR_VALUE: 0
GL_STENCIL_FAIL: GL_KEEP
GL_STENCIL_FUNC: GL_ALWAYS
GL_STENCIL_PASS_DEPTH_FAIL: GL_KEEP
GL_STENCIL_PASS_DEPTH_PASS: GL_KEEP
GL_STENCIL_REF: 0
GL_STENCIL_TEST: FALSE
GL_STENCIL_TEST_TWO_SIDE_EXT: FALSE
GL_STENCIL_VALUE_MASK: -1
GL_STENCIL_WRITEMASK: -1
GL_TEXTURE_2D: TRUE
 

i have not experience of opengl, but in directx, i think it should be blend state error, but this blend state looks like no problem.

 

so, which reason can cause this error in opengl?

 

 

wacko.png sleep.png smile.png

thank you very much~~~smile.png

 

 

-------------------------------------------------------------------------------------------------------------------------

//// 2014.2.23

it is the error of gdebugger/

 

Edited by db123

Share this post


Link to post
Share on other sites
Advertisement

is the reason i have use a rendertarget texture which is already as a shader resource?mellow.png ????

i have call glBindTexture(GL_TEXTURE_2D, 0); 

after i use that render target as a shader texture parameters.

there is nothing changed.

 

this is the code i used to create texture render target

glEnable(GL_TEXTURE_2D);
                    glGenTextures(1, &m_Resource);
                    glBindTexture(GL_TEXTURE_2D, m_Resource);
                    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
                    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
                    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

                    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_SizeX, m_SizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
                    

                    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_Resource, 0);
                    glBindTexture(GL_TEXTURE_2D, 0);
                    glDisable(GL_TEXTURE_2D);

create depth buffer:

glGenRenderbuffersEXT(1, &m_Resource);
                    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_Resource);
                    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, m_SizeX, m_SizeY);
                    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_Resource);

Share this post


Link to post
Share on other sites

i have found this error, because i set two framebuffer and clear them, but the of them is not used...

if i am not set the unused framebuffer, it works...

angry.png angry.png angry.png angry.png why????blink.png

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!