OpenGLHelper::setTextureParam


#1

We often find this code in classical GL code:

            glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0 );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mode );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mode );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

So what about adding:

static void setTextureParameters(const double priority = 1.0, const bool bilinearFiltering = true, const bool withEdges = false)
{
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, priority );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bilinearFiltering ? GL_LINEAR : GL_NEAREST );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bilinearFiltering ? GL_LINEAR : GL_NEAREST );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, withEdges ?  GL_CLAMP : GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, withEdges ?  GL_CLAMP : GL_CLAMP_TO_EDGE );
}

to the OpenGLHelpers ?


#2

Is that valid in GLES 2.0?


#3

Seems so:


#4

Well, I’d maybe add something like this…

static void setTextureParameters (const double priority, GLenum filterType, GLenum edgeMode) { glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, priority ); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterType); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterType); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, edgeMode); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, edgeMode); }