How can I use glGenSamplers in OpenGL version 3.2 ?
As stated in OpenGL reference webpage, glGenSamplers is first provided in the version 3.3. but how it can be used through the version 3.2 in Qt5.
If your OpenGL implementation supports it there are extension classes that can help you here. They are in a new static module called QtOpenGLExtensions. To enable this add:
QT += openglextensions
to your .pro file. Then, once you have your OpenGL 3.2 context instantiate a suitable extension class and initialize it with something like:
QOpenGLExtension_ARB_sampler_objects* ext = new QOpenGL_ARB_sampler_objects;
qWarning() << "Could not resolve sampler function pointers";
Then use the functions as needed:
I'm also hoping to add QOpenGLSampler and QpenGLTexture to Qt 5.2.
Note however, that OS X doesn't support sampler objects until OS X Mavericks is released.
Thank you ZapB.
Now Im using OS X and I am going to implement it with the old-fashioned style by following codes
@// Bind the texture
// Associate with sampler uniform in shader QString samplerName = sampler->getSamplerNameInShaderProgram(); GLuint samplerLoc = m_shader_program->uniformLocation(samplerName); m_shader_program->setUniformValue(samplerLoc, unit);@
Do you think it will work?
Oh sorry I thought you meant OpenGL sampler objects but you actually mean GLSL texture sampler opaque types. Yes that should work fine.