I can set my texture with the code below but the part that sets the sampler parameters has no effect on the texture drawn (it is still linear lookup)
// Get sampler
GLuint textureSamplerParam = glGetUniformLocation(m_effect, "AtlasTextureSampler");
// Bind our texture in Texture Unit 0
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
// Bind the texture to the sampler
glBindSampler(texture, textureSamplerParam);
// Set sampler parameters
glSamplerParameteri(textureSamplerParam, GL_TEXTURE_WRAP_S, GL_CLAMP);
glSamplerParameteri(textureSamplerParam, GL_TEXTURE_WRAP_T, GL_CLAMP);
glSamplerParameteri(textureSamplerParam, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameteri(textureSamplerParam, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
I’m currently automating my texture loading through the glload library, does that affect the texture at all?
std::string filename(LOCAL_FILE_DIR);
filename.append("TextureAtlasTexture.png");
// 'glload' must be initialised for 'glimg::CreateTexture' to work
if (glload::LoadFunctions() == glload::LS_LOAD_FAILED)
{
// Initialisation failed
}
std::auto_ptr<glimg::ImageSet> pImgSet(glimg::loaders::stb::LoadFromFile(filename));
m_texture = glimg::CreateTexture(pImgSet.get(), 0);
I have tried creating it myself but that returns nothing but an array of 0’s. The dimensions of the array match that of the image though.
std::auto_ptr<glimg::ImageSet> pImgSet(glimg::loaders::stb::LoadFromFile(filename));
glimg::SingleImage image = pImgSet->GetImage(0, 0, 0);
glimg::Dimensions dims = image.GetDimensions();
// Allocate a new texture
glGenTextures(1, &m_texture);
// Bind the new texture
glBindTexture(GL_TEXTURE_2D, m_texture);
// Bind the data to the currently bound texture
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_RGBA8,
dims.width,
dims.height,
0,
GL_RED,
GL_UNSIGNED_BYTE,
image.GetImageData() // Returns nothing but an array of '0'
);
// Automatically generate mipmaps
glGenerateMipmap(GL_TEXTURE_2D);
// Unbind texture
glBindTexture(GL_TEXTURE_2D, 0);