English 中文(简体)
怎么能够使VBO的冰川融化?
原标题:What can make glDrawArrays with a VBO not draw anything?

I m trying to figure out how to work with VBOs, using an OpenGL 2.0 rendering context. I ve got a 2D (ortho) rendering context set up, and I can draw a simple rectangle like this:

glBegin(GL_QUADS);
   glColor4f(1, 1, 1, 1);
   glVertex2f(0, 0);
   glVertex2f(0, 10);
   glVertex2f(100, 10);
   glVertex2f(100, 0);
glEnd;

但是,当我试图与一个VBO打交道时,它就失败了。 我设立了《维也纳行动计划》,其数据与以前相同:

procedure initialize;
const
   VERTICES: array[1..8] of single =
   (
   0, 0,
   0, 10,
   100, 10,
   100, 0
   );
begin
   glEnable(GL_VERTEX_ARRAY);
   glGenBuffers(1, @VBO);
   glBindBuffer(GL_ARRAY_BUFFER, VBO);
   glBufferData(GL_ARRAY_BUFFER, sizeof(VERTICES), @VERTICES[1], GL_DYNAMIC_DRAW);
   glBindBuffer(GL_ARRAY_BUFFER, 0);
end;

我试图这样做:

begin
   glColor4f(1, 1, 1, 1);
   glEnableClientState(GL_VERTEX_ARRAY);
   glBindBuffer(GL_ARRAY_BUFFER, VBO);
   glVertexPointer(2, GL_FLOAT, 0, 0);
   glDrawArrays(GL_QUADS, 0, 1);
   glBindBuffer(GL_ARRAY_BUFFER, 0);
end;

从我看,这应该奏效。 我通过gDEBugger管理,没有GL错误,VBO的数据被正确地装上,但在我冲动缓冲器时,没有实际出现。 改变垂直阵列中的数据,以使用正常坐标(0.1.0)也无所作为。 任何想法,我会错做什么? (假设情况本身是正确的,GL的功能点全都是正确的。)

最佳回答

glDrawArrays(GL_QUADS, 0, 1);

看一看你试图用一个独一无二的顶点。 你们还需要三个方面:

glDrawArrays(GL_QUADS, 0, 4);

或转向点数:

glDrawArrays(GL_POINTS, 0, 1);
问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签