Beispiel #1
0
void Actor::SetBlendMode( CString s )
{
	s.MakeLower();
	if     (s=="normal")	SetBlendMode( BLEND_NORMAL );
	else if(s=="add")		SetBlendMode( BLEND_ADD );
	else if(s=="noeffect")	SetBlendMode( BLEND_NO_EFFECT );
	else	ASSERT(0);
}
Beispiel #2
0
	//------------------------------------------------------------------------------------------
	HRESULT CGraphicDevice::Activate()
	{
		HRESULT hr;

		// 準備中
		if( m_bValid == false )
		{
			return E_FAIL;
		}	

		V_RETURN( m_pd3dDevice9->BeginScene() );		

		// 実行中フラグをセット
		m_bActive = true;
		
		// ビューポートを設定
		V_RETURN( m_pd3dDevice9->SetViewport(&m_viewport) );

		// レンダーステートの設定
		V_RETURN( m_pd3dDevice9->SetRenderState(D3DRS_ZENABLE, TRUE ) );
		V_RETURN( m_pd3dDevice9->SetRenderState(D3DRS_ZWRITEENABLE, TRUE ) );
		V_RETURN( m_pd3dDevice9->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL ) );
		// カリングの設定
		V_RETURN( m_pd3dDevice9->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW ));

		// ブレンドモードの設定
		V_RETURN( SetBlendMode( m_nBlendMode, true ) );

		
		return hr;
	}
void moPostEffectColorFilter::Draw( moTempo* tempogral,moEffectState* parentstate)
{
    PreDraw( tempogral, parentstate);
	UpdateParameters();

	filters.Apply(&state.tempo, FilterParams);	

    glDisable(GL_DEPTH_TEST);
	glClear (GL_DEPTH_BUFFER_BIT);
	m_pResourceManager->GetGLMan()->SetOrthographicView(sWidth, sHeight);

    glColor4f(color[0] * state.tintr,
              color[1] * state.tintg,
              color[2] * state.tintb,
              color[3] * state.alpha);


	SetBlendMode();

	glBindTexture(GL_TEXTURE_2D, tex_glid);
    glBegin(GL_QUADS);
        glTexCoord2f(0.0, 0.0);
        glVertex2f(0.0, 0.0);

        glTexCoord2f(0.0, 1.0);
        glVertex2f(0.0, sHeight);

        glTexCoord2f(1.0, 1.0);
        glVertex2f(sWidth, sHeight);

        glTexCoord2f(1.0, 0.0);
        glVertex2f(sWidth, 0.0);
	glEnd();
}
Beispiel #4
0
void Drawable2D::SetBlendModeAttr(BlendMode mode)
{
    // Delay applying material update
    materialUpdatePending_ = true;

    SetBlendMode(mode);
}
//-- SetDefaults --------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void Renderer::SetDefaults()
{
	for (;g_matrixStackLevel > 0; g_matrixStackLevel--)
	{
		g_matrixStack->Pop();
	}

	g_matrixStack->LoadIdentity();

	// Renderstates
	m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
	//  d3dSetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
	m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
	m_pD3DDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
	m_pD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
	m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
	m_pD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
	m_pD3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
	m_pD3DDevice->SetRenderState(D3DRS_ALPHAREF, 0);
	m_pD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);

	m_pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE);

	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );
	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );

	for (int i = 0; i < 4; i++)
	{
		m_pD3DDevice->SetSamplerState( i, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
		m_pD3DDevice->SetSamplerState( i, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
		m_pD3DDevice->SetSamplerState( i, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		m_pD3DDevice->SetSamplerState( i, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		m_pD3DDevice->SetTexture(i, NULL);
	}

	CurrentTextureStageMode = TSM_TEXTURE;
 	g_envMapSet = false;
 	g_textureSet = false;

	// Globals
	g_colour = 0xffffffff;
	g_fColour = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
	g_aspect = g_defaultAspect;
	g_aspectValue = 1.0f;

	SetDrawMode3d();
	D3DXMATRIX matView;
	D3DXMatrixIdentity( &matView );
	SetView( matView );

	SetBlendMode( BLEND_OFF ); 

//	m_pD3DDevice->SetVertexDeclaration( g_pVertexDeclaration );

} // SetDefaults
static int
PrepareDraw(SDL_Renderer * renderer)
{
    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    IDirectFBSurface *destsurf = data->target;

    Uint8 r, g, b, a;

    r = renderer->r;
    g = renderer->g;
    b = renderer->b;
    a = renderer->a;

    SetBlendMode(data, renderer->blendMode, NULL);
    SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf, data->drawFlags));

    switch (renderer->blendMode) {
    case SDL_BLENDMODE_NONE:
    /* case SDL_BLENDMODE_MASK: */
    case SDL_BLENDMODE_BLEND:
        break;
    case SDL_BLENDMODE_ADD:
    case SDL_BLENDMODE_MOD:
        r = ((int) r * (int) a) / 255;
        g = ((int) g * (int) a) / 255;
        b = ((int) b * (int) a) / 255;
        a = 255;
        break;
    }

    SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, r, g, b, a));
    return 0;
  error:
    return -1;
}
Beispiel #7
0
 MIDDECL(gl_blend) (Value &ret)
 {
     auto m = g_vm->Pop();
     assert(m.type == V_INT);
     SetBlendMode((BlendMode)m.ival);
     return ret;
 }
Beispiel #8
0
    STARTDECL(gl_blend) (Value &mode, Value &body)
    {
        TestGL();

        int old = SetBlendMode((BlendMode)mode.ival);
        if (body.type != V_NIL) g_vm->Push(Value(old));
        return body;
    }
Beispiel #9
0
void ResourceManager::AddSurfaceWithTransparency(std::string key,
                                                 std::string file_path,
                                                 SDL_Color alpha) {
  auto surface = std::make_shared<SDL2pp::Surface>(SDL2pp::Surface(file_path));
  surface->SetBlendMode(SDL_BLENDMODE_NONE);
  surface->SetColorKey(true, SDL_MapRGB(&surface->Lock().GetFormat(), alpha.r,
                                        alpha.g, alpha.b));
  surfaces_[key] = surface;
}
Beispiel #10
0
void OpenGLFrameStart(const int2 &screensize)
{
    glViewport(0, 0, screensize.x(), screensize.y());

    SetBlendMode(BLEND_ALPHA);

    curcolor = float4(1);

    lights.clear();
}
Beispiel #11
0
    CreditsScreen::CreditsScreen(ScreenManager &ScreenManager)
        :VideoScreen(ScreenManager, "content/videos/credits.flv")
    {
        transitionOnTime = 1.0f;
        transitionOffTime = 1.0f;

        videoScale = 2.0f;

        SetBlendMode(sf::Blend::Add);
    }
Beispiel #12
0
void ae3d::GfxDevice::Draw( VertexBuffer& vertexBuffer, int startIndex, int endIndex, Shader& shader, BlendMode blendMode, DepthFunc depthFunc )
{
    ae3d::System::Assert( startIndex > -1 && startIndex <= vertexBuffer.GetFaceCount() / 3, "Invalid vertex buffer draw range in startIndex" );
    ae3d::System::Assert( endIndex > -1 && endIndex >= startIndex && endIndex <= vertexBuffer.GetFaceCount() / 3, "Invalid vertex buffer draw range in endIndex" );

    SetBlendMode( blendMode );
    SetDepthFunc( depthFunc );
    shader.Use();
    vertexBuffer.Bind();
    vertexBuffer.DrawRange( startIndex, endIndex );
}
Beispiel #13
0
void RageDisplay::SetDefaultRenderStates()
{
	SetLighting( false );
	SetCullMode( CULL_NONE );
	SetZWrite( false ); 
	SetZTestMode( ZTEST_OFF );
	SetAlphaTest( true );
	SetBlendMode( BLEND_NORMAL );
	SetTextureFiltering( true );
	LoadMenuPerspective(0, SCREEN_CENTER_X, SCREEN_CENTER_Y);	// 0 FOV = ortho
	ChangeCentering(0,0,0,0);
}
void RageDisplay::SetDefaultRenderStates()
{
	SetLighting( false );
	SetCullMode( CULL_NONE );
	SetZWrite( false ); 
	SetZTestMode( ZTEST_OFF );
	SetAlphaTest( true );
	SetBlendMode( BLEND_NORMAL );
	SetTextureFiltering( TextureUnit_1, true );
	SetZBias( 0 );
	LoadMenuPerspective( 0, 640, 480, 320, 240 ); // 0 FOV = ortho
}
		Material::Material()
		{
			//Set default lighting and shadows
			SetLightingEnabled(false);
			SetLightingMode(ePhong);
			SetBlendMode(eAdditive);
			SetReceiveShadows(false);

#if defined ION_RENDERER_SHADER
			m_vertexShader = NULL;
			m_pixelShader = NULL;
#endif
		}
Beispiel #16
0
bool RendererLegacy::DrawPointSprites(int count, const vector3f *positions, Material *material, float size)
{
	if (count < 1 || !material || !material->texture0) return false;

	SetBlendMode(BLEND_ALPHA_ONE);
	SetDepthWrite(false);
	VertexArray va(ATTRIB_POSITION | ATTRIB_UV0, count * 6);

	matrix4x4f rot;
	glGetFloatv(GL_MODELVIEW_MATRIX, &rot[0]);
	rot.ClearToRotOnly();
	rot = rot.InverseOf();

	const float sz = 0.5f*size;
	const vector3f rotv1 = rot * vector3f(sz, sz, 0.0f);
	const vector3f rotv2 = rot * vector3f(sz, -sz, 0.0f);
	const vector3f rotv3 = rot * vector3f(-sz, -sz, 0.0f);
	const vector3f rotv4 = rot * vector3f(-sz, sz, 0.0f);

	//do two-triangle quads. Could also do indexed surfaces.
	//GL2 renderer should use actual point sprites
	//(see history of Render.cpp for point code remnants)
	for (int i=0; i<count; i++) {
		const vector3f &pos = positions[i];

		va.Add(pos+rotv4, vector2f(0.f, 0.f)); //top left
		va.Add(pos+rotv3, vector2f(0.f, 1.f)); //bottom left
		va.Add(pos+rotv1, vector2f(1.f, 0.f)); //top right

		va.Add(pos+rotv1, vector2f(1.f, 0.f)); //top right
		va.Add(pos+rotv3, vector2f(0.f, 1.f)); //bottom left
		va.Add(pos+rotv2, vector2f(1.f, 1.f)); //bottom right
	}
	DrawTriangles(&va, material);
	SetBlendMode(BLEND_SOLID);
	SetDepthWrite(true);

	return true;
}
Beispiel #17
0
Sprite::Sprite(const std::string& path) :
	m_sdl_texture{nullptr},
	m_width{0},
	m_height{0},
	m_path{path}
{
	LoadFrom(m_path);

	SetBlendMode(SDL_BLENDMODE_BLEND);
	SetAlpha(255);

	ASSERT(m_width >= 0 , "Must be >= 0");
	ASSERT(m_height >= 0, "Must be >= 0");
}
Beispiel #18
0
bool RuntimeSpriteObject::ChangeProperty(std::size_t propertyNb, gd::String newValue)
{
    if ( propertyNb == 0 ) { return SetCurrentAnimation(newValue.To<int>()); }
    else if ( propertyNb == 1 )
    {
        if ( currentAnimation >= GetAnimationsCount() ) return false;

        return animations[currentAnimation].Get().useMultipleDirections ? SetDirection(newValue.To<std::size_t>()) : SetAngle(newValue.To<float>());
    }
    else if ( propertyNb == 2 ) { return SetSprite(newValue.To<int>()); }
    else if ( propertyNb == 3 ) { SetOpacity(newValue.To<float>()); }
    else if ( propertyNb == 4 ) { SetBlendMode(newValue.To<int>()); }
    else if ( propertyNb == 5 ) {SetScaleX(newValue.To<float>());}
    else if ( propertyNb == 6 ) {SetScaleY(newValue.To<float>());}

    return true;
}
Beispiel #19
0
bool RuntimeSpriteObject::ChangeProperty(unsigned int propertyNb, std::string newValue)
{
    if ( propertyNb == 0 ) { return SetCurrentAnimation(ToInt(newValue)); }
    else if ( propertyNb == 1 )
    {
        if ( currentAnimation >= GetAnimationsCount() ) return false;

        return animations[currentAnimation].Get().useMultipleDirections ? SetDirection(ToInt(newValue)) : SetAngle(ToFloat(newValue));
    }
    else if ( propertyNb == 2 ) { return SetSprite(ToInt(newValue)); }
    else if ( propertyNb == 3 ) { SetOpacity(ToFloat(newValue)); }
    else if ( propertyNb == 4 ) { SetBlendMode(ToInt(newValue)); }
    else if ( propertyNb == 5 ) {SetScaleX(ToFloat(newValue));}
    else if ( propertyNb == 6 ) {SetScaleY(ToFloat(newValue));}

    return true;
}
Beispiel #20
0
bool GLVideo::StartApplication(
	const unsigned int width,
	const unsigned int height,
	const str_type::string& winTitle,
	const bool windowed,
	const bool sync,
	const Texture::PIXEL_FORMAT pfBB,
	const bool maximizable)
{
	SetFilterMode(Video::TM_ALWAYS);
	SetAlphaMode(Video::AM_PIXEL);

	SetZBuffer(false);
	SetZWrite(false);
	SetClamp(true);
	SetBlendMode(1, Video::BM_MODULATE);

	Enable2DStates();

	// don't reset cg context if it is an opengl context reset
	if (!m_shaderContext)
		m_shaderContext = GLCgShaderContextPtr(new GLCgShaderContext);

	if (!m_defaultVS)
		m_defaultVS = LoadShaderFromString("defaultShader", gs2dglobal::defaultVSCode, Shader::SF_VERTEX, Shader::SP_MODEL_2, "sprite");

	if (!m_rectVS)
		m_rectVS = LoadShaderFromString("rectShader", gs2dglobal::defaultVSCode, Shader::SF_VERTEX, Shader::SP_MODEL_2, "rectangle");

	if (!m_fastVS)
		m_fastVS = LoadShaderFromString("fastShader", gs2dglobal::fastSimpleVSCode, Shader::SF_VERTEX, Shader::SP_MODEL_2, "fast");

	m_currentVS = m_defaultVS;

	UpdateInternalShadersViewData(GetScreenSizeF(), false);

	return true;
}
Beispiel #21
0
////////////////////////////////////////////////////////////
/// Set the color of a shape
////////////////////////////////////////////////////////////
void sfShape_SetColor(sfShape* Shape, sfColor Color)
{
    CSFML_CALL(Shape, SetColor(sf::Color(Color.r, Color.g, Color.b, Color.a)))
}


////////////////////////////////////////////////////////////
/// Set the blending mode for a shape
////////////////////////////////////////////////////////////
void sfShape_SetBlendMode(sfShape* Shape, sfBlendMode Mode)
{
    CSFML_CALL(Shape, SetBlendMode(static_cast<sf::Blend::Mode>(Mode)))
}


////////////////////////////////////////////////////////////
/// Get the X position of a shape
////////////////////////////////////////////////////////////
float sfShape_GetX(sfShape* Shape)
{
    CSFML_CALL_RETURN(Shape, GetPosition().x, 0.f)
}


////////////////////////////////////////////////////////////
/// Get the Y position of a shape
////////////////////////////////////////////////////////////
Beispiel #22
0
    void InitFx_Repeater01()
    {
        // effect
        auto _ps = DiEffectManager::GetInstance().CreateParticleSystemTemplate("Fx_repeater1");
        std::shared_ptr<DiTransformUnit> ps(_ps);

        _ps->Start();
        {
            DiParticleElement* element = _ps->CreateElement();
            element->SetRenderer("Billboard");
            auto emitter = element->CreateEmitter("Box");
            
            auto mat = DiMaterial::QuickCreate("basic_v", "basic_p", SHADER_FLAG_USE_COLOR | SHADER_FLAG_USE_MAP);
            mat->GetShaderParameter()->WriteTexture2D("map", "glow_01.dds");
            mat->SetBlendMode(BLEND_ADD);
            mat->SetDepthWrite(false);
            element->SetMaterialName(mat->GetName());
            
            ((DiBoxEmitter*)emitter)->SetWidth(50);
            ((DiBoxEmitter*)emitter)->SetHeight(70);
            ((DiBoxEmitter*)emitter)->SetDepth(50);
            emitter->position = DiVec3(0, 165, 5);
            
            auto rt = DI_NEW DiAttributeFixed();
            rt->SetValue(30);
            emitter->SetDynEmissionRate(rt);
            
            auto spd = DI_NEW DiAttributeFixed();
            spd->SetValue(20);
            emitter->SetDynVelocity(spd);
            
            auto ttl = DI_NEW DiAttributeRandom();
            ttl->SetMinMax(1, 2);
            emitter->SetDynTotalTimeToLive(ttl);
            
            auto sz = DI_NEW DiAttributeRandom();
            sz->SetMinMax(20, 40);
            emitter->SetDynParticleAllDimensions(sz);
            
            DiColorController* colorCtrl = (DiColorController*)element->CreateController("Color");
            colorCtrl->AddColour(0, DiColor::Black);
            colorCtrl->AddColour(0.5f, DiColor(0.25f, 1, 0.5f));
            colorCtrl->AddColour(1, DiColor::Black);
        }
        {
            DiParticleElement* element = _ps->CreateElement();
            element->SetRenderer("Billboard");
            auto emitter = element->CreateEmitter("Box");
            
            auto mat = DiMaterial::QuickCreate("basic_v", "basic_p", SHADER_FLAG_USE_COLOR | SHADER_FLAG_USE_MAP);
            auto texture = mat->GetShaderParameter()->WriteTexture2D("map", "mysticenergy2.dds");
            mat->SetBlendMode(BLEND_ADD);
            mat->SetDepthWrite(false);
            element->SetMaterialName(mat->GetName());
            texture->SetAddressing(AM_CLAMP);
            
            ((DiBoxEmitter*)emitter)->SetWidth(50);
            ((DiBoxEmitter*)emitter)->SetHeight(70);
            ((DiBoxEmitter*)emitter)->SetDepth(50);
            emitter->position = DiVec3(0, 165, 5);
            
            auto rt = DI_NEW DiAttributeFixed();
            rt->SetValue(6);
            emitter->SetDynEmissionRate(rt);
            
            auto spd = DI_NEW DiAttributeFixed();
            spd->SetValue(20);
            emitter->SetDynVelocity(spd);
            
            auto ttl = DI_NEW DiAttributeRandom();
            ttl->SetMinMax(1, 2);
            emitter->SetDynTotalTimeToLive(ttl);
            
            auto sz = DI_NEW DiAttributeRandom();
            sz->SetMinMax(20, 40);
            emitter->SetDynParticleAllDimensions(sz);
            
            DiColorController* colorCtrl = (DiColorController*)element->CreateController("Color");
            colorCtrl->AddColour(0, DiColor::Black);
            colorCtrl->AddColour(0.5f, DiColor(0.25f, 1, 0.5f));
            colorCtrl->AddColour(1, DiColor::Black);
            
            DiTextureRotatorController* texrotCtrl = (DiTextureRotatorController*)element->CreateController("TextureRotator");
            texrotCtrl->SetUseOwnRotationSpeed(true);
            auto rotspeed = DI_NEW DiAttributeRandom();
            rotspeed->SetMinMax(-100, 100);
            texrotCtrl->SetRotationSpeed(rotspeed);
            auto rot = DI_NEW DiAttributeRandom();
            rot->SetMinMax(0, 300);
            texrotCtrl->SetRotation(rot);
        }
        
        // create the editor object from the particle system
        DiEditorManager::Get()->LoadParticleSystem(_ps);
    }
static int
DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
                    const SDL_Rect * srcrect, const SDL_FRect * dstrect)
{
    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    IDirectFBSurface *destsurf = data->target;
    DirectFB_TextureData *texturedata =
        (DirectFB_TextureData *) texture->driverdata;
    Uint8 alpha, r, g, b;
    DFBRegion clip_region;
    DFBRectangle sr, dr;

    DirectFB_ActivateRenderer(renderer);

    SDLtoDFBRect(srcrect, &sr);
    SDLtoDFBRect_Float(dstrect, &dr);

    destsurf->GetClip(destsurf, &clip_region);
    dr.x += clip_region.x1;
    dr.y += clip_region.y1;

    if (texturedata->display) {
        int px, py;
        SDL_Window *window = renderer->window;
        IDirectFBWindow *dfbwin = get_dfb_window(window);
        SDL_DFB_WINDOWDATA(window);
        SDL_VideoDisplay *display = texturedata->display;
        DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;

        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetSourceRectangle(dispdata->vidlayer,
                                                      sr.x, sr.y, sr.w, sr.h));
        dfbwin->GetPosition(dfbwin, &px, &py);
        px += windata->client.x;
        py += windata->client.y;
        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetScreenRectangle(dispdata->vidlayer,
                                                      px + dr.x,
                                                      py + dr.y,
                                                      dr.w,
                                                      dr.h));
    } else {
        DFBSurfaceBlittingFlags flags = 0;

#if 0
        if (texturedata->dirty.list) {
            SDL_DirtyRect *dirty;
            void *pixels;
            int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format));
            int pitch = texturedata->pitch;

            for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
                SDL_Rect *rect = &dirty->rect;
                pixels =
                    (void *) ((Uint8 *) texturedata->pixels +
                              rect->y * pitch + rect->x * bpp);
                DirectFB_UpdateTexture(renderer, texture, rect,
                                       pixels,
                                       texturedata->pitch);
            }
            SDL_ClearDirtyRects(&texturedata->dirty);
        }
#endif
        if (texturedata->isDirty)
        {
            SDL_Rect rect;

            rect.x = 0;
            rect.y = 0;
            rect.w = texture->w;
            rect.h = texture->h;

            DirectFB_UpdateTexture(renderer, texture, &rect, texturedata->pixels, texturedata->pitch);
        }

        alpha = r = g = b = 0xff;
        if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA){
            alpha = texture->a;
            flags |= DSBLIT_BLEND_COLORALPHA;
        }

        if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
            r = texture->r;
            g = texture->g;
            b = texture->b;
            flags |= DSBLIT_COLORIZE;
        }
        SDL_DFB_CHECKERR(destsurf->
                         SetColor(destsurf, r, g, b, alpha));

        /* ???? flags |= DSBLIT_SRC_PREMULTCOLOR; */

        SetBlendMode(data, texture->blendMode, texturedata);

        SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf,
                                                    data->blitFlags | flags));

#if (DFB_VERSION_ATLEAST(1,2,0))
        SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
                                                    texturedata->
                                                    render_options));
#endif

        if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
            SDL_DFB_CHECKERR(destsurf->Blit(destsurf,
                                            texturedata->surface,
                                            &sr, dr.x, dr.y));
        } else {
            SDL_DFB_CHECKERR(destsurf->StretchBlit(destsurf,
                                                   texturedata->surface,
                                                   &sr, &dr));
        }
    }
    return 0;
  error:
    return -1;
}
void RenderInputPostprocess::Render(GraphicsState & glstate, std::ostream & error_output)
{
	assert(shader);

	CheckForOpenGLErrors("postprocess begin", error_output);

	glstate.SetColorMask(writecolor, writealpha);
	glstate.SetDepthMask(writedepth);

	if (clearcolor && cleardepth)
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	else if (clearcolor)
		glClear(GL_COLOR_BUFFER_BIT);
	else if (cleardepth)
		glClear(GL_DEPTH_BUFFER_BIT);

	shader->Enable();

	CheckForOpenGLErrors("postprocess shader enable", error_output);

	Mat4 projMatrix, viewMatrix;
	projMatrix.SetOrthographic(0, 1, 0, 1, -1, 1);
	viewMatrix.LoadIdentity();

	glMatrixMode(GL_PROJECTION);
	glLoadMatrixf(projMatrix.GetArray());

	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf(viewMatrix.GetArray());

	glstate.SetColor(1,1,1,1);

	SetBlendMode(glstate);

	if (writedepth || depth_mode != GL_ALWAYS)
		glstate.Enable(GL_DEPTH_TEST);
	else
		glstate.Disable(GL_DEPTH_TEST);
	glDepthFunc( depth_mode );
	glstate.Enable(GL_TEXTURE_2D);

	glActiveTexture(GL_TEXTURE0);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
	glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);

	CheckForOpenGLErrors("postprocess flag set", error_output);


	float maxu = 1.f;
	float maxv = 1.f;

	int num_nonnull = 0;
	for (unsigned int i = 0; i < source_textures.size(); i++)
	{
		//std::cout << i << ": " << source_textures[i] << std::endl;
		glActiveTexture(GL_TEXTURE0+i);
		if (source_textures[i])
		{
			source_textures[i]->Activate();
			num_nonnull++;
			if (source_textures[i]->IsRect())
			{
				maxu = source_textures[i]->GetW();
				maxv = source_textures[i]->GetH();
			}
		}
	}
	if (source_textures.size() && !num_nonnull)
	{
		error_output << "Out of the " << source_textures.size() << " input textures provided as inputs to this postprocess stage, zero are available. This stage will have no effect." << std::endl;
		return;
	}
	glActiveTexture(GL_TEXTURE0);

	CheckForOpenGLErrors("postprocess texture set", error_output);

	// build the frustum corners
	float ratio = w/h;
	std::vector <Vec3 > frustum_corners(4);
	frustum_corners[0].Set(-lod_far,-lod_far,-lod_far);	//BL
	frustum_corners[1].Set(lod_far,-lod_far,-lod_far);	//BR
	frustum_corners[2].Set(lod_far,lod_far,-lod_far);	//TR
	frustum_corners[3].Set(-lod_far,lod_far,-lod_far);	//TL
	Mat4 inv_proj;
	inv_proj.InvPerspective(camfov, ratio, 0.1, lod_far);
	for (int i = 0; i < 4; i++)
	{
		inv_proj.TransformVectorOut(frustum_corners[i][0], frustum_corners[i][1], frustum_corners[i][2]);
		frustum_corners[i][2] = -lod_far;
	}
	// frustum corners in world space for dynamic sky shader
	std::vector <Vec3 > frustum_corners_w(4);
	Mat4 inv_view_rot;
	(-cam_rotation).GetMatrix4(inv_view_rot);
	for (int i = 0; i < 4; i++)
	{
		frustum_corners_w[i] = frustum_corners[i];
		inv_view_rot.TransformVectorOut(frustum_corners_w[i][0], frustum_corners_w[i][1], frustum_corners_w[i][2]);
	}

	// send shader parameters
	{
		Vec3 lightvec = lightposition;
		cam_rotation.RotateVector(lightvec);
		shader->UploadActiveShaderParameter3f("directlight_eyespace_direction", lightvec);
		shader->UploadActiveShaderParameter1f("contrast", contrast);
		shader->UploadActiveShaderParameter1f("znear", 0.1);
		//std::cout << lightvec << std::endl;
		shader->UploadActiveShaderParameter3f("frustum_corner_bl", frustum_corners[0]);
		shader->UploadActiveShaderParameter3f("frustum_corner_br_delta", frustum_corners[1]-frustum_corners[0]);
		shader->UploadActiveShaderParameter3f("frustum_corner_tl_delta", frustum_corners[3]-frustum_corners[0]);
	}

	// draw a quad
	unsigned faces[2 * 3] = {
		0, 1, 2,
		2, 3, 0,
	};
	float pos[4 * 3] = {
		0.0f,  0.0f, 0.0f,
		1.0f,  0.0f, 0.0f,
		1.0f,  1.0f, 0.0f,
		0.0f,  1.0f, 0.0f,
	};
	// send the UV corners in UV set 0
	float tc0[4 * 2] = {
		0.0f, 0.0f,
		maxu, 0.0f,
		maxu, maxv,
		0.0f, maxv,
	};
	// send the frustum corners in UV set 1
	float tc1[4 * 3] = {
		frustum_corners[0][0], frustum_corners[0][1], frustum_corners[0][2],
		frustum_corners[1][0], frustum_corners[1][1], frustum_corners[1][2],
		frustum_corners[2][0], frustum_corners[2][1], frustum_corners[2][2],
		frustum_corners[3][0], frustum_corners[3][1], frustum_corners[3][2],
	};
	// fructum corners in world space in uv set 2
	float tc2[4 * 3] = {
		frustum_corners_w[0][0], frustum_corners_w[0][1], frustum_corners_w[0][2],
		frustum_corners_w[1][0], frustum_corners_w[1][1], frustum_corners_w[1][2],
		frustum_corners_w[2][0], frustum_corners_w[2][1], frustum_corners_w[2][2],
		frustum_corners_w[3][0], frustum_corners_w[3][1], frustum_corners_w[3][2],
	};

	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, pos);

	glClientActiveTexture(GL_TEXTURE0);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2, GL_FLOAT, 0, tc0);

	glClientActiveTexture(GL_TEXTURE1);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(3, GL_FLOAT, 0, tc1);

	glClientActiveTexture(GL_TEXTURE2);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(3, GL_FLOAT, 0, tc2);

	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, faces);

	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glClientActiveTexture(GL_TEXTURE1);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glClientActiveTexture(GL_TEXTURE0);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glDisableClientState(GL_VERTEX_ARRAY);

	CheckForOpenGLErrors("postprocess draw", error_output);

	glstate.Enable(GL_DEPTH_TEST);
	glstate.Disable(GL_TEXTURE_2D);

	for (unsigned int i = 0; i < source_textures.size(); i++)
	{
		//std::cout << i << ": " << source_textures[i] << std::endl;
		glActiveTexture(GL_TEXTURE0+i);
		if (source_textures[i])
			source_textures[i]->Deactivate();
	}
	glActiveTexture(GL_TEXTURE0);

	CheckForOpenGLErrors("postprocess end", error_output);
}
Beispiel #25
0
bool Pass::Load(const void* wrapper)
{
    EntityUtil::Ptr entityUtil = EntityUtil::Instance();
    EnumUtil::Ptr enumUtil = EnumUtil::Instance();

    std::string str;

    if (!IsObject(wrapper)) return false;

    if (!LoadMemberValue(wrapper, "camera", str))
    {
        LOGE << "Pass param 'camera' not found!";
        return false;
    }
    if (auto camNode = entityUtil->FindEntity<SceneNode>(str))
        SetCameraNode(camNode);

    if (!LoadMemberValue(wrapper, "blendMode", str))
    {
        LOGE << "Pass param 'blendMode' not found!";
        return false;
    }
    SetBlendMode(enumUtil->BlendModeFromString(str));

    if (!LoadMemberValue(wrapper, "compareMode", str))
    {
        LOGE << "Pass param 'compareMode' not found!";
        return false;
    }
    SetCompareMode(enumUtil->CompareModeFromString(str));

    if (!LoadMemberValue(wrapper, "cullMode", str))
    {
        LOGE << "Pass param 'cullMode' not found!";
        return false;
    }
    SetCullMode(enumUtil->CullModeFromString(str));

    if (!LoadMemberValue(wrapper, "drawMode", str))
    {
        LOGE << "Pass param 'drawMode' not found!";
        return false;
    }
    SetDrawMode(enumUtil->DrawModeFromString(str));

    if (!LoadMemberValue(wrapper, "index", (int&)m_RenderIndex))
    {
        LOGE << "Pass param 'index' not found!";
        return false;
    }

    if (!LoadArray(wrapper, "shaders", [&](const void* node) -> bool
{
    if (!LoadValue(node, str))
        {
            LOGE << "Pass's shader name not found!";
            return false;
        }
        if (auto shader = entityUtil->FindEntity<Shader>(str))
        {
            AddShader(shader);
            return true;
        }
        else
        {
            LOGW << "Shader " << str << " not found!";
            return false;
        }
    })) return false;

    if (!LoadArray(wrapper, "input", [&](const void* node) -> bool
{
    if (!LoadValue(node, str))
        {
            LOGE << "Pass's inputTexture name not found!";
            return false;
        }
        if (auto texture = entityUtil->FindEntity<Texture>(str))
        {
            AddTexture(texture, true);
            return true;
        }
        else
        {
            LOGW << "Input Texture " << str << " not found!";
            return false;
        }
    })) return false;

    if (!LoadArray(wrapper, "output", [&](const void* node) -> bool
{
    if (!LoadValue(node, str))
        {
            LOGE << "Pass's outputTexture name not found!";
            return false;
        }
        if (auto texture = entityUtil->FindEntity<Texture>(str))
        {
            AddTexture(texture, false);
            return true;
        }
        else
        {
            LOGW << "Output Texture " << str << " not found!";
            return false;
        }
    })) return false;

    return true;
}
Beispiel #26
0
	void PartSysParser::ParseEmitter(const TabFileRecord& record) {
		auto systemName = record[COL_PARTSYS_NAME].AsString();

		auto& system = mSpecs[tolower(systemName)];
		// Create it on demand
		if (!system) {
			system = std::make_shared<PartSysSpec>(systemName);
		}

		// Add the emitter
		auto emitter = system->CreateEmitter(record[COL_EMITTER_NAME].AsString());

		ParseOptionalFloat(record, COL_DELAY, "Delay", [&] (float value) {
			                   emitter->SetDelay(value / 30.0f);
		                   });

		ParseLifespan(record, emitter);

		ParseParticleLifespan(record, emitter);

		ParseParticleRate(record, emitter);

		ParseOptionalEnum<PartSysEmitterSpace>(record, COL_EMITTER_SPACE, "emitter space", EmitterSpaceMapping, [&](auto space) {
			                                       emitter->SetSpace(space);
		                                       });

		ParseEmitterNodeName(record, emitter);

		ParseOptionalEnum<PartSysCoordSys>(record, COL_EMITTER_COORD_SYS, "emitter coord sys", CoordSysMapping, [&](auto coordSys) {
			                                   emitter->SetCoordSys(coordSys);
		                                   });

		ParseOptionalEnum<PartSysCoordSys>(record, COL_EMITTER_OFFSET_COORD_SYS, "emitter offset coord sys", CoordSysMapping, [&](auto coordSys) {
			                                   emitter->SetOffsetCoordSys(coordSys);
		                                   });

		ParseOptionalEnum<PartSysParticleType>(record, COL_PARTICLE_TYPE, "particle type", ParticleTypeMapping, [&](PartSysParticleType type) {
			                                       emitter->SetParticleType(type);
		                                       });

		ParseOptionalEnum<PartSysBlendMode>(record, COL_BLEND_MODE, "blend mode", BlendModeMapping, [&](auto mode) {
			                                    emitter->SetBlendMode(mode);
		                                    });

		ParseMaterial(record, emitter);

		ParseOptionalEnum<PartSysCoordSys>(record, COL_PARTICLE_POS_COORD_SYS, "particle pos coord sys", CoordSysMapping, [&](auto coordSys) {
			                                   emitter->SetParticlePosCoordSys(coordSys);
		                                   });
		ParseOptionalEnum<PartSysCoordSys>(record, COL_PARTICLE_VELOCITY_COORD_SYS, "particle velocity coord sys", CoordSysMapping, [&](auto coordSys) {
			                                   emitter->SetParticleVelocityCoordSys(coordSys);
		                                   });
		ParseOptionalEnum<PartSysParticleSpace>(record, COL_PARTICLE_SPACE, "particle space", ParticleSpaceMapping, [&](auto space) {
			                                        emitter->SetParticleSpace(space);
		                                        });

		ParseMesh(record, emitter);

		// Parse the bounding box
		ParseOptionalFloat(record, COL_BB_LEFT, "bb left", [&](float val) {
			                   emitter->SetBoxLeft(val);
		                   });
		ParseOptionalFloat(record, COL_BB_TOP, "bb top", [&](float val) {
			                   emitter->SetBoxTop(val);
		                   });
		ParseOptionalFloat(record, COL_BB_RIGHT, "bb right", [&](float val) {
			                   emitter->SetBoxRight(val);
		                   });
		ParseOptionalFloat(record, COL_BB_BOTTOM, "bb bottom", [&](float val) {
			                   emitter->SetBoxBottom(val);
		                   });

		for (int paramId = 0; paramId <= part_attractorBlend; paramId++) {
			int colIdx = 22 + paramId;
			auto col = record[colIdx];
			if (col) {
				bool success;
				std::unique_ptr<PartSysParam> param(ParserParams::Parse((PartSysParamId) paramId,
				                                                        col,
				                                                        emitter->GetLifespan(),
				                                                        emitter->GetParticleLifespan(),
				                                                        success));
				if (success) {
					emitter->SetParam((PartSysParamId)paramId, param);
				} else {
					logger->warn("Unable to parse particle system param {} for particle system {} and emitter {} with value {}",
					             paramId, systemName, emitter->GetName(), col.AsString());
				}
			}
		}

	}
Beispiel #27
0
// Load():
const char * IllumiSurf_Instance::Load( const LWLoadState *loader ) {
  char cvalue;

  if( ISIOPRE_ISFV == LWLOAD_FIND( loader, illumisurf_io_isfv ) ) {
    LWLOAD_I1( loader, &cvalue, 1 );
    if( cvalue != 1 )
      return "IllumiSurf Error:  Unsupported version found, aborting load";

    while( int id = LWLOAD_FIND( loader, illumisurf_io_root ) ) {
      switch( id ) {
        case ISIOPRE_BLND:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetBlendMode( (IllumiSurf_BlendModes)cvalue );
          break;

        case ISIOPRE_BINT:
          vparam_funcs->load( GetBaseIntensity(), loader );
          break;

        case ISIOPRE_AINT:
          vparam_funcs->load( GetAltIntensity(), loader );
          break;

        case ISIOPRE_COLR:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseColor( cvalue != 0 );
          vparam_funcs->load( GetColor(), loader );
          break;

        case ISIOPRE_LUMI:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseLuminosity( cvalue != 0 );
          vparam_funcs->load( GetLuminosity(), loader );
          break;

        case ISIOPRE_DIFF:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseDiffusion( cvalue != 0 );
          vparam_funcs->load( GetDiffusion(), loader );
          break;

        case ISIOPRE_SPEC:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseSpecular( cvalue != 0 );
          vparam_funcs->load( GetSpecular(), loader );
          break;

        case ISIOPRE_GLOS:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseGlossiness( cvalue != 0 );
          vparam_funcs->load( GetGlossiness(), loader );
          break;

        case ISIOPRE_REFL:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseReflection( cvalue != 0 );
          vparam_funcs->load( GetReflection(), loader );
          break;

        case ISIOPRE_TRNP:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseTransparency( cvalue != 0 );
          vparam_funcs->load( GetTransparency(), loader );
          break;

        case ISIOPRE_REFR:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseRefraction( cvalue != 0 );
          vparam_funcs->load( GetRefraction(), loader );
          break;

        case ISIOPRE_TRNC:
          LWLOAD_I1( loader, &cvalue, 1 );
          SetUseTranslucency( cvalue != 0 );
          vparam_funcs->load( GetTranslucency(), loader );
          break;
      }

      LWLOAD_END( loader );            // End Keyword
    }

    LWLOAD_END( loader );            // End Keyword
  }

  return NULL;
}
Beispiel #28
0
static int
DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
                    const SDL_Rect * srcrect, const SDL_Rect * dstrect)
{
    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    SDL_DFB_WINDOWSURFACE(data->window);
    DirectFB_TextureData *texturedata =
        (DirectFB_TextureData *) texture->driverdata;
    Uint8 alpha = 0xFF;
    DFBResult ret;

    if (texturedata->display) {
        int px, py;
        SDL_Window *window = SDL_GetWindowFromID(renderer->window);
        SDL_DFB_WINDOWDATA(window);
        SDL_VideoDisplay *display = texturedata->display;
        DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;

        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetSourceRectangle(dispdata->vidlayer,
                                                      srcrect->x, srcrect->y,
                                                      srcrect->w,
                                                      srcrect->h));
        windata->window->GetPosition(windata->window, &px, &py);
        px += windata->client.x;
        py += windata->client.y;
        SDL_DFB_CHECKERR(dispdata->
                         vidlayer->SetScreenRectangle(dispdata->vidlayer,
                                                      px + dstrect->x,
                                                      py + dstrect->y,
                                                      dstrect->w,
                                                      dstrect->h));
    } else {
        DFBRectangle sr, dr;
        DFBSurfaceBlittingFlags flags = 0;

        if (texturedata->dirty.list) {
            SDL_DirtyRect *dirty;
            void *pixels;
            int bpp = SDL_BYTESPERPIXEL(texture->format);
            int pitch = texturedata->pitch;

            for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
                SDL_Rect *rect = &dirty->rect;
                pixels =
                    (void *) ((Uint8 *) texturedata->pixels +
                              rect->y * pitch + rect->x * bpp);
                DirectFB_UpdateTexture(renderer, texture, rect,
                                       texturedata->pixels,
                                       texturedata->pitch);
            }
            SDL_ClearDirtyRects(&texturedata->dirty);
        }

        SDLtoDFBRect(srcrect, &sr);
        SDLtoDFBRect(dstrect, &dr);

        SDL_DFB_CHECKERR(destsurf->
                         SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF));
        if (texture->
            modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA))
        {
            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
                alpha = texture->a;
                SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
                                                    0xFF, alpha));
            }
            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {

                SDL_DFB_CHECKERR(destsurf->SetColor(destsurf,
                                                    texture->r,
                                                    texture->g,
                                                    texture->b, alpha));
                flags |= DSBLIT_COLORIZE;
            }
            if (alpha < 0xFF)
                flags |= DSBLIT_SRC_PREMULTCOLOR;
        } else
            SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
                                                0xFF, 0xFF));

        SetBlendMode(data, texture->blendMode, texturedata);

        SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf,
                                                    data->blitFlags | flags));

#if (DFB_VERSION_ATLEAST(1,2,0))
        SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
                                                    texturedata->
                                                    render_options));
#endif

        if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
            SDL_DFB_CHECKERR(destsurf->Blit(destsurf,
                                            texturedata->surface,
                                            &sr, dr.x, dr.y));
        } else {
            SDL_DFB_CHECKERR(destsurf->StretchBlit(destsurf,
                                                   texturedata->surface,
                                                   &sr, &dr));
        }
    }
    return 0;
  error:
    return -1;
}
Beispiel #29
0
void Actor::HandleCommand( const ParsedCommand &command )
{
	HandleParams;

	const CString& sName = sParam(0);

	// Commands that go in the tweening queue:
	if     ( sName=="sleep" )			Sleep( fParam(1) );
	else if( sName=="linear" )			BeginTweening( fParam(1), TWEEN_LINEAR );
	else if( sName=="accelerate" )		BeginTweening( fParam(1), TWEEN_ACCELERATE );
	else if( sName=="decelerate" )		BeginTweening( fParam(1), TWEEN_DECELERATE );
	else if( sName=="bouncebegin" )		BeginTweening( fParam(1), TWEEN_BOUNCE_BEGIN );
	else if( sName=="bounceend" )		BeginTweening( fParam(1), TWEEN_BOUNCE_END );
	else if( sName=="spring" )			BeginTweening( fParam(1), TWEEN_SPRING );
	else if( sName=="stoptweening" )	{ StopTweening(); BeginTweening( 0.0001f, TWEEN_LINEAR ); }	// Why BeginT again? -Chris
	else if( sName=="finishtweening" )	FinishTweening();
	else if( sName=="hurrytweening" )	HurryTweening( fParam(1) );
	else if( sName=="x" )				SetX( fParam(1) );
	else if( sName=="y" )				SetY( fParam(1) );
	else if( sName=="z" )				SetZ( fParam(1) );
	else if( sName=="addx" )			SetX( GetDestX()+fParam(1) );
	else if( sName=="addy" )			SetY( GetDestY()+fParam(1) );
	else if( sName=="addz" )			SetZ( GetDestZ()+fParam(1) );
	else if( sName=="zoom" )			SetZoom( fParam(1) );
	else if( sName=="zoomx" )			SetZoomX( fParam(1) );
	else if( sName=="zoomy" )			SetZoomY( fParam(1) );
	else if( sName=="zoomz" )			SetZoomZ( fParam(1) );
	else if( sName=="zoomtowidth" )		ZoomToWidth( fParam(1) );
	else if( sName=="zoomtoheight" )	ZoomToHeight( fParam(1) );
	else if( sName=="stretchto" )		StretchTo( RectF( fParam(1), fParam(2), fParam(3), fParam(4) ) );
	else if( sName=="cropleft" )		SetCropLeft( fParam(1) );
	else if( sName=="croptop" )			SetCropTop( fParam(1) );
	else if( sName=="cropright" )		SetCropRight( fParam(1) );
	else if( sName=="cropbottom" )		SetCropBottom( fParam(1) );
	else if( sName=="fadeleft" )		SetFadeLeft( fParam(1) );
	else if( sName=="fadetop" )			SetFadeTop( fParam(1) );
	else if( sName=="faderight" )		SetFadeRight( fParam(1) );
	else if( sName=="fadebottom" )		SetFadeBottom( fParam(1) );
	else if( sName=="fadecolor" )		SetFadeDiffuseColor( cParam(1) );
	else if( sName=="diffuse" )			SetDiffuse( cParam(1) );
	else if( sName=="diffuseleftedge" )		SetDiffuseLeftEdge( cParam(1) );
	else if( sName=="diffuserightedge" )	SetDiffuseRightEdge( cParam(1) );
	else if( sName=="diffusetopedge" )		SetDiffuseTopEdge( cParam(1) );
	else if( sName=="diffusebottomedge" )	SetDiffuseBottomEdge( cParam(1) );
	/* Add left/right/top/bottom for alpha if needed. */
	else if( sName=="diffusealpha" )	SetDiffuseAlpha( fParam(1) );
	else if( sName=="diffusecolor" )	SetDiffuseColor( cParam(1) );
	else if( sName=="glow" )			SetGlow( cParam(1) );
	else if( sName=="glowmode" ) {
		if(!sParam(1).CompareNoCase("whiten"))
			SetGlowMode( GLOW_WHITEN );
		else if(!sParam(1).CompareNoCase("brighten"))
			SetGlowMode( GLOW_BRIGHTEN );
		else ASSERT(0);
	}
	else if( sName=="rotationx" )		SetRotationX( fParam(1) );
	else if( sName=="rotationy" )		SetRotationY( fParam(1) );
	else if( sName=="rotationz" )		SetRotationZ( fParam(1) );
	else if( sName=="heading" )			AddRotationH( fParam(1) );
	else if( sName=="pitch" )			AddRotationP( fParam(1) );
	else if( sName=="roll" ) 			AddRotationR( fParam(1) );
	else if( sName=="shadowlength" )	SetShadowLength( fParam(1) );
	else if( sName=="horizalign" )		SetHorizAlign( sParam(1) );
	else if( sName=="vertalign" )		SetVertAlign( sParam(1) );
	else if( sName=="diffuseblink" )	SetEffectDiffuseBlink();
	else if( sName=="diffuseshift" )	SetEffectDiffuseShift();
	else if( sName=="glowblink" )		SetEffectGlowBlink();
	else if( sName=="glowshift" )		SetEffectGlowShift();
	else if( sName=="rainbow" )			SetEffectRainbow();
	else if( sName=="wag" )				SetEffectWag();
	else if( sName=="bounce" )			SetEffectBounce();
	else if( sName=="bob" )				SetEffectBob();
	else if( sName=="pulse" )			SetEffectPulse();
	else if( sName=="spin" )			SetEffectSpin();
	else if( sName=="vibrate" )			SetEffectVibrate();
	else if( sName=="stopeffect" )		SetEffectNone();
	else if( sName=="effectcolor1" )	SetEffectColor1( cParam(1) );
	else if( sName=="effectcolor2" )	SetEffectColor2( cParam(1) );
	else if( sName=="effectperiod" )	SetEffectPeriod( fParam(1) );
	else if( sName=="effectoffset" )	SetEffectOffset( fParam(1) );
	else if( sName=="effectdelay" )		SetEffectDelay( fParam(1) );
	else if( sName=="effectclock" )		SetEffectClock( sParam(1) );
	else if( sName=="effectmagnitude" )	SetEffectMagnitude( RageVector3(fParam(1),fParam(2),fParam(3)) );
	else if( sName=="scaletocover" )	{ RectI R(iParam(1), iParam(2), iParam(3), iParam(4));  ScaleToCover(R); }
	else if( sName=="scaletofit" )		{ RectI R(iParam(1), iParam(2), iParam(3), iParam(4));  ScaleToFitInside(R); }
	// Commands that take effect immediately (ignoring the tweening queue):
	else if( sName=="animate" )			EnableAnimation( bParam(1) );
	else if( sName=="setstate" )		SetState( iParam(1) );
	else if( sName=="texturewrapping" )	SetTextureWrapping( bParam(1) );
	else if( sName=="additiveblend" )	SetBlendMode( bParam(1) ? BLEND_ADD : BLEND_NORMAL );
	else if( sName=="blend" )			SetBlendMode( sParam(1) );
	else if( sName=="zbuffer" )			SetUseZBuffer( bParam(1) );
	else if( sName=="ztest" )			SetZTestMode( bParam(1)?ZTEST_WRITE_ON_PASS:ZTEST_OFF );
	else if( sName=="ztestmode" )		SetZTestMode( sParam(1) );
	else if( sName=="zwrite" )			SetZWrite( bParam(1) );
	else if( sName=="clearzbuffer" )	SetClearZBuffer( bParam(1) );
	else if( sName=="backfacecull" )	SetCullMode( bParam(1) ? CULL_BACK : CULL_NONE );
	else if( sName=="cullmode" )		SetCullMode( sParam(1) );
	else if( sName=="hidden" )			SetHidden( bParam(1) );
	else if( sName=="hibernate" )		SetHibernate( fParam(1) );
	else if( sName=="draworder" )		SetDrawOrder( iParam(1) );
	else if( sName=="playcommand" )		PlayCommand( sParam(1) );
	else if( sName=="queuecommand" )	
	{
		ParsedCommand newcommand = command;
		newcommand.vTokens.erase( newcommand.vTokens.begin() );
		QueueCommand( newcommand );
		return;	// don't do parameter number checking
	}

	/* These are commands intended for a Sprite commands, but they will get 
	 * sent to all sub-actors (which aren't necessarily Sprites) on 
	 * GainFocus and LoseFocus.  So, don't run CheckHandledParams 
	 * on these commands. */
	else if( sName=="customtexturerect" || sName=="texcoordvelocity" || sName=="scaletoclipped" ||
		 sName=="stretchtexcoords" || sName=="position" || sName=="loop" || sName=="play" ||
		 sName=="pause" || sName=="rate" )
		return;
	else
	{
		CString sError = ssprintf( "Actor::HandleCommand: Unrecognized command name '%s'.", sName.c_str() );
		LOG->Warn( sError );
		Dialog::OK( sError );
	}

	CheckHandledParams;
}