PDA

View Full Version : PBO



serdar akbayrak
06-26-2008, 02:25 PM
i want to map the texture to geometry with using PBO.when i use the following code. the geometry is mapped strange way.where is the error.i apologize to you.i am not good on english.

void init(){
glClearColor(0,0,0,0);
glShadeModel(GL_SMOOTH);


glGenTextures(1,&textureObject);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,textureObject);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

int w=tga.GetImageWidth();
int h=tga.GetImageHeight();
unsigned char* data=tga.GetPixels();

glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,w,h,0,GL_RGB,G L_UNSIGNED_BYTE,data);

if(GLEE_ARB_pixel_buffer_object){
glGenBuffers(1,&PBO);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,PBO);
glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB,w*h*3,0,GL _STATIC_DRAW);
void* temp=glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,GL_WRI TE_ONLY_ARB);
memcpy(temp,data,w*h*3);
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,w,h,GL_RGB,GL_ UNSIGNED_BYTE,(void*)0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,0);
}


// Sisteme göre VBO yada VertexArray oluşturuluyor...
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
if(GLEE_ARB_vertex_buffer_object){
glGenBuffers(1,&VBO);
glBindBuffer(GL_ARRAY_BUFFER_ARB,VBO);
glBufferData(GL_ARRAY_BUFFER_ARB,(6*4*3*sizeof(flo at))+(6*4*2*sizeof(float)),NULL,GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER_ARB,0,6*4*3*sizeof (float),vertex);
glBufferSubData(GL_ARRAY_BUFFER_ARB,6*4*3*sizeof(f loat),6*4*2*sizeof(float),texCoord);

glVertexPointer(3,GL_FLOAT,0,0);
glTexCoordPointer(2,GL_FLOAT,0,(void*)(6*4*3*sizeo f(float)));

}
else{
glVertexPointer(3,GL_FLOAT,0,vertex);
glTexCoordPointer(2,GL_FLOAT,0,texCoord);
}

}

serdar akbayrak
06-27-2008, 11:01 AM
hi
i have a wood texture.when i want to use mapping texture to geometry with using PBO.geometry is mapped white-black pattern .where is the problem.thanks in advance.