diff --git a/src/graphics/texture_read.cpp b/src/graphics/texture_read.cpp index d7e5090a0..22d8a8e85 100644 --- a/src/graphics/texture_read.cpp +++ b/src/graphics/texture_read.cpp @@ -20,9 +20,10 @@ #include "config/user_config.hpp" -TextureReadBaseNew::BindFunction TextureReadBaseNew::m_all_bind_functions[] = -{ &bindTextureNearest, - &bindTextureTrilinearAnisotropic }; +TextureReadBaseNew::BindFunction TextureReadBaseNew::m_all_bind_functions[] = +{ &TextureReadBaseNew::bindTextureNearest, + &TextureReadBaseNew::bindTextureTrilinearAnisotropic }; + GLuint TextureReadBaseNew::m_all_texture_types[] = { GL_TEXTURE_2D, GL_TEXTURE_2D }; // ---------------------------------------------------------------------------- @@ -37,11 +38,12 @@ GLuint TextureReadBaseNew::createSamplers(SamplerTypeNew sampler_type) default: assert(false); + return 0; } // switch } // createSamplers // ---------------------------------------------------------------------------- -void bindTextureNearest(GLuint texture_unit, GLuint tex) +void TextureReadBaseNew::bindTextureNearest(GLuint texture_unit, GLuint tex) { glActiveTexture(GL_TEXTURE0 + texture_unit); glBindTexture(GL_TEXTURE_2D, tex); @@ -53,9 +55,9 @@ void bindTextureNearest(GLuint texture_unit, GLuint tex) } // bindTextureNearest // ---------------------------------------------------------------------------- -void bindTextureTrilinearAnisotropic(GLuint TU, GLuint tex) +void TextureReadBaseNew::bindTextureTrilinearAnisotropic(GLuint tex_unit, GLuint tex) { - glActiveTexture(GL_TEXTURE0 + TU); + glActiveTexture(GL_TEXTURE0 + tex_unit); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); @@ -83,8 +85,8 @@ GLuint createNearestSampler() } // createNearestSampler // ---------------------------------------------------------------------------- -void bindTextureNearesClamped(GLuint texture_unit, - GLuint tex_id) +void TextureReadBaseNew::bindTextureNearestClamped(GLuint texture_unit, + GLuint tex_id) { glActiveTexture(GL_TEXTURE0 + texture_unit); glBindTexture(GL_TEXTURE_2D, tex_id); @@ -108,9 +110,9 @@ void bindTextureBilinear(GLuint texture_unit, GLuint tex) } // bindTextureBilinear // ---------------------------------------------------------------------------- -void bindTextureBilinearClamped(GLuint TU, GLuint tex) +void bindTextureBilinearClamped(GLuint tex_unit, GLuint tex) { - glActiveTexture(GL_TEXTURE0 + TU); + glActiveTexture(GL_TEXTURE0 + tex_unit); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -120,9 +122,9 @@ void bindTextureBilinearClamped(GLuint TU, GLuint tex) } // bindTextureBilinearClamped // ---------------------------------------------------------------------------- -void bindTextureSemiTrilinear(GLuint TU, GLuint tex) +void bindTextureSemiTrilinear(GLuint tex_unit, GLuint tex) { - glActiveTexture(GL_TEXTURE0 + TU); + glActiveTexture(GL_TEXTURE0 + tex_unit); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); diff --git a/src/graphics/texture_read.hpp b/src/graphics/texture_read.hpp index 0baf704cb..2d34724fb 100644 --- a/src/graphics/texture_read.hpp +++ b/src/graphics/texture_read.hpp @@ -20,12 +20,10 @@ #include "shaders_util.hpp" +#include -void bindTextureNearest(unsigned TU, unsigned tid); GLuint createNearestSampler(); -void bindTextureTrilinearAnisotropic(unsigned, unsigned); GLuint createTrilinearSampler(); -void bindTextureNearesClamped(GLuint texture_unit, GLuint tex); enum SamplerTypeNew { @@ -44,13 +42,15 @@ enum SamplerTypeNew { class TextureReadBaseNew { -protected: - -private: - - typedef void(*BindFunction)(unsigned, unsigned); +public: + typedef std::function BindFunction; protected: + static void bindTextureNearest(GLuint TU, GLuint tid); + static void bindTextureNearestClamped(GLuint texture_unit, GLuint tex); + static void bindTextureTrilinearAnisotropic(GLuint, GLuint); + + static BindFunction m_all_bind_functions[2]; std::vector m_bind_functions; static GLuint m_all_texture_types[]; @@ -65,14 +65,6 @@ class TextureReadNew : public TextureReadBaseNew { private: - static void bindTextureNearest(unsigned TU, unsigned tid); -// static void bindTextureTrilinearAnisotropic(unsigned , unsigned ); - - //typedef void(TextureReadBaseNew::*BindFunction)(unsigned, unsigned); - - //static void(*)(unsigned, unsigned) m_all_bind_functions[2]; - -// std::vector m_bind_functions; std::vector m_texture_units; std::vector m_texture_type;