GL_TRIANGLES有效,但GL_QUADS不显示任何内容 [英] GL_TRIANGLES works but GL_QUADS displays nothing

查看:629
本文介绍了GL_TRIANGLES有效,但GL_QUADS不显示任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在从一个程序交换到另一个程序,我不知道为什么,但是GL_QUADS将不再显示相同的代码.为了弄清楚为什么旧代码不起作用,我制作了这个新的简单代码,它仍然不起作用.

So I'm swapping from one program to another, and I can't figure out why but GL_QUADS will no longer display with the same code. To try and figure out why old code was not working, I made this new, simple code and it STILL does not work.

设置:

vector <vec3f> squarepoints;
vec3f temper(-0.5f, 0.5f, 0.5f);
squarepoints.push_back(temper);
temper.x += 1.0f;
squarepoints.push_back(temper);
temper.y -= 1.0f;
squarepoints.push_back(temper);
temper.x -= 1.0f;
squarepoints.push_back(temper);
vector <unsigned int> squareindex;
squareindex.push_back(0);
squareindex.push_back(1);
squareindex.push_back(2);
//squareindex.push_back(0);
//squareindex.push_back(2);
squareindex.push_back(3);
GLuint VAOO;
GLuint IBOO;
GLuint VBOO;


glGenVertexArrays(1, &VAOO);
glBindVertexArray(VAOO);

glGenBuffers(1, &VBOO);
glBindBuffer(GL_ARRAY_BUFFER, VBOO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vec3f) * squarepoints.size(), &squarepoints[0], GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT,GL_FALSE, 0, 0);       


glGenBuffers(1, &IBOO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * squareindex.size(), &squareindex[0], GL_STATIC_DRAW);
glBindVertexArray(0);

图形:

glBindVertexArray(VAOO);
    glDrawElements(GL_QUADS, squareindex.size(), GL_UNSIGNED_INT, 0);
    glBindVertexArray(0);

这什么也不显示.现在,如果我在设置中添加两条注释线以使其达到6点并将其更改为图形中的GL_TRIANGLES,则所有显示都将完美显示.我不确定问题出在哪里,但是我一直在尝试修复模型加载和其他功能,以至于现在我确定自己只是在忽略一些明显的问题.

This displays nothing. Now if I add in the two commented lines in the setup to make it 6 points and change it to GL_TRIANGLES in the drawing, it all displays perfectly. I am not sure where the fault is lying here, but I've been trying to fix my model loading and other features so long that I'm sure I'm just overlooking something super obvious at this point.

推荐答案

GL_QUADS 从核心OpenGL 3.1及更高版本中删除了.

GL_QUADS have been removed from core OpenGL 3.1 and above.

这篇关于GL_TRIANGLES有效,但GL_QUADS不显示任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆