/* Here I have two swappable VBO, thirst (m_idVertecesVBO_0) drwaing in this thread
* second calculated in second thread, then they swaps. So here I use mutex.
* All wark fine without shaders.
*/
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMateriali ( GL_SHININESS, GL_FRONT_AND_BACK, 127);
GLfloat vSpecular[4] = {0.3,0.3,1,1};
glMaterialfv ( GL_SPECULAR, GL_FRONT_AND_BACK, vSpecular);
GLfloat vEmission[4] = {1,1,1,1};
glMaterialfv ( GL_EMISSION, GL_FRONT_AND_BACK, vEmission);
tDrawingMutex.lock();
GLint attribute_coord3d = glGetAttribLocation(m_ShaderProgram, "coord3d"); //zero in using of first two versions of shader
if (attribute_coord3d == -1) {
throw runtime_error ( _ExceptionString "Could not bind attribute coord3d");
}
glUseProgram(m_ShaderProgram);
glEnableVertexAttribArray(attribute_coord3d);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
tBindingMutex.lock();
glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_idVertecesVBO_0);
glVertexAttribPointer(
attribute_coord3d, // attribute
3, // number of elements per vertex, here (x,y,z)
GL_FLOAT, // the type of each element
GL_FALSE, // take our values as-is
0, // no extra data between each position
0 // pointer to the C array
);
tBindingMutex.unlock();
tBindingMutex.lock();
glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_idNormalsVBO_0);
glVertexAttribPointer(
0, // attribute
3, // number of elements per vertex, here (x,y,z)
GL_FLOAT, // the type of each element
GL_FALSE, // take our values as-is
0, // no extra data between each position
0 // pointer to the C array
);
tBindingMutex.unlock();
glDrawArrays(GL_TRIANGLE_STRIP, 0,(m_Dimension + 1)*(m_Dimension - 1)*2);
glDisableVertexAttribArray(attribute_coord3d);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glUseProgram(0);
tDrawingMutex.unlock();