bool OpenGLSWFrameBuffer::WipeDo(int ticks)
{
	if (!Accel2D)
	{
		return Super::WipeDo(ticks);
	}

	// Sanity checks.
	if (InitialWipeScreen == NULL || FinalWipeScreen == NULL)
	{
		return true;
	}
	if (GatheringWipeScreen)
	{ // This is the first time we've been called for this wipe.
		GatheringWipeScreen = false;
	}
	else
	{ // This is the second or later time we've been called for this wipe.
		InScene = true;
	}

	In2D = 3;

	EnableAlphaTest(false);
	bool done = ScreenWipe->Run(ticks, this);
	return done;
}
Beispiel #2
0
void nuiGLDrawContext::DrawLine(float x1, float y1, float x2, float y2)
{
  if (mCurrentState.mAntialiasing && mPermitAntialising)
  {
    EnableTexture2D(true);
    EnableBlending(true);
    EnableAlphaTest(true);
    glBindTexture(GL_TEXTURE_2D, glAA_texture[0]);
    SetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glAlphaFunc(GL_GREATER, 1.0f/255.0f);

    // texture init

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glScalef(0.25/phf, 0.25/phf, 1.0);              // glAArg requires rectangle coordinate setup
    glMatrixMode(GL_MODELVIEW);

    glAALineWidth(mCurrentState.mLineWidth);

    glAABegin(GL_LINES);
    glAAColor4f(mCurrentState.mStrokeColor.Red(), mCurrentState.mStrokeColor.Green(), mCurrentState.mStrokeColor.Blue(), mCurrentState.mStrokeColor.Alpha());
    glAAVertex2f(x1, y1);
    glAAVertex2f(x2, y2);
    glAAEnd();

    glAAFlush();

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);

    SetTexture(NULL);
    EnableTexture2D(false);
    EnableBlending(false);
    EnableAlphaTest(false);
  }
  else
  {
    mCurrentState.mStrokeColor.Apply();
    glBegin(GL_LINES);
    glVertex2f(x1,y1);
    glVertex2f(x2,y2);
    glEnd();
  }
}
Beispiel #3
0
bool D3DFB::WipeDo(int ticks)
{
	if (!Accel2D)
	{
		return Super::WipeDo(ticks);
	}

	// Sanity checks.
	if (InitialWipeScreen == NULL || FinalWipeScreen == NULL)
	{
		return true;
	}
	if (GatheringWipeScreen)
	{ // This is the first time we've been called for this wipe.
		GatheringWipeScreen = false;

		if (OldRenderTarget == NULL)
		{
			return true;
		}
		D3DDevice->SetRenderTarget(0, OldRenderTarget);
	}
	else
	{ // This is the second or later time we've been called for this wipe.
		D3DDevice->BeginScene();
		InScene = true;
	}
	SAFE_RELEASE( OldRenderTarget );
	if (TempRenderTexture != NULL && TempRenderTexture != FinalWipeScreen)
	{
		IDirect3DSurface9 *targetsurf;
		if (SUCCEEDED(TempRenderTexture->GetSurfaceLevel(0, &targetsurf)))
		{
			if (SUCCEEDED(D3DDevice->GetRenderTarget(0, &OldRenderTarget)))
			{
				if (FAILED(D3DDevice->SetRenderTarget(0, targetsurf)))
				{
					// Setting the render target failed.
				}
			}
			targetsurf->Release();
		}
	}
	In2D = 3;

	EnableAlphaTest(FALSE);
	bool done = ScreenWipe->Run(ticks, this);
	DrawLetterbox();
	return done;
}
Beispiel #4
0
void nuiGLDrawContext::DrawCachedShape(std::list<nuiShape::CacheElement*>* pElements, nuiShapeMode Mode)
{
  bool blend = mCurrentState.mBlending;
  uint func1,func2;
  bool tex2D;
  func1 = mCurrentState.mBlendSourceFactor;
  func2 = mCurrentState.mBlendDestinationFactor;
  tex2D = mCurrentState.mTexture2D;

  nuiColor c;

  if (Mode == eStrokeShape)
  {
    if (mCurrentState.mAntialiasing && mPermitAntialising)
    {
      EnableTexture2D(true);
      EnableBlending(true);
      EnableAlphaTest(true);
      glBindTexture(GL_TEXTURE_2D, glAA_texture[0]);
      SetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glAlphaFunc(GL_GREATER, 1.0f/255.0f);

      // texture init

      glMatrixMode(GL_TEXTURE);
      glLoadIdentity();
      glScalef(0.25/phf, 0.25/phf, 1.0);              // glAArg requires rectangle coordinate setup
      glMatrixMode(GL_MODELVIEW);

      glAALineWidth(mCurrentState.mLineWidth);

      std::list<nuiShape::CacheElement*>::iterator it;
      std::list<nuiShape::CacheElement*>::iterator end = pElements->end();

      for (it = pElements->begin(); it != end; ++it)
      {
        nuiShape::CacheElement* pElement = *it;
        uint i = 0;

        switch (pElement->mOperation)
        {
        case GL_POINTS:
        case GL_LINES:
        case GL_LINE_LOOP:
        case GL_LINE_STRIP:
          c = mCurrentState.mStrokeColor;
          break;

        case GL_TRIANGLES:
        case GL_TRIANGLE_STRIP:
        case GL_TRIANGLE_FAN:
        case GL_QUADS:
        case GL_QUAD_STRIP:
        case GL_POLYGON:
          c = mCurrentState.mFillColor;
          break;
        }

        /*
        if (pElement->mCount > 16)
        glAADisable(GLAA_VERTEX_ARRAY); // we want VAR acceleration and we will handle flushing
        else
        glAAEnable(GLAA_VERTEX_ARRAY); // we want VAR acceleration and we will handle flushing
        */

        glAAColor4f(
          c.Red(),
          c.Green(),
          c.Blue(),
          c.Alpha()
          );
        glAABegin(pElement->mOperation);

        for (i = 0; i<pElement->mCount; i++)
        {
          nuiShape::CacheElement* pElement = *it;
          /*float* c = pElement->mpVertices[i].mColor; (unused) */
          float* coords = pElement->mpVertices[i].mCoord;
          glAAVertex2f(coords[0], coords[1]);
        }
        glAAEnd();
        glAAFlush();
      }

      glMatrixMode(GL_TEXTURE);
      glLoadIdentity();
      glMatrixMode(GL_MODELVIEW);

      SetTexture(NULL);
      EnableTexture2D(false);
      EnableBlending(false);
      EnableAlphaTest(false);
      return;
    }

    glLineWidth(mCurrentState.mLineWidth);
  }

  std::list<nuiShape::CacheElement*>::iterator it;
  std::list<nuiShape::CacheElement*>::iterator end = pElements->end();

  for (it = pElements->begin(); it != end; ++it)
  {
    nuiShape::CacheElement* pElement = *it;
    switch (pElement->mOperation)
    {
    case GL_POINTS:
    case GL_LINES:
    case GL_LINE_LOOP:
    case GL_LINE_STRIP:
      c = mCurrentState.mStrokeColor;
      break;

    case GL_TRIANGLES:
    case GL_TRIANGLE_STRIP:
    case GL_TRIANGLE_FAN:
    case GL_QUADS:
    case GL_QUAD_STRIP:
    case GL_POLYGON:
      c = mCurrentState.mFillColor;
      break;
    }
    glColor4f(
      c.Red(),
      c.Green(),
      c.Blue(),
      c.Alpha()
      );
    if (pElement->mCount <= NUI_COMPLEX_SHAPE_THRESHOLD)
    {
      uint i = 0;
      glBegin(pElement->mOperation);

      for (i = 0; i<pElement->mCount; i++)
      {
        nuiShape::CacheElement* pElement = *it;
        glVertex3fv(pElement->mpVertices[i].mCoord);
      }
      glEnd();
    }
    else
    {
      glVertexPointer(3,GL_FLOAT,sizeof(nuiShape::CacheElement::Vertex),pElement->mpVertices->mCoord);
      glEnableClientState(GL_VERTEX_ARRAY);
      glDrawArrays(pElement->mOperation, 0, pElement->mCount);
    }
  }

  //EnableLineSmooth(false);
  glDisable(GL_LINE_SMOOTH);
  SetBlendFunc(func1, func2);
  EnableTexture2D(tex2D);
  EnableBlending(blend);
}