本文整理汇总了C++中Model::GetMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ Model::GetMaterial方法的具体用法?C++ Model::GetMaterial怎么用?C++ Model::GetMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::GetMaterial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
void Demo::Init(const Options* options) {
glGenTextures(1, &mColTex);
glBindTexture(GL_TEXTURE_2D, mColTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, WindowWidth, WindowHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glGenTextures(1, &mDepthTex);
glBindTexture(GL_TEXTURE_2D, mDepthTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, WindowWidth, WindowHeight, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
glGenFramebuffers(1, &mFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mColTex, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, mDepthTex, 0);
ASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
glFrontFace(GL_CW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glClearColor(0.0f, 0.125f, 0.3f, 1.0f);
mEffect.Create();
mEffect.FromByteFile(std::string(options->fragmentFile));
mEffect.FromByteFile(std::string(options->vertexFile));
mEffect.Link();
gWorld = Matrix4::identity();
Point3 Eye( 0.0f, 0.0f, -800 );
Point3 At( 0.0f, 0.0f, 0.0f );
Vector3 Up( 0.0f, 1.0f, 0.0f );
gView = Matrix4::lookAt(Eye, At, Up);
ResizeDisplay(WindowWidth, WindowHeight);
gModel.Import3DFromFile("models/Tiny.x");
mPostFXEnabled = false;
if(options->postprocessFile)
{
mPostFXEnabled = true;
mPostProcessEffect.Create();
mPostProcessEffect.FromByteFile(std::string(options->postprocessFile));
mPostProcessEffect.FromByteFile(std::string("shaders/generic/templatePostFXVS.o"));
mPostProcessEffect.Link();
glGenVertexArrays(1, &mPostFXVAO);
glBindVertexArray(mPostFXVAO);
//Vertex setup for post-process quad
uint32_t indices[] =
{
1, 0, 3,
2, 3, 0
};
glGenBuffers(1, &mPostFXIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mPostFXIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32_t) * 6,
indices, GL_STATIC_DRAW);
PostProcessVertex vertices[] =
{
{-1, -1, 0},
{1, -1, 0},
{-1, 1, 0},
{1, 1, 0}
};
glGenBuffers(1, &mPostFXVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mPostFXVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(PostProcessVertex) * 4,
vertices, GL_STATIC_DRAW);
}
mComputeEnabled = false;
if(options->computeFile)
{
mComputeEnabled = true;
mCompute.Create();
mCompute.SetLanguage(LANG_430);
mCompute.FromByteFile(std::string(options->computeFile));
mCompute.Link();
gModel.GetMaterial().BindForLoadStore(GL_WRITE_ONLY);
}
}