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. Some problems of using opengl es in qt
Forum Updated to NodeBB v4.3 + New Features

Some problems of using opengl es in qt

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 6.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
    halftone
    wrote on last edited by
    #1

    when I ported my code which is developed by opengl es from windows framework to qt framework, some run errors occured in functions such as "glDrawElements" .
    Are there some differences between qt framework and windows in using buffer objects or kind of "glDrawElements" function ?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ixSci
      wrote on last edited by
      #2

      I'm sure you will have the more appropriate advices when others can see your code and what is wrong with it.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        halftone
        wrote on last edited by
        #3

        when I was using qt with opengl es, in my render code, I used VBO in the way just like in win32 project, the code is the following:

        @
        void DrawMesh()

        {
        #if 1
        glDisableClientState(GL_NORMAL_ARRAY);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        GLuint buf1,buf2;
        glGenBuffers(1,&buf1);
        glBindBuffer(GL_ARRAY_BUFFER,buf1);
        GLfloat a[]={
        0.0f, 0.0f, 0.0f, 0.0f,
        1.0f, 0.0f, 0.0f, 1.0f,
        0.0f, 1.0f, 0.0f, 2.0f
        };

        GLushort index[] = {
        0,1,2
        };
        glBufferData(GL_ARRAY_BUFFER,12sizeof(GLfloat),a,GL_STATIC_DRAW);
        glEnableClientState(GL_VERTEX_ARRAY);
        glVertexPointer(3,GL_FLOAT,4
        sizeof(GL_FLOAT),0);
        glGenBuffers(1,&buf2);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,buf2);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER,3*sizeof(GLushort),index,GL_STATIC_DRAW);
        glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_SHORT,0);
        glDisableClientState(GL_VERTEX_ARRAY);
        #endif
        }
        @

        when run to "glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_SHORT,0);" error occured "Unhandled exception at 0x0239faec in hellogl_es2.exe: 0xC0000005: Access violation reading location 0x00000000. "
        I want to know why this happened?

        here if I remove VBO parts, no error occured, how to use VBO in QT?

        1 Reply Last reply
        0
        • O Offline
          O Offline
          olihey
          wrote on last edited by
          #4

          Hej,

          I am not sure if that helps you with your problem but I had a similar problem when using VBOs in the QGLWidget on Windows. It worked fine on the Mac ;)

          Anyway seems like you have to get the function pointers to some OpenGL calls before you can use them.

          Here are some snippets from my code

          In the header:
          @#ifdef WIN32
          #include <windows.h>
          #include <GL/gl.h>

          #include "OGL/glext.h"

          extern PFNGLGENBUFFERSPROC glGenBuffers;
          extern PFNGLBINDBUFFERPROC glBindBuffer;
          extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
          extern PFNGLBUFFERDATAPROC glBufferData;
          #endif
          @

          and when initializing OpenGL do that (UIWidgetScene is my subclass of QGLWidget

          @void UIWidgetScene::initializeGL()
          {
          #ifdef WIN32
          // get the pointer to the GL functions
          glGenBuffers = (PFNGLGENBUFFERSPROC) wglGetProcAddress("glGenBuffers");
          glBindBuffer = (PFNGLBINDBUFFERPROC) wglGetProcAddress("glBindBuffer");
          glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) wglGetProcAddress("glDeleteBuffers");
          glBufferData = (PFNGLBUFFERDATAPROC) wglGetProcAddress("glBufferData");
          _canVBO = (NULL != glGenBuffers) && (NULL != glBindBuffer) && (NULL != glDeleteBuffers) && (NULL != glBufferData);
          #else
          // Mac supports VBO out of the box, GET A MAC!!!!
          _canVBO = true;
          #endif

          ..... do the other OpenGL stuff .....

          @

          Hope that helps,
          Oli

          1 Reply Last reply
          0
          • H Offline
            H Offline
            halftone
            wrote on last edited by
            #5

            but error occured that "PFNGLGENBUFFERSPROC , PFNGLBINDBUFFERPROC , PFNGLDELETEBUFFERSPROC , PFNGLBUFFERDATAPROC not defined" , I searched in the network, it said that these defines in gl/glext.h , so I download opengl files including glext.h , put it into "C:\Program Files\Microsoft Visual Studio 9.0\VC\include\gl" , but it doesn't work

            1 Reply Last reply
            0
            • O Offline
              O Offline
              olihey
              wrote on last edited by
              #6

              Well, I'didn't put the glext.h in the path you did!
              I just placed it in the subdirectory "OGL" in my project root!

              I am not sure why they aren't defined.

              I have the first snippet of code at the top of my header file before including any other files.

              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