MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / Initialize

Method Initialize

GTE/Graphics/GL46/GL46TextureArray.cpp:30–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30void GL46TextureArray::Initialize()
31{
32 // Save current binding for this texture target in order to restore it
33 // when done because the gl texture object is needed to be bound to this
34 // texture target for the operations to follow.
35 GLint prevBinding;
36 glGetIntegerv(mTargetBinding, &prevBinding);
37 glBindTexture(mTarget, mGLHandle);
38
39 // The default is 4-byte alignment. This allows byte alignment when data
40 // from user buffers into textures and vice versa.
41 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
42 glPixelStorei(GL_PACK_ALIGNMENT, 1);
43
44 // Set the range of levels.
45 glTexParameteri(mTarget, GL_TEXTURE_BASE_LEVEL, 0);
46 glTexParameteri(mTarget, GL_TEXTURE_MAX_LEVEL, mNumLevels-1);
47
48 // Initialize with data?
49 auto texture = GetTexture();
50 auto const numItems = texture->GetNumItems();
51 if (texture->GetData())
52 {
53 if (CanAutoGenerateMipmaps())
54 {
55 // Initialize with the first mipmap level and then generate
56 // the remaining mipmaps.
57 for (uint32_t item = 0; item < numItems; ++item)
58 {
59 auto data = texture->GetDataFor(item, 0);
60 if (data)
61 {
62 LoadTextureLevel(item, 0, data);
63 }
64 }
65 GenerateMipmaps();
66 }
67 else
68 {
69 // Initialize with each mipmap level.
70 for (uint32_t item = 0; item < numItems; ++item)
71 {
72 for (int32_t level = 0; level < mNumLevels; ++level)
73 {
74 auto data = texture->GetDataFor(item, level);
75 if (data)
76 {
77 LoadTextureLevel(item, level, data);
78 }
79 }
80 }
81 }
82 }
83
84 glBindTexture(mTarget, prevBinding);
85}
86
87bool GL46TextureArray::Update()

Callers

nothing calls this directly

Calls 7

glGetIntegervFunction · 0.85
glBindTextureFunction · 0.85
glPixelStoreiFunction · 0.85
glTexParameteriFunction · 0.85
GetNumItemsMethod · 0.80
GetDataMethod · 0.45
GetDataForMethod · 0.45

Tested by

no test coverage detected