コード例 #1
0
ファイル: System.cpp プロジェクト: nobitalwm/FCEngine
void CSystem::InitShader()
{
    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!"));
    m_pProgram = CRenderManager::GetInstance()->GetShaderProgram(pVS->ID(), pPS->ID());
}
コード例 #2
0
SharePtr<CMaterial> CFontManager::CreateDefaultMaterial(bool bBitmapFont)
{
    if(!m_pProgramFreetypeText)
    {
        SharePtr<CShader> pVS = CResourceManager::GetInstance()->
            GetResource<CShader>(_T("TextShader.vs"));
        SharePtr<CShader> pPS = CResourceManager::GetInstance()->
            GetResource<CShader>(_T("TextShader.ps"));
        BEATS_ASSERT(pVS && pPS, _T("Load Shader Failed!"));
        m_pProgramFreetypeText = CRenderManager::GetInstance()->GetShaderProgram(pVS->ID(), pPS->ID());
    }
    if(!m_pProgramBitmapText)
    {
        SharePtr<CShader> pVS = CResourceManager::GetInstance()->
            GetResource<CShader>(_T("PointTexShader.vs"));
        SharePtr<CShader> pPS = CResourceManager::GetInstance()->
            GetResource<CShader>(_T("PointTexShader.ps"));
        BEATS_ASSERT(pVS && pPS, _T("Load Shader Failed!"));
        m_pProgramBitmapText = CRenderManager::GetInstance()->GetShaderProgram(pVS->ID(), pPS->ID());
    }
    SharePtr<CMaterial> material = new CMaterial();
    material->GetRenderState()->SetBoolState(CBoolRenderStateParam::eBSP_ScissorTest, false);
    material->GetRenderState()->SetBoolState(CBoolRenderStateParam::eBSP_Blend, true);
    material->GetRenderState()->SetBlendFuncSrcFactor(GL_SRC_ALPHA);
    material->GetRenderState()->SetBlendFuncTargetFactor(GL_ONE_MINUS_SRC_ALPHA);
    material->GetRenderState()->SetShaderProgram(bBitmapFont ? m_pProgramBitmapText->ID() : m_pProgramFreetypeText->ID());

    return material;
}
コード例 #3
0
CSpriteFrameBatchManager::CSpriteFrameBatchManager()
{
    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!"));
    m_pProgram = CRenderManager::GetInstance()->GetShaderProgram(pVS->ID(), pPS->ID());
    m_pCamera = new CCamera(CCamera::eCT_2D);
    int width, height;
    CRenderManager::GetInstance()->GetWindowSize(width, height);
    m_pCamera->SetWidth(width);
    m_pCamera->SetHeight(height);
}
コード例 #4
0
ファイル: FontFace.cpp プロジェクト: nobitalwm/FCEngine
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;
}
コード例 #5
0
void CSpriteFrameBatchManager::AddQuad( const CQuadPT &quad, SharePtr<CTexture> texture )
{
    if(texture)
	{
	    GLuint textureID = texture->ID();
	    auto itr = m_batches.find(textureID);
		CSpriteFrameBatch *batch = nullptr;
	    if(itr == m_batches.end())
	    {
	        batch = new CSpriteFrameBatch;
	        m_batches[textureID] = batch;
	    }
	    else
	    {
	        batch = itr->second;
	    }
		batch->AddQuad(quad, texture);
	}
}
コード例 #6
0
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;
}