I have a problem.
I'm learning OpenGL and I want to draw a triangle. But it does'nt work.
Error Messages:
LNK1120 1 unresolved externals
LNK2019 Reference to unresolved external symbol"__imp__glDrawArrays@12" in function ""void __cdecl draw(void)" (?draw@@YAXXZ)".
Code:
#include <GL/glew.h>
GLuint vertexBuffer;
void initDraw() {
GLuint vertexArrayID;
glGenVertexArrays(1, &vertexArrayID);
glBindVertexArray(vertexArrayID);
static const GLfloat g_vertex_buffer_data[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
};
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data),
g_vertex_buffer_data, GL_STATIC_DRAW);
}
void draw() {
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
}
Sorry for the bad english, especially for the error messages. My IDE show me the errors in german and I must translate this.