Sign in to follow this  

OpenGL blending/drawing help

This topic is 4744 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 have a slight dilema
//draw everything
void Render(NewEarth &Earth, NewShot &Shot)
{
  glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
  glClear (GL_COLOR_BUFFER_BIT);
  
  glBindTexture(GL_TEXTURE_2D, tex.texID);
  glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  glBegin(GL_QUADS);
  glTexCoord2f(0.0f, 0.0f); glVertex2f(Shot.loc[0]-2.0f, Shot.loc[1]-2.0f);
  glTexCoord2f(0.0f, 1.0f); glVertex2f(Shot.loc[0]-2.0f, Shot.loc[1]+2.0f);
  glTexCoord2f(1.0f, 1.0f); glVertex2f(Shot.loc[0]+2.0f, Shot.loc[1]+2.0f);
  glTexCoord2f(1.0f, 0.0f); glVertex2f(Shot.loc[0]+2.0f, Shot.loc[1]-2.0f);
  glEnd();
  
  /*
  glBegin(GL_LINES);
  glColor3f(0.0f,0.5f,0.0f);
  for(int a=0;a<800;a++)
  {
    glVertex2f(Earth.Dirt[a].loc[0],Earth.Dirt[a].loc[1]);
    glVertex2f(Earth.Dirt[a].loc[2],Earth.Dirt[a].loc[3]);
  }      
  glEnd();
  for(int a=0;a<128;a++)
  {
    if(Earth.Chunk[a].active)
    {
      glBegin(GL_POINTS);
      glColor3f(0.0f,0.5f,0.0f);
      glVertex2f(Earth.Chunk[a].loc[0],Earth.Chunk[a].loc[1]);
      glEnd();
    }  
  }
  */
  
  glFlush();
}
This is my render function, right now there are two part, the commented and not commented. The uncommented part draws a little bullet texture and the commented part draws the ground and dirt particles. Now they both work seperately, I can use one or the other, but as soon as I try to run them together they blink on for a second and then the whole screen goes black. But I'm greedy and want them both to mingle peacefully, any suggestions?

Share this post


Link to post
Share on other sites

This topic is 4744 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this