Esempio n. 1
0
bool THRenderTarget::create(const THRenderTargetCreationParams* pParams)
{
    if(m_pSurface != NULL)
        return false;
    m_pSurface = SDL_SetVideoMode(pParams->iWidth, pParams->iHeight,
        pParams->iBPP, pParams->iSDLFlags);

    // Create another surface that's simply blue. This is used as an overlay
    // when the game is paused to create a blue filter.
    m_bBlueFilterActive = false;
    const SDL_PixelFormat& fmt = *(m_pSurface->format);
    m_pDummySurface = SDL_CreateRGBSurface(SDL_HWSURFACE, pParams->iWidth, pParams->iHeight,
        fmt.BitsPerPixel, fmt.Rmask,fmt.Gmask,fmt.Bmask,fmt.Amask );
    SDL_FillRect(m_pDummySurface, NULL, mapColour(50, 50, 200));
    SDL_SetAlpha(m_pDummySurface, SDL_SRCALPHA, 128);

    return m_pSurface != NULL;
}
Esempio n. 2
0
bool THRenderTarget::fillBlack()
{
    return SDL_FillRect(m_pSurface, NULL, mapColour(0, 0, 0)) == 0;
}
Esempio n. 3
0
void testApp :: update()
{
	if( tileSaver.bGoTiling )
		return;
	
	noiseField.update();
	
	for( int i=0; i<pTotal; i++ )
	{
		ofxVec3f vel;
		ofxVec3f sph = sphericalField.getNormalisedForce( pos[ i ][ 0 ], pos[ i ][ 1 ], pos[ i ][ 2 ] );
		ofxVec3f noi = noiseField.getNormalisedForce( pos[ i ][ 0 ], pos[ i ][ 1 ], pos[ i ][ 2 ] );
		
		sph *= 1.2;
		
		vel = sph + noi;
		vel.normalize();
		vel *= 3;
		
		pos[ i ][ 0 ] += vel.x;
		pos[ i ][ 1 ] += vel.y;
		pos[ i ][ 2 ] += vel.z;

		int j = 0;
		if( trailIndex < MAX_TRAIL_LENGTH )
		{
			j = trailIndex;
		}
		else
		{
			j = MAX_TRAIL_LENGTH - 1;
		}
		
		// TRAIL POSITIONS.
		if( trailIndex > 0 )
		{
			memmove( trl[ i ] + 3, trl[ i ], 3 * j * sizeof(float) );
		}

		trl[ i ][ 0 ] = pos[ i ][ 0 ];
		trl[ i ][ 1 ] = pos[ i ][ 1 ];
		trl[ i ][ 2 ] = pos[ i ][ 2 ];

		// TRAIL VERTEX.
		if( trailIndex > 0 )
		{
			memmove( tvr[ i ] + 6, tvr[ i ], 6 * j * sizeof(float) );
		}
			
		if( trailIndex == 0 )
		{
			tvr[ i ][ 0 ] = pos[ i ][ 0 ];
			tvr[ i ][ 1 ] = pos[ i ][ 1 ];
			tvr[ i ][ 2 ] = pos[ i ][ 2 ];
			tvr[ i ][ 3 ] = pos[ i ][ 0 ];
			tvr[ i ][ 4 ] = pos[ i ][ 1 ];
			tvr[ i ][ 5 ] = pos[ i ][ 2 ];
		}
		else
		{
			int m = 0;
			int n = 1;
			
			float t0x = trl[ i ][ m * 3 + 0 ];	// xyz position of 1st trail point.
			float t0y = trl[ i ][ m * 3 + 1 ];
			float t0z = trl[ i ][ m * 3 + 2 ];
			
			float t1x = trl[ i ][ n * 3 + 0 ];	// xyz position of 2nd trail point.
			float t1y = trl[ i ][ n * 3 + 1 ];
			float t1z = trl[ i ][ n * 3 + 2 ];
			
			ofxVec3f t0 = ofxVec3f( t0x, t0y, t0z );	// position vector of 1st trail point.
			ofxVec3f t1 = ofxVec3f( t1x, t1y, t1z );	// position vector of 2nd trail point.
			
			ofxVec3f v1 = t0 - t1;
			v1.normalize();
			ofxVec3f ya = ofxVec3f( upAxis );
			ofxVec3f v2 = ya.cross( v1 );
			ofxVec3f v3 = v1.cross( v2 ).normalize();
			
			float w		= 2;
			float xOff	= v3.x * w;
			float yOff	= v3.y * w;
			float zOff	= v3.z * w;
			
			tvr[ i ][ 0 ] = t0x - xOff;
			tvr[ i ][ 1 ] = t0y - yOff;
			tvr[ i ][ 2 ] = t0z - zOff;
			tvr[ i ][ 3 ] = t0x + xOff;
			tvr[ i ][ 4 ] = t0y + yOff;
			tvr[ i ][ 5 ] = t0z + zOff;
		}
		
		// TRAIL COLOUR.
		int r, g, b;
//		mapColour( pos[ i ][ 0 ], pos[ i ][ 1 ], &r, &g, &b );
		mapColour( pos[ i ][ 0 ], pos[ i ][ 2 ], &r, &g, &b );

		if( trailIndex > 0 )
		{
			memmove( tcl[ i ] + 4 * 2, tcl[ i ], 4 * 2 * j * sizeof(float) );
		}

		tcl[ i ][ 0 ] = tcl[ i ][ 4 ] = r / 255.0f;
		tcl[ i ][ 1 ] = tcl[ i ][ 5 ] = g / 255.0f;
		tcl[ i ][ 2 ] = tcl[ i ][ 6 ] = b / 255.0f;
		tcl[ i ][ 3 ] = tcl[ i ][ 7 ] = 0.7f;
	}
	
	if( trailIndex < MAX_TRAIL_LENGTH )
	{
		++trailIndex;
	}
	
	upAxis.rotate( upAxisRot, ofxVec3f( 1, 0, 0 ) );
	
	rotateY += 0.1;
}