Vertex Buffer Objects Problem



  • 1. Is This a Good Application of OpenGL
    I am looking for a way to display some 3-D data and am wondering if OpenGL is capable of doing what I want. The data is a three dimensional array of scaler numerical values that represent the amount of light emitted by corresponding points in a physical volume. These points collectively represent bodies of various shape in this volume. These bodies are transparent and emit light in all directions. The light comes from the entire volume of these diffuse bodies like glowing gas. I want calculate the 2-D representation of this 3-D volume for a particular viewing location. After reading through 'The Red Book', it is still unclear to me if the OpenGL functions can perform the operations I need. Perhaps my question is answered by 'The Red Book', but my understanding is very limited at this time. Is OpenGL appropriate, or is there something that is better suited to this problem? -- Gavrik Peterson
  • 2. determining texture memory size
    Hi, Does anybody know if/how its possible to find out the total and/or available texture memory for GeForce cards (or all graphics cards) from within a c++ program? Thanks
  • 3. random view of a rect...
    hallo, following source void CGLObjCst::Draw() { GLfloat x=m_x, y=m_y, z=m_z; if( m_state == OBJ_STATE_NONE ) glColor3f(0.40f, 0.40f, 0.40f); else if( m_state == OBJ_STATE_SELECT ) glColor3f(0.40f, 0.99f, 0.40f); //----------------- METHOD 1 /*glBegin( GL_QUADS ); glVertex3i( x , y , 0.0f); glVertex3i( x+0.6f, y , 0.0f); glVertex3i( x+0.6f, y+0.6f, 0.0f); glVertex3i( x , y+0.6f, 0.0f); glEnd();*/ //----------------- METHOD 2 glRectf(x,y,x+0.6f, y+0.6f); } If I draw the rect with method 1, sometimes it is not displayed. Method 2 shows the rect always. why? mario
  • 4. Ball's trail
    Hi, I'm programming a game in which I would like the ball have a trail. Do anyone have an idea different than a vector which memorizes positions? (scuse for my poor language !!!) Thanks -- Fanny <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> Hi, <p>I'm programming a game in which I would like the ball have a trail. <br>Do anyone have an idea different than a vector which memorizes <br>positions? <p>(scuse for my poor language !!!) <p>Thanks <pre>--  Fanny  </pre>  </html>

Vertex Buffer Objects Problem

Postby Gareth » Sat, 27 Jan 2007 01:33:34 GMT

am using the Tao OpenGL libraries for .net in c# and I'm having a
problem with vertex buffer objects. My code builds buffers for vertex,
tex coord, normal and colour information into arrays of floats. Then
if it detects that the vbo extension is supported it binds the data to
vbos. Then it renders the arrays each frame using drawarrays.

The problem is that if I turn of vbos the terrain renders properly but
if I enable vbos the terrain renders with the opposite polygon winding
and with the z and y coordinates swapped (also the z value seems to be
negated). I don't understand why this should happen since I'm feeding
exactly the same data in regardless of whether I'm using vbos or not.

I am running this under linux through mono with an nvidia card. Could
this be a bug with my ogl drivers/mono/tao?

Any suggestions?

Here's some code:

private void _generateVBOs()
vboVertexBuffer =new int[_width];
vboTexCoordBuffer =new int[_width];
vboNormalBuffer =new int[_width];
vboColourBuffer =new int[_width][];

float f=0.0f;
for(int i=0;i<_width;i++)
vboColourBuffer[i] =new int[TERRAIN_TEXTURE_COUNT];

Gl.glGenBuffersARB(1, out vboVertexBuffer[i]);
Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, vboVertexBuffer[i]);

Gl.glGenBuffersARB(1, out vboTexCoordBuffer[i]);
Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, vboTexCoordBuffer[i]);

Gl.glGenBuffersARB(1, out vboNormalBuffer[i]);
Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, vboNormalBuffer[i]);

for(int j=0;j<TERRAIN_TEXTURE_COUNT;j++)
Gl.glGenBuffersARB(1, out vboColourBuffer[i][j]);
Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, vboColourBuffer[i][j]);

public void Render()


float[] matAmb=new float[4]{1.0f, 1.0f, 1.0f, 1.0f};
float[] matDif=new float[4]{1.0f, 1.0f, 1.0f, 1.0f};
float[] matSpe=new float[4]{1.0f, 1.0f, 1.0f, 1.0f};
float[] matEmi=new float[4]{0.0f, 0.0f, 0.0f, 1.0f};

Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, matAmb);
Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, matDif);
Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, matSpe);
Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_EMISSION, matEmi);
Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, 50.0f);


Gl.glColorMaterial(Gl.GL_FRONT, Gl.GL_DIFFUSE);

for(int i=0;i<TERRAIN_TEXTURE_COUNT;i++)

Re: Vertex Buffer Objects Problem

Postby Marcel Heinz » Sat, 27 Jan 2007 03:18:57 GMT


This isn't the way VBOs work. Only one buffer can be bound per buffer
target (and there's only GL_ARRAY_BUFFER_ARB for that kind of stuff) at
any time, so all vertex attributes must be stored in the same VBO. What
your code actually does is using the same data from your
vboColourBuffer-array as vertex coordinates, texcoords, normals and

Regards, Marcel
Marcel Heinz | < XXXX@XXXXX.COM > | PGP-KeyID: E78E9442
"Perfection is attained not when there is nothing more to add,
 but when there is nothing more to remove."  -- Antoine de Saint-Exupy

Re: Vertex Buffer Objects Problem

Postby Rolf Magnus » Sat, 27 Jan 2007 04:23:40 GMT

What makes you think that? The OpenGL spec disagrees.

Re: Vertex Buffer Objects Problem

Postby Marcel Heinz » Sat, 27 Jan 2007 04:50:06 GMT


Oh, you are right. I forgot that there is a VBO binding point for every array

Regrads, Marcel
Marcel Heinz | < XXXX@XXXXX.COM > | PGP-KeyID: E78E9442
"Perfection is attained not when there is nothing more to add,
 but when there is nothing more to remove."  -- Antoine de Saint-Exupy

Re: Vertex Buffer Objects Problem

Postby Gareth » Sat, 27 Jan 2007 20:00:27 GMT

My app seems to work in windows xp pro under the .net framework 1.1
using vbos so I think it must be something wrong with my nvidia linux
ogl drivers and/or mono.  Not sure what to do about this now because
there isn't a good way to know whether or not using vbos will work when
my application starts doesn't even know if it's in windows or



Re: Vertex Buffer Objects Problem

Postby strangebreed » Tue, 30 Jan 2007 02:33:29 GMT

So your terrain shifts orientation? It sounds like there's a 90 degree 
rotation on the whole thing?


Re: Vertex Buffer Objects Problem

Postby Gareth » Tue, 30 Jan 2007 21:36:09 GMT

Yeah, only in linux, windows is fine.  The x and z axis are meant to 
be longitude and latitude and y axis is height of the terrain.  When I 
use vbos in linux the y axis is used for latitude and the z axis is 
used for height, which is very odd.  It also looks like the winding of 
the triangle strip is backwards so a mountain looks like a pit.

The only thing I can think to do is to try to render a square using 
vbos at initialisation then read some pixel colours from the back 
buffer and check if it's correct.  If not then assume this bug is in 
effect and disable vbos... So say I draw a red square and the clear 
colour is black, if the orientation is wrong I will be reading black 
from the screen buffer instead of red.


Re: Vertex Buffer Objects Problem

Postby jbwest » Tue, 30 Jan 2007 23:50:08 GMT

I can't believe that VBO's are that broken on Linux. Indeed, I know that 
they are not, in general.
Which leaves us with something in how you initialize Linux vs Windows which 
is different.
A mixup in going from X11 coordinates to OpenGL maybe? (forgetting to flip 

Re: Vertex Buffer Objects Problem

Postby Rolf Magnus » Wed, 31 Jan 2007 00:04:11 GMT

The mono wrapper might still be broken.

Similar Threads:

1.Vertex Buffer Object problem


    I've just implement the ARB_vertex_buffer_objet in one my my program,
all works perfectly, but ... All run Twice SLOWER than a normal loop.

    I create all things like that :

    GLuint vbo_v,vbo_nv...;





    Where v and nv and pointers on 2 arrays (vertices and vertices
normals) - i do the same with vertex color, tex coords ...



    For indexs

    When i bind all that




                // DRAWING


    I have with a normal loop about 60 fps and 30 fps when using VBO
    I run on an AMD ATHLON 2Ghz 512Mo GeForce4MX

    All Works perfectly but TWICE slower than normal loop with glNormals,
glVertex, glTexCoord ...
    Why ? Did i do something wrong ? Isn't vertex buffer objects are
supposed to increase the number of fps and not make your programs run slower
? Help !

    Thanks in advanced for your help

2.Vertex Arrays, Vertex Buffer Objects

Hi list.

I implemented rendering using display lists, vertex arrays, and vertex
buffer objects. And guess what was the faster ? ... display lists !

It should mean that I implemented badly those array stuff.
For the VBO part, I'm quite sure that today drivers are not correctly
implemented - systematically crash on some ATI hardware, even if
extention is detected, poor perfs on nVidia. After all, it runs as
fast as plain vertex arrays.
For the VA part ... I guess all static geometry could be rendered
using glLockArray() ... ? I think this is called compiled vertex array
? Is this an improvement compared to plain vertex arrays ?
Will I have to go to VAR to achieve correct perfs ?

Thx for enlightments


3.Changing vertex color after vertex buffer and index buffer definition


Say you have this custom vertex structure:

	float x, y, z;
	DWORD color;

Is it possible once you've defined values for a vertex 
buffer using that structure to subsequently change the 
color for a vertex that you defined? If so, how?

Thanks :)

4.Multiple objects in a single vertex buffer.

The book I'm reading shows as illustration example, multiple objects
in a single v-buffer.  These more primitive though: sphere, box and a
cylinder.  Is it wise to have a v-buffer handle more than one object? scale a pVB vertex buffer object ?

I have a vertex buff obj, it's a meshed(tessulated) square in D3DX8,
 Vertex *v;

    g_pd3dDevice->CreateVertexBuffer( g_nTriCount*3*sizeof(Vertex),
                                      D3DPOOL_MANAGED, &g_pWallVB );

    g_pWallVB->Lock( 0, 0, (BYTE**)&v, 0 );

    float dX = 1.0f/(g_nNumVertsX-1);
    float dZ = 2.0f/(g_nNumVertsZ-1);//dz=1.0f/
    int i = 0;

    for( int z = 0; z < (g_nNumVertsZ-1); ++z )
        for( int x = 0; x < (g_nNumVertsX-1); ++x )
            v[i].p = D3DXVECTOR3(10*x*dX, 0.0f, 10*z*dZ );
            v[i].n = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
            v[i].p = D3DXVECTOR3(10*x*dX, 0.0f, 10*(z+1)*dZ );
            v[i].n = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
            v[i].p = D3DXVECTOR3(10*(x+1)*dX, 0.0f, 10*(z+1)*dZ );
            v[i].n = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
            v[i].p = D3DXVECTOR3(10*x*dX, 0.0f, 10*z*dZ );
            v[i].n = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
            v[i].p = D3DXVECTOR3(10*(x+1)*dX, 0.0f, 10*(z+1)*dZ );
            v[i].n = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
            v[i].p = D3DXVECTOR3(10*(x+1)*dX, 0.0f, 10*z*dZ );
            v[i].n = D3DXVECTOR3(0.0f, 1.0f, 0.0f);


How can I rescale its size.

6. Vertex buffer objects: how to improve speed further ?

7. GL_OUT_OF_MEMORY ( vertex buffer objects )

8. Missing Function Definitions for Vertex Buffer Objects (VBOs) on Linux

Return to graphics


Who is online

Users browsing this forum: No registered users and 52 guest