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?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 899 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.
  • 8 Offline
    8 Offline
    8Observer8
    wrote on 12 Dec 2014, 11:39 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 12 Dec 2014, 13:56 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
      • 8 Offline
        8 Offline
        8Observer8
        wrote on 12 Dec 2014, 14:44 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 12 Dec 2014, 14:59 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

          3/4

          12 Dec 2014, 14:44

          • Login

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