Skip to content

Instantly share code, notes, and snippets.

Bartłomiej Filipek fenbf

Block or report user

Report or block fenbf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
fenbf / CalcTexPixels.cpp
Created Oct 30, 2013
Function that will go through all texture object levels and count pixel counts and memory in bytes. Currently only Compressed textures formats are supported and RGB8 (RGB) or RGBA8 (RGBA)
View CalcTexPixels.cpp
void CalculateTextureObjectPixels(GLuint texID, unsigned long *pixelCount, unsigned long *memoryUsed)
int baseLevel = 0, maxLevel = 0;
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, &baseLevel);
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, &maxLevel);
long pixels = 0, bytes = 0, bpp = 0;
int texW = 0, texH = 0, texFmt = 0, compressed = 0, compressedBytes = 0;
for (int level = baseLevel; level <= maxLevel; ++level)
You can’t perform that action at this time.