Esempio n. 1
0
void CFontFace::NewPage()
{
    SharePtr<CTexture> texture = new CTexture;
    texture->InitWithData(nullptr, 0, PixelFormat::A8, PAGE_WIDTH, PAGE_HEIGHT);
    ++m_nCurrPage;
    m_textures.push_back(texture);

    SharePtr<CMaterial> material = CFontManager::GetInstance()->CreateDefaultMaterial();
    material->SetTexture(0, texture);
    m_materialMap[texture->ID()] = material;
}
SharePtr<CMaterial> CComponentGraphic_GL::CreateMaterial(const TString &textureFileName)
{
    SharePtr<CMaterial> material = new CMaterial(true);
    material->GetRenderState()->SetBoolState(GL_DEPTH_TEST, true);
    material->GetRenderState()->SetBoolState(GL_ALPHA_TEST, true);
    material->GetRenderState()->SetAlphaFunc(GL_GREATER);
    material->GetRenderState()->SetAlphaRef(0);
    material->GetRenderState()->SetBoolState(GL_BLEND, true);
    material->GetRenderState()->SetBlendFuncSrcFactor(GL_SRC_ALPHA);
    material->GetRenderState()->SetBlendFuncTargetFactor(GL_ONE_MINUS_SRC_ALPHA);
    SharePtr<CShader> pVS = CResourceManager::GetInstance()->GetResource<CShader>(_T("PointTexShader.vs"), false);
    SharePtr<CShader> pPS = CResourceManager::GetInstance()->GetResource<CShader>(_T("PointTexShader.ps"), false);
    BEATS_ASSERT(pVS && pPS, _T("Load Shader Failed!"));
    CShaderProgram *program = CRenderManager::GetInstance()->GetShaderProgram(pVS->ID(), pPS->ID());
    material->GetRenderState()->SetShaderProgram(program->ID());
    SharePtr<CTexture> texture = CResourceManager::GetInstance()->GetResource<CTexture>(textureFileName, false);
    BEATS_ASSERT(texture, _T("Create Component Texture Failed!"));
    material->SetTexture(0, texture);
    return material;
}