本文整理汇总了C++中Quad::update方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::update方法的具体用法?C++ Quad::update怎么用?C++ Quad::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quad
的用法示例。
在下文中一共展示了Quad::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateScene
void ColoredCubeApp::updateScene(float dt)
{
D3DApp::updateScene(dt);
xLine.update(dt);
yLine.update(dt);
zLine.update(dt);
quad1.update(dt);
quad2.update(dt);
quad3.update(dt);
quad4.update(dt);
quad5.update(dt);
for(int i = 0; i < WALL_SIZE; ++i) {
wall[i].update(dt);
}
D3DXVECTOR3 pos(0.0f,0.0f,15.0f);
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&mView, &pos, &target, &up);
}
示例2: main
int main() {
std::string dataRoot;
#ifdef DATA_ROOT
dataRoot = DATA_ROOT;
#else
std::cerr << "No DATA_ROOT path found" << std::endl;
return -1;
#endif
GLFWwindow *window = nullptr;
if (initWindow(window)) {
return -1;
}
Shader shader(dataRoot + "/data/shaders/shader.vert", dataRoot + "/data/shaders/shader.frag");
Texture textures(dataRoot + "/data/assets/textures.png");
Texture normals(dataRoot + "/data/assets/normals.png");
std::vector<GLfloat> vertices;
std::vector<GLuint> indices;
std::vector<Quad> quads;
Map map(10, 10);
for (int x = 0; x < map.getWidth(); ++x) {
for (int y = 0; y < map.getHeight(); ++y) {
if (map.isPassable(x, y)) {
quads.push_back(Quad(glm::vec3(x, 0, -y), glm::vec3(0, 0, -1), glm::vec3(1, 0, 0), 0.5f, 0.0f));
quads.push_back(Quad(glm::vec3(x, 1, -y), glm::vec3(1, 0, 0), glm::vec3(0, 0, -1), 0.0f, 0.5f));
}
for (int direction = 0; direction < 4; ++direction) {
int cx = x + dx[direction];
int cy = y + dy[direction];
if (map.isPassable(x, y) && !map.isPassable(cx, cy)) {
quads.push_back(Quad(
glm::vec3(x, 0, -y) + WALL_SHIFT[direction],
glm::vec3(0, 1, 0),
WALL_DIRECTION[direction],
0.0f,
0.0f
));
}
}
}
}
for (int index = 0; index < quads.size(); ++index) {
Quad quad = quads[index];
quad.update(vertices);
indices.push_back(GLuint(4 * index + 0));
indices.push_back(GLuint(4 * index + 1));
indices.push_back(GLuint(4 * index + 2));
indices.push_back(GLuint(4 * index + 2));
indices.push_back(GLuint(4 * index + 3));
indices.push_back(GLuint(4 * index + 0));
}
GLuint VBO, VAO, EBO;
createBuffers(VBO, VAO, EBO, vertices, indices);
glm::mat4 projection = glm::perspective(45.0f, WIDTH / (float) HEIGHT, 0.1f, 100.0f);
glm::vec3 lamp(map.getWidth() / 2, 0.9f, -map.getHeight() / 2);
float time = (float) glfwGetTime();
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
float cTime = (float) glfwGetTime();
float delta = cTime - time;
time = cTime;
update(map, delta);
glClearColor(117 / 255.0f, 187 / 255.0f, 253 / 255.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shader.use();
GLint textureLocation = glGetUniformLocation(shader.get(), "textureSampler");
glUniform1i(textureLocation, 0);
GLint normalLocation = glGetUniformLocation(shader.get(), "normalSampler");
glUniform1i(normalLocation, 1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures.get());
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, normals.get());
GLfloat timeValue = (GLfloat) glfwGetTime();
GLfloat xValue = (GLfloat) (sin(timeValue) / 4) + 0.25f;
GLint xValueLocation = glGetUniformLocation(shader.get(), "xValue");
glUniform1f(xValueLocation, xValue);
//.........这里部分代码省略.........