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
55
extern
"C"
{
56
#endif
57
58
typedef
struct
vgl_d3d11_backend
vgl_d3d11_backend
;
59
61
typedef
struct
vgl_d3d11_backend_create_info
62
{
63
uint32_t
struct_size
;
66
vgl_depth_convention
depth_convention
;
68
ID3D11Device*
device
;
69
VGL_POINTER_PADDING
(device_padding)
72
ID3D11DeviceContext*
device_context
;
73
VGL_POINTER_PADDING
(device_context_padding)
74
}
vgl_d3d11_backend_create_info
;
75
99
VGL_D3D11_API
vgl_result
vgl_d3d11_backend_create
(
vgl_context
* context,
100
const
vgl_d3d11_backend_create_info
* info,
101
vgl_d3d11_backend
** out_backend);
102
115
VGL_D3D11_API
vgl_result
vgl_d3d11_backend_destroy
(
vgl_d3d11_backend
* backend);
116
118
typedef struct
vgl_d3d11_draw_info
119
{
120
uint32_t
struct_size
;
123
vgl_bool
mirrored
;
126
const
vgl_dmat4
*
view_matrix
;
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;
143
vgl_draw_features
features;
146
vgl_debug_views
debug_views;
149
double
earth_rotation_angle;
152
double
contour_interval;
155
double
cloud_height;
156
}
vgl_d3d11_draw_info
;
157
184
VGL_D3D11_API
vgl_result
vgl_d3d11_backend_draw
(
vgl_d3d11_backend
* backend,
185
const
vgl_d3d11_draw_info
* info);
186
207
VGL_D3D11_API
vgl_result
vgl_d3d11_backend_clouds_set
(
vgl_d3d11_backend
* backend,
208
const uint8_t* coverage,
209
uint32_t width,
210
uint32_t height);
211
231
VGL_D3D11_API
vgl_result
vgl_d3d11_backend_stars_set
(
vgl_d3d11_backend
* backend,
232
const
vgl_star
* stars,
233
uint32_t star_count);
234
254
VGL_D3D11_API
vgl_result
vgl_d3d11_backend_device_reset
(
vgl_d3d11_backend
* backend,
255
ID3D11Device*
device
,
256
ID3D11DeviceContext*
device_context
);
257
258
#ifdef __cplusplus
259
}
260
#endif
261
262
#endif
/* VGL_D3D11_H */
base.h
vgl_result
vgl_result
Definition
base.h:98
vgl_bool
uint32_t vgl_bool
Definition
base.h:56
VGL_POINTER_PADDING
#define VGL_POINTER_PADDING(name)
Definition
base.h:46
context.h
vgl_context
struct vgl_context vgl_context
Definition
context.h:23
d3d11.h
vgl_d3d11_backend_stars_set
vgl_result vgl_d3d11_backend_stars_set(vgl_d3d11_backend *backend, const vgl_star *stars, uint32_t star_count)
vgl_d3d11_backend
struct vgl_d3d11_backend vgl_d3d11_backend
Definition
d3d11.h:58
vgl_d3d11_backend_create
vgl_result vgl_d3d11_backend_create(vgl_context *context, const vgl_d3d11_backend_create_info *info, vgl_d3d11_backend **out_backend)
VGL_D3D11_API
#define VGL_D3D11_API
Definition
d3d11.h:51
vgl_d3d11_backend_destroy
vgl_result vgl_d3d11_backend_destroy(vgl_d3d11_backend *backend)
vgl_d3d11_backend_draw
vgl_result vgl_d3d11_backend_draw(vgl_d3d11_backend *backend, const vgl_d3d11_draw_info *info)
vgl_d3d11_backend_device_reset
vgl_result vgl_d3d11_backend_device_reset(vgl_d3d11_backend *backend, ID3D11Device *device, ID3D11DeviceContext *device_context)
vgl_d3d11_backend_clouds_set
vgl_result vgl_d3d11_backend_clouds_set(vgl_d3d11_backend *backend, const uint8_t *coverage, uint32_t width, uint32_t height)
render.h
vgl_draw_features
uint32_t vgl_draw_features
Definition
render.h:480
vgl_depth_convention
vgl_depth_convention
Definition
render.h:105
vgl_debug_views
uint32_t vgl_debug_views
Definition
render.h:516
vgl_d3d11_backend_create_info
Definition
d3d11.h:62
vgl_d3d11_backend_create_info::struct_size
uint32_t struct_size
Definition
d3d11.h:63
vgl_d3d11_backend_create_info::device_context
ID3D11DeviceContext * device_context
Definition
d3d11.h:72
vgl_d3d11_backend_create_info::depth_convention
vgl_depth_convention depth_convention
Definition
d3d11.h:66
vgl_d3d11_backend_create_info::device
ID3D11Device * device
Definition
d3d11.h:68
vgl_d3d11_draw_info
Definition
d3d11.h:119
vgl_d3d11_draw_info::mirrored
vgl_bool mirrored
Definition
d3d11.h:123
vgl_d3d11_draw_info::struct_size
uint32_t struct_size
Definition
d3d11.h:120
vgl_d3d11_draw_info::view_matrix
const vgl_dmat4 * view_matrix
Definition
d3d11.h:126
vgl_dmat4
Definition
base.h:88
vgl_dvec3
Definition
base.h:69
vgl_star
Definition
render.h:53
vgl
d3d11.h
Generated by
1.9.8