hi, i have a really kind of silly question. i see the problem i just don't know how to solve it. i am trying to fill in a linked list of info on lighting. i will post the structures relevant in the linked list and the code snippet im having troubles with. i just want to assign some allocated memory to a pointer to the next available light structure. but what im doing right now is im just pointing a pointer that points to the next member of the list to the allocated memory. i want to point the pointer that the first pointer points to to the memory. sorry its kinda hard to say (:P) but the code should help you see the problem.
Code:
typedef struct DirectionalLight
{
int id;
struct Type4D colorlight;
struct Type3D lightdirection;
float intensity;
struct DirectionalLight *next;
} Directional;
typedef struct LightStruct
{
int id;
struct AmbientLight *ambient;
struct DirectionalLight *directional;
struct PointLight *point;
} Lights;
and the loading code:
Code:
if (lighttype == DIRECTIONAL_LIGHT) //1
{
struct DirectionalLight *dirlight = lights->directional;
while(dirlight != NULL)
dirlight = dirlight->next;
dirlight = (struct DirectionalLight *)malloc(sizeof(struct DirectionalLight));