本文整理汇总了C++中Quad::drawGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::drawGeometry方法的具体用法?C++ Quad::drawGeometry怎么用?C++ Quad::drawGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quad
的用法示例。
在下文中一共展示了Quad::drawGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notifyDisplayFrame
//functia de afisare (lucram cu banda grafica)
void notifyDisplayFrame() {
// Deseneaza doar daca s-a modificat pozitia camerei sau perspectiva (a fost apasata o tasta).
if (modified) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Foloseste shaderul.
glUseProgram(gl_program_shader);
// Trimite variabile uniforme la shader.
glUniformMatrix4fv(glGetUniformLocation(gl_program_shader, "projection_matrix"), 1, false, glm::value_ptr(projection_matrix));
glUniform1i(glGetUniformLocation(gl_program_shader, "tps_color"), 0);
glUniform3f(glGetUniformLocation(gl_program_shader, "light_position"),
view1->getPosition().x, view1->getPosition().y, view1->getPosition().z);
glUniform3f(glGetUniformLocation(gl_program_shader, "eye_position"),
view1->getPosition().x, view1->getPosition().y, view1->getPosition().z);
glUniform3f(glGetUniformLocation(gl_program_shader, "light_direction"),
view1->getForward().x, view1->getForward().y, view1->getForward().z);
glUniform1i(glGetUniformLocation(gl_program_shader, "material_shininess"), material_shininess);
if (is_fps)
vehicle->drawGeometry(gl_program_shader, textures.size());
view_matrix = is_fps ? view1->getViewMatrix() : view2->getViewMatrix();
glUniformMatrix4fv(glGetUniformLocation(gl_program_shader, "view_matrix"), 1, false, glm::value_ptr(view_matrix));
glUniform1f(glGetUniformLocation(gl_program_shader, "material_kd"), is_fps ? material_kd : 0);
glUniform1f(glGetUniformLocation(gl_program_shader, "material_ks"), is_fps ? material_ks : 0);
std::vector<glm::vec4> plane_coefs;
glm::mat4 pv = projection_matrix * view1->getViewMatrix();
// Calculeaza coeficientii ecuatiilor pentru planurile frustumului.
plane_coefs.push_back(glm::vec4(pv[0][3] + pv[0][0], pv[1][3] + pv[1][0], pv[2][3] + pv[2][0], pv[3][3] + pv[3][0])); // left
plane_coefs.push_back(glm::vec4(pv[0][3] - pv[0][0], pv[1][3] - pv[1][0], pv[2][3] - pv[2][0], pv[3][3] - pv[3][0])); // right
plane_coefs.push_back(glm::vec4(pv[0][3] + pv[0][1], pv[1][3] + pv[1][1], pv[2][3] + pv[2][1], pv[3][3] + pv[3][1])); // bottom
plane_coefs.push_back(glm::vec4(pv[0][3] - pv[0][1], pv[1][3] - pv[1][1], pv[2][3] - pv[2][1], pv[3][3] - pv[3][1])); // top
plane_coefs.push_back(glm::vec4(pv[0][3] + pv[0][2], pv[1][3] + pv[1][2], pv[2][3] + pv[2][2], pv[3][3] + pv[3][2])); // near
plane_coefs.push_back(glm::vec4(pv[0][3] - pv[0][2], pv[1][3] - pv[1][2], pv[2][3] - pv[2][2], pv[3][3] - pv[3][2])); // far
quad->drawGeometry(gl_program_shader, is_fps, plane_coefs);
city->draw(gl_program_shader, is_fps, plane_coefs);
modified = false;
}
}
示例2: notifyDisplayFrame
// Functia de afisare (lucram cu banda grafica)
void notifyDisplayFrame() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, screen_width, screen_height);
glUseProgram(gl_program_shader);
glUniformMatrix4fv(glGetUniformLocation(gl_program_shader, "view_matrix"), 1, false, glm::value_ptr(cams[cam_index]->getViewMatrix()));
glUniformMatrix4fv(glGetUniformLocation(gl_program_shader, "projection_matrix"), 1, false, glm::value_ptr(projection_matrix));
glUniform3f(glGetUniformLocation(gl_program_shader, "light_position"), light_position.x, light_position.y, light_position.z);
glUniform3f(glGetUniformLocation(gl_program_shader, "eye_position"),
cams[cam_index]->getPosition().x, cams[cam_index]->getPosition().y, cams[cam_index]->getPosition().z);
glUniform1i(glGetUniformLocation(gl_program_shader, "material_shininess"), material_shininess);
glUniform1f(glGetUniformLocation(gl_program_shader, "material_kd"), material_kd);
glUniform1f(glGetUniformLocation(gl_program_shader, "material_ks"), material_ks);
glUniform1f(glGetUniformLocation(gl_program_shader, "x_quake"), -1);
quad->drawGeometry(gl_program_shader);
if(x_quake > -1) {
// In timpul unui cutremur trimit variabilele uniforme corespunzatoare
// la shader.
glUniform1f(glGetUniformLocation(gl_program_shader, "x_quake"), x_quake);
float y_quake = amplitude * cos(frequency * x_quake),
z_quake = amplitude * sin(frequency * x_quake);
glUniform1f(glGetUniformLocation(gl_program_shader, "y_quake"), y_quake);
glUniform1f(glGetUniformLocation(gl_program_shader, "z_quake"), z_quake);
}
main_character->drawGeometry(gl_program_shader);
main_slope->drawGeometry(gl_program_shader);
// Restul obiectelor nu tin cont de cutremur.
glUniform1f(glGetUniformLocation(gl_program_shader, "x_quake"), -1);
for (int i = 0; i < characters.size(); ++i) {
if (characters[i] != main_character)
characters[i]->drawGeometry(gl_program_shader);
if (characters[i] == main_character || characters[i] == second_character)
characters[i]->drawGeometryCam(gl_program_shader);
}
second_slope->drawGeometry(gl_program_shader);
}