MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / LoadLevels

Method LoadLevels

engine/PoseidonGL33/TextureGL33_Loading.cpp:148–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146 // Upload to GL
147 TextureDescGL33 fmtDesc;
148 InitGLPixelFormat(fmtDesc, dstFmt, true);
149
150 if (fmtDesc.compressed)
151 {
152 glCompressedTexSubImage2D(GL_TEXTURE_2D, aLevel, 0, 0, srcMip._w, srcMip._h, fmtDesc.internalFormat, dataSize,
153 pixelData.Data());
154 GLenum err = glGetError();
155 if (err != GL_NO_ERROR)
156 {
157 LOG_ERROR(
158 Graphics,
159 "GL33: glCompressedTexSubImage2D FAILED err=0x{:04X} tex={} level={} {}x{} fmt=0x{:04X} size={}",
160 err, tex, aLevel, srcMip._w, srcMip._h, fmtDesc.internalFormat, dataSize);
161 }
162 }
163 else
164 {
165 glTexSubImage2D(GL_TEXTURE_2D, aLevel, 0, 0, srcMip._w, srcMip._h, fmtDesc.pixelFormat, fmtDesc.pixelType,
166 pixelData.Data());
167 GLenum err = glGetError();
168 if (err != GL_NO_ERROR)
169 {
170 LOG_ERROR(Graphics, "GL33: glTexSubImage2D FAILED err=0x{:04X} tex={} level={} {}x{} fmt=0x{:04X}", err,
171 tex, aLevel, srcMip._w, srcMip._h, fmtDesc.pixelFormat);
172 }
173 }
174 }
175
176 GL33Bind::ActiveUnit(0);
177 return 0;
178}
179
180int TextureGL33::LoadLevels(int levelMin)
181{
182 if (levelMin < 0)
183 return 0;
184
185 TextBankGL33* bank = static_cast<TextBankGL33*>(GEngine->TextBank());
186
187 PoseidonAssert(levelMin < _nMipmaps);
188 PoseidonAssert(levelMin >= 0);
189
190 int ret = 0;
191
192 if (_interpolate)
193 _interpolate->_inUse++;
194
195 if (_levelLoaded > levelMin)
196 {
197 ReleaseMemory(true);
198
199 _inUse++;
200
201 TextureDescGL33 desc;
202 InitDesc(desc, levelMin, true);
203
204 PacFormat format = UploadFormatForTextureGL33(_mipmaps[levelMin].DstFormat(), _interpolate);
205 bank->UseReleased(_surface, desc, format);

Callers 1

UseMipmapMethod · 0.80

Calls 7

DstFormatMethod · 0.80
UseReleasedMethod · 0.80
ReuseMethod · 0.80
ReserveMemoryMethod · 0.80
CreateGPUSurfaceMethod · 0.80
TextBankMethod · 0.45
GetTextureMethod · 0.45

Tested by

no test coverage detected