keywords: Graphics, Shading, Texture Downsampling (Downscaling) Notes

Texture Parameters (glTexParameteri)

OpenGL

textures_exercise4.cpp from LearnOpenGL

// load and create a texture 
// -------------------------
unsigned int texture2;
// texture 2
// ---------
glGenTextures(1, &texture2);
glBindTexture(GL_TEXTURE_2D, texture2);
// set the texture wrapping parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// set texture filtering parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // set texture filtering to nearest neighbor to clearly see the texels/pixels
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// load image, create texture and generate mipmaps
data = stbi_load(FileSystem::getPath("resources/textures/awesomeface.png").c_str(), &width, &height, &nrChannels, 0);
if (data)
{
    // note that the awesomeface.png has transparency and thus an alpha channel, so make sure to tell OpenGL the data type is of GL_RGBA
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
    glGenerateMipmap(GL_TEXTURE_2D);
}
else
{
    std::cout << "Failed to load texture" << std::endl;
}
stbi_image_free(data);

Texture Downsampling (Downscaling)

OpenGL

What is texture downsampling (downscaling) using OpenGL?
https://stackoverflow.com/a/30290468/1645289

DirectX

Downscaling texture via mipmap [DirectX 11]
https://computergraphics.stackexchange.com/questions/8975/downscaling-texture-via-mipmap-directx-11


“What's measured improves” ― Peter Drucker