I have no idea how c is typecasting a single 32 bit Integer into a struct with multiple elements... Any help explaining would be greatly appreciated
Declarations
Code:
struct md2_glcmd_t
{
float s;
float t;
int index;
};
struct md2_model_t
{
struct md2_header_t header;
struct md2_skin_t *skins;
struct md2_texCoord_t *texcoords;
struct md2_triangle_t *triangles;
struct md2_frame_t *frames;
int *glcmds;
GLuint tex_id;
};
Reading
Code:
ReadMD2Model (const char *filename, struct md2_model_t *mdl)
{
. . .
fseek (fp, mdl->header.offset_glcmds, SEEK_SET);
fread (mdl->glcmds, sizeof (int), mdl->header.num_glcmds, fp);
. . .
}
Another example of the typecasting used...
Code:
. . .
int i, *pglcmds;
packet = (struct md2_glcmd_t *)pglcmds;
. . .