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