Skip to main content
gamedev.net
🔒 Locked

Pointers

Started by Allebarde 8 replies 450+ views
Original Post
Allebarde
Allebarde
Hi! I have a problem with pointers: typedef struct part { .. }PARTICLES; PARTICLES particle[MAX_PARTICLES]; // = 1000 GLvoid Init_Particles(PARTICLES* particle[]) { .. particle.. .. } Init_Particles(&particle[1000]); What shall I change to make it work?? thnks
sprochet
sprochet
Since it''s called Init_Particle(s) I guess you want them
all initialized..

GLvoid Init_Particles( PARTICLES *particle,
int NumParticles) {

//Loop through them


}


Init(Particle, MAX_PARTICLES)
woha
Allebarde
Allebarde
Hi!
In fact I want to acces each particle with an index (i)

typedef struct part
{
..
}PARTICLES;

PARTICLES particle[MAX_PARTICLES]; // = 1000


GLvoid Init_Particles(PARTICLES* particle[])
{
..
particle.. //here
..
}


Init_Particles(&particle[1000]);

What shall I change to make it work??
thnks
Allebarde
Allebarde
Shit!
It doesn''t work:
I don''t manage to write a i between hooks:
test: (i)
I want to add a i between hooks (an index) next to the particle in my function to initialise all the particles.
Thanks again )
Allebarde
Allebarde
I re-explain my problem (excuse my bad english):

I have for example:

GLvoid Render_Particles(PARTICLES* particle[1000])
and i want to acces in this function the 1000 particules by an index: i to draw them all!

particle[ index ] = (..)

But how can I call this function (with what parameters?)
Tahnks )
Allebarde
Allebarde
I re-explain my problem (excuse my bad english):

I have for example:

GLvoid Render_Particles(PARTICLES* particle[1000])
and i want to acces in this function the 1000 particules by an index: i to draw them all!

particle[ index ] = (..)

But how can I call this function (with what parameters?)
Tahnks )
_SHO_NUFF
_SHO_NUFF
Well, you define your struct

struct particles
{
..
} PARTICLES;

and then PARTICLES myparts[100];

but should it be:

struct particles
{
..
};

particles myparts[100];

I think when you say PARTICLES, you are just creating an instance of particles. I''m not sure.
RoTTer
RoTTer
Hey

If you have :

typedef struct part
{
..
}PARTICLES;

PARTICLES particle[MAX_PARTICLES]; // = 1000


then its a global already (er, I guess it is, actually).

Then you dont have to pass that as parameter to the

GLvoid Init_Particles(PARTICLES* particle[])
{
..
particle..
..
}

You should just do :

GLvoid Init_Particles (void)
{
int i;
for (i = 0; i < 1000; i++)
{
Render(&particle); // or something
}

}

Or you could have, instead (void), (int NumPart) in case 1000 is max (but the actual number of particles might be less than 1000).
Then you would have to change the loop as well (i=0; i < NumPart; i++)...

Or maybe Im just nuts or something (as everybody is telling him to pass the particle thing as parameter, I could be missing something here).

Cya,
-RoTTer

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.