/* * Modification History * * 2006-July-6 Jason Rohrer * Created. */ #include "RestartButton.h" #include "../glCommon.h" #include "minorGems/graphics/filters/BoxBlurFilter.h" #include RestartButton::RestartButton( double inAnchorX, double inAnchorY, double inWidth, double inHeight ) : ButtonBase( inAnchorX, inAnchorY, inWidth, inHeight ) { // construct arrow texture // a blurry white triangle // black border int textureSize = 32; double halfTextureSize = 0.5 * textureSize; Image *textureImage = new Image( textureSize, textureSize, 4, false ); double *channels[4]; int pixelsPerChannel = textureSize * textureSize; int i; int p; for( i=0; i<4; i++ ) { channels[i] = textureImage->getChannel( i ); } // start all pixels as black and transparent for( p=0; p 1 ) { currentAlpha = 1; } if( currentAlpha < 0 ) { currentAlpha = 0; } } // blur alpha int blurRadius = 1; BoxBlurFilter blur( blurRadius ); // blur all channels textureImage->filter( &blur, 3 ); // rgb are identical, so blur one and copy textureImage->filter( &blur, 0 ); memcpy( channels[1], channels[0], pixelsPerChannel * sizeof( double ) ); memcpy( channels[2], channels[0], pixelsPerChannel * sizeof( double ) ); mArrowTexture = new SingleTextureGL( textureImage, // no wrap false ); delete textureImage; } RestartButton::~RestartButton() { delete mArrowTexture; } void RestartButton::drawIcon( Vector3D *inCenter, double inRadius, double inAlpha ) { // draw a green back arrow glColor4f( 0, 1, 0, inAlpha ); // compensate for small radius of texture double drawRadius = inRadius / 0.6666; drawTextureQuad( mArrowTexture, inCenter, drawRadius ); }