glDrawElements работает под Linux, но не под Windows - PullRequest
0 голосов
/ 31 августа 2018

Я просто хочу сделать квад. Я использую QtOpengWindows для моего класса рендеринга, и вот код для рендеринга четырехугольника:

QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
float x0 = -(float)150.f, y0 = -(float)150.f;
float x1 =  (float)150.f, y1 =  (float)150.f;
// Set attributes
QVector3D vertices[4] = {
    QVector3D( x0, y0, 0.0f),
    QVector3D( x0, y1, 0.0f),
    QVector3D( x1, y1, 0.0f),
    QVector3D( x1, y0, 0.0f)
};

const QVector3D normals[4] = {
QVector3D(0.0f, 0.0f,1.0f),
QVector3D(0.0f, 0.0f,1.0f),
QVector3D(0.0f, 0.0f,1.0f),
QVector3D(0.0f, 0.0f,1.0f)
};

const unsigned int indices[4] = { 0, 1, 2, 3 };

shProgram.enableAttributeArray("vVertices");
shProgram.enableAttributeArray("vNormals");

shProgram.setAttributeArray("vVertices", vertices);
shProgram.setAttributeArray("vNormals", normals);

f->glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_INT, indices);


shProgram.disableAttributeArray("vVertices");
shProgram.disableAttributeArray("vNormals");

Он хорошо работает под Linux, но когда я пытаюсь запустить его под Windows, эта часть кода ничего не отображает. Вот мой вершинный шейдер:

#version 450

// Per vertex attributes
layout (location = 0)in vec3 vVertices;
layout (location = 1)in vec3 vNormals;

// Model View matrix, Normal matrix, and Model View Projection matrix
uniform mat4 M;
uniform mat4 MVP;



out vec3 interpolatedPosition;
out vec3 interpolatedNormal;


void main()
{
    interpolatedPosition = vec3( M * vec4( vVertices, 1.0 ) );
    interpolatedNormal = vNormals;
    gl_Position = MVP  * vec4(vVertices,1);
}
...