Unify texture configuration.
This commit is contained in:
@@ -61,14 +61,7 @@ InputLayerVisualisation::InputLayerVisualisation(const LayerData &data)
|
|||||||
nodePositions_.push_back(nodePositions_[i % 3]);
|
nodePositions_.push_back(nodePositions_[i % 3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
texture.bind(GL_TEXTURE_2D);
|
texture.configure(GL_TEXTURE_2D);
|
||||||
// Set up (lack of) repetition
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
|
||||||
|
|
||||||
// Set up texture scaling
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); // Use mipmapping for scaling down
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Use nearest pixel when scaling up.
|
|
||||||
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_FLOAT, imageData.data());
|
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_FLOAT, imageData.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,3 +34,18 @@ void Texture::bind(GLenum target) const
|
|||||||
{
|
{
|
||||||
glBindTexture(target, id);
|
glBindTexture(target, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Texture::configure(GLenum target) const
|
||||||
|
{
|
||||||
|
bind(target);
|
||||||
|
const float color[] = {1, 0, 1}; // Background color for textures.
|
||||||
|
|
||||||
|
// Set up (lack of) repetition
|
||||||
|
glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
|
||||||
|
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||||
|
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, color);
|
||||||
|
|
||||||
|
// Set up texture scaling
|
||||||
|
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); // Use mipmapping for scaling down
|
||||||
|
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Use nearest pixel when scaling up.
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace fmri
|
|||||||
* @param target valid target for glBindTexture.
|
* @param target valid target for glBindTexture.
|
||||||
*/
|
*/
|
||||||
void bind(GLenum target) const;
|
void bind(GLenum target) const;
|
||||||
|
void configure(GLenum target) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLuint id;
|
GLuint id;
|
||||||
|
|||||||
@@ -38,21 +38,8 @@ fmri::Texture fmri::loadTexture(DType const *data, int width, int height, int su
|
|||||||
vector<float> textureBuffer(data, data + (width * height));
|
vector<float> textureBuffer(data, data + (width * height));
|
||||||
rescaleSubImages(textureBuffer, subImages);
|
rescaleSubImages(textureBuffer, subImages);
|
||||||
|
|
||||||
const float color[] = {1, 1, 1}; // Background color for textures.
|
|
||||||
|
|
||||||
Texture texture;
|
Texture texture;
|
||||||
texture.bind(GL_TEXTURE_2D);
|
texture.configure(GL_TEXTURE_2D);
|
||||||
|
|
||||||
// Set up (lack of) repetition
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
|
||||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color);
|
|
||||||
|
|
||||||
// Set up texture scaling
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); // Use mipmapping for scaling down
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Use nearest pixel when scaling up.
|
|
||||||
checkGLErrors();
|
|
||||||
|
|
||||||
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_LUMINANCE, width, height, GL_LUMINANCE, GL_FLOAT, textureBuffer.data());
|
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_LUMINANCE, width, height, GL_LUMINANCE, GL_FLOAT, textureBuffer.data());
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
|
|||||||
Reference in New Issue
Block a user