Ejemplo n.º 1
0
GFXTextureObject *RenderPassManager::getDepthTargetTexture()
{
   // If this is OpenGL, or something else has set the depth buffer, return the pointer
   if( mDepthBuff.isValid() )
   {
      // If this is OpenGL, make sure the depth target matches up
      // with the active render target.  Otherwise recreate.
      
      if( GFX->getAdapterType() == OpenGL )
      {
         GFXTarget* activeRT = GFX->getActiveRenderTarget();
         AssertFatal( activeRT, "Must be an active render target to call 'getDepthTargetTexture'" );
         
         Point2I activeRTSize = activeRT->getSize();
         if( mDepthBuff.getWidth() == activeRTSize.x &&
             mDepthBuff.getHeight() == activeRTSize.y )
            return mDepthBuff.getPointer();
      }
      else
         return mDepthBuff.getPointer();
   }

   if(GFX->getAdapterType() == OpenGL)
   {
      AssertFatal(GFX->getActiveRenderTarget(), "Must be an active render target to call 'getDepthTargetTexture'");

      const Point2I rtSize = GFX->getActiveRenderTarget()->getSize();
      mDepthBuff.set(rtSize.x, rtSize.y, GFXFormatD24S8, 
         &GFXDefaultZTargetProfile, avar("%s() - mDepthBuff (line %d)", __FUNCTION__, __LINE__));
      return mDepthBuff.getPointer();
   }

   // Default return value
   return GFXTextureTarget::sDefaultDepthStencil;
}
Ejemplo n.º 2
0
GFXTextureObject* ReflectionManager::getRefractTex( bool forceUpdate )
{
   GFXTarget *target = GFX->getActiveRenderTarget();
   GFXFormat targetFormat = target->getFormat();
   const Point2I &targetSize = target->getSize();

#if defined(TORQUE_OS_XENON)
   // On the Xbox360, it needs to do a resolveTo from the active target, so this
   // may as well be the full size of the active target
   const U32 desWidth = targetSize.x;
   const U32 desHeight = targetSize.y;
#else
   const U32 desWidth = mFloor( (F32)targetSize.x * smRefractTexScale );
   const U32 desHeight = mFloor( ( F32)targetSize.y * smRefractTexScale );
#endif

   if ( mRefractTex.isNull() || 
        mRefractTex->getWidth() != desWidth ||
        mRefractTex->getHeight() != desHeight ||
        mRefractTex->getFormat() != targetFormat )
   {
      mRefractTex.set( desWidth, desHeight, targetFormat, &RefractTextureProfile, "mRefractTex" );    
      mUpdateRefract = true;
   }

   if ( forceUpdate || mUpdateRefract )
   {
      target->resolveTo( mRefractTex );   
      mUpdateRefract = false;
   }

   return mRefractTex;
}
Ejemplo n.º 3
0
void GuiGradientCtrl::onMouseDown(const GuiEvent &event)
{
   if (!mActive)
      return;
   
   mouseLock(this);
   
   if (mProfile->mCanKeyFocus)
      setFirstResponder();
	
	if (mActive) 
      onAction();

	Point2I extent = getRoot()->getExtent();
   Point2I resolution = getRoot()->getExtent();
   GFXTexHandle bb( resolution.x, 
                    resolution.y, 
                    GFXFormatR8G8B8A8, &GFXDefaultRenderTargetProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__) );
   
   Point2I tmpPt( event.mousePoint.x, event.mousePoint.y );
   GFXTarget *targ = GFX->getActiveRenderTarget();
   targ->resolveTo( bb );
   GBitmap bmp( bb.getWidth(), bb.getHeight() );
   bb.copyToBmp( &bmp );
   ColorI tmp;
   bmp.getColor( event.mousePoint.x, event.mousePoint.y, tmp );
	
	addColorRange( globalToLocalCoord(event.mousePoint), ColorF(tmp) );
   
   mMouseDown = true;
}
Ejemplo n.º 4
0
GFXTextureObject* ReflectionManager::getRefractTex()
{
   GFXTarget *target = GFX->getActiveRenderTarget();
   GFXFormat targetFormat = target->getFormat();
   const Point2I &targetSize = target->getSize();
   const U32 desWidth = mFloor( (F32)targetSize.x * mRefractTexScale );
   const U32 desHeight = mFloor( ( F32)targetSize.y * mRefractTexScale );

   if ( mRefractTex.isNull() || 
        mRefractTex->getWidth() != desWidth ||
        mRefractTex->getHeight() != desHeight ||
        mRefractTex->getFormat() != targetFormat )
   {
      mRefractTex.set( desWidth, desHeight, targetFormat, &RefractTextureProfile, "mRefractTex" );    
      mUpdateRefract = true;
   }

   if ( mUpdateRefract )
   {
      target->resolveTo( mRefractTex );   
      mUpdateRefract = false;
   }

   return mRefractTex;
}
Ejemplo n.º 5
0
void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
{
   if (mStateBlock.isNull())
   {
      GFXStateBlockDesc desc;
      desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
      desc.setZReadWrite(false);
      desc.zWriteEnable = false;
      desc.setCullMode(GFXCullNone);
      mStateBlock = GFX->createStateBlock( desc );
   }

   RectI boundsRect(offset, getExtent()); 
   renderColorBox(boundsRect);

   if (mPositionChanged) 
   {
      mPositionChanged = false;
      Point2I extent = getRoot()->getExtent();
      // If we are anything but a pallete, change the pick color
      if (mDisplayMode != pPallet)
      {
         Point2I resolution = getRoot()->getExtent();

         U32 buf_x = offset.x + mSelectorPos.x + 1;
         U32 buf_y = ( extent.y - ( offset.y + mSelectorPos.y + 1 ) );
         if(GFX->getAdapterType() != OpenGL)
            buf_y = resolution.y - buf_y;

         GFXTexHandle bb( resolution.x, 
                          resolution.y, 
                          GFXFormatR8G8B8A8, &GFXDefaultRenderTargetProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__) );
         
         Point2I tmpPt( buf_x, buf_y );

         GFXTarget *targ = GFX->getActiveRenderTarget();
         targ->resolveTo( bb );
         
         GBitmap bmp( bb.getWidth(), bb.getHeight() );

         bb.copyToBmp( &bmp );
         
         //bmp.writePNGDebug( "foo.png" );

         ColorI tmp;
         bmp.getColor( buf_x, buf_y, tmp );

         mPickColor = (ColorF)tmp;

         // Now do onAction() if we are allowed
         if (mActionOnMove) 
            onAction();
      }
      
   }
   
   //render the children
   renderChildControls( offset, updateRect);
}
Ejemplo n.º 6
0
void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
{
   if (mStateBlock.isNull())
   {
      GFXStateBlockDesc desc;
      desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
      desc.setZReadWrite(false);
      desc.zWriteEnable = false;
      desc.setCullMode(GFXCullNone);
      mStateBlock = GFX->createStateBlock(desc);
   }

   RectI boundsRect(offset, getExtent());
   renderColorBox(boundsRect);

   if (mPositionChanged || mBitmap == NULL)
   {
      bool nullBitmap = false;

      if (mPositionChanged == false && mBitmap == NULL)
         nullBitmap = true;

      mPositionChanged = false;
      Point2I extent = getRoot()->getExtent();

      // If we are anything but a pallete, change the pick color
      if (mDisplayMode != pPallet)
      {
         Point2I resolution = getRoot()->getExtent();

         U32 buf_x = offset.x + mSelectorPos.x + 1;
         U32 buf_y = resolution.y - (extent.y - (offset.y + mSelectorPos.y + 1));

         GFXTexHandle bb( resolution.x, resolution.y, GFXFormatR8G8B8A8, &GFXDefaultRenderTargetProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__) );

         Point2I tmpPt(buf_x, buf_y);

         GFXTarget *targ = GFX->getActiveRenderTarget();
         targ->resolveTo(bb);

         if (mBitmap)
         {
            delete mBitmap;
            mBitmap = NULL;
         }

         mBitmap = new GBitmap(bb.getWidth(), bb.getHeight());

         bb.copyToBmp(mBitmap);

         if (!nullBitmap)
         {
            if (mSelectColor)
            {
               Point2I pos = findColor(mSetColor, offset, resolution, *mBitmap);
               mSetColor = mSetColor.BLACK;
               mSelectColor = false;
               setSelectorPos(pos);
            }
            else
            {
               ColorI tmp;
               mBitmap->getColor(buf_x, buf_y, tmp);

               mPickColor = (ColorF)tmp;

               // Now do onAction() if we are allowed
               if (mActionOnMove)
                  onAction();
            }
         }
      }
   }

   //render the children
   renderChildControls(offset, updateRect);
}