本文整理汇总了C++中Floor::drawFloor方法的典型用法代码示例。如果您正苦于以下问题:C++ Floor::drawFloor方法的具体用法?C++ Floor::drawFloor怎么用?C++ Floor::drawFloor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Floor
的用法示例。
在下文中一共展示了Floor::drawFloor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
/* Called to update the display. Note that this function is called in the event loop in the wrapper
class because we registered display as a callback function */
void display()
{
/* Define the background colour */
if (weather == 0)
glClearColor(0.25f, 0.7f, 1.0f, 1.0f);
else
glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
/* Clear the colour and frame buffers */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* Enable depth test */
glEnable(GL_DEPTH_TEST);
/* Make the compiled shader program current */
glUseProgram(program);
/* Bind cube colours. Note that this is in attribute index 1 */
glBindBuffer(GL_ARRAY_BUFFER, colourObject);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, 0);
// Define the model transformations for the cube
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(x, y, z));
model = glm::scale(model, glm::vec3(scale, scale, scale));//scale equally in all axis
model = glm::rotate(model, -angle_x, glm::vec3(1, 0, 0)); //rotating in clockwise direction around x-axis
model = glm::rotate(model, -angle_y, glm::vec3(0, 1, 0)); //rotating in clockwise direction around y-axis
model = glm::rotate(model, -angle_z, glm::vec3(0, 0, 1)); //rotating in clockwise direction around z-axis
// Projection matrix : 45° Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units
glm::mat4 Projection = glm::perspective(30.0f, aspect_ratio, 0.1f, 100.0f);
// Camera matrix
glm::mat4 View = glm::lookAt(
glm::vec3(0, 0.8, 6), // Camera is at (0,0,4), in World Space
glm::vec3(0, 0.8, 0), // and looks at 1 on the y
glm::vec3(0, 1, 0) // Head is up (set to 0,-1,0 to look upside-down)
);
// Send our uniforms variables to the currently bound shader,
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model[0][0]);
glUniform1ui(colourmodeID, weather);
glUniformMatrix4fv(viewID, 1, GL_FALSE, &View[0][0]);
glUniformMatrix4fv(projectionID, 1, GL_FALSE, &Projection[0][0]);
flooring.drawFloor();
walls.drawRoom();
//sky.drawSky();
for (int i = 0; i < planters.size(); i++) {
SquarePlanter planter = planters[i];
planter.drawSquarePlanter();
}
glm::mat4 model2 = model;
model2 = glm::scale(model2, glm::vec3(3.0f, 3.0f, 3.0f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model2[0][0]);
birchTree.drawObject();
glm::mat4 model3 = glm::translate(model2, glm::vec3(1.0f, 0.0f, -0.5f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model3[0][0]);
tree2.drawObject();
glm::mat4 model4 = glm::translate(model2, glm::vec3(-0.6f, 0.0f, -0.5f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model4[0][0]);
tree3.drawObject();
glm::mat4 model5 = glm::translate(model2, glm::vec3(0.4f, 0.0f, 0.2f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model5[0][0]);
tree4.drawObject();
glm::mat4 model6 = glm::translate(model2, glm::vec3(-0.4f, 0.0f, -0.2f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model6[0][0]);
tree5.drawObject();
glm::mat4 model7 = glm::translate(model2, glm::vec3(0.1f, 0.0f, 0.8f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model7[0][0]);
tree6.drawObject();
glm::mat4 model8 = glm::translate(model2, glm::vec3(0.0f, 0.0f, -0.5f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model8[0][0]);
tree7.drawObject();
glm::mat4 model9 = glm::translate(model2, glm::vec3(-1.0f, 0.0f, 0.2f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model9[0][0]);
tree8.drawObject();
glm::mat4 model10 = glm::translate(model2, glm::vec3(0.5f, 0.0f, -0.4f));
glUniformMatrix4fv(modelID, 1, GL_FALSE, &model10[0][0]);
tree9.drawObject();
if (weather == 2)
snow->drawObject(0);
//.........这里部分代码省略.........