How can I use glGenSamplers in OpenGL version 3.2 ?
-
Hi,
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;
if (!ext->initializeOpenGLFunctions())
qWarning() << "Could not resolve sampler function pointers";
@Then use the functions as needed:
@
GLuint m_samplerId;
...
ext->glGenSamplers(1, &m_samplerId);
...
@I'm also hoping to add QOpenGLSampler and QpenGLTexture to Qt 5.2.
-
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
m_funcs->glActiveTexture( GL_TEXTURE0);
texture->bind();// 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?