Skip to content

Commit

Permalink
[Examples] Minor changes in examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Sep 7, 2024
1 parent 794ed2d commit 95ff758
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions examples/Cpp/ExampleBase/Stopwatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ void Stopwatch::Start()
std::uint64_t Stopwatch::Stop()
{
isRunning_ = false;
auto endTick = LLGL::Timer::Tick();
const std::uint64_t endTick = LLGL::Timer::Tick();
return endTick - startTick_;
}

void Stopwatch::MeasureTime()
{
const bool wasRunning = IsRunning();
auto elapsed = Stop();
const std::uint64_t elapsed = Stop();
Start();
if (wasRunning)
deltaTime_ = static_cast<double>(elapsed) / static_cast<double>(GetFrequency());
Expand Down
2 changes: 1 addition & 1 deletion examples/Cpp/PBR/Example.Sky.vert
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This function generates the coordinates for a fullscreen triangle with its verte
*----------*--------*
(-1,-1) (+1,-1) (+3,-1)
*/
vec4 GetFullscreenTriangleVertex(uint id)
vec4 GetFullscreenTriangleVertex(int id)
{
return vec4(
(id == 2 ? 3.0 : -1.0),
Expand Down
14 changes: 7 additions & 7 deletions examples/Cpp/PostProcessing/Example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#endif

// Enables custom render pass to clear at the begin of a render pass section (more efficient)
#define ENABLE_CUSTOM_RENDER_PASS
#define ENABLE_CUSTOM_RENDER_PASS 1


class Example_PostProcessing : public ExampleBase
Expand Down Expand Up @@ -59,7 +59,7 @@ class Example_PostProcessing : public ExampleBase
LLGL::RenderTarget* renderTargetBlurX = nullptr;
LLGL::RenderTarget* renderTargetBlurY = nullptr;

#ifdef ENABLE_CUSTOM_RENDER_PASS
#if ENABLE_CUSTOM_RENDER_PASS
LLGL::RenderPass* renderPassScene = nullptr;
#endif

Expand Down Expand Up @@ -99,7 +99,7 @@ class Example_PostProcessing : public ExampleBase
CreateSamplers();
CreateTextures();
CreateRenderTargets();
#ifdef ENABLE_CUSTOM_RENDER_PASS
#if ENABLE_CUSTOM_RENDER_PASS
CreateRenderPasses();
#endif
CreatePipelineLayouts();
Expand Down Expand Up @@ -168,7 +168,7 @@ class Example_PostProcessing : public ExampleBase

// Load final shader program
shaderPipelineFinal.vs = LoadShader({ LLGL::ShaderType::Vertex, "PostProcess.vert" });
shaderPipelineFinal.ps = LoadShader({ LLGL::ShaderType::Fragment, "Final.frag" });
shaderPipelineFinal.ps = LoadShader({ LLGL::ShaderType::Fragment, "Final.frag" });
}
else if (Supported(LLGL::ShadingLanguage::SPIRV))
{
Expand Down Expand Up @@ -282,7 +282,7 @@ class Example_PostProcessing : public ExampleBase
renderTargetBlurY = renderer->CreateRenderTarget(renderTargetBlurYDesc);
}

#ifdef ENABLE_CUSTOM_RENDER_PASS
#if ENABLE_CUSTOM_RENDER_PASS

void CreateRenderPasses()
{
Expand Down Expand Up @@ -524,7 +524,7 @@ class Example_PostProcessing : public ExampleBase
// Set graphics pipeline and vertex buffer for scene rendering
commands->SetVertexBuffer(*vertexBufferScene);

#ifdef ENABLE_CUSTOM_RENDER_PASS
#if ENABLE_CUSTOM_RENDER_PASS

// Clear scene render target with render pass and initial clear values
LLGL::ClearValue clearValues[3];
Expand All @@ -547,7 +547,7 @@ class Example_PostProcessing : public ExampleBase
// Set viewport to full size
commands->SetViewport(viewportFull);

#ifndef ENABLE_CUSTOM_RENDER_PASS
#if !ENABLE_CUSTOM_RENDER_PASS

// Clear individual buffers in render target (color, glossiness, depth)
constexpr float glossinessColor[4] = { 0, 0, 0, 0 };
Expand Down
16 changes: 15 additions & 1 deletion examples/Cpp/Texturing/Example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include <LLGL/Utils/TypeNames.h>
#include <ImageReader.h>
#include <DDSImageReader.h>
#include <LLGL/Platform/Platform.h>

#if !defined(LLGL_OS_ANDROID) && !defined(LLGL_OS_WASM)
# define ENABLE_COMPRESSED_TEXTURE_DDX 1
#endif


class Example_Texturing : public ExampleBase
Expand Down Expand Up @@ -130,7 +135,7 @@ class Example_Texturing : public ExampleBase
texDesc.type = LLGL::TextureType::Texture2D;

// Texture hardware format: RGBA with normalized 8-bit unsigned char type
texDesc.format = LLGL::Format::BGRA8UNorm;//RGBA8UNorm; //BGRA8UNorm
texDesc.format = LLGL::Format::RGBA8UNorm; //BGRA8UNorm

// Texture size
texDesc.extent = reader.GetTextureDesc().extent;
Expand Down Expand Up @@ -179,8 +184,13 @@ class Example_Texturing : public ExampleBase

void CreateTextures()
{
#if ENABLE_COMPRESSED_TEXTURE_DDX
LoadCompressedTexture("Crate-DXT1-MipMapped.dds");
LoadUncompressedTexture("Crate.jpg");
#else
LoadUncompressedTexture("Crate.jpg");
colorMaps[0] = colorMaps[1];
#endif
}

void CreateSamplers()
Expand Down Expand Up @@ -218,10 +228,14 @@ class Example_Texturing : public ExampleBase
if (input.KeyDown(LLGL::Key::Tab))
{
// Switch to next resource we want to present
#if defined(LLGL_OS_ANDROID) || defined(LLGL_OS_IOS) || defined(LLGL_OS_WASM)
resourceIndex = 3 - resourceIndex;
#else
if (input.KeyPressed(LLGL::Key::Shift))
resourceIndex = ((resourceIndex - 1) % 4 + 4) % 4;
else
resourceIndex = (resourceIndex + 1) % 4;
#endif

const std::string spaces(30, ' ');
LLGL::Log::Printf(
Expand Down
4 changes: 2 additions & 2 deletions sources/Renderer/DXCommon/DXManagedComPtrArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DXManagedComPtrArray
// Emplaces the specified object into the first available entry.
T* Emplace(const ComPtr<T>& object, std::size_t* outIndex = nullptr)
{
auto index = FindFreeIndex();
const std::size_t index = FindFreeIndex();
if (index < container_.size())
container_[index] = object;
else
Expand All @@ -49,7 +49,7 @@ class DXManagedComPtrArray
// Emplaces the specified object into the first available entry.
T* Emplace(ComPtr<T>&& object, std::size_t* outIndex = nullptr)
{
auto index = FindFreeIndex();
const std::size_t index = FindFreeIndex();
if (index < container_.size())
container_[index] = std::forward<ComPtr<T>&&>(object);
else
Expand Down

0 comments on commit 95ff758

Please sign in to comment.