💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.1 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "renderer/passes/ui-pass.hpp"
  20. #include "resources/resource-manager.hpp"
  21. #include "rasterizer/rasterizer.hpp"
  22. #include "rasterizer/framebuffer.hpp"
  23. #include "rasterizer/shader.hpp"
  24. #include "rasterizer/shader-type.hpp"
  25. #include "rasterizer/shader-program.hpp"
  26. #include "rasterizer/shader-input.hpp"
  27. #include "rasterizer/vertex-buffer.hpp"
  28. #include "rasterizer/vertex-array.hpp"
  29. #include "rasterizer/vertex-attribute-type.hpp"
  30. #include "rasterizer/drawing-mode.hpp"
  31. #include "rasterizer/texture-2d.hpp"
  32. #include "rasterizer/texture-wrapping.hpp"
  33. #include "rasterizer/texture-filter.hpp"
  34. #include "renderer/vertex-attributes.hpp"
  35. #include "renderer/material-flags.hpp"
  36. #include "renderer/render-context.hpp"
  37. #include "scene/camera.hpp"
  38. #include "scene/collection.hpp"
  39. #include "scene/ambient-light.hpp"
  40. #include "scene/directional-light.hpp"
  41. #include "scene/billboard.hpp"
  42. #include "math/math.hpp"
  43. #include <cmath>
  44. #include <glad/glad.h>
  45. ui_pass::ui_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager):
  46. render_pass(rasterizer, framebuffer),
  47. time(0.0f)
  48. {}
  49. ui_pass::~ui_pass()
  50. {}
  51. void ui_pass::render(render_context* context) const
  52. {
  53. glEnable(GL_BLEND);
  54. glDisable(GL_DEPTH_TEST);
  55. glDepthMask(GL_FALSE);
  56. glCullFace(GL_BACK);
  57. auto viewport = framebuffer->get_dimensions();
  58. rasterizer->set_viewport(0, 0, std::get<0>(viewport), std::get<1>(viewport));
  59. float4x4 view = context->camera->get_view_tween().interpolate(context->alpha);
  60. float4x4 projection = context->camera->get_projection_tween().interpolate(context->alpha);
  61. float4x4 view_projection = projection * view;
  62. float4x4 model_view_projection;
  63. // Collect billboards
  64. std::list<scene::object_base*> billboards = *context->collection->get_objects(scene::billboard::object_type_id);
  65. // Sort billboards
  66. // Rebuild vertex buffer
  67. }
  68. void ui_pass::set_time(float time)
  69. {
  70. this->time = time;
  71. }
  72. const ui_pass::parameter_set* ui_pass::load_parameter_set(const shader_program* program) const
  73. {
  74. // Allocate a new parameter set
  75. parameter_set* parameters = new parameter_set();
  76. // Connect inputs
  77. parameters->time = program->get_input("time");
  78. parameters->model_view_projection = program->get_input("model_view_projection");
  79. // Add parameter set to map of parameter sets
  80. parameter_sets[program] = parameters;
  81. return parameters;
  82. }