2015-07-27 3 views

ответ

0

Вы должны действительно прочитать учебник об этом, как это: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/#The_VAO

Я могу дать вам этот фрагмент кода:

float vertices[] = { 
1, 0, 0, 1, 
0, 1, 0, 1, 
0, 0, 1, 1, 
}; 

GLuint vertexnumber = 3; //Amount of vertices in your array 

int VertexStrideSize = 4*sizeof(float); //How much values you give for one vertex 

// Create the vertex buffer object 
GLuint buf; 
glGenBuffers(1, &buf); //Create the buffer 
glBindBuffer(GL_ARRAY_BUFFER, buf); //Binding the buffer 
glBufferData(GL_ARRAY_BUFFER, VertexStrideSize*vertexnumber, vertices, GL_STATIC_DRAW); //Fill the buffer 

// For your vertex shader 
GLuint posLoc = glGetAttribLocation(shadername, "aPosition"); //In your shader you can use the variable aPosition now as a input with "in vec4 aPosition" 
glVertexAttribPointer(posLoc, 4, GL_FLOAT, GL_FALSE, VertexStrideSize, 0); 
glEnableVertexAttribArray(posLoc); 
+0

Ошибка: glGenBuffers не определен. :((Visual Studio 2015) –

+0

@ ЛеонтийХачуев [попробуйте это] (https://www.google.com.au/search?q=glGenBuffers+is+not+defined). – jozxyqk

+0

спасибо вам, ребята :) –

Смежные вопросы