Skip to content

Commit

Permalink
Merge pull request #11 from ancientjpeg/globals-refactor
Browse files Browse the repository at this point in the history
Refactor app/globals into context
  • Loading branch information
ancientjpeg authored Nov 11, 2024
2 parents 06721d7 + 4d70b6d commit e98f88a
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 211 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
jobs:
test:
runs-on: ubuntu-latest
env:
ACTIONS_UNIT_TESTS: "1"
steps:

- name: Apt Install Dependencies
Expand Down
21 changes: 14 additions & 7 deletions example/example0.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "rndr/application.h"
#include "rndr/context.h"
#include "rndr/math/ops.h"
#include "rndr/utils/helpers.h"
#include <cassert>
Expand All @@ -8,7 +8,7 @@
constexpr int w = 640;
constexpr int h = 480;

ustd::result performBufferCopies(rndr::Application &program_gpu)
ustd::result performBufferCopies(rndr::Context &program_gpu)
{
const wgpu::Device &device = program_gpu.getDevice();

Expand Down Expand Up @@ -68,7 +68,7 @@ ustd::result performBufferCopies(rndr::Application &program_gpu)
return {};
}

ustd::result renderFrame(rndr::Application &program_gpu)
ustd::result renderFrame(rndr::Context &program_gpu)
{

const wgpu::Device &device = program_gpu.getDevice();
Expand All @@ -79,8 +79,15 @@ ustd::result renderFrame(rndr::Application &program_gpu)
program_gpu.processEvents();

/* get current texture to write to */
auto surface_optional = program_gpu.getSurface();
if (!surface_optional) {
return ustd::unexpected(surface_optional.message());
}

const wgpu::Surface &surface = *surface_optional;

wgpu::SurfaceTexture surface_tex;
program_gpu.getSurface().GetCurrentTexture(&surface_tex);
surface.GetCurrentTexture(&surface_tex);

if (surface_tex.status != wgpu::SurfaceGetCurrentTextureStatus::Success) {
std::ostringstream oss;
Expand Down Expand Up @@ -148,15 +155,15 @@ ustd::result renderFrame(rndr::Application &program_gpu)
/* program_gpu.blockOnFuture(work_future); */

/* finally, present the next texture */
program_gpu.getSurface().Present();
surface.Present();

return {};
}

int main()
{
rndr::Application program_gpu;
ustd::result init_result = program_gpu.initialize();
rndr::Context program_gpu;
ustd::result init_result = program_gpu.initialize();

if (!init_result.ok()) {
std::cerr << "Initialization failed for reason: " << init_result;
Expand Down
4 changes: 2 additions & 2 deletions src/rndr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_library(rndr STATIC
${CMAKE_CURRENT_SOURCE_DIR}/application.h
${CMAKE_CURRENT_SOURCE_DIR}/application.cpp
${CMAKE_CURRENT_SOURCE_DIR}/context.h
${CMAKE_CURRENT_SOURCE_DIR}/context.cpp
)

Include(FetchContent)
Expand Down
68 changes: 0 additions & 68 deletions src/rndr/application.cpp

This file was deleted.

63 changes: 0 additions & 63 deletions src/rndr/application.h

This file was deleted.

Loading

0 comments on commit e98f88a

Please sign in to comment.