Skip to content

Commit

Permalink
Merge branch 'SFTtech:master' into array_curve
Browse files Browse the repository at this point in the history
  • Loading branch information
jere8184 authored Jan 8, 2025
2 parents 827f46c + fe60b2b commit e0eafb3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/windows-server-2019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
$DLL_PATH = Join-Path package dll | Resolve-Path
cd package
python -m openage --add-dll-search-path $DLL_PATH --version
./run.exe test -a
python -m openage --add-dll-search-path $DLL_PATH test -a
shell: pwsh
- name: Publish build artifacts
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-server-2022.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
$DLL_PATH = Join-Path package dll | Resolve-Path
cd package
python -m openage --add-dll-search-path $DLL_PATH --version
./run.exe test -a
python -m openage --add-dll-search-path $DLL_PATH test -a
shell: pwsh
- name: Publish build artifacts
uses: actions/upload-artifact@v4
Expand Down
3 changes: 2 additions & 1 deletion libopenage/renderer/opengl/geometry.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2024 the openage authors. See copying.md for legal info.
// Copyright 2015-2025 the openage authors. See copying.md for legal info.

#include "geometry.h"

Expand Down Expand Up @@ -54,6 +54,7 @@ void GlGeometry::update_verts_offset(std::vector<uint8_t> const &verts, size_t o
void GlGeometry::draw() const {
switch (this->get_type()) {
case geometry_t::bufferless_quad:
// any VAO must be bound before this call
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
break;

Expand Down
13 changes: 10 additions & 3 deletions libopenage/renderer/opengl/renderer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2024 the openage authors. See copying.md for legal info.
// Copyright 2017-2025 the openage authors. See copying.md for legal info.

#include "renderer.h"

Expand All @@ -15,6 +15,7 @@
#include "renderer/opengl/texture.h"
#include "renderer/opengl/uniform_buffer.h"
#include "renderer/opengl/uniform_input.h"
#include "renderer/opengl/vertex_array.h"
#include "renderer/opengl/window.h"
#include "renderer/resources/buffer_info.h"

Expand All @@ -26,7 +27,8 @@ GlRenderer::GlRenderer(const std::shared_ptr<GlContext> &ctx,
gl_context{ctx},
display{std::make_shared<GlRenderTarget>(ctx,
viewport_size[0],
viewport_size[1])} {
viewport_size[1])},
shared_quad_vao{std::make_shared<GlVertexArray>(ctx)} {
// color used to clear the color buffers
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

Expand Down Expand Up @@ -100,7 +102,7 @@ std::shared_ptr<UniformBuffer> GlRenderer::add_uniform_buffer(resources::Uniform
resources::UniformBufferInfo::get_size(input, info.get_layout()),
resources::UniformBufferInfo::get_stride_size(input.type, info.get_layout()),
input.count,
input.name});
input.name});

offset += size;
}
Expand Down Expand Up @@ -169,6 +171,11 @@ void GlRenderer::render(const std::shared_ptr<RenderPass> &pass) {
auto gl_target = std::dynamic_pointer_cast<GlRenderTarget>(pass->get_target());
gl_target->bind_write();

// ensure that an (empty) VAO is bound before rendering geometry
// a bound VAO is required to render bufferless quad geometries by OpenGL
// see https://www.khronos.org/opengl/wiki/Vertex_Rendering#Causes_of_rendering_failure
shared_quad_vao->bind();

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// TODO: Option for face culling
Expand Down
11 changes: 10 additions & 1 deletion libopenage/renderer/opengl/renderer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2024 the openage authors. See copying.md for legal info.
// Copyright 2017-2025 the openage authors. See copying.md for legal info.

#pragma once

Expand All @@ -17,6 +17,7 @@ namespace opengl {
class GlContext;
class GlRenderPass;
class GlRenderTarget;
class GlVertexArray;
class GlWindow;

/// The OpenGL specialization of the rendering interface.
Expand Down Expand Up @@ -67,6 +68,14 @@ class GlRenderer final : public Renderer {

/// The main screen surface as a render target.
std::shared_ptr<GlRenderTarget> display;

/// An empty vertex array object (VAO).
///
/// This VAO has to be bound at the start of a render pass to ensure
/// that bufferless quad geometry can be drawn without errors. Drawing a
/// bufferless quad requires any VAO to be bound
/// see https://www.khronos.org/opengl/wiki/Vertex_Rendering#Causes_of_rendering_failure
std::shared_ptr<GlVertexArray> shared_quad_vao;
};

} // namespace opengl
Expand Down
4 changes: 2 additions & 2 deletions openage/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def main(argv=None):
"codegen",
parents=[global_cli]))

args = cli.parse_args(argv)
args, remaining_args = cli.parse_known_args(argv)

dll_manager = None
if sys.platform == 'win32':
Expand All @@ -139,7 +139,7 @@ def main(argv=None):

if not args.subcommand:
# the user didn't specify a subcommand. default to 'main'.
args = main_cli.parse_args(argv)
args = main_cli.parse_args(remaining_args)

args.dll_manager = dll_manager

Expand Down

0 comments on commit e0eafb3

Please sign in to comment.