void Track::display(glutil::MatrixStack model_matrix) { //glutil::PushStack push(model_matrix); //model_matrix.do_stuff(...); glutil::PushStack push(model_matrix); //model_matrix.Translate(position_); model_matrix.ApplyMatrix(transformation_.Top()); glm::mat3 normal_model_to_world_matrix; glUseProgram(top_track_program_data_.program); glBindVertexArray(top_track_program_data_.vao); glUniformMatrix4fv(top_track_program_data_.model_to_clip_mat_unif, 1, GL_FALSE, glm::value_ptr(model_matrix.Top())); glUniformMatrix3fv(top_track_program_data_.normal_model_to_world_mat_unif, 1, GL_FALSE, glm::value_ptr(normal_model_to_world_matrix)); glUniform3fv(top_track_program_data_.dir_to_light_unif, 1, glm::value_ptr(bezier_game_->get_dir_to_light())); glUniform4fv(top_track_program_data_.light_intensity_unif, 1, glm::value_ptr(bezier_game_->get_light_intensity())); glUniform4fv(top_track_program_data_.ambient_intensity_unif, 1, glm::value_ptr(bezier_game_->get_ambient_intensity())); glDrawArrays(GL_TRIANGLE_STRIP, 0, bezier_points_amount_ * 2); glBindVertexArray(0); glUseProgram(0); glUseProgram(bottom_track_program_data_.program); glBindVertexArray(bottom_track_program_data_.vao); glUniformMatrix4fv(bottom_track_program_data_.model_to_clip_mat_unif, 1, GL_FALSE, glm::value_ptr(model_matrix.Top())); glUniformMatrix3fv(bottom_track_program_data_.normal_model_to_world_mat_unif, 1, GL_FALSE, glm::value_ptr(normal_model_to_world_matrix)); glUniform3fv(bottom_track_program_data_.dir_to_light_unif, 1, glm::value_ptr(bezier_game_->get_dir_to_light())); glUniform4fv(bottom_track_program_data_.light_intensity_unif, 1, glm::value_ptr(bezier_game_->get_light_intensity())); glUniform4fv(bottom_track_program_data_.ambient_intensity_unif, 1, glm::value_ptr(bezier_game_->get_ambient_intensity())); glDrawArrays(GL_TRIANGLE_STRIP, bezier_points_amount_ * 2, bezier_points_amount_ * 2); glBindVertexArray(0); glUseProgram(0); }
void PlayerCar::display(glutil::MatrixStack model_matrix) { glutil::PushStack push(model_matrix); //model_matrix.Translate(position_); //model_matrix.ApplyMatrix(rotation_.Top()); //model_matrix.Scale(scale_); model_matrix.ApplyMatrix(transformation_.Top()); glm::mat3 normal_model_to_world_matrix(rotation_.Top()); glUseProgram(player_car_program_data_.program); glBindVertexArray(player_car_program_data_.vao); glUniformMatrix4fv(player_car_program_data_.model_to_clip_mat_unif, 1, GL_FALSE, glm::value_ptr(model_matrix.Top())); glUniformMatrix3fv(player_car_program_data_.normal_model_to_world_mat_unif, 1, GL_FALSE, glm::value_ptr(normal_model_to_world_matrix)); glUniform3fv(player_car_program_data_.dir_to_light_unif, 1, glm::value_ptr(bezier_game_->get_dir_to_light())); glUniform4fv(player_car_program_data_.light_intensity_unif, 1, glm::value_ptr(bezier_game_->get_light_intensity())); glUniform4fv(player_car_program_data_.ambient_intensity_unif, 1, glm::value_ptr(bezier_game_->get_ambient_intensity())); glDrawElements(GL_TRIANGLES, player_car_index_data_.size(), GL_UNSIGNED_SHORT, 0); glBindVertexArray(0); glUseProgram(0); }