-1
int main() {
using namespace game1;
using namespace graphics;
using namespace maths;
using namespace util;
using namespace std;
Window window("Game 1", 960, 540);
glClearColor(0.2f, 0.3f, 0.8f, 1.0f);
GLfloat vertices[] = {
4, 3, 5,
12, 3, 5,
4, 6, 5,
4, 6, 5,
12, 6, 5,
4, 3, 5
};
Matrix4f ortho = Matrix4f::genOrtho(0.0f, 16.0f, 0.0f, 9.0f, -1, 1);
GLuint vbo;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
ShaderProgram s;
s.attachShader(File("res/testVert.vert"), GL_VERTEX_SHADER);
s.attachShader(File("res/testFrag.frag"), GL_FRAGMENT_SHADER);
s.link();
s.enable();
s.setUniformMat4f("model", Matrix4f::identity());
s.setUniformMat4f("world", Matrix4f::identity());
s.setUniformMat4f("proj", ortho);
while (!window.closed())
{
window.clear();
glDrawArrays(GL_TRIANGLES, 0, 3);
window.update();
}
return 0;
}
我是opengl的新手,我不確定我做錯了什麼。我懷疑它與vbo或vertexAttribArrayPointer有關,我測試了很多東西,但我不能找到錯誤。它與一個正常的三角頂點三角形一起工作,並且我確定我的錯誤主要在某處opengl頂點不渲染
嘗試檢查'glGetError()'。它說什麼? – Vallentin