Exemple #1
0
int main(int argc, char **argv)
{

    Engine* engine = new Engine();
    engine->Init();

    engine->GetShader_Manager()->CreateProgram("cubeShader",
            "Shaders\\Cube_Vertex_Shader.glsl",
            "Shaders\\Cube_Fragment_Shader.glsl");

    CubeTexture* cube = new CubeTexture();
    int program = engine->GetShader_Manager()->GetShader("cubeShader");
    if (program != 0)
    {
        cube->SetProgram(program);
        cube->Create();
    }
    else
    {
        std::cout << "invalid program...";
        std::cin.get();
    }
    unsigned int texture = engine->GetTexture_Loader()->LoadTexture("Textures\\Crate.bmp", 256, 256);
    cube->SetTexture("Create",texture);

    engine->GetModels_Manager()->SetModel("cube", cube);

    engine->Run();

    delete engine;
    return 0;
}
//=======================================================================================
//		public method
//=======================================================================================
//-------------------------------------------------------------
//!	@brief		: example
//!	@param[in]	: example
//!	@return		: example
//-------------------------------------------------------------
ITexture* CubeTextureFactory::CreateTexture()
{
	CubeTexture* out = NEW CubeTexture();

	IDirect3DCubeTexture9* tex = NULL;

	out->SetTexture(&tex);

	return out;
}
//-------------------------------------------------------------
//!	@brief		: example
//!	@param[in]	: example
//!	@return		: example
//-------------------------------------------------------------
ITexture* CubeTextureFactory::CreateTextureFromFile(const std::string& filePath)
{
	CubeTexture* out = NEW CubeTexture();

	IDirect3DCubeTexture9* tex = NULL;

	USES_CONVERSION;

	D3DXCreateCubeTextureFromFile(
		GraphicsManager::GetInstance()->GetD3DDevice(),
		A2W(filePath.c_str()),
		&tex);

	out->SetTexture(&tex);
	return out;
}