OpenGLRenderer: Fix Y flipping for FBOs
This commit is contained in:
@@ -106,6 +106,7 @@ namespace Nz
|
||||
std::optional<Nz::Recti> scissorRegion;
|
||||
std::optional<Nz::Recti> viewportRegion;
|
||||
std::vector<VertexBuffer> vertexBuffers;
|
||||
bool shouldFlipY = false;
|
||||
};
|
||||
|
||||
struct DrawData
|
||||
|
||||
@@ -142,6 +142,8 @@ namespace Nz
|
||||
std::copy(clearValues.begin(), clearValues.end(), setFramebuffer.clearValues.begin());
|
||||
|
||||
m_commands.emplace_back(std::move(setFramebuffer));
|
||||
|
||||
m_currentStates.shouldFlipY = (framebuffer.GetType() == OpenGLFramebuffer::Type::Window);
|
||||
}
|
||||
|
||||
inline void OpenGLCommandBuffer::SetScissor(Nz::Recti scissorRegion)
|
||||
|
||||
@@ -24,11 +24,15 @@ namespace Nz
|
||||
|
||||
void Apply(const GL::Context& context) const;
|
||||
|
||||
void FlipY(bool shouldFlipY) const;
|
||||
|
||||
inline const RenderPipelineInfo& GetPipelineInfo() const override;
|
||||
|
||||
private:
|
||||
RenderPipelineInfo m_pipelineInfo;
|
||||
GL::Program m_program;
|
||||
GLint m_flipYUniformLocation;
|
||||
mutable bool m_isYFlipped;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,14 @@ namespace Nz::GL
|
||||
|
||||
inline void AttachShader(GLuint shader);
|
||||
|
||||
inline bool GetLinkStatus(std::string* error = nullptr);
|
||||
inline bool GetLinkStatus(std::string* error = nullptr) const;
|
||||
inline GLint GetUniformLocation(const char* uniformName) const;
|
||||
inline GLint GetUniformLocation(const std::string& uniformName) const;
|
||||
|
||||
inline void Link();
|
||||
|
||||
inline void Uniform(GLint uniformLocation, float value) const;
|
||||
|
||||
Program& operator=(const Program&) = delete;
|
||||
Program& operator=(Program&&) noexcept = default;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Nz::GL
|
||||
context.glAttachShader(m_objectId, shader);
|
||||
}
|
||||
|
||||
inline bool Program::GetLinkStatus(std::string* error)
|
||||
inline bool Program::GetLinkStatus(std::string* error) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
@@ -45,6 +45,19 @@ namespace Nz::GL
|
||||
return true;
|
||||
}
|
||||
|
||||
inline GLint Program::GetUniformLocation(const char* uniformName) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
const Context& context = EnsureDeviceContext();
|
||||
|
||||
return context.glGetUniformLocation(m_objectId, uniformName);
|
||||
}
|
||||
|
||||
inline GLint Program::GetUniformLocation(const std::string& uniformName) const
|
||||
{
|
||||
return GetUniformLocation(uniformName.c_str());
|
||||
}
|
||||
|
||||
inline void Program::Link()
|
||||
{
|
||||
assert(m_objectId);
|
||||
@@ -53,6 +66,15 @@ namespace Nz::GL
|
||||
context.glLinkProgram(m_objectId);
|
||||
}
|
||||
|
||||
inline void Program::Uniform(GLint uniformLocation, float value) const
|
||||
{
|
||||
assert(m_objectId);
|
||||
|
||||
const Context& context = EnsureDeviceContext();
|
||||
context.BindProgram(m_objectId);
|
||||
context.glUniform1f(uniformLocation, value);
|
||||
}
|
||||
|
||||
inline GLuint Program::CreateHelper(OpenGLDevice& /*device*/, const Context& context)
|
||||
{
|
||||
return context.glCreateProgram();
|
||||
|
||||
Reference in New Issue
Block a user