MCPcopy Create free account
hub / github.com/StereoKit/StereoKit / Initialize

Method Initialize

Examples/StereoKitTest/Docs/DocTextures.cs:5–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3internal class DocTextures : ITest
4{
5 public void Initialize()
6 {
7 /// :CodeSample: Tex.GetColorData
8 /// ### Get data from a Tex
9 /// Reading texture data from a Tex can be a slow operation, since
10 /// texture memory lives on the GPU, and isn't generally optimized for
11 /// readability. But, sometimes you still have to do it! Just remember
12 /// to avoid doing it too often or casually, and be cautious about how
13 /// you treat the large amounts of memory involved.
14
15 // Reading colors can be as simple as this! Remember to select a color
16 // format that matches the data stored in the texture, as StereoKit
17 // will not convert the data for you. Most images from file are 32 bit
18 // RGBA images!
19 Tex texture = Tex.FromFile("floor.png");
20 Color32[] colors = texture.GetColorData<Color32>();
21
22 // For a more complex texture, such as this generated texture with 32
23 // bits per channel, we can load the data into a float array, with 4
24 // floats per-pixel! A `Color` would probably be fine here too.
25 Tex texture2 = Tex.GenColor(Color.White, 16, 16, TexType.Image, TexFormat.Rgba128);
26 float[] colors2 = texture2.GetColorData<float>(0, 4);
27 /// :End:
28 }
29
30 public void Shutdown()
31 {

Callers

nothing calls this directly

Calls 2

GenColorMethod · 0.80
FromFileMethod · 0.45

Tested by

no test coverage detected