title: OpenGL Alpha Blending Issue, Blending ignored (maybe)?
body: <p>EDIT + BETTER SOLUTION:</p>
  
  <p>In case anyone happens to run into the problem I was running into, there are two solutions. One is the solution accepted, but that only applies if you are doing things how I <em>was</em>. Let me explain what I was doing:</p>
  
  <p>1.) Render star background to screen</p>
  
  <p>2.) Render ships, then particles to the FBO</p>
  
  <p>3.) Render FBO to screen</p>
  
  <p>This problem, and therefor the solution to this problem, occurred in the first place because I was blending the FBO with the star background.</p>
  
  <p>The real solution, which is supposedly also slightly faster, is to simply render the star background to the FBO, then render the FBO to screen with blending disabled. Using this method, I do not need to mess with glBlendFuncSeparate...</p>
  
  <p>1.) Render stars, then ships, then particles to FBO</p>
  
  <p>2.) Render FBO to screen <strong>with blending disabled</strong></p>
  
  <p>----------ORIGINAL QUESTION:----------</p>
  
  <p>From what I understand of the issue, blending is being ignored somehow. The particle texture with alpha transparency completely overwrites below pixels.</p>
  
  <p>I am creating a top-down game. The camera is slightly angled so that there is some feeling of depth. I am rendering my ships, then rending the particles above them...</p>
  
  <p>After beginning the OpenGL context</p>
  
  <pre><code>glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  glCullFace(GL_BACK);
  </code></pre>
  
  <p>In the render loop, I do this:</p>
  
  <pre><code>glBindFramebuffer(GL_FRAMEBUFFER,ook-&gt;fbo);
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);
  
  entitymgr_render(ook); //Render entities. Always 1.0 alpha textures.
  
  glDisable(GL_DEPTH_TEST);
  glDisable(GL_CULL_FACE);
  
  //glBlendFunc(GL_SRC_ALPHA,GL_ONE); //This would enable additive blending for non-premult
  particlemgr_render(ook); //Render particles. Likely always &lt;1.0 alpha textures
  //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  
  glBindFramebuffer(GL_FRAMEBUFFER,0);
  </code></pre>
  
  <p>If I run with the above code, I get results like this...</p>
  
  <p>Particle tex:</p>
  
  <p><img src="https://i.stack.imgur.com/PVRy5.png" alt="Particle tex"></p>
  
  <p>Screenshot from OGL Profiler (Mac tool):</p>
  
  <p><img src="https://i.stack.imgur.com/DqI0n.png" alt="Screenshot from OGL Profiler"></p>
  
  <p>Screenshot of the FBO without any particle rendered:</p>
  
  <p><img src="https://i.stack.imgur.com/YAEL5.png" alt="Screenshot of the FBO without any particle rendered"></p>
  
  <p>Screenshot of the FBO with some particles rendered on top:</p>
  
  <p><img src="https://i.stack.imgur.com/SCviE.png" alt="Screenshot of the FBO with some particles rendered on top"></p>
  
  <p>As you can see, the particle, despite having alpha transparency, doesn't blend with the ship rendered below. Instead, it just completely overwrites the pixels.</p>
  
  <p>Final notes, setting pixel transparency in the shader blends correctly - the ship appears below. And here is my shader:</p>
  
  <pre><code>#version 150
  uniform sampler2D s_tex1;
  uniform float v4_color;
  in vec4 vertex;
  in vec3 normal;
  in vec2 texcoord;
  
  out vec4 frag_color;
  
  void main()
  {
      frag_color=texture(s_tex1,texcoord)*v4_color;
      if(frag_color.a==0.0) discard;
  }
  </code></pre>
  
  <p>Let me know if there is anything I can provide.</p>