I could not figure out how to dereference this pointer...
sizeof(shapetest2->tripsName) in this line below, it is obviously not going to work because it is a pointer, i could not figure out how to dereference it? (is it easy? or is it a couple steps?, i've tried several things, but could not get close) I am not an experience enough coder to figure this particular circumstance out.
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(shapetest2->tripsName), shapetest2->tripsName);
here is the setup code. (i am experimenting with a VOB in openGL ES 1.5, so if it looks odd, that is why) if i forgot some important setup or definitions, or code, let me know and i'll include it.
GLsizeiptr dataSize;
GLsizeiptr indexSize;
typedef struct shapeBase {
void *stripsName[maxStrips];
void *tripsName;
void *fansName;
int totStrips;
int stripsNum[maxStrips];
int tripsNum;
int totFans;
int fansBgn[maxStrips];
int fansNum[maxStrips];
void *dataName;
void *listOfInserts;
Vertex3D center;
Vertex3D radius;
int damageMax;
float weight;
GLuint bufferName;
GLuint indexName;
} shapeBase;
static const GLushort test2Trips[] =
{
0, 1, 3, 1, 2, 3,
4, 5, 7, 5, 6, 7,
8, 9, 11, 9, 10, 11,
12, 13, 15, 13, 14, 15,
16, 17, 19, 17, 18, 19,
20, 21, 23, 21, 22, 23,
24, 25, 27, 25, 26, 27,
28, 29, 31, 29, 30, 31,
32, 33, 35, 33, 34, 35,
36, 37, 39, 37, 38, 39,
40, 41, 43, 41, 42, 43,
44, 45, 47, 45, 46, 47,
};
//-------------------------
static inline void shapetest2Setup(void)
{
shapetest2 = malloc(sizeof(shapeBase));
shapetest2->stripsName[1] = NULL;
shapetest2->tripsName = &test2Trips;
shapetest2->fansName = NULL;
shapetest2->dataName = &test2Data;
shapetest2->totStrips = 0;
shapetest2->stripsNum[1] = 0;
shapetest2->tripsNum = 72;
shapetest2->totFans = 0;
shapetest2->listOfInserts = NULL;
shapetest2->center = Vertex3DMake( 0.000000, -0.000000, 2.000000 );
shapetest2->radius = Vertex3DMake( 1.000000, 1.000000, 2.000000 );
dataSize = sizeof(test1Data) + sizeof(test2Data);
glGenBuffers(1, &mainBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mainBuffer);
glBufferData(GL_ARRAY_BUFFER, dataSize, NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(test1Data), test1Data);
glBufferSubData(GL_ARRAY_BUFFER, sizeof(test1Data), sizeof(test2Data), test2Data);
// glGenBuffers(1, &shapetest2->indexName);
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapetest2->indexName);
// glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(test2Trips), test2Trips, GL_STATIC_DRAW);
indexSize = sizeof(test1Trips) + sizeof(test2Trips);
glGenBuffers(1, &mainIndex);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mainIndex);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize, NULL, GL_STATIC_DRAW);
}
//------------------------------------------------------
static inline void DrawOutShape(void)
{
glBindBuffer(GL_ARRAY_BUFFER, mainBuffer);
glVertexPointer(3, GL_FLOAT, sizeof(VertexData3D), (void*)0);
glNormalPointer(GL_FLOAT, sizeof(VertexData3D), (void*)12);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mainIndex);
// glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(theInsert->insertName->tripsName), theInsert->insertName->tripsName);
// glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(test1Trips), test1Trips);
// glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, sizeof(test1Trips), sizeof(test2Trips), shapetest2->tripsName);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(shapetest2->tripsName), shapetest2->tripsName);
glDrawElements(GL_TRIANGLES, theInsert->insertName->tripsNum, GL_UNSIGNED_SHORT, (void*)0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
polys += theInsert->insertName->tripsNum;
}
(theInsert is a handle (pointer to pointer) of the shapetest2, so you can substitute shapetest2 if you see "theInsert->insertName")
if i comment out the offending line, and uncomment the line above, it is working, but i need this indirection, (and actually i need another level of indirection that you can see in another commented out line) but if i can figure out how to dereference this line, i should be able to do it for another level of indirection?)
sizeof
is compile-time constant that works on exact type you provide. sizeof
of void*
is just a size of pointer on your machine (likely 4/8 bytes). Just store size along with other data.