title: OpenGL + Qt 4.8 is not drawing anything
body: <p>I've been trying to use OpenGL in Qt with shaders and a simple vertex array. I basically want a plain to be drawn in the middle of the screen but nothing appears when I run the program. I'm basing my code in the "Texture" example of Qt, everything looks the same to me, but It's not working!</p>
  
  <p>Here's the code of my glwidget.cpp:</p>
  
  <pre><code>#include "glwidget.h"
  
  GLWidget::GLWidget(QWidget *parent):QGLWidget(parent)
  {
      timer.start(10);
      //connect(&amp;timer, SIGNAL(timeout()), this, SLOT(updateGL()));
  
      Object aux;
  
      QVector3D auxV;
      auxV.setX(0.4); auxV.setY(0.4); auxV.setZ(1.0);
      aux.vertices.append(auxV);
  
      auxV.setX(0.4); auxV.setY(-0.4); auxV.setZ(1.0);
      aux.vertices.append(auxV);
  
      auxV.setX(-0.4); auxV.setY(-0.4); auxV.setZ(1.0);
      aux.vertices.append(auxV);
  
      auxV.setX(-0.4); auxV.setY(-0.4); auxV.setZ(1.0);
      aux.vertices.append(auxV);
  
      Objects.append(aux);
  }
  
  GLWidget::~GLWidget()
  {
  }
  
  void GLWidget::initializeGL()
  {
      #define PROGRAM_VERTEX_ATTRIBUTE 0
  
      printf("Objects Size: %d\nObj1 Size: %d\n", Objects.size(), Objects.at(0).vertices.size());
      glEnable(GL_DEPTH_TEST);
      glEnable(GL_CULL_FACE);
  
      //printf("Version: %s\n", glGetString(GL_VERSION));
  
      vShader= new QGLShader (QGLShader::Vertex, this);
      vShader-&gt;compileSourceFile("../src/shaders/editorVshader.glsl");
  
      fShader= new QGLShader (QGLShader::Fragment, this);
      fShader-&gt;compileSourceFile("../src/shaders/editorFshader.glsl");
  
      editor= new QGLShaderProgram (this);
      editor-&gt;addShader(vShader);
      editor-&gt;addShader(fShader);
      editor-&gt;bindAttributeLocation("vertices", PROGRAM_VERTEX_ATTRIBUTE);
      editor-&gt;link();
      editor-&gt;bind();
  }
  
  void GLWidget::paintGL()
  {
      glClearColor(0.4765625, 0.54296875, 0.6171875, 1.0);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
      glLoadIdentity();
      glTranslatef(0.0f, 0.0f, -10.0f);
  
      glVertexPointer(3, GL_FLOAT, 0, Objects.at(0).vertices.constData());
      glEnableClientState(GL_VERTEX_ARRAY);
  
      QMatrix4x4 auxM;
      auxM.ortho(-0.5, 0.5, 0.5, -0.5, 4.0, -15.0);
      auxM.translate(0.0f, 0.0f, -10.0f);
      editor-&gt;setUniformValue("modelmatrix", auxM);
  
      editor-&gt;enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE);
  
      //editor-&gt;enableAttributeArray(editor-&gt;attributeLocation("vertices"));
      //editor-&gt;setAttributeArray(editor-&gt;attributeLocation("vertices"), Objects.at(0).vertices.constData(), 3);
  
      editor-&gt;setAttributeArray (PROGRAM_VERTEX_ATTRIBUTE, Objects.at(0).vertices.constData());
      glDrawArrays(GL_QUADS, 0, 4);
  }
  
  void GLWidget::resizeGL(int w, int h)
  {
      int side = qMin(w, h);
      glViewport((w - side) / 2, (h - side) / 2, side, side);
  
      //glViewport(0, 0, w, h);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrtho(-0.5, 0.5, -0.5, 0.5, 4.0, -15.0);
      glMatrixMode(GL_MODELVIEW);
      updateGL();
  }
  </code></pre>
  
  <p>And here are my vShader:</p>
  
  <pre><code>attribute highp vec4 vertices;
  attribute highp mat4x4 modelmatrix;
  
  void main (void)
  {
  gl_Position= modelmatrix*vertices;
  }
  </code></pre>
  
  <p>And my fShader:</p>
  
  <pre><code>void main(void)
  {
      gl_FragColor= vec4(0.0, 0.1, 1.0, 1.0);
  }
  </code></pre>
  
  <p>Do you see the error in there?</p>