vgl 1.0.0
Virtual Globe Library: API reference
Loading...
Searching...
No Matches
d3d11.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2026 Jeremiah van Oosten
4 *
5 * vgl Direct3D 11 backend: draws a context's globe with Direct3D 11 at feature level 11_0, into
6 * the host's render targets (design document, section 7.6). It is a consumer of the render
7 * interface (vgl/render.h), linked separately as vgl_d3d11, and uses vgl only through the C API.
8 *
9 * The host creates the device and passes it, with the device context to draw with:
10 *
11 * vgl_d3d11_backend_create_info info = {.struct_size = sizeof(info)};
12 * info.device = device;
13 * info.device_context = immediate_context;
14 * vgl_d3d11_backend* backend;
15 * vgl_d3d11_backend_create(context, &info, &backend);
16 *
17 * // Each frame, after vgl_context_update, with the host's render target and depth buffer
18 * // bound and its viewport set:
19 * vgl_d3d11_backend_draw(backend, NULL);
20 *
21 * vgl_d3d11_backend_destroy(backend); // Before the context and the device.
22 *
23 * State (NFR-08). The backend saves the following state of the device context when it draws,
24 * and restores it before returning: the input layout, the primitive topology, vertex buffer 0
25 * and the index buffer; the vertex shader and its constant buffers 0 and 1; the pixel shader,
26 * its constant buffers 0 and 1, its shader resources 0 to 5 and its samplers 0 and 1; the
27 * rasterizer state; the depth-stencil state and stencil reference; and the blend state, blend
28 * factor and sample mask. It draws with the host's render targets, viewports and scissor
29 * rectangles as they are, with the stencil test and blending off.
30 *
31 * Projections map depth to [0, 1], as Direct3D does, and camera space is the view matrix's:
32 * right-handed, like ECEF, looking along -z.
33 */
34#ifndef VGL_D3D11_H
35#define VGL_D3D11_H
36
37#include <d3d11.h>
38
39#include <vgl/base.h>
40#include <vgl/context.h>
41#include <vgl/render.h>
42
43/* Symbol visibility of the backend library, which is shared when vgl is. */
44#if defined(VGL_SHARED)
45# if defined(VGL_D3D11_BUILDING)
46# define VGL_D3D11_API __declspec(dllexport)
47# else
48# define VGL_D3D11_API __declspec(dllimport)
49# endif
50#else
51# define VGL_D3D11_API
52#endif
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
59
62{
63 uint32_t struct_size;
68 ID3D11Device* device;
69 VGL_POINTER_PADDING(device_padding)
72 ID3D11DeviceContext* device_context;
73 VGL_POINTER_PADDING(device_context_padding)
75
101 vgl_d3d11_backend** out_backend);
102
116
119{
120 uint32_t struct_size;
127 VGL_POINTER_PADDING(view_matrix_padding)
130 const vgl_dmat4* projection_matrix;
131 VGL_POINTER_PADDING(projection_matrix_padding)
134 vgl_dvec3 sun_direction;
137 double logarithmic_far;
140 uint64_t upload_budget;
146 vgl_debug_views debug_views;
149 double earth_rotation_angle;
152 double contour_interval;
155 double cloud_height;
157
185 const vgl_d3d11_draw_info* info);
186
208 const uint8_t* coverage,
209 uint32_t width,
210 uint32_t height);
211
232 const vgl_star* stars,
233 uint32_t star_count);
234
255 ID3D11Device* device,
256 ID3D11DeviceContext* device_context);
257
258#ifdef __cplusplus
259}
260#endif
261
262#endif /* VGL_D3D11_H */
vgl_result
Definition base.h:98
uint32_t vgl_bool
Definition base.h:56
#define VGL_POINTER_PADDING(name)
Definition base.h:46
struct vgl_context vgl_context
Definition context.h:23
vgl_result vgl_d3d11_backend_stars_set(vgl_d3d11_backend *backend, const vgl_star *stars, uint32_t star_count)
struct vgl_d3d11_backend vgl_d3d11_backend
Definition d3d11.h:58
vgl_result vgl_d3d11_backend_create(vgl_context *context, const vgl_d3d11_backend_create_info *info, vgl_d3d11_backend **out_backend)
#define VGL_D3D11_API
Definition d3d11.h:51
vgl_result vgl_d3d11_backend_destroy(vgl_d3d11_backend *backend)
vgl_result vgl_d3d11_backend_draw(vgl_d3d11_backend *backend, const vgl_d3d11_draw_info *info)
vgl_result vgl_d3d11_backend_device_reset(vgl_d3d11_backend *backend, ID3D11Device *device, ID3D11DeviceContext *device_context)
vgl_result vgl_d3d11_backend_clouds_set(vgl_d3d11_backend *backend, const uint8_t *coverage, uint32_t width, uint32_t height)
uint32_t vgl_draw_features
Definition render.h:480
vgl_depth_convention
Definition render.h:105
uint32_t vgl_debug_views
Definition render.h:516
Definition d3d11.h:62
uint32_t struct_size
Definition d3d11.h:63
ID3D11DeviceContext * device_context
Definition d3d11.h:72
vgl_depth_convention depth_convention
Definition d3d11.h:66
ID3D11Device * device
Definition d3d11.h:68
Definition d3d11.h:119
vgl_bool mirrored
Definition d3d11.h:123
uint32_t struct_size
Definition d3d11.h:120
const vgl_dmat4 * view_matrix
Definition d3d11.h:126
Definition base.h:88
Definition base.h:69
Definition render.h:53