Skip to content

Add triangle rendering example with GLFW and surface support#3

Merged
Andthehand merged 4 commits intomainfrom
copilot/add-simple-triangle-example
Feb 10, 2026
Merged

Add triangle rendering example with GLFW and surface support#3
Andthehand merged 4 commits intomainfrom
copilot/add-simple-triangle-example

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Adds a complete triangle rendering example using GLFW. The Device class now supports window surface creation through instance extension forwarding.

API Changes

Extended DeviceCreateInfo to accept instance extensions (e.g., GLFW surface extensions). When provided, automatically enables VK_KHR_swapchain device extension:

// Get GLFW required extensions
uint32_t count = 0;
const char** glfwExtensions = glfwGetRequiredInstanceExtensions(&count);
std::vector<const char*> extensions(glfwExtensions, glfwExtensions + count);

// Create device with surface support
RealEngine::DeviceCreateInfo createInfo {
    .AppName = "MyApp",
    .EnableValidationLayers = false,
    .RequiredExtensions = extensions,  // New field
};

RealEngine::Device device;
device.Create(createInfo);

// Create surface and swapchain
VkSurfaceKHR surface;
glfwCreateWindowSurface(device.GetInstance(), window, nullptr, &surface);

TriangleExample Implementation

  • Complete self-contained example (~790 LOC)
  • Embedded SPIR-V shaders (no external files)
  • Swapchain creation and management
  • Graphics pipeline with vertex colors
  • Proper frame synchronization (semaphores/fences)
  • Full resource cleanup

Build Configuration

  • Added GLFW dependency to examples CMakeLists
  • Updated README with GLFW installation and usage examples
  • Note: Examples require Vulkan-capable GPU

The example renders a triangle with per-vertex RGB colors and demonstrates the complete RealRHI rendering pipeline from window creation through presentation.

Original prompt

Create an example that renders a simple triangle using glfw and RealRHI


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 10, 2026 17:56
Co-authored-by: Andthehand <56981831+Andthehand@users.noreply.github.com>
Co-authored-by: Andthehand <56981831+Andthehand@users.noreply.github.com>
Co-authored-by: Andthehand <56981831+Andthehand@users.noreply.github.com>
Copilot AI changed the title [WIP] Add example to render triangle using GLFW and RealRHI Add triangle rendering example with GLFW and surface support Feb 10, 2026
Copilot AI requested a review from Andthehand February 10, 2026 18:03
@Andthehand Andthehand marked this pull request as ready for review February 10, 2026 18:04
RealEngine::DeviceCreateInfo createInfo {
.AppName = "RealRHI Basic Example",
.EnableValidationLayers = true,
.EnableValidationLayers = false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want this to always have ValidationLayers enabled

Suggested change
.EnableValidationLayers = false,
.EnableValidationLayers = true,

@Andthehand Andthehand merged commit 255a0a3 into main Feb 10, 2026
1 check failed
@Andthehand Andthehand deleted the copilot/add-simple-triangle-example branch February 10, 2026 18:08
Copilot AI requested a review from Andthehand February 10, 2026 18:09
Copilot stopped work on behalf of Andthehand due to an error February 10, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants