В настоящее время моя программа открывает указанный файл OBJ и анализирует его с помощью механизма анализа, описанного в руководстве здесь — http://www.opengl-tutorial.org/beginner ... g_the_file.
Объект, который я пытаюсь визуализировать, Куб расположен по тому же URL-адресу страницы руководства.
Я считаю, что моя проблема заключается в моей функции display(void). После того, как я выполнил GlutDisplayFunc(display); в моей функции main(), вместо моей визуализированной модели появляется черное окно.
Это моя текущая функция отображения (void):
Код: Выделить всё
void display(void)
{
GLuint vbo;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(glm::vec3) * 3, &vertices[0], GL_STATIC_DRAW);
glDrawElements(GL_TRIANGLES, vertices.size() * sizeof(glm::vec3) * 3, GL_UNSIGNED_INT, &vertices[0]);
// check OpenGL error
GLenum err;
while ((err = glGetError()) != GL_NO_ERROR)
{
printf("OpenGL error: %u", err);
}
glEnd();
glutSwapBuffers();
}
Код: Выделить всё
Success: GLEW_OK
Success: Opened OBJ File cube.obj
Read in Vertices: 1.000000, -1.000000, -1.000000
Read in Vertices: 1.000000, -1.000000, 1.000000
Read in Vertices: -1.000000, -1.000000, 1.000000
Read in Vertices: -1.000000, -1.000000, -1.000000
Read in Vertices: 1.000000, 1.000000, -1.000000
Read in Vertices: 0.999999, 1.000000, 1.000001
Read in Vertices: -1.000000, 1.000000, 1.000000
Read in Vertices: -1.000000, 1.000000, -1.000000
Read in texture coordinate: 0.748573, 0.750412
Read in texture coordinate: 0.749279, 0.501284
Read in texture coordinate: 0.999110, 0.501077
Read in texture coordinate: 0.999455, 0.750380
Read in texture coordinate: 0.250471, 0.500702
Read in texture coordinate: 0.249682, 0.749677
Read in texture coordinate: 0.001085, 0.750380
Read in texture coordinate: 0.001517, 0.499994
Read in texture coordinate: 0.499422, 0.500239
Read in texture coordinate: 0.500149, 0.750166
Read in texture coordinate: 0.748355, 0.998230
Read in texture coordinate: 0.500193, 0.998728
Read in texture coordinate: 0.498993, 0.250415
Read in texture coordinate: 0.748953, 0.250920
Read in Normals: 0.000000, 0.000000, -1.000000
Read in Normals: -1.000000, -0.000000, -0.000000
Read in Normals: -0.000000, -0.000000, 1.000000
Read in Normals: -0.000001, 0.000000, 1.000000
Read in Normals: 1.000000, -0.000000, 0.000000
Read in Normals: 1.000000, 0.000000, 0.000001
Read in Normals: 0.000000, 1.000000, -0.000000
Read in Normals: -0.000000, -1.000000, 0.000000
Reached end of file
Out Vertices Size: 234Есть предложения/информация?
Подробнее здесь: https://stackoverflow.com/questions/291 ... -from-file