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 to use the bindTexture() function outside of the QGLWidget children?
QtWS25 Last Chance

How to use the bindTexture() function outside of the QGLWidget children?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 886 Views
  • 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.
  • 8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by
    #1

    Hello!

    I have a class Scene:

    @class Scene : public QGLWidget
    {
    // ...
    void genTexture();
    // ...
    }

    void Scene::genTexture()
    {
    triangleTextureID = bindTexture( QPixmap( QString( ":Textures/Stub.jpg" ) ), GL_TEXTURE_2D );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
    }@

    And I have a class Triangle:
    @#ifndef TRIANGLE_H
    #define TRIANGLE_H

    // ...

    class Triangle
    {
    // ...
    }

    #endif // TRIANGLE_H@

    I want to move genTexture() to the class Triangle. How to use the bindTexture() function outside of the QGLWidget children?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ceora
      wrote on last edited by
      #2

      Hi, not sure if it work have you tried to pass a "Scene" pointer to class Triangle??
      @#ifndef TRIANGLE_H
      #define TRIANGLE_H

      #include "scene.h"
      // ...

      class Triangle
      {
      private:
      Scene *m_scene;
      void genTexture(){m_scene->genTexture;}

      }@

      if not work try also to add m_scene->context()->makeCurrent(); before m_scene->genTexture();

      1 Reply Last reply
      0
      • 8Observer88 Offline
        8Observer88 Offline
        8Observer8
        wrote on last edited by
        #3

        Thank you! I will try it. But I cannot see a texture. I don't know where is mistake. Please, run my simple example from this theme: http://qt-project.org/forums/viewthread/50872/

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ceora
          wrote on last edited by
          #4

          unfortunately i can't help you with this, i've just started learning OpenGL v3.3 and i have also some problems... However in previous version you should try glEnable(GL_TEXTURE_2D); if you are in compatibly context it should work, don't know if still exist in new version of openGL...

          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