Zainstalowałem dodatki właśnie te, które są na wyposażeniu VirtualBox i program też się nie uruchamia, ale przy próbie uruchamiania pojawia się taki log:
Uruchamianie /home/xxx/Pulpit/OpenGlTest/build-OpenGlTest-Desktop_Qt_5_0_2_GCC_32bit-Debug/OpenGlTest...
OpenGL Warning: glFlushVertexArrayRangeNV not found in mesa table
OpenGL Warning: glVertexArrayRangeNV not found in mesa table
OpenGL Warning: glCombinerInputNV not found in mesa table
OpenGL Warning: glCombinerOutputNV not found in mesa table
OpenGL Warning: glCombinerParameterfNV not found in mesa table
OpenGL Warning: glCombinerParameterfvNV not found in mesa table
OpenGL Warning: glCombinerParameteriNV not found in mesa table
OpenGL Warning: glCombinerParameterivNV not found in mesa table
OpenGL Warning: glFinalCombinerInputNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterivNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glDeleteFencesNV not found in mesa table
OpenGL Warning: glFinishFenceNV not found in mesa table
OpenGL Warning: glGenFencesNV not found in mesa table
OpenGL Warning: glGetFenceivNV not found in mesa table
OpenGL Warning: glIsFenceNV not found in mesa table
OpenGL Warning: glSetFenceNV not found in mesa table
OpenGL Warning: glTestFenceNV not found in mesa table
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x9d868c8, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x9d868c8, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x9d868c8, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x9d868c8, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x9d868c8, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x9d868c8, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x9d868c8, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x9d868c8
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x9d868c8, failed to get XVisualInfo
ASSERT: "QOpenGLFunctions::isInitialized(d_ptr)" in file ../../../Qt5.0.2/5.0.2/gcc/include/QtGui/qopenglfunctions.h, line 749
Program nieoczekiwanie przerwał pracę.
/home/xxx/Pulpit/OpenGlTest/build-OpenGlTest-Desktop_Qt_5_0_2_GCC_32bit-Debug/OpenGlTest zakończone kodem 0
Skompilowałem i uruchomiłem program "cube" dołączony do Qt jako przykład i program działa idealnie.
Wracając do mojego programu, jak się w procedurze "DrawRectangle" zakomentuje wszystkie linie oprócz "glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);", to program się uruchamia, tylko, że nie pokazuje obrazu.
Jak się nawet zakomentuje całą treść metody "paintGl", to po uruchomieniu aplikacji w logu jest takie coś:
Uruchamianie /home/xxx/Pulpit/OpenGlTest/build-OpenGlTest-Desktop_Qt_5_0_2_GCC_32bit-Debug/OpenGlTest...
OpenGL Warning: glFlushVertexArrayRangeNV not found in mesa table
OpenGL Warning: glVertexArrayRangeNV not found in mesa table
OpenGL Warning: glCombinerInputNV not found in mesa table
OpenGL Warning: glCombinerOutputNV not found in mesa table
OpenGL Warning: glCombinerParameterfNV not found in mesa table
OpenGL Warning: glCombinerParameterfvNV not found in mesa table
OpenGL Warning: glCombinerParameteriNV not found in mesa table
OpenGL Warning: glCombinerParameterivNV not found in mesa table
OpenGL Warning: glFinalCombinerInputNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterivNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glDeleteFencesNV not found in mesa table
OpenGL Warning: glFinishFenceNV not found in mesa table
OpenGL Warning: glGenFencesNV not found in mesa table
OpenGL Warning: glGetFenceivNV not found in mesa table
OpenGL Warning: glIsFenceNV not found in mesa table
OpenGL Warning: glSetFenceNV not found in mesa table
OpenGL Warning: glTestFenceNV not found in mesa table
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x8c23720, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x8c23720, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x8c23720, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x8c23720, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x8c23720, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x8c23720, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x8c23720, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 0x8c23720
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 0x8c23720, failed to get XVisualInfo
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
QBackingStore::flush() called with non-exposed window, behavior is undefined
/home/xxx/Pulpit/OpenGlTest/build-OpenGlTest-Desktop_Qt_5_0_2_GCC_32bit-Debug/OpenGlTest zakończone kodem 0
W tym programie najważniejsza jest klasa "TestWidget", której pełny kod jest poniżej, opisane powyżej zakomentowywanie fragmentów kodu dotyczy właśnie tego ponizszego kodu:
#ifndef TESTWIDGET_H
#define TESTWIDGET_H
#include <QWidget>
#include <QGLWidget>
//#include <GL/glu.h>
#include <QOpenGLShaderProgram>
#include <QOpenGLFunctions>
class TestWidget : public QGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
explicit TestWidget(QWidget *parent = 0);
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void DrawTriangle(float (&TablePoints)[9], float (&TableColors)[9]);
void DrawRectangle(float (&TablePoints)[12], float (&TableColors)[12]);
int XRot;
int YRot;
int ZRot;
int XTrans;
int YTrans;
int ZTrans;
protected:
signals:
public slots:
private:
GLuint m_posAttr;
GLuint m_colAttr;
GLuint m_matrixUniform;
QOpenGLShaderProgram *m_program;
};
#endif // TESTWIDGET_H
#include "testwidget.h"
TestWidget::TestWidget(QWidget *parent) :
QGLWidget(parent)
{
XRot = 0;
YRot = 0;
ZRot = 0;
XTrans = 0;
YTrans = 0;
ZTrans = -50;
}
QVector<QVector3D> vertices;
QVector<QVector3D> normals;
void TestWidget::initializeGL()
{
const char *vertexShaderSource =
"attribute highp vec4 posAttr;\n"
"attribute lowp vec4 colAttr;\n"
"varying lowp vec4 col;\n"
"uniform highp mat4 matrix;\n"
"void main() {\n"
" col = colAttr;\n"
" gl_Position = matrix * posAttr;\n"
"}\n";
const char *fragmentShaderSource =
"varying lowp vec4 col;\n"
"void main() {\n"
" gl_FragColor = col;\n"
"}\n";
m_program = new QOpenGLShaderProgram(this);
m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
m_program->link();
m_posAttr = m_program->attributeLocation("posAttr");
m_colAttr = m_program->attributeLocation("colAttr");
m_matrixUniform = m_program->uniformLocation("matrix");
glEnable(GL_DEPTH_TEST);
}
void TestWidget::resizeGL(int w, int h)
{
}
void TestWidget::paintGL()
{
glViewport(0, 0, this->width(), this->height());
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_program->bind();
QMatrix4x4 matrix;
float WW = width();
float HH = height();
matrix.setToIdentity();
matrix.perspective(60, WW / HH, 1.0, 100.0);
matrix.translate(((float)XTrans) / 10.0, ((float)YTrans) / 10.0, ((float)ZTrans) / 10.0);
matrix.rotate(XRot, 1, 0, 0);
matrix.rotate(YRot, 0, 1, 0);
matrix.rotate(ZRot, 0, 0, 1);
m_program->setUniformValue(m_matrixUniform, matrix);
float Points1[12] = {-1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1};
float Points2[12] = {-1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1};
float Points3[12] = {-1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1};
float Points4[12] = {-1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1};
float Points5[12] = {-1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1};
float Points6[12] = { 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1};
float Colors1[12] = {1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0};
float Colors2[12] = {0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0};
float Colors3[12] = {0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0};
float Colors4[12] = {1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1};
float Colors5[12] = {1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0};
float Colors6[12] = {0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0};
DrawRectangle(Points1, Colors1);
DrawRectangle(Points2, Colors2);
DrawRectangle(Points3, Colors3);
DrawRectangle(Points4, Colors4);
DrawRectangle(Points5, Colors5);
DrawRectangle(Points6, Colors6);
m_program->release();
}
void TestWidget::DrawTriangle(float (&TablePoints)[9], float (&TableColors)[9])
{
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(m_posAttr, 3, GL_FLOAT, GL_FALSE, 0, &TablePoints);
glVertexAttribPointer(m_colAttr, 3, GL_FLOAT, GL_FALSE, 0, &TableColors);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0);
}
void TestWidget::DrawRectangle(float (&TablePoints)[12], float (&TableColors)[12])
{
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(m_posAttr, 3, GL_FLOAT, GL_FALSE, 0, &TablePoints);
glVertexAttribPointer(m_colAttr, 3, GL_FLOAT, GL_FALSE, 0, &TableColors);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0);
}
Mam przeczucie, że tu o jakiś drobiazg chodzi, bo w Windowsie to działa bez najmniejszych problemów.