我正在尝试解决Anton的OpenGL 4 Tutorials一书中的实验。在第一章的实验中,它要求创建第二个VAO来绘制两个形状而不是一个形状,但我不知道如何做到这一点,第二个如何同时显示?
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
int main () {
// start GL context and O/S window using the GLFW helper library
if (!glfwInit ()) {
我编写了这个“模型”类来加载.obj文件并在VBO中为它们分配数据。它的代码如下所示:(注意它如何不使用VAOs)
class Model {...}
void Model::LoadOBJ(const char *file)
{
//load vertices, normals, UVs, and put them all in _vec, which is a private data member of std::vector<glm::vec3>
...
//if an .obj file is loaded for the first time
我从OpenGL文档中了解到,可以删除VAO (glDeleteVertexArrays),然后再重新生成(glGenVertexArrays)。但是,当我试图在块类中重用一个现有的VAO变量时(对于一个OpenGL克隆),当我得到一个错误时,我遇到了一个问题。这种情况只发生在一些小块上,我不明白为什么。我输出了VAO值(无符号int类型),在使用glDeleteVertexArrays删除之后,它似乎没有改变。我从文档中了解到,在运行此函数后,该值将被重置为零。请参见下面的块类代码。
void Chunk::load()
{
// Update chunk state
loa
这是我的代码:
#include <GL/glew.h> // include GLEW and new version of GL on Windows
#include <GLFW/glfw3.h> // GLFW helper library
#include <stdio.h>
int main () {
// start GL context and O/S window using the GLFW helper library
if (!glfwInit ()) {
fprintf (stderr, "