Overte C++ Documentation
oculusMobile/src/ovr/Framebuffer.h
1 //
2 // Created by Bradley Austin Davis on 2018/11/20
3 // Copyright 2013-2018 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 #pragma once
9 
10 #include <cstdint>
11 #include <glm/glm.hpp>
12 #include <glad/glad.h>
13 
14 #include <VrApi_Types.h>
15 
16 namespace ovr {
17 
18 struct Framebuffer {
19 public:
20  void updateLayer(int eye, ovrLayerProjection2& layer, const ovrMatrix4f* projectionMatrix = nullptr) const;
21  void create(const glm::uvec2& size);
22  void advance();
23  void destroy();
24  void bind(GLenum target = GL_DRAW_FRAMEBUFFER);
25  void invalidate(GLenum target = GL_DRAW_FRAMEBUFFER);
26  void drawBuffers(ovrEye eye) const;
27 
28  const glm::uvec2& size() const { return _size; }
29 
30 private:
31  uint32_t _fbo{ 0 };
32  glm::uvec2 _size;
33  struct SwapChainInfo {
34  int length{ -1 };
35  int index{ -1 };
36  bool validTexture{ false };
37  ovrTextureSwapChain* swapChain{ nullptr };
38 
39  void create(const glm::uvec2& size);
40  void destroy();
41  void advance();
42  void bind(GLenum target, GLenum attachment);
43  };
44 
45  SwapChainInfo _swapChainInfos[VRAPI_FRAME_LAYER_EYE_MAX];
46 };
47 
48 } // namespace ovr