Norbert's Game Engine v200
Loading...
Searching...
No Matches
eLayer Class Reference

#include <Layer.hpp>

Inheritance diagram for eLayer:
eBase

Public Member Functions

 eLayer (bool useFramebuffer=true)
 
bool Initialize ()
 
void Unload ()
 
void Update (vec2 size)
 
void SetViewport (eViewport3D *viewport)
 
eViewport3D * GetViewport ()
 
eLayerProperties & GetProperties ()
 
eFramebuffer & GetFramebuffer ()
 
- Public Member Functions inherited from eBase
template<typename T >
T * Cast (eBase *obj)
 Cast class to base.
 

Static Public Attributes

static bool mRefreshSize = true
 

Detailed Description

Layer class

Definition at line 47 of file Layer.hpp.

Constructor & Destructor Documentation

◆ eLayer()

eLayer::eLayer ( bool useFramebuffer = true)

Definition at line 11 of file Layer.cpp.

12{
13 mFramebuffer.mFbh = BGFX_INVALID_HANDLE;
14 mFramebuffer.mTexture = BGFX_INVALID_HANDLE;
15 mFramebuffer.mDepthMap = BGFX_INVALID_HANDLE;
16 bUseFramebuffer = useFramebuffer;
17}

◆ ~eLayer()

eLayer::~eLayer ( )

Definition at line 19 of file Layer.cpp.

20{
21 Unload();
22}

Member Function Documentation

◆ GetFramebuffer()

eFramebuffer & eLayer::GetFramebuffer ( )

Definition at line 183 of file Layer.cpp.

184{
185 return mFramebuffer;
186}

◆ GetProperties()

eLayerProperties & eLayer::GetProperties ( )

Definition at line 178 of file Layer.cpp.

179{
180 return mProperties;
181}

◆ GetViewport()

eViewport3D * eLayer::GetViewport ( )

Definition at line 173 of file Layer.cpp.

174{
175 return mViewport;
176}

◆ Initialize()

bool eLayer::Initialize ( )

Definition at line 24 of file Layer.cpp.

25{
26 bgfx::setViewMode(mProperties.mViewId, bgfx::ViewMode::DepthDescending);
27 UpdateFB(vec2i(static_cast<int>(mProperties.mResolution.x), static_cast<int>(mProperties.mResolution.y)));
28 SetFBViewId(mProperties.mViewId);
29 bgfx::setViewRect(mProperties.mViewId, (uint16)mProperties.mPosition.x, (uint16)mProperties.mPosition.y, static_cast<uint16>(mProperties.mResolution.x), static_cast<uint16>(mProperties.mResolution.y));
30 bgfx::setViewScissor(mProperties.mViewId, (uint16)mProperties.mPosition.x, (uint16)mProperties.mPosition.y, static_cast<uint16>(mProperties.mResolution.x), static_cast<uint16>(mProperties.mResolution.y));
31 uint16 flags = BGFX_CLEAR_NONE;
32 if (mProperties.bTopMost)
33 flags |= BGFX_CLEAR_DEPTH;
34 if (!mProperties.bTransparent)
35 flags |= BGFX_CLEAR_COLOR;
36
37 bgfx::setViewClear(mProperties.mViewId, flags, mProperties.mClearColor, 1.0f, 0);
38 return true;
39}

◆ SetViewport()

void eLayer::SetViewport ( eViewport3D * viewport)

Definition at line 168 of file Layer.cpp.

169{
170 mViewport = viewport;
171}

◆ Unload()

void eLayer::Unload ( )

Definition at line 41 of file Layer.cpp.

42{
43 DestroyFB();
44}

◆ Update()

void eLayer::Update ( vec2 size)

Definition at line 46 of file Layer.cpp.

47{
48 if (mRefreshSize)
49 {
50 if (mProperties.bUpdateSize)
51 {
52 mProperties.mResolution = size;
53 mProperties.mAspectRatio = mProperties.mResolution;
54 }
55
56 if (bgfx::isValid(mFramebuffer.mFbh))
57 {
58 DestroyFB();
59 UpdateFB(vec2i(static_cast<int>(mProperties.mResolution.x), static_cast<int>(mProperties.mResolution.y)));
60 SetFBViewId(mProperties.mViewId);
61 }
62
63 bgfx::setViewRect(mProperties.mViewId, (uint16)mProperties.mPosition.x, (uint16)mProperties.mPosition.y, static_cast<uint16>(mProperties.mResolution.x), static_cast<uint16>(mProperties.mResolution.y)); //bgfx::BackbufferRatio::Equal
64 bgfx::setViewScissor(mProperties.mViewId, (uint16)mProperties.mPosition.x, (uint16)mProperties.mPosition.y, static_cast<uint16>(mProperties.mResolution.x), static_cast<uint16>(mProperties.mResolution.y));
65 }
66
67 if (!mProperties.bIs2D)
68 {
69 if (mViewport != nullptr)
70 mViewport->Update(mProperties.mViewId, mProperties.mAspectRatio.x / mProperties.mAspectRatio.y, 0.1f, 9999999.0f);
71 }
72
73 uint16 flags = BGFX_CLEAR_NONE;
74 if (mProperties.bTopMost)
75 flags |= BGFX_CLEAR_DEPTH;
76 if (!mProperties.bTransparent)
77 flags |= BGFX_CLEAR_COLOR;
78
79 bgfx::setViewClear(mProperties.mViewId, flags, mProperties.mClearColor, 1.0f, 0);
80}

Member Data Documentation

◆ mRefreshSize

bool eLayer::mRefreshSize = true
static

Definition at line 62 of file Layer.hpp.


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