Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I use glGenSamplers in OpenGL version 3.2 ?
Qt 6.11 is out! See what's new in the release blog

How can I use glGenSamplers in OpenGL version 3.2 ?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hesheit
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #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.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Note however, that OS X doesn't support sampler objects until OS X Mavericks is released.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hesheit
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Oh sorry I thought you meant OpenGL sampler objects but you actually mean GLSL texture sampler opaque types. Yes that should work fine.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved