gdk-graphics 0b051eb9b5c1eaa0658babaa4463dd7a80aa9d2c
Loading...
Searching...
No Matches
webgl1es2_texture_camera.h
1// © Joseph Cameron - All Rights Reserved
2
3#ifndef GDK_GFX_WEBGL1ES2_TEXTURE_CAMERA_H
4#define GDK_GFX_WEBGL1ES2_TEXTURE_CAMERA_H
5
6#include <gdk/color.h>
7#include <gdk/graphics_types.h>
8#include <gdk/texture_camera.h>
9#include <gdk/webgl1es2_camera.h>
10#include <gdk/webgl1es2_texture.h>
11
12#include <jfc/unique_handle.h>
13
14#include <memory>
15#include <optional>
16#include <vector>
17
18namespace gdk {
19 class entity;
20
22 class webgl1es2_texture_camera final : public texture_camera, public webgl1es2_camera {
23 public:
26 //
27 virtual void set_perspective_projection(const float aFieldOfView,
28 const float aNearClippingPlane,
29 const float aFarClippingPlane,
30 const float aViewportAspectRatio) override;
31
32 virtual void set_orthographic_projection(const float aWidth,
33 const float aHeight,
34 const float aNearClippingPlane,
35 const float aFarClippingPlane,
36 const float aViewportAspectRatio) override;
37
38 virtual void set_clear_color(const gdk::color& acolor) override;
39
40 virtual void set_clear_mode(const clear_mode aClearMode) override;
41
42 virtual void set_transform(const gdk::graphics_vector3_type& aWorldPos,
43 const gdk::graphics_quaternion_type& aRotation) override;
44 virtual void set_transform(const gdk::graphics_matrix4x4_type &aMatrix) override;
45
46 virtual const std::shared_ptr<gdk::texture> get_color_texture(const size_t i) const override;
47
48 virtual const std::shared_ptr<gdk::texture> get_depth_texture() const override;
50
53 //
54 void activate() const;
56
57 webgl1es2_texture_camera(const graphics_intvector2_type &textureSize = {1024, 1024});
58
59 ~webgl1es2_texture_camera() = default;
60
61 private:
62 graphics_intvector2_type m_TextureSize;
63
65 jfc::unique_handle<GLuint> m_FrameBufferHandle;
66
68 jfc::unique_handle<GLuint> m_DepthBuffer;
69
71 mutable std::optional<std::shared_ptr<webgl1es2_texture>> m_ColorBufferTexture;
72
74 mutable std::optional<std::shared_ptr<webgl1es2_texture>> m_DepthBufferTexture;
75 };
76}
77
78#endif
79
clear_mode
controls which buffers in the active frame buffer object to clear
Definition camera.h:13
represents an observable 3d object.
Definition entity.h:13
texture camera renders to textures instead of the screen
Definition texture_camera.h:12
webgl1es2_camera(const webgl1es2_camera &a)=default
copy semantics
webgl1es2_camera implementation of texture_camera
Definition webgl1es2_texture_camera.h:22
virtual void set_clear_color(const gdk::color &acolor) override
sets the clear color, used to fill color buffer after it is cleared.
virtual const std::shared_ptr< gdk::texture > get_depth_texture() const override
get the texture attached to the depth buffer
virtual void set_perspective_projection(const float aFieldOfView, const float aNearClippingPlane, const float aFarClippingPlane, const float aViewportAspectRatio) override
sets the projection matrix to a perspective projection
virtual void set_clear_mode(const clear_mode aClearMode) override
clear mode decides which buffers to clear. see enum
virtual void set_orthographic_projection(const float aWidth, const float aHeight, const float aNearClippingPlane, const float aFarClippingPlane, const float aViewportAspectRatio) override
sets the projection matrix to an orthographic projection
virtual void set_transform(const gdk::graphics_vector3_type &aWorldPos, const gdk::graphics_quaternion_type &aRotation) override
checks whether a point in world space is within the camera's frustum
virtual const std::shared_ptr< gdk::texture > get_color_texture(const size_t i) const override
get a texture attached to the color buffer
Represents a 4 channel color: {Red, Green, Blue, Alpha}. TODO: channel values should be limited to th...
Definition color.h:11