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

Method Initialize

GTE/Graphics/GL46/GL46TextureSingle.cpp:30–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30void GL46TextureSingle::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 if (texture->GetData())
51 {
52 if (CanAutoGenerateMipmaps())
53 {
54 // Initialize with the first mipmap level and then generate
55 // the remaining mipmaps.
56 auto data = texture->GetDataFor(0);
57 if (data)
58 {
59 LoadTextureLevel(0, data);
60 GenerateMipmaps();
61 }
62 }
63 else
64 {
65 // Initialize with each mipmap level.
66 for (int32_t level = 0; level < mNumLevels; ++level)
67 {
68 auto data = texture->GetDataFor(level);
69 if (data)
70 {
71 LoadTextureLevel(level, data);
72 }
73 }
74 }
75 }
76
77 glBindTexture(mTarget, prevBinding);
78}
79
80bool GL46TextureSingle::Update()
81{

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected