Skip to content

Commit

Permalink
renderer: Make sure that alpha is 1 for blend results.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Dec 15, 2023
1 parent 5ae0c63 commit 8f1662e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions libopenage/renderer/opengl/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@ GlRenderer::GlRenderer(const std::shared_ptr<GlContext> &ctx,
display{std::make_shared<GlRenderTarget>(ctx,
viewport_size[0],
viewport_size[1])} {
// color used to clear the color buffers
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

// global GL alpha blending settings
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFuncSeparate(
GL_SRC_ALPHA, // source (overlaying) RGB factor
GL_ONE_MINUS_SRC_ALPHA, // destination (underlying) RGB factor
GL_ONE, // source (overlaying) alpha factor
GL_ONE_MINUS_SRC_ALPHA // destination (underlying) alpha factor
);

// global GL depth testing settings
glDepthFunc(GL_LEQUAL);
Expand Down Expand Up @@ -157,7 +166,6 @@ void GlRenderer::render(const std::shared_ptr<RenderPass> &pass) {
auto gl_target = std::dynamic_pointer_cast<GlRenderTarget>(pass->get_target());
gl_target->bind_write();

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// TODO: Option for face culling
Expand Down
2 changes: 1 addition & 1 deletion libopenage/renderer/stages/hud/render_stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void HudRenderStage::update() {
auto geometry = this->renderer->add_mesh_geometry(resources::MeshData::make_quad());
auto transform_unifs = this->drag_select_shader->new_uniform_input(
"in_col",
Eigen::Vector4f{0.0f, 0.0f, 0.0f, 0.5f});
Eigen::Vector4f{0.0f, 0.0f, 0.0f, 0.2f});

Renderable display_obj{
transform_unifs,
Expand Down

0 comments on commit 8f1662e

Please sign in to comment.