Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a way to put in a buffer FBO texture output format GL_ALPHA?
    primarykey
    data
    text
    <p>I am using ftgl font library.</p> <p>ftgl function to create image has this code:</p> <pre><code>glBindTexture(GL_TEXTURE_2D, textID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(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_ALPHA, textureWidth, textureHeight,0, GL_ALPHA, GL_UNSIGNED_BYTE, textureMemory); </code></pre> <p>Format GL_ALPHA.</p> <p>When I render to FBO images(GL_RGBA) they look ok. But when I render fonts to fbo texture, there is some problems with colour and alpha.</p> <p>This image should open in editor that don't touch pixels(browser uses anti-aliasing).</p> <p><img src="https://i.stack.imgur.com/cyqgx.png" alt=""></p> <hr> <p>Code:</p> <p>/// 1 step create FBO</p> <pre><code> // Create the color buffer glGenTextures(1, &amp;id_tex); glBindTexture(GL_TEXTURE_2D, id_tex); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wid, hei, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); // GL_RGBA GL_ALPHA // Create the frame buffer glGenFramebuffersEXT(1, &amp;id_buf); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id_buf); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, id_tex, 0); GLenum err = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); assert(err == GL_FRAMEBUFFER_COMPLETE_EXT); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); </code></pre> <p>/// 2 step render to fbo</p> <pre><code>glBindTexture(GL_TEXTURE_2D, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id_buf); glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor (0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0,0, 1920 , 1080); </code></pre> <p>ftgl::render();</p> <pre><code>glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glDisable(GL_TEXTURE_2D); glFlush (); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); glViewport (0, 0, 1920, 1080); glClearColor (0.0f, 0.0f, 0.0f, 1.0f); </code></pre> <p>/// 3 step render texture</p> <pre><code>glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR); glBindTexture(GL_TEXTURE_2D, id_tex); glBegin(GL_QUADS); glTexCoord2d(0,0); glVertex3f(point4.X , point4.Y , point4.Z); glTexCoord2d(0,1); glVertex3f(point1.X , point1.Y , point1.Z); glTexCoord2d(1,1); glVertex3f(point2.X , point2.Y , point2.Z); glTexCoord2d(1,0); glVertex3f(point3.X , point3.Y , point3.Z); glEnd(); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload