Hi, I am creating my own graphics engine and noticed that vertex/element buffers are not created in a separate thread, example:
Everything is going well here:
Personaj* persik = new Personaj(igra.VzyatOsnovShaderProgId(), versh, inds, "biblioteka/ya.png");
obnov += persik;
otrisovat += persik;
etotIgrok.pers = persik;
But when I create a character in a separate thread, gl Create Vertex Arrays and glGenBuffers do not create buffers with arrays
potok = std::thread([&]() {
Personaj* persik = new Personaj(igra.VzyatOsnovShaderProgId(), versh, inds, "biblioteka/ya.png");
obnov += persik;
otrisovat += persik;
etotIgrok.pers = persik;
});
The function of generating buffers and arrays for a new character
void DDModel::ObnovitVershini(GLuint& proga, Massiv<Vershina>& vershini_per, Massiv<GLuint>& indeksi_per)
{
vershini = vershini_per;
indeksi = indeksi_per;
if (VAO)
glDeleteVertexArrays(1, &VAO);
if (VBO)
glDeleteBuffers(1, &VBO);
if (EBO)
glDeleteBuffers(1, &EBO);
glCreateVertexArrays(1, &VAO);
glBindVertexArray(VAO);
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, vershini.VzyatRazmer() * sizeof(Vershina), vershini.VzyatMas(), GL_STATIC_DRAW);
glGenBuffers(1, &EBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indeksi.VzyatRazmer() * sizeof(GLuint), indeksi.VzyatMas(), GL_STATIC_DRAW);
GLuint attribMest = glGetAttribLocation(proga, "mesto_vershini");
glVertexAttribPointer(attribMest, 3, GL_FLOAT, GL_FALSE, sizeof(Vershina), (GLvoid*)offsetof(Vershina, mesto));
glEnableVertexAttribArray(attribMest);
attribMest = glGetAttribLocation(proga, "cvetKoordi_vershini");
glVertexAttribPointer(attribMest, 2, GL_FLOAT, GL_FALSE, sizeof(Vershina), (GLvoid*)offsetof(Vershina, cvetKoordi));
glEnableVertexAttribArray(attribMest);
glBindVertexArray(0);
}