Overte C++ Documentation
Skybox.h
1 //
2 // Skybox.h
3 // libraries/graphics/src/graphics
4 //
5 // Created by Sam Gateau on 5/4/2015.
6 // Copyright 2015 High Fidelity, Inc.
7 // Copyright 2024 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 //
12 #ifndef hifi_model_Skybox_h
13 #define hifi_model_Skybox_h
14 
15 #include <gpu/Texture.h>
16 
17 #include "Light.h"
18 
19 class ViewFrustum;
20 
21 namespace gpu { class Batch; }
22 
23 namespace graphics {
24 
25 typedef glm::vec3 Color;
26 
27 class Skybox {
28 public:
29  typedef gpu::BufferView UniformBufferView;
30 
31  Skybox();
32  Skybox& operator= (const Skybox& skybox);
33  virtual ~Skybox() {};
34 
35  void setColor(const Color& color);
36  const Color getColor() const { return _schemaBuffer.get<Schema>().color; }
37 
38  void setCubemap(const gpu::TexturePointer& cubemap);
39  const gpu::TexturePointer& getCubemap() const { return _cubemap; }
40 
41  void setOrientation(const glm::quat& orientation);
42  const glm::quat getOrientation() const { return _orientation; }
43 
44  virtual bool empty() { return _empty; }
45  virtual void clear();
46 
47  void prepare(gpu::Batch& batch) const;
48  virtual void render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward, uint transformSlot) const;
49 
50  static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox, bool forward, uint transformSlot);
51 
52  const UniformBufferView& getSchemaBuffer() const { return _schemaBuffer; }
53 
54 protected:
55  class Schema {
56  public:
57  glm::vec3 color { 0.0f, 0.0f, 0.0f };
58  float blend { 0.0f };
59  };
60 
61  void updateSchemaBuffer() const;
62 
63  mutable gpu::BufferView _schemaBuffer;
64  gpu::TexturePointer _cubemap;
65  glm::quat _orientation;
66 
67  bool _empty{ true };
68 };
69 typedef std::shared_ptr<Skybox> SkyboxPointer;
70 
71 };
72 
73 #endif //hifi_model_Skybox_h