💿🐜 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.

91 lines
2.8 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 "render/passes/ui-pass.hpp"
  20. #include "resources/resource-manager.hpp"
  21. #include "gl/rasterizer.hpp"
  22. #include "gl/framebuffer.hpp"
  23. #include "gl/shader-program.hpp"
  24. #include "gl/shader-input.hpp"
  25. #include "gl/vertex-buffer.hpp"
  26. #include "gl/vertex-array.hpp"
  27. #include "gl/vertex-attribute.hpp"
  28. #include "gl/drawing-mode.hpp"
  29. #include "gl/texture-2d.hpp"
  30. #include "gl/texture-wrapping.hpp"
  31. #include "gl/texture-filter.hpp"
  32. #include "render/vertex-attribute.hpp"
  33. #include "render/material-flags.hpp"
  34. #include "render/context.hpp"
  35. #include "scene/camera.hpp"
  36. #include "scene/collection.hpp"
  37. #include "scene/ambient-light.hpp"
  38. #include "scene/directional-light.hpp"
  39. #include "scene/billboard.hpp"
  40. #include <cmath>
  41. #include <glad/glad.h>
  42. namespace render {
  43. ui_pass::ui_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager):
  44. pass(rasterizer, framebuffer)
  45. {}
  46. ui_pass::~ui_pass()
  47. {}
  48. void ui_pass::render(const render::context& ctx, render::queue& queue) const
  49. {
  50. glEnable(GL_BLEND);
  51. glDisable(GL_DEPTH_TEST);
  52. glDepthMask(GL_FALSE);
  53. glCullFace(GL_BACK);
  54. auto viewport = framebuffer->get_dimensions();
  55. rasterizer->set_viewport(0, 0, std::get<0>(viewport), std::get<1>(viewport));
  56. float4x4 view = ctx.camera->get_view_tween().interpolate(ctx.alpha);
  57. float4x4 projection = ctx.camera->get_projection_tween().interpolate(ctx.alpha);
  58. float4x4 view_projection = projection * view;
  59. float4x4 model_view_projection;
  60. // Collect billboards
  61. std::list<scene::object_base*> billboards = *ctx.collection->get_objects(scene::billboard::object_type_id);
  62. // Sort billboards
  63. // Rebuild vertex buffer
  64. }
  65. const ui_pass::parameter_set* ui_pass::load_parameter_set(const gl::shader_program* program) const
  66. {
  67. // Allocate a new parameter set
  68. parameter_set* parameters = new parameter_set();
  69. // Connect inputs
  70. parameters->time = program->get_input("time");
  71. parameters->model_view_projection = program->get_input("model_view_projection");
  72. // Add parameter set to map of parameter sets
  73. parameter_sets[program] = parameters;
  74. return parameters;
  75. }
  76. } // namespace render