Witajcie,
Chcę potwierdzić swoją wiedzę z VBO i napisałem program:
void OpenGLWidget::initializeGL()
{
if(glewInit() == GLEW_OK)
{
glEnable(GL_DEPTH_TEST);
GLfloat data[] = { 0.0 , 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 };
glGenBuffers(1, &vao);
glBindBuffer(GL_ARRAY_BUFFER, vao);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3*3, (void*)data, GL_STATIC_DRAW);
glVetrexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 3*3 * sizeof(GLfloat));
}
}
void OpenGLWidget::resizeGL(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70,w/h,0.1, 100);
glMatrixMode(GL_MODELVIEW);
}
void OpenGLWidget::paintGL()
{
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glEnableVertexAttribArray(vao);
glEnableVertexAttribArray(vbo);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(vbo);
glDisableVertexAttribArray(vao);
}
Do pliku .pro
dopisałem: LIBS += -lGLEW -lGL -lGLU
. W pliku .hpp
mam:
#include <GL/glew.h>
#include <QOpenGLWidget>
Dostaje błąd: /home/patryk/projekty/BennuEngine/OpenGLWidget.cpp:31: błąd: 'glVetrexAttribPointer' was not declared in this scope glVetrexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
Platforma to Linux Ubuntu x64 i biblioteka Qt5. Jak się domyślam to problem z glew. W Linuxie zainstalowałem fglrx
i mam OpenGL 4.4.13283 więc nie powinno być problemu z funkcją typu glVertexAttribPointer bo w standardzie jest od OGL 2.0.
PS. Nie chodzi już o poprawne działanie programu bo jeszcze shaderów nie dodałem, ale o samo skompilowanie :P.