Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan hoffstadt committed May 29, 2024
1 parent 7be8a64 commit ade01be
Show file tree
Hide file tree
Showing 9 changed files with 1,105 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
if not exist ../out/example_2.dll exit 1
if not exist ../out/example_3.dll exit 1
if not exist ../out/example_4.dll exit 1
if not exist ../out/example_5.dll exit 1
if not exist ../out/example_6.dll exit 1
if not exist ../out/example_8.dll exit 1
if not exist ../out/pilot_light.exe exit 1
if not exist ../out/pl_graphics_ext.dll exit 1
Expand Down Expand Up @@ -122,6 +124,8 @@ jobs:
test -f ./out/example_2.dylib || exit 1
test -f ./out/example_3.dylib || exit 1
test -f ./out/example_4.dylib || exit 1
test -f ./out/example_5.dylib || exit 1
test -f ./out/example_6.dylib || exit 1
test -f ./out/example_8.dylib || exit 1
test -f ./out/pl_stats_ext.dylib || exit 1
test -f ./out/pl_image_ext.dylib || exit 1
Expand Down Expand Up @@ -201,6 +205,8 @@ jobs:
test -f ./out/example_2.so || exit 1
test -f ./out/example_3.so || exit 1
test -f ./out/example_4.so || exit 1
test -f ./out/example_5.so || exit 1
test -f ./out/example_6.so || exit 1
test -f ./out/example_8.so || exit 1
test -f ./out/pl_graphics_ext.so || exit 1
test -f ./out/pl_image_ext.so || exit 1
Expand Down
30 changes: 29 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,35 @@ Demonstrates:
* loading APIs
* hot reloading
* loading extensions
* basic graphics extension use
* vertex buffers
* graphics shaders
* non-indexed drawing

## Example 5 - Hello Quad (example_5.c)
Demonstrates:
* loading APIs
* hot reloading
* loading extensions
* vertex buffers
* index buffers
* staging buffers
* graphics shaders
* indexed drawing

## Example 6 - Textured Quad (example_6.c)
Demonstrates:
* loading APIs
* hot reloading
* loading extensions
* vertex, index, staging buffers
* samplers, textures, bindgroups
* graphics shaders
* indexed drawing
* image extension

## Example 7 - Compute (example_7.c)
Demonstrates:
* WIP

## Example 8 - Drawing Extension 3D (example_8.c)
Demonstrates:
Expand Down
13 changes: 8 additions & 5 deletions examples/example_4.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
- demonstrates loading APIs
- demonstrates loading extensions
- demonstrates hot reloading
- demonstrates basic graphics extension use
- demonstrates vertex buffers
- demonstrates graphics shaders
- demonstrates non-index drawing
*/

/*
Expand Down Expand Up @@ -125,7 +127,6 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)

// load graphics extension (provides graphics & device apis)
ptExtensionRegistry->load("pl_graphics_ext", NULL, NULL, false);
ptExtensionRegistry->load("pl_draw_ext", NULL, NULL, true);

// load required apis (NULL if not available)
gptIO = ptApiRegistry->first(PL_API_IO);
Expand Down Expand Up @@ -156,6 +157,8 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
for(uint32_t i = 0; i < PL_FRAMES_IN_FLIGHT; i++)
ptAppData->atSempahore[i] = gptDevice->create_semaphore(ptDevice, false);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~buffers~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// vertex buffer data
const float atVertexData[] = { // x, y, r, g, b, a
-0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f,
Expand All @@ -176,8 +179,7 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
// allocate memory for the vertex buffer
// NOTE: for this example we are using host visible memory for simplicity (PL_MEMORY_GPU_CPU)
// which is persistently mapped. For rarely updated memory, device local memory should
// be used, with uploads transfered from staging buffers (later examples will demonstrate
// this)
// be used, with uploads transfered from staging buffers (see example 5)
const plDeviceMemoryAllocation tAllocation = gptDevice->allocate_memory(ptDevice,
ptVertexBuffer->tMemoryRequirements.ulSize,
PL_MEMORY_GPU_CPU,
Expand All @@ -190,7 +192,8 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
// copy vertex data to newly allocated memory
memcpy(ptVertexBuffer->tMemoryAllocation.pHostMapped, atVertexData, sizeof(float) * 18);

// create simple shader
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~shaders~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

const plShaderDescription tShaderDesc = {
#ifdef PL_METAL_BACKEND
.pcVertexShader = "../examples/shaders/example_4.metal",
Expand Down
Loading

0 comments on commit ade01be

Please sign in to comment.