my problem is not properly drawing simple plane; I dont know why i get once error at begining : Invalid Operation 1282. Can someone check that?
My variables :
GLfloat *tab for verticies plane
int *tab2 for indecies
this is my init funcion:
// kolor tła - zawartość bufora koloru
glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
// wczytanie shaderów i przygotowanie obsługi programu
program=LoadShaders("shader.vert","shader.frag" );
//Vertexy
//VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
//Verticies;
glGenBuffers(1, &Verticies);
glBindBuffer(GL_ARRAY_BUFFER, Verticies);
glBufferData( GL_ARRAY_BUFFER,foo*sizeof(GLfloat), tab, GL_STATIC_DRAW );
unsigned int m_ciezarkow[]={0,1,0};
//Indicies
glGenBuffers(1,&Indeksy);
glBindBuffer(GL_ARRAY_BUFFER,Indeksy);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int)*size, tab2, GL_STATIC_DRAW);
glUseProgram( program );
pos_cam=glGetUniformLocation( program, "camera" );
pos_color=glGetUniformLocation( program, "_color" );
glUseProgram(0);
This is my draw function:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(program);
//my camera
glUniformMatrix4fv(pos_cam,1,GL_FALSE,&cam.matrix()[0][0]);
//Verticies
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, Verticies);
glVertexAttribPointer( 0, 3 , GL_FLOAT, GL_FALSE, 0, (void*)0 );
//Masa
//glEnableVertexAttribArray(1);
//glBindBuffer(GL_ARRAY_BUFFER, Masa);
//glVertexAttribPointer( 0, 3 , GL_FLOAT, GL_FALSE, 0, (void*)0 );
//Indicies
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,Indeksy);
glDrawElements(GL_TRIANGLES,size,GL_UNSIGNED_INT,(void*)0);
glUseProgram( 0 );
glDisableVertexAttribArray(0);`
glGetError()to different places in your code, can you figure out the exact line?