1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-29 03:33:48 +00:00
Aquaria/BBGE/RenderState.h
fgenesis 1a90625979 refactor rendering logic to be a lot less wasteful
Observations:
- Entity::renderPass was never set to RENDER_ALL -> can simplify some things
- The initial pass check in RenderObject::render() was constant for each pass
-> All logic that is per-pass-constant can be moved to a renderability pre-check
- Core::overrideStartLayer, Core::overrideEndLayer, Core::rlayer were never used
- Should be possible eventually to prepare & render layers in parallel

I am not sure if the changes in this commit are 100% correct, but layer passes
are still working and the hug looks like it should.

Thinking about it, the overrideRenderPass functionality should never have existed.
The game scripts don't actually use entity_setRenderPass
(which in turn calls Entity::setOverrideRenderPass())
so I might remove that function in a future commit,
together with the rest of the "override" functionality.
2022-05-22 17:26:16 +02:00

44 lines
827 B
C++

#ifndef BBGE_RENDERSTATE_H
#define BBGE_RENDERSTATE_H
#include "Vector.h"
#include "EngineEnums.h"
struct CombinedRenderAndGPUState;
// Only once of these exists at any time.
// It stores the known GPU state so that we don't need so many futile state changes
struct GPUState
{
friend struct CombinedRenderAndGPUState;
GPUState();
void setBlend(BlendType bt);
private:
BlendType _blendType;
};
// The RenderState is passed through the scene graph as each layer is rendered
// TODO: what needs to end up here? matrix stack too?
struct RenderState
{
GPUState& gpu;
Vector color;
float alpha;
int pass;
protected:
RenderState(GPUState& gpu);
};
struct CombinedRenderAndGPUState : public RenderState
{
GPUState gpu;
CombinedRenderAndGPUState() : RenderState(gpu) {}
};
#endif