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

Method GetPixel

engine/PoseidonGL33/TextureGL33_Init.cpp:259–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259Color TextureGL33::GetPixel(int level, float u, float v) const
260{
261 LoadHeadersNV();
262
263 QIFStream in;
264 GFileServer->Open(in, Name());
265 if (in.fail())
266 return HWhite;
267
268 Color icol;
269 QIFStream ipol;
270 if (_interpolate)
271 {
272 GFileServer->Open(ipol, _interpolate->Name());
273 if (ipol.fail())
274 return HWhite;
275 }
276
277 PacLevelMem mip = _mipmaps[level];
278
279 AUTO_STATIC_ARRAY(char, mem, 256 * 256 * 2);
280 mem.Realloc(mip._pitch * mip._h);
281 mem.Resize(mip._pitch * mip._h);
282
283 _src->GetMipmapData(mem.Data(), mip, level);
284
285 if (_interpolate)
286 {
287 AUTO_STATIC_ARRAY(char, imem, 256 * 256 * 2);
288 PacLevelMem& imip = _interpolate->_mipmaps[level];
289 imem.Realloc(imip._pitch * imip._h);
290 imem.Resize(imip._pitch * imip._h);
291 _interpolate->_src->GetMipmapData(imem.Data(), imip, level);
292 icol = imip.GetPixel(imem.Data(), u, v);
293 }
294 Color col = mip.GetPixel(mem.Data(), u, v);
295 if (_interpolate)
296 {
297 col = col * (1 - _iFactor) + icol * _iFactor;
298 }
299 return col;
300}
301
302// Decode the top (full-resolution) mip once and classify its alpha channel.
303// Reads the texture's bytes through the VFS (so it works for PBO-packed textures) and
304// decodes via the shared DecodePAABuffer, which handles every PAA/PAC pixel format
305// (DXT1/3/5, ARGB8888/4444/1555, AI88, P8) — unlike PacLevelMem::GetPixelInt, which
306// only covers a subset and would Fail per texel on the rest. Top mip on purpose: a
307// smaller mip blurs a cutout's crisp 0/255 holes into false partial-alpha, which would
308// mis-route a pole/fence to the blend pass.
309Poseidon::AlphaStats::Kind TextureGL33::ScanTopMipAlphaClass()
310{
311 LoadHeadersNV();
312 if (!_src)
313 return Poseidon::AlphaStats::Opaque;
314
315 QIFStream in;
316 GFileServer->Open(in, Name());

Callers 1

AUTO_STATIC_ARRAYFunction · 0.45

Calls 4

LoadHeadersNVFunction · 0.85
OpenMethod · 0.45
failMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected