Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper::OpenGLFramebuffer Class Reference

#include <OpenGLFramebuffer.h>

Inheritance diagram for Vesper::OpenGLFramebuffer:
Vesper::Framebuffer

Public Member Functions

 OpenGLFramebuffer (const FramebufferSpecification &spec)
virtual ~OpenGLFramebuffer ()
void Invalidate ()
virtual void Bind () override
virtual void Unbind () override
virtual void Resize (uint32_t width, uint32_t height) override
 Resizes the framebuffer to the given width and height.
virtual uint32_t GetColorAttachmentRendererID () const override
 Returns the renderer ID of the color attachment texture.
virtual const FramebufferSpecificationGetSpecification () const
 Returns the specification used to create the framebuffer.
Public Member Functions inherited from Vesper::Framebuffer
 ~Framebuffer ()=default

Private Attributes

uint32_t m_RendererID
uint32_t m_ColorAttachment
uint32_t m_DepthAttachment
FramebufferSpecification m_Specification

Additional Inherited Members

Static Public Member Functions inherited from Vesper::Framebuffer
static Ref< FramebufferCreate (const FramebufferSpecification &spec)
 Creates a framebuffer with the given specification.

Constructor & Destructor Documentation

◆ OpenGLFramebuffer()

Vesper::OpenGLFramebuffer::OpenGLFramebuffer ( const FramebufferSpecification & spec)
12 : m_Specification(spec)
13 {
14 Invalidate();
15 }
void Invalidate()
Definition OpenGLFramebuffer.cpp:24
FramebufferSpecification m_Specification
Definition OpenGLFramebuffer.h:26

References Invalidate(), and m_Specification.

◆ ~OpenGLFramebuffer()

Vesper::OpenGLFramebuffer::~OpenGLFramebuffer ( )
virtual
18 {
19 glDeleteFramebuffers(1, &m_RendererID);
20 glDeleteTextures(1, &m_ColorAttachment);
21 glDeleteTextures(1, &m_DepthAttachment);
22 }
uint32_t m_DepthAttachment
Definition OpenGLFramebuffer.h:25
uint32_t m_ColorAttachment
Definition OpenGLFramebuffer.h:25
uint32_t m_RendererID
Definition OpenGLFramebuffer.h:24

References m_ColorAttachment, m_DepthAttachment, and m_RendererID.

Member Function Documentation

◆ Bind()

void Vesper::OpenGLFramebuffer::Bind ( )
overridevirtual

Implements Vesper::Framebuffer.

57 {
58 glBindFramebuffer(GL_FRAMEBUFFER, m_RendererID);
59 glViewport(0, 0, m_Specification.Width, m_Specification.Height);
60 }

References Vesper::FramebufferSpecification::Height, m_Specification, and Vesper::FramebufferSpecification::Width.

◆ GetColorAttachmentRendererID()

virtual uint32_t Vesper::OpenGLFramebuffer::GetColorAttachmentRendererID ( ) const
inlineoverridevirtual

Returns the renderer ID of the color attachment texture.

Implements Vesper::Framebuffer.

19{ return m_ColorAttachment; }

References m_ColorAttachment.

◆ GetSpecification()

virtual const FramebufferSpecification & Vesper::OpenGLFramebuffer::GetSpecification ( ) const
inlinevirtual

Returns the specification used to create the framebuffer.

Implements Vesper::Framebuffer.

20{ return m_Specification; }

References m_Specification.

◆ Invalidate()

void Vesper::OpenGLFramebuffer::Invalidate ( )
25 {
26 if (m_RendererID)
27 {
28 glDeleteFramebuffers(1, &m_RendererID);
29 glDeleteTextures(1, &m_ColorAttachment);
30 glDeleteTextures(1, &m_DepthAttachment);
31 }
32
33 glCreateFramebuffers(1, &m_RendererID);
34 glBindFramebuffer(GL_FRAMEBUFFER, m_RendererID);
35
36 glCreateTextures(GL_TEXTURE_2D, 1, &m_ColorAttachment);
37 glBindTexture(GL_TEXTURE_2D, m_ColorAttachment);
38 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Specification.Width, m_Specification.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
39 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
40 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
41
42 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_ColorAttachment, 0);
43
44 glCreateTextures(GL_TEXTURE_2D, 1, &m_DepthAttachment);
45 glBindTexture(GL_TEXTURE_2D, m_DepthAttachment);
46 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_Specification.Width, m_Specification.Height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
47
48 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthAttachment, 0);
49
50 VZ_CORE_ASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Framebuffer is complete!");
51
52 glBindFramebuffer(GL_FRAMEBUFFER, 0);
53
54 }
#define VZ_CORE_ASSERT(x,...)
Definition Asserts.h:20

References m_ColorAttachment, m_DepthAttachment, and m_RendererID.

Referenced by OpenGLFramebuffer(), and Resize().

◆ Resize()

void Vesper::OpenGLFramebuffer::Resize ( uint32_t width,
uint32_t height )
overridevirtual

Resizes the framebuffer to the given width and height.

Implements Vesper::Framebuffer.

68 {
69 if (width == 0 || height == 0 || width > 8192 || height > 8192)
70 {
71 VZ_CORE_WARN("Attempted to resize framebuffer to {0}, {1}", width, height);
72 return;
73 }
74 m_Specification.Width = width;
75 m_Specification.Height = height;
76 Invalidate();
77 }
#define VZ_CORE_WARN(...)
warn: indicates a potential issue or important event
Definition Log.h:39

References Vesper::FramebufferSpecification::Height, Invalidate(), m_Specification, and Vesper::FramebufferSpecification::Width.

◆ Unbind()

void Vesper::OpenGLFramebuffer::Unbind ( )
overridevirtual

Implements Vesper::Framebuffer.

63 {
64 glBindFramebuffer(GL_FRAMEBUFFER, 0);
65 }

Member Data Documentation

◆ m_ColorAttachment

uint32_t Vesper::OpenGLFramebuffer::m_ColorAttachment
private

◆ m_DepthAttachment

uint32_t Vesper::OpenGLFramebuffer::m_DepthAttachment
private

Referenced by Invalidate(), and ~OpenGLFramebuffer().

◆ m_RendererID

uint32_t Vesper::OpenGLFramebuffer::m_RendererID
private

Referenced by Invalidate(), and ~OpenGLFramebuffer().

◆ m_Specification

FramebufferSpecification Vesper::OpenGLFramebuffer::m_Specification
private

The documentation for this class was generated from the following files: