Exemplo n.º 1
0
void FBO::begin( bool clear )
{
	//
	// draw into fbo
	//
	oglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboId);

	//finalize();

	glPushAttrib(GL_VIEWPORT_BIT);
	glViewport(0,0,width, height);

	// Set the render target
	GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT };
	oglDrawBuffers(numAttachments, buffers);

	if( clear )
	{
		glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	}//else
	//	glDisable( GL_DEPTH_TEST );
}
Exemplo n.º 2
0
  void render(date renderDate)
  {
    assert(trailElements != NULL);

    Shader::Program::unUse();
    Texture::Unit::unUse();
    VBO::Element::unUse();
    FBO::list[FBO::trails].use();

    GLenum buffers[] = {
      GL_COLOR_ATTACHMENT0_EXT,
      GL_COLOR_ATTACHMENT1_EXT
    };

    oglDrawBuffers(1, buffers);

#if DEBUG_TRAILS
    glClearColor(0.1f, 0.1f, 0.1f, 1.f);
#else
    glClearColor(0, 0, 0, 1.f);
#endif // DEBUG_TRAILS

    glClear(GL_COLOR_BUFFER_BIT);

    glDisable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    glDisable( GL_LIGHTING );
    glDisable(GL_DEPTH_TEST);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0., 1., 0., 1.);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    /*
    {
      int i = 0;
      while (i < trailElements->size)
	if ((*trailElements)[i].birth + 500 < renderDate)
	{
	  trailElements->remove(i);
	}
	else
	{
	  ++i;
	}
    }
    */

#if DEBUG_TRAILS

    // Fond pour debugger
    glColor4f(0.4f, 0.4f, 0.4f, 0.4f);

    glBegin(GL_QUADS);
    glVertex2f(0.05f, 0.05f);
    glVertex2f(0.05f, 0.95f);
    glVertex2f(0.95f, 0.95f);
    glVertex2f(0.95f, 0.05f);
    glEnd();

#endif // DEBUG_TRAILS

    glEnableClientState(GL_VERTEX_ARRAY);

    Array<trailDesc> & list = (*trailElements);
    for (int i = 0; i < list.size; ++i)
    {
      const trailDesc & element = list[i];
      if (element.birth + 500 >= renderDate &&
	  element.birth <= renderDate)
      {
	renderElement(element, 0.002f * (renderDate - element.birth));
      }
    }

    glDisableClientState(GL_VERTEX_ARRAY);
  }