wisdom
Loading...
Searching...
No Matches
Initialization

This page walks through initialization using the hello_triangle example. The sample exists in both C++ and C and demonstrates the same startup flow.

CMake Configuration (from hello_triangle)

Example target setup links core + platform targets, with static/shared variants.

# Static variant
target_link_libraries(my_app_cpp
PUBLIC wis::wisdom wis::wisdom-platform SDL3::SDL3)
# Shared variant
target_link_libraries(my_app_cpp_shared
PUBLIC wis::wisdom-shared wis::wisdom-platform-shared SDL3::SDL3)
# Header-interface variant
target_link_libraries(my_app_cpp_headers
PUBLIC wis::wisdom-headers wis::wisdom-platform-headers SDL3::SDL3)

The real example also builds C and C++ executables side-by-side and reuses shared backend helpers.

Initialization Flow

High-level startup sequence used by hello_triangle:

  1. Create platform extension helper (SDL backend wrapper).
  2. Create Instance with debug settings and platform extension.
  3. Create Surface from the window.
  4. Query adapters and create Device.
  5. Create queue, swapchain, fence, heaps, and command objects.
Note
Once Device is created, you usually do not need to keep Instance alive for frame execution. Device keeps the required internal references. Keep Instance only when you plan to re-enumerate adapters and rebuild device selection.

C++ initialization snippet

#include <wisdom/wisdom.hpp>
#include <wisdom/wisdom_platform.hpp>
wis::DebugDesc debug_desc{ .enable_debug_layer = true, .callback = log_callback };
wis::InstanceExtensionHeader* extensions[] = { platform.Extension() }; // From somewhere like SDL or GLFW platform
wrapper
wis::Result result;
wis::Instance instance = wis::CreateInstance(&debug_desc, wis::span{extensions}, result);
wis::Surface surface = platform.CreateWindowSurface(window);
wis::AdapterQuery adapters = instance.QueryAdapters(wis::AdapterPreference::Performance, result);
wis::DeviceRequirements requirements{};
requirements.queue_descs = { queue_descs, 1 };
wis::Device device = adapters.CreateDevice(0, requirements, result);

C initialization snippet

#include <wisdom/wisdom.h>
WisDebugDesc debug_desc = {
.enable_debug_layer = true,
.callback = log_callback,
};
WisInstance instance = {0};
WisInstanceExtensionHeader* extensions[] = { platform.platform_extension }; // From somewhere like SDL or GLFW
platform wrapper
WisResult result = wisCreateInstance(&debug_desc, extensions, 1, &instance);
WisAdapterQuery adapters = {0};
result = wisInstanceQueryAdapters(&instance, WisAdapterPreferencePerformance, &adapters);
result = wisAdapterQueryCreateDevice(&adapters, 0, &requirements, &device);

Both paths continue with queue/swapchain/pipeline creation as shown in examples/hello_triangle.