CCVRGenericRenderer.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /****************************************************************************
  2. Copyright (c) 2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef CCVRGenericRenderer_hpp
  22. #define CCVRGenericRenderer_hpp
  23. #include "vr/CCVRProtocol.h"
  24. #include "renderer/CCCustomCommand.h"
  25. #include "renderer/CCFrameBuffer.h"
  26. NS_CC_BEGIN
  27. class Camera;
  28. class Sprite;
  29. class DistortionMesh;
  30. class Distortion;
  31. class GLProgramState;
  32. class VRGenericHeadTracker;
  33. struct CC_DLL VREye
  34. {
  35. enum class EyeType {
  36. MONO,
  37. LEFT,
  38. RIGHT,
  39. };
  40. EyeType type;
  41. experimental::Viewport viewport;
  42. };
  43. class CC_DLL VRGenericRenderer : public VRIRenderer
  44. {
  45. public:
  46. VRGenericRenderer();
  47. virtual ~VRGenericRenderer();
  48. virtual void setup(GLView* glview) override;
  49. virtual void cleanup() override;
  50. virtual void render(Scene* scene, Renderer* renderer) override;
  51. virtual VRIHeadTracker* getHeadTracker() override;
  52. protected:
  53. void setupGLProgram();
  54. void renderDistortionMesh(DistortionMesh *mesh, Texture2D* texture);
  55. DistortionMesh* createDistortionMesh(VREye::EyeType eyeType);
  56. experimental::FrameBuffer* _fb;
  57. Size _texSize;
  58. VREye _leftEye;
  59. VREye _rightEye;
  60. DistortionMesh* _leftDistortionMesh;
  61. DistortionMesh* _rightDistortionMesh;
  62. Distortion* _distortion;
  63. bool _vignetteEnabled;
  64. GLProgramState* _glProgramState;
  65. VRGenericHeadTracker* _headTracker;
  66. };
  67. NS_CC_END
  68. #endif // CCVRGenericRenderer_hpp