1package d3d11_test
2
3import D3D11 "vendor:directx/d3d11"
4import DXGI "vendor:directx/dxgi"
5import D3D "vendor:directx/d3d_compiler"
6import SDL "vendor:sdl2"
7import glm "core:math/linalg/glsl"
8
9
10
11main :: proc() {
12 SDL.Init({.VIDEO})
13 defer SDL.Quit()
14
15 SDL.SetHintWithPriority(SDL.HINT_RENDER_DRIVER, "direct3d11", .OVERRIDE)
16 window := SDL.CreateWindow("D3D11 in Odin",
17 SDL.WINDOWPOS_CENTERED, SDL.WINDOWPOS_CENTERED,
18 854, 480,
19 {.ALLOW_HIGHDPI, .HIDDEN, .RESIZABLE},
20 )
21 defer SDL.DestroyWindow(window)
22
23 window_system_info: SDL.SysWMinfo
24 SDL.GetVersion(&window_system_info.version)
25 SDL.GetWindowWMInfo(window, &window_system_info)
26 assert(window_system_info.subsystem == .WINDOWS)
27
28 native_window := DXGI.HWND(window_system_info.info.win.window)
29
30 feature_levels := [?]D3D11.FEATURE_LEVEL{._11_0}
31
32 base_device: ^D3D11.IDevice
33 base_device_context: ^D3D11.IDeviceContext
34
35 D3D11.CreateDevice(nil, .HARDWARE, nil, {.BGRA_SUPPORT}, &feature_levels[0], len(feature_levels), D3D11.SDK_VERSION, &base_device, nil, &base_device_context)
36
37 device: ^D3D11.IDevice
38 base_device->QueryInterface(D3D11.IDevice_UUID, (^rawptr)(&device))
39
40 device_context: ^D3D11.IDeviceContext
41 base_device_context->QueryInterface(D3D11.IDeviceContext_UUID, (^rawptr)(&device_context))
42
43 dxgi_device: ^DXGI.IDevice
44 device->QueryInterface(DXGI.IDevice_UUID, (^rawptr)(&dxgi_device))
45
46 dxgi_adapter: ^DXGI.IAdapter
47 dxgi_device->GetAdapter(&dxgi_adapter)
48
49 dxgi_factory: ^DXGI.IFactory2
50 dxgi_adapter->GetParent(DXGI.IFactory2_UUID, (^rawptr)(&dxgi_factory))
51
52
53
54 swapchain_desc := DXGI.SWAP_CHAIN_DESC1{
55 Width = 0,
56 Height = 0,
57 Format = .B8G8R8A8_UNORM_SRGB,
58 Stereo = false,
59 SampleDesc = {
60 Count = 1,
61 Quality = 0,
62 },
63 BufferUsage = {.RENDER_TARGET_OUTPUT},
64 BufferCount = 2,
65 Scaling = .STRETCH,
66 SwapEffect = .DISCARD,
67 AlphaMode = .UNSPECIFIED,
68 Flags = {},
69 }
70
71 swapchain: ^DXGI.ISwapChain1
72 dxgi_factory->CreateSwapChainForHwnd(device, native_window, &swapchain_desc, nil, nil, &swapchain)
73
74 framebuffer: ^D3D11.ITexture2D
75 swapchain->GetBuffer(0, D3D11.ITexture2D_UUID, (^rawptr)(&framebuffer))
76
77 framebuffer_view: ^D3D11.IRenderTargetView
78 device->CreateRenderTargetView(framebuffer, nil, &framebuffer_view)
79
80 depth_buffer_desc: D3D11.TEXTURE2D_DESC
81 framebuffer->GetDesc(&depth_buffer_desc)
82 depth_buffer_desc.Format = .D24_UNORM_S8_UINT
83 depth_buffer_desc.BindFlags = {.DEPTH_STENCIL}
84
85 depth_buffer: ^D3D11.ITexture2D
86 device->CreateTexture2D(&depth_buffer_desc, nil, &depth_buffer)
87
88 depth_buffer_view: ^D3D11.IDepthStencilView
89 device->CreateDepthStencilView(depth_buffer, nil, &depth_buffer_view)
90
91
92
93 vs_blob: ^D3D11.IBlob
94 D3D.Compile(raw_data(shaders_hlsl), len(shaders_hlsl), "shaders.hlsl", nil, nil, "vs_main", "vs_5_0", 0, 0, &vs_blob, nil)
95 assert(vs_blob != nil)
96
97 vertex_shader: ^D3D11.IVertexShader
98 device->CreateVertexShader(vs_blob->GetBufferPointer(), vs_blob->GetBufferSize(), nil, &vertex_shader)
99
100 input_element_desc := [?]D3D11.INPUT_ELEMENT_DESC{
101 { "POS", 0, .R32G32B32_FLOAT, 0, 0, .VERTEX_DATA, 0 },
102 { "NOR", 0, .R32G32B32_FLOAT, 0, D3D11.APPEND_ALIGNED_ELEMENT, .VERTEX_DATA, 0 },
103 { "TEX", 0, .R32G32_FLOAT, 0, D3D11.APPEND_ALIGNED_ELEMENT, .VERTEX_DATA, 0 },
104 { "COL", 0, .R32G32B32_FLOAT, 0, D3D11.APPEND_ALIGNED_ELEMENT, .VERTEX_DATA, 0 },
105 }
106
107 input_layout: ^D3D11.IInputLayout
108 device->CreateInputLayout(&input_element_desc[0], len(input_element_desc), vs_blob->GetBufferPointer(), vs_blob->GetBufferSize(), &input_layout)
109
110 ps_blob: ^D3D11.IBlob
111 D3D.Compile(raw_data(shaders_hlsl), len(shaders_hlsl), "shaders.hlsl", nil, nil, "ps_main", "ps_5_0", 0, 0, &ps_blob, nil)
112
113 pixel_shader: ^D3D11.IPixelShader
114 device->CreatePixelShader(ps_blob->GetBufferPointer(), ps_blob->GetBufferSize(), nil, &pixel_shader)
115
116
117
118 rasterizer_desc := D3D11.RASTERIZER_DESC{
119 FillMode = .SOLID,
120 CullMode = .BACK,
121 }
122 rasterizer_state: ^D3D11.IRasterizerState
123 device->CreateRasterizerState(&rasterizer_desc, &rasterizer_state)
124
125 sampler_desc := D3D11.SAMPLER_DESC{
126 Filter = .MIN_MAG_MIP_POINT,
127 AddressU = .WRAP,
128 AddressV = .WRAP,
129 AddressW = .WRAP,
130 ComparisonFunc = .NEVER,
131 }
132 sampler_state: ^D3D11.ISamplerState
133 device->CreateSamplerState(&sampler_desc, &sampler_state)
134
135
136 depth_stencil_desc := D3D11.DEPTH_STENCIL_DESC{
137 DepthEnable = true,
138 DepthWriteMask = .ALL,
139 DepthFunc = .LESS,
140 }
141 depth_stencil_state: ^D3D11.IDepthStencilState
142 device->CreateDepthStencilState(&depth_stencil_desc, &depth_stencil_state)
143
144
145
146 Constants :: struct #align (16) {
147 transform: glm.mat4,
148 projection: glm.mat4,
149 light_vector: glm.vec3,
150 }
151
152 constant_buffer_desc := D3D11.BUFFER_DESC{
153 ByteWidth = size_of(Constants),
154 Usage = .DYNAMIC,
155 BindFlags = {.CONSTANT_BUFFER},
156 CPUAccessFlags = {.WRITE},
157 }
158 constant_buffer: ^D3D11.IBuffer
159 device->CreateBuffer(&constant_buffer_desc, nil, &constant_buffer)
160
161 vertex_buffer_desc := D3D11.BUFFER_DESC{
162 ByteWidth = size_of(vertex_data),
163 Usage = .IMMUTABLE,
164 BindFlags = {.VERTEX_BUFFER},
165 }
166 vertex_buffer: ^D3D11.IBuffer
167 device->CreateBuffer(&vertex_buffer_desc, &D3D11.SUBRESOURCE_DATA{pSysMem = &vertex_data[0], SysMemPitch = size_of(vertex_data)}, &vertex_buffer)
168
169 index_buffer_desc := D3D11.BUFFER_DESC{
170 ByteWidth = size_of(index_data),
171 Usage = .IMMUTABLE,
172 BindFlags = {.INDEX_BUFFER},
173 }
174 index_buffer: ^D3D11.IBuffer
175 device->CreateBuffer(&index_buffer_desc, &D3D11.SUBRESOURCE_DATA{pSysMem = &index_data[0], SysMemPitch = size_of(index_data)}, &index_buffer)
176
177
178
179 texture_desc := D3D11.TEXTURE2D_DESC{
180 Width = TEXTURE_WIDTH,
181 Height = TEXTURE_HEIGHT,
182 MipLevels = 1,
183 ArraySize = 1,
184 Format = .R8G8B8A8_UNORM_SRGB,
185 SampleDesc = {Count = 1},
186 Usage = .IMMUTABLE,
187 BindFlags = {.SHADER_RESOURCE},
188 }
189
190 texture_data := D3D11.SUBRESOURCE_DATA{
191 pSysMem = &texture_data[0],
192 SysMemPitch = TEXTURE_WIDTH * 4,
193 }
194
195 texture: ^D3D11.ITexture2D
196 device->CreateTexture2D(&texture_desc, &texture_data, &texture)
197
198 texture_view: ^D3D11.IShaderResourceView
199 device->CreateShaderResourceView(texture, nil, &texture_view)
200
201
202
203 vertex_buffer_stride := u32(11 * 4)
204 vertex_buffer_offset := u32(0)
205
206 model_rotation := glm.vec3{0.0, 0.0, 0.0}
207 model_translation := glm.vec3{0.0, 0.0, 4.0}
208
209 SDL.ShowWindow(window)
210 for quit := false; !quit; {
211 for e: SDL.Event; SDL.PollEvent(&e); {
212 #partial switch e.type {
213 case .QUIT:
214 quit = true
215 case .KEYDOWN:
216 if e.key.keysym.sym == .ESCAPE {
217 quit = true
218 }
219 }
220 }
221
222 viewport := D3D11.VIEWPORT{
223 0, 0,
224 f32(depth_buffer_desc.Width), f32(depth_buffer_desc.Height),
225 0, 1,
226 }
227
228 w := viewport.Width / viewport.Height
229 h := f32(1)
230 n := f32(1)
231 f := f32(9)
232
233 rotate_x := glm.mat4Rotate({1, 0, 0}, model_rotation.x)
234 rotate_y := glm.mat4Rotate({0, 1, 0}, model_rotation.y)
235 rotate_z := glm.mat4Rotate({0, 0, 1}, model_rotation.z)
236 translate := glm.mat4Translate(model_translation)
237
238 model_rotation.x += 0.005
239 model_rotation.y += 0.009
240 model_rotation.z += 0.001
241
242 mapped_subresource: D3D11.MAPPED_SUBRESOURCE
243 device_context->Map(constant_buffer, 0, .WRITE_DISCARD, {}, &mapped_subresource)
244 {
245 constants := (^Constants)(mapped_subresource.pData)
246 constants.transform = translate * rotate_z * rotate_y * rotate_x
247 constants.light_vector = {+1, -1, +1}
248
249 constants.projection = {
250 2 * n / w, 0, 0, 0,
251 0, 2 * n / h, 0, 0,
252 0, 0, f / (f - n), n * f / (n - f),
253 0, 0, 1, 0,
254 }
255 }
256 device_context->Unmap(constant_buffer, 0)
257
258
259
260 device_context->ClearRenderTargetView(framebuffer_view, &[4]f32{0.25, 0.5, 1.0, 1.0})
261 device_context->ClearDepthStencilView(depth_buffer_view, {.DEPTH}, 1, 0)
262
263 device_context->IASetPrimitiveTopology(.TRIANGLELIST)
264 device_context->IASetInputLayout(input_layout)
265 device_context->IASetVertexBuffers(0, 1, &vertex_buffer, &vertex_buffer_stride, &vertex_buffer_offset)
266 device_context->IASetIndexBuffer(index_buffer, .R32_UINT, 0)
267
268 device_context->VSSetShader(vertex_shader, nil, 0)
269 device_context->VSSetConstantBuffers(0, 1, &constant_buffer)
270
271 device_context->RSSetViewports(1, &viewport)
272 device_context->RSSetState(rasterizer_state)
273
274 device_context->PSSetShader(pixel_shader, nil, 0)
275 device_context->PSSetShaderResources(0, 1, &texture_view)
276 device_context->PSSetSamplers(0, 1, &sampler_state)
277
278 device_context->OMSetRenderTargets(1, &framebuffer_view, depth_buffer_view)
279 device_context->OMSetDepthStencilState(depth_stencil_state, 0)
280 device_context->OMSetBlendState(nil, nil, ~u32(0))
281
282
283
284 device_context->DrawIndexed(len(index_data), 0, 0)
285
286 swapchain->Present(1, {})
287 }
288}
289
290shaders_hlsl := `
291cbuffer constants : register(b0) {
292 float4x4 transform;
293 float4x4 projection;
294 float3 light_vector;
295}
296struct vs_in {
297 float3 position : POS;
298 float3 normal : NOR;
299 float2 texcoord : TEX;
300 float3 color : COL;
301};
302struct vs_out {
303 float4 position : SV_POSITION;
304 float2 texcoord : TEX;
305 float4 color : COL;
306};
307Texture2D mytexture : register(t0);
308SamplerState mysampler : register(s0);
309vs_out vs_main(vs_in input) {
310 float light = clamp(dot(normalize(mul(transform, float4(input.normal, 0.0f)).xyz), normalize(-light_vector)), 0.0f, 1.0f) * 0.8f + 0.2f;
311 vs_out output;
312 output.position = mul(projection, mul(transform, float4(input.position, 1.0f)));
313 output.texcoord = input.texcoord;
314 output.color = float4(input.color * light, 1.0f);
315 return output;
316}
317float4 ps_main(vs_out input) : SV_TARGET {
318 return mytexture.Sample(mysampler, input.texcoord) * input.color;
319}
320`
321
322TEXTURE_WIDTH :: 2
323TEXTURE_HEIGHT :: 2
324
325texture_data := [TEXTURE_WIDTH*TEXTURE_HEIGHT]u32{
326 0xffffffff, 0xff7f7f7f,
327 0xff7f7f7f, 0xffffffff,
328}
329
330
331vertex_data := [?]f32{
332 -1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.973, 0.480, 0.002,
333 -0.6, 1.0, -1.0, 0.0, 0.0, -1.0, 2.0, 0.0, 0.973, 0.480, 0.002,
334 0.6, 1.0, -1.0, 0.0, 0.0, -1.0, 8.0, 0.0, 0.973, 0.480, 0.002,
335 1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 10.0, 0.0, 0.973, 0.480, 0.002,
336 -0.6, 0.6, -1.0, 0.0, 0.0, -1.0, 2.0, 2.0, 0.973, 0.480, 0.002,
337 0.6, 0.6, -1.0, 0.0, 0.0, -1.0, 8.0, 2.0, 0.973, 0.480, 0.002,
338 -0.6, -0.6, -1.0, 0.0, 0.0, -1.0, 2.0, 8.0, 0.973, 0.480, 0.002,
339 0.6, -0.6, -1.0, 0.0, 0.0, -1.0, 8.0, 8.0, 0.973, 0.480, 0.002,
340 -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 10.0, 0.973, 0.480, 0.002,
341 -0.6, -1.0, -1.0, 0.0, 0.0, -1.0, 2.0, 10.0, 0.973, 0.480, 0.002,
342 0.6, -1.0, -1.0, 0.0, 0.0, -1.0, 8.0, 10.0, 0.973, 0.480, 0.002,
343 1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 10.0, 10.0, 0.973, 0.480, 0.002,
344 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
345 1.0, 1.0, -0.6, 1.0, 0.0, 0.0, 2.0, 0.0, 0.897, 0.163, 0.011,
346 1.0, 1.0, 0.6, 1.0, 0.0, 0.0, 8.0, 0.0, 0.897, 0.163, 0.011,
347 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 10.0, 0.0, 0.897, 0.163, 0.011,
348 1.0, 0.6, -0.6, 1.0, 0.0, 0.0, 2.0, 2.0, 0.897, 0.163, 0.011,
349 1.0, 0.6, 0.6, 1.0, 0.0, 0.0, 8.0, 2.0, 0.897, 0.163, 0.011,
350 1.0, -0.6, -0.6, 1.0, 0.0, 0.0, 2.0, 8.0, 0.897, 0.163, 0.011,
351 1.0, -0.6, 0.6, 1.0, 0.0, 0.0, 8.0, 8.0, 0.897, 0.163, 0.011,
352 1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 0.0, 10.0, 0.897, 0.163, 0.011,
353 1.0, -1.0, -0.6, 1.0, 0.0, 0.0, 2.0, 10.0, 0.897, 0.163, 0.011,
354 1.0, -1.0, 0.6, 1.0, 0.0, 0.0, 8.0, 10.0, 0.897, 0.163, 0.011,
355 1.0, -1.0, 1.0, 1.0, 0.0, 0.0, 10.0, 10.0, 0.897, 0.163, 0.011,
356 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.612, 0.000, 0.069,
357 0.6, 1.0, 1.0, 0.0, 0.0, 1.0, 2.0, 0.0, 0.612, 0.000, 0.069,
358 -0.6, 1.0, 1.0, 0.0, 0.0, 1.0, 8.0, 0.0, 0.612, 0.000, 0.069,
359 -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 10.0, 0.0, 0.612, 0.000, 0.069,
360 0.6, 0.6, 1.0, 0.0, 0.0, 1.0, 2.0, 2.0, 0.612, 0.000, 0.069,
361 -0.6, 0.6, 1.0, 0.0, 0.0, 1.0, 8.0, 2.0, 0.612, 0.000, 0.069,
362 0.6, -0.6, 1.0, 0.0, 0.0, 1.0, 2.0, 8.0, 0.612, 0.000, 0.069,
363 -0.6, -0.6, 1.0, 0.0, 0.0, 1.0, 8.0, 8.0, 0.612, 0.000, 0.069,
364 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 10.0, 0.612, 0.000, 0.069,
365 0.6, -1.0, 1.0, 0.0, 0.0, 1.0, 2.0, 10.0, 0.612, 0.000, 0.069,
366 -0.6, -1.0, 1.0, 0.0, 0.0, 1.0, 8.0, 10.0, 0.612, 0.000, 0.069,
367 -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 10.0, 10.0, 0.612, 0.000, 0.069,
368 -1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
369 -1.0, 1.0, 0.6, -1.0, 0.0, 0.0, 2.0, 0.0, 0.127, 0.116, 0.408,
370 -1.0, 1.0, -0.6, -1.0, 0.0, 0.0, 8.0, 0.0, 0.127, 0.116, 0.408,
371 -1.0, 1.0, -1.0, -1.0, 0.0, 0.0, 10.0, 0.0, 0.127, 0.116, 0.408,
372 -1.0, 0.6, 0.6, -1.0, 0.0, 0.0, 2.0, 2.0, 0.127, 0.116, 0.408,
373 -1.0, 0.6, -0.6, -1.0, 0.0, 0.0, 8.0, 2.0, 0.127, 0.116, 0.408,
374 -1.0, -0.6, 0.6, -1.0, 0.0, 0.0, 2.0, 8.0, 0.127, 0.116, 0.408,
375 -1.0, -0.6, -0.6, -1.0, 0.0, 0.0, 8.0, 8.0, 0.127, 0.116, 0.408,
376 -1.0, -1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 10.0, 0.127, 0.116, 0.408,
377 -1.0, -1.0, 0.6, -1.0, 0.0, 0.0, 2.0, 10.0, 0.127, 0.116, 0.408,
378 -1.0, -1.0, -0.6, -1.0, 0.0, 0.0, 8.0, 10.0, 0.127, 0.116, 0.408,
379 -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 10.0, 10.0, 0.127, 0.116, 0.408,
380 -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
381 -0.6, 1.0, 1.0, 0.0, 1.0, 0.0, 2.0, 0.0, 0.000, 0.254, 0.637,
382 0.6, 1.0, 1.0, 0.0, 1.0, 0.0, 8.0, 0.0, 0.000, 0.254, 0.637,
383 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 10.0, 0.0, 0.000, 0.254, 0.637,
384 -0.6, 1.0, 0.6, 0.0, 1.0, 0.0, 2.0, 2.0, 0.000, 0.254, 0.637,
385 0.6, 1.0, 0.6, 0.0, 1.0, 0.0, 8.0, 2.0, 0.000, 0.254, 0.637,
386 -0.6, 1.0, -0.6, 0.0, 1.0, 0.0, 2.0, 8.0, 0.000, 0.254, 0.637,
387 0.6, 1.0, -0.6, 0.0, 1.0, 0.0, 8.0, 8.0, 0.000, 0.254, 0.637,
388 -1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 0.0, 10.0, 0.000, 0.254, 0.637,
389 -0.6, 1.0, -1.0, 0.0, 1.0, 0.0, 2.0, 10.0, 0.000, 0.254, 0.637,
390 0.6, 1.0, -1.0, 0.0, 1.0, 0.0, 8.0, 10.0, 0.000, 0.254, 0.637,
391 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 10.0, 10.0, 0.000, 0.254, 0.637,
392 -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
393 -0.6, -1.0, -1.0, 0.0, -1.0, 0.0, 2.0, 0.0, 0.001, 0.447, 0.067,
394 0.6, -1.0, -1.0, 0.0, -1.0, 0.0, 8.0, 0.0, 0.001, 0.447, 0.067,
395 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 10.0, 0.0, 0.001, 0.447, 0.067,
396 -0.6, -1.0, -0.6, 0.0, -1.0, 0.0, 2.0, 2.0, 0.001, 0.447, 0.067,
397 0.6, -1.0, -0.6, 0.0, -1.0, 0.0, 8.0, 2.0, 0.001, 0.447, 0.067,
398 -0.6, -1.0, 0.6, 0.0, -1.0, 0.0, 2.0, 8.0, 0.001, 0.447, 0.067,
399 0.6, -1.0, 0.6, 0.0, -1.0, 0.0, 8.0, 8.0, 0.001, 0.447, 0.067,
400 -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 10.0, 0.001, 0.447, 0.067,
401 -0.6, -1.0, 1.0, 0.0, -1.0, 0.0, 2.0, 10.0, 0.001, 0.447, 0.067,
402 0.6, -1.0, 1.0, 0.0, -1.0, 0.0, 8.0, 10.0, 0.001, 0.447, 0.067,
403 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 10.0, 10.0, 0.001, 0.447, 0.067,
404 -0.6, 0.6, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
405 -0.6, 0.6, -0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
406 -0.6, -0.6, -0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
407 -0.6, -0.6, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
408 0.6, 0.6, -0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
409 0.6, 0.6, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
410 0.6, -0.6, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
411 0.6, -0.6, -0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
412 -0.6, -0.6, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
413 -0.6, -0.6, -0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
414 0.6, -0.6, -0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
415 0.6, -0.6, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
416 -0.6, 0.6, -0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
417 -0.6, 0.6, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
418 0.6, 0.6, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
419 0.6, 0.6, -0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.973, 0.480, 0.002,
420 1.0, 0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.897, 0.163, 0.011,
421 0.6, 0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.897, 0.163, 0.011,
422 0.6, -0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.897, 0.163, 0.011,
423 1.0, -0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.897, 0.163, 0.011,
424 0.6, 0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.897, 0.163, 0.011,
425 1.0, 0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.897, 0.163, 0.011,
426 1.0, -0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.897, 0.163, 0.011,
427 0.6, -0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.897, 0.163, 0.011,
428 1.0, 0.6, 0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
429 0.6, 0.6, 0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
430 0.6, 0.6, -0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
431 1.0, 0.6, -0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
432 0.6, -0.6, 0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
433 1.0, -0.6, 0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
434 1.0, -0.6, -0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
435 0.6, -0.6, -0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.897, 0.163, 0.011,
436 0.6, 0.6, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
437 0.6, 0.6, 0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
438 0.6, -0.6, 0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
439 0.6, -0.6, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
440 -0.6, 0.6, 0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
441 -0.6, 0.6, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
442 -0.6, -0.6, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
443 -0.6, -0.6, 0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
444 0.6, -0.6, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
445 0.6, -0.6, 0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
446 -0.6, -0.6, 0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
447 -0.6, -0.6, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
448 0.6, 0.6, 0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
449 0.6, 0.6, 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
450 -0.6, 0.6, 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
451 -0.6, 0.6, 0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.612, 0.000, 0.069,
452 -1.0, 0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.127, 0.116, 0.408,
453 -0.6, 0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.127, 0.116, 0.408,
454 -0.6, -0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.127, 0.116, 0.408,
455 -1.0, -0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.127, 0.116, 0.408,
456 -0.6, 0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.127, 0.116, 0.408,
457 -1.0, 0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.127, 0.116, 0.408,
458 -1.0, -0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.127, 0.116, 0.408,
459 -0.6, -0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.127, 0.116, 0.408,
460 -1.0, -0.6, 0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
461 -0.6, -0.6, 0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
462 -0.6, -0.6, -0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
463 -1.0, -0.6, -0.6, 0.0, 1.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
464 -0.6, 0.6, 0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
465 -1.0, 0.6, 0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
466 -1.0, 0.6, -0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
467 -0.6, 0.6, -0.6, 0.0, -1.0, 0.0, 0.0, 0.0, 0.127, 0.116, 0.408,
468 -0.6, 1.0, 0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
469 -0.6, 0.6, 0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
470 -0.6, 0.6, -0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
471 -0.6, 1.0, -0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
472 0.6, 0.6, 0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
473 0.6, 1.0, 0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
474 0.6, 1.0, -0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
475 0.6, 0.6, -0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.000, 0.254, 0.637,
476 -0.6, 1.0, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.000, 0.254, 0.637,
477 -0.6, 0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.000, 0.254, 0.637,
478 0.6, 0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.000, 0.254, 0.637,
479 0.6, 1.0, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.000, 0.254, 0.637,
480 -0.6, 0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.000, 0.254, 0.637,
481 -0.6, 1.0, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.000, 0.254, 0.637,
482 0.6, 1.0, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.000, 0.254, 0.637,
483 0.6, 0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.000, 0.254, 0.637,
484 -0.6, -0.6, 0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
485 -0.6, -1.0, 0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
486 -0.6, -1.0, -0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
487 -0.6, -0.6, -0.6, 1.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
488 0.6, -1.0, 0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
489 0.6, -0.6, 0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
490 0.6, -0.6, -0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
491 0.6, -1.0, -0.6, -1.0, 0.0, 0.0, 0.0, 0.0, 0.001, 0.447, 0.067,
492 -0.6, -0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.001, 0.447, 0.067,
493 -0.6, -1.0, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.001, 0.447, 0.067,
494 0.6, -1.0, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.001, 0.447, 0.067,
495 0.6, -0.6, -0.6, 0.0, 0.0, 1.0, 0.0, 0.0, 0.001, 0.447, 0.067,
496 -0.6, -1.0, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.001, 0.447, 0.067,
497 -0.6, -0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.001, 0.447, 0.067,
498 0.6, -0.6, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.001, 0.447, 0.067,
499 0.6, -1.0, 0.6, 0.0, 0.0, -1.0, 0.0, 0.0, 0.001, 0.447, 0.067,
500}
501
502index_data := [?]u32{
503 0, 1, 9, 9, 8, 0, 1, 2, 5, 5, 4, 1, 6, 7, 10, 10, 9, 6, 2, 3, 11, 11, 10, 2,
504 12, 13, 21, 21, 20, 12, 13, 14, 17, 17, 16, 13, 18, 19, 22, 22, 21, 18, 14, 15, 23, 23, 22, 14,
505 24, 25, 33, 33, 32, 24, 25, 26, 29, 29, 28, 25, 30, 31, 34, 34, 33, 30, 26, 27, 35, 35, 34, 26,
506 36, 37, 45, 45, 44, 36, 37, 38, 41, 41, 40, 37, 42, 43, 46, 46, 45, 42, 38, 39, 47, 47, 46, 38,
507 48, 49, 57, 57, 56, 48, 49, 50, 53, 53, 52, 49, 54, 55, 58, 58, 57, 54, 50, 51, 59, 59, 58, 50,
508 60, 61, 69, 69, 68, 60, 61, 62, 65, 65, 64, 61, 66, 67, 70, 70, 69, 66, 62, 63, 71, 71, 70, 62,
509 72, 73, 74, 74, 75, 72, 76, 77, 78, 78, 79, 76, 80, 81, 82, 82, 83, 80, 84, 85, 86, 86, 87, 84,
510 88, 89, 90, 90, 91, 88, 92, 93, 94, 94, 95, 92, 96, 97, 98, 98, 99, 96, 100, 101, 102, 102, 103, 100,
511 104, 105, 106, 106, 107, 104, 108, 109, 110, 110, 111, 108, 112, 113, 114, 114, 115, 112, 116, 117, 118, 118, 119, 116,
512 120, 121, 122, 122, 123, 120, 124, 125, 126, 126, 127, 124, 128, 129, 130, 130, 131, 128, 132, 133, 134, 134, 135, 132,
513 136, 137, 138, 138, 139, 136, 140, 141, 142, 142, 143, 140, 144, 145, 146, 146, 147, 144, 148, 149, 150, 150, 151, 148,
514 152, 153, 154, 154, 155, 152, 156, 157, 158, 158, 159, 156, 160, 161, 162, 162, 163, 160, 164, 165, 166, 166, 167, 164,
515}