PDA

View Full Version : Weird prob



colinisinhere
07-14-2003, 11:38 AM
im making a particle engine(i just started)

and here is my code http://www.opengl.org/discussion_boards/ubb/frown.gifnote: its not near done, i jsut started 5 minutes ago)



struct particle
{
GLfloat x;
GLfloat y;
GLfloat r;
GLfloat g;
GLfloat b;
GLfloat xspeed;
GLfloat yspeed;
bool live;
};

particle particles[1000];

void initall()
{
for(int i = 0; i <= 1000; i++)
{
particles[i].x = rand() % 102400;
particles[i].x = particles[i].x * 0.01f;
particles[i].r = rand() % 100;
particles[i].r = particles[i].r * 0.01f;
particles[i].g = rand() % 100;
particles[i].g = particles[i].g * 0.01f;
particles[i].b = rand() % 100;
particles[i].b = particles[i].b * 0.01f;
particles[i].xspeed = rand() % 50;
particles[i].xspeed = particles[i].xspeed * 0.01f;
particles[i].yspeed = rand() % 100;
particles[i].yspeed = particles[i].yspeed * 0.01f;
particles[i].live = true;
}
}

void initentity(int i)
{
particles[i].x = rand() % 102400;
particles[i].x = particles[i].x * 0.01f;
particles[i].r = rand() % 100;
particles[i].r = particles[i].r * 0.01f;
particles[i].g = rand() % 100;
particles[i].g = particles[i].g * 0.01f;
particles[i].b = rand() % 100;
particles[i].b = particles[i].b * 0.01f;
particles[i].xspeed = rand() % 50;
particles[i].xspeed = particles[i].xspeed * 0.01f;
particles[i].yspeed = rand() % 100;
particles[i].yspeed = particles[i].yspeed * 0.01f;
particles[i].live = true;
}


but when i run initall in my initogl function it makes all my textures a solid color!

im guessing this is a memory problem, but how do i fix it????

Relic
07-14-2003, 11:43 AM
Your for-loop has a bug.
for (i = 0; i <= 1000; i++) indices 1001 items!

colinisinhere
07-14-2003, 12:22 PM
Thanks!