08-22-2011, 01:29 AM
I'm drawing terrain using vertex arrays and texture is stored in PBO and everything works fine. Problem is when I store vertex data in VBO.
I suspect that problem that I need 2 buffers to be binded at the same time, PBO for texture and VBO for vertexes and it makes a confuse. When I bind these 2 buffers together outcome is completely erased texture (some mixed colors)
How to bind several buffers at the time without disturbing each other?
08-22-2011, 02:31 AM
Can you post some relevant code, ie the bits where you define the VBO and PBO, plus the bits of code where you load data into the buffers, and finally the drawing code.
08-22-2011, 03:15 AM
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
0,GL_RGB, GL_UNSIGNED_BYTE, pixTexture);
//store on pbo
if(pixTexture) free(pixTexture); pixTexture = NULL;
NumVertices*( sizeof(float) * 3)), pVertices,GL_STATIC_DRAW);
glColor3f(1.0f, 1.0f, 1.0f);
notice - I'm keeping index array on CPU and not making it index buffer
We can assume that all the index (Offset , NumSteps) are correct since it works perfect when I turn off VBO
I'm not posting all the drawing loop since it's a bit complicated
but the relevant line is this
disabling , unbinding
08-22-2011, 03:49 AM
This could be your problem:
glIndexPointer has nothing to do with vertex indicies (actually to do with colour indexes).
See here for a description (http://www.opengl.org/sdk/docs/man/xhtml/glIndexPointer.xml)
When you enable VBO rendering, you can still use CPU vertex indicies as a starter-for-ten. Then the next step is to also upload the indicies as a buffer object.
Also note that when you do want your vertex indicies to be uploaded as a buffer object, there is a separate element buffer binding point for that - so you will need another buffer object. I use the term EBO (Element Buffer Object).
08-22-2011, 04:18 AM
Thank you for you pointing it out about glIndexPointer(GL_UNSIGNED_INT,0,pIndexes)! I really misinterpreted it and it's removed now,but it luckily didnt do any harm so far.
My problem is solved - the reason was weird - appears that you have to bind PBO first than all VBO and "vertex array state stuff"
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.