c++ - OpenGL with FBO RTT, blending when it shouldn't -


It should be really simple, but it has been consumed multi-hour of my time, and I have a clue That's not what's happening. / P>

I'm providing a flat-color full-screen tray for texture, then read the result glGetTexImage. It is related to GPGPU, so I want to behave alpha values ​​as if it is any of the other three, using an NBIDI card on MacBook Pro with a FBO, textual format GL_RGBA32F_ARB , 10.5 I am, if it matters, it matters.

If I specify alpha then I only bring the right color back to the one; With any other value it is already in the framebuffer, still I have been explicitly compromised with GL_BLEND has been disabled and I also see the glBlendFunc (GL_ONE, GL_ZERO ) , but the end result is the same I can clear the framebuffer in zero before render, which fixes it, but I have to understand why it is necessary . As a second test, rendering two overlapping quads gives a mixed result, when I just want to return the original 4-channel color, should definitely overwrite pixels in solid color quad framebuffers? I'm guessing that I have understood something fundamentally wrong. Thank you.

const size_t res = 16; Glutton Tech; Glencutters (1, End Tech); Globinated (GL_TEXTURE_2D, Tech); GlTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GlTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GlTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); GlTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); GlTexParameteri (GL_TEXTURE_2D, GL_ GENERATE_MIPMAP, GL_FALSE); GlTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, res, res, 0, GL_RGBA, GL_floyet, 0); GlobIndactations (GL_Edit DD, 0); Glutton fibers; GlGenFramebuffersEXT (1, and fbo); GlBindFramebufferEXT (GL_FRAMEBUFFER_EXT, FB); GlFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Texx, 0); GlDrawBuffer (GL_COLOR_ATTACHMENT0_EXT); GlViewport (0, 0, res, res); GlMatrixMode (GL_PROJECTION); GlLoadIdentity (); Glotho (0, race, 0, race, -1, 1); GlClearColor (0,0,0,0); GlClear (GL_COLOR_BUFFER_BIT); // glEnable (GL_BLEND); // glBlendFunc (GL_ONE, GL_Zero); GlDisable (GL_BLEND); GlDisable (GL_DEPTH_TEST); GlColor4f (0.2, 0.3, 0.4, 0.5); {GlBegin (GL_QUADS) for (int i = 0; i & lt; 2; ++ i); GlVertex2i (0,0); Glitax 2i (race, 0); GlVertex2i (res, res); GlVertex2i (0, tar); GlEnd (); } GlBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); Std :: vector & lt; Float & gt; Tmp (race * race * 4); Globinated (GL_TEXTURE_2D, Tech); Glagtax image (GL- especially DD, 0, GL_RGBA, GL_Flota, and TMP.Front ()); Const float * cons x = & amp; Tmp.front (); Serie Lieutenant; & Lt; X [0] & lt; & Lt; "" & Lt; & Lt; X [1] & lt; & Lt; "" & Lt; & Lt; X [2] & lt; & Lt; "" & Lt; & Lt; X [3] & lt; & Lt; Endl; // print 0.3 0.45 0.6 0.75 Gladiadectature (1, and take); GlDeleteFramebuffersEXT (1, & FBO);

Not really a good answer, however, keep in mind some things:

  • What you see is not exactly what the mix looks like, for one, your back-buffer starts at RGBA = 0, so the alpha-blending 0 returns, You can see as 0.2 0 0.3 0.4 0.5.
  • My tilt was that in some way you made the same texture texture as buffer and framebuffer attachment it is undetermined in the imagery that you provide the code snippet, you can enter a GlBindTexture (GL_TEXTURE_2D, 0) , however, it should be ensured that this is not the case ... I will give it here when you remember it.

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -