mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 14:53:01 +02:00
clening and getting ready for pr
This commit is contained in:
parent
c7049bad39
commit
dff598ebd1
4 changed files with 25 additions and 1 deletions
|
@ -205,6 +205,13 @@ void Batch::setViewportTransform(const Vec4i& viewport) {
|
|||
_params.push_back(cacheData(sizeof(Vec4i), &viewport));
|
||||
}
|
||||
|
||||
void Batch::setDepthRangeTransform(float nearDepth, float farDepth) {
|
||||
ADD_COMMAND(setDepthRangeTransform);
|
||||
|
||||
_params.push_back(farDepth);
|
||||
_params.push_back(nearDepth);
|
||||
}
|
||||
|
||||
void Batch::setPipeline(const PipelinePointer& pipeline) {
|
||||
ADD_COMMAND(setPipeline);
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ public:
|
|||
void setProjectionTransform(const Mat4& proj);
|
||||
// Viewport is xy = low left corner in framebuffer, zw = width height of the viewport, expressed in pixels
|
||||
void setViewportTransform(const Vec4i& viewport);
|
||||
void setDepthRangeTransform(float nearDepth, float farDepth);
|
||||
|
||||
// Pipeline Stage
|
||||
void setPipeline(const PipelinePointer& pipeline);
|
||||
|
@ -285,6 +286,7 @@ public:
|
|||
COMMAND_setViewTransform,
|
||||
COMMAND_setProjectionTransform,
|
||||
COMMAND_setViewportTransform,
|
||||
COMMAND_setDepthRangeTransform,
|
||||
|
||||
COMMAND_setPipeline,
|
||||
COMMAND_setStateBlendFactor,
|
||||
|
|
|
@ -314,6 +314,7 @@ protected:
|
|||
void do_setViewTransform(Batch& batch, uint32 paramOffset);
|
||||
void do_setProjectionTransform(Batch& batch, uint32 paramOffset);
|
||||
void do_setViewportTransform(Batch& batch, uint32 paramOffset);
|
||||
void do_setDepthRangeTransform(Batch& batch, uint32 paramOffset);
|
||||
|
||||
void initTransform();
|
||||
void killTransform();
|
||||
|
@ -339,6 +340,7 @@ protected:
|
|||
Transform _view;
|
||||
Mat4 _projection;
|
||||
Vec4i _viewport{ 0, 0, 1, 1 };
|
||||
Vec2 _depthRange{ 0.0f, 1.0f };
|
||||
bool _invalidModel{true};
|
||||
bool _invalidView{false};
|
||||
bool _invalidProj{false};
|
||||
|
|
|
@ -45,10 +45,21 @@ void GLBackend::do_setViewportTransform(Batch& batch, uint32 paramOffset) {
|
|||
|
||||
glViewport(vp.x, vp.y, vp.z, vp.w);
|
||||
|
||||
// The Viewport is tagged invalid because the CameraTransformUBO is not up to date and willl need update on next drawcall
|
||||
// The Viewport is tagged invalid because the CameraTransformUBO is not up to date and will need update on next drawcall
|
||||
_transform._invalidViewport = true;
|
||||
}
|
||||
|
||||
void GLBackend::do_setDepthRangeTransform(Batch& batch, uint32 paramOffset) {
|
||||
|
||||
Vec2 depthRange(batch._params[paramOffset + 0]._float, batch._params[paramOffset + 1]._float);
|
||||
|
||||
if ((depthRange.x != _transform._depthRange.x) || (depthRange.y != _transform._depthRange.y)) {
|
||||
_transform._depthRange = depthRange;
|
||||
|
||||
glDepthRangef(depthRange.x, depthRange.y);
|
||||
}
|
||||
}
|
||||
|
||||
void GLBackend::initTransform() {
|
||||
glGenBuffers(1, &_transform._objectBuffer);
|
||||
glGenBuffers(1, &_transform._cameraBuffer);
|
||||
|
@ -75,6 +86,8 @@ void GLBackend::syncTransformStateCache() {
|
|||
|
||||
glGetIntegerv(GL_VIEWPORT, (GLint*) &_transform._viewport);
|
||||
|
||||
glGetFloatv(GL_DEPTH_RANGE, (GLfloat*)&_transform._depthRange);
|
||||
|
||||
Mat4 modelView;
|
||||
auto modelViewInv = glm::inverse(modelView);
|
||||
_transform._view.evalFromRawMatrix(modelViewInv);
|
||||
|
|
Loading…
Reference in a new issue