PDA

View Full Version : glDrawRangeElementsBaseVertex problems



kamimail
05-20-2010, 09:43 PM
Hi, i have some problems with glDrawRangeElementsBaseVertex function.
i want to store the vertices of all models in one vertex buffer and index buffer, and only render one model of them, how to do it?
FOR EXAMPLE: THERE ARE 2 MODELS

struct POSITION
{
FLOAT P[3];
};

struct NORMAL
{
FLOAT N[3];
};

MODEL0:
VERTICES: P0,P1,P2,P3,N0,N1,N2,N3
INDICES: 0,1,2,3,2,1

MODEL1:
VERTICES: P4,P5,P6,P7,P8,P9,N4,N5,N6,N7,N8,N9
INDICES: 0,2,3,1,4,5,1

I STORE VERTICES OF ALL MODELS IN A SINGLE VERTEXBUFFER AND INDEX BUFFER.


VERTEX BUFFER: P0,P1,P2,P3,N0,N1,N2,N3, P4,P5,P6,P7,P8,P9,N4,N5,N6,N7,N8,N9
INDEX BUFFER: 0,1,2,3,2,1, 0,2,3,1,4,5,1


I ONLY WANT TO RENDER MODEL1, SO ,FOR MODEL1:

BindVertexBuffer
BindIndexBuffer
VertexPointer(..., SIZEOF(POSITION)*4 + SIZEOF(NORMAL)*4);
NormalPointer(..., SIZEOF(POSITION)*4 + SIZEOF(NORMAL)*4 + SIZEOF(POSITION)*6 );

DrawRangeElementsBaseVertex(TRIANGLES,0,6,6,UNSIGN ED_INT,7,0);// THE BASE VERTEX IS 0, BECAUSE I SPECIFY THE EXACT OFFSET BY VERTEX POINTER

BUT THE ABOVE CODE DESCRIBED IN PSEUDO-CODE CAN NOT WORK. I DONT KNOW WHY, HOPE SOMEONE CAN TELL ME THE REASON,THANKS!

Alfonse Reinheart
05-20-2010, 10:42 PM
THERE'S TOO MUCH SHOUTING IN YOUR POST! IT IS VERY HARD TO READ! TURN OFF YOUR CAPSLOCK, AND MAYBE PEOPLE CAN HELP YOU! AM I TALKING LOUD ENOUGH!

;)

But seriously, post again without the ALL CAPS.