Results 1 to 3 of 3

Thread: Weird prob

  1. #1

    Weird prob

    im making a particle engine(i just started)

    and here is my code note: its not near done, i jsut started 5 minutes ago)
    Code :
    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????
    Programming makes my head burn.

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Weird prob

    Your for-loop has a bug.
    for (i = 0; i <= 1000; i++) indices 1001 items!

  3. #3

    Re: Weird prob

    Thanks!
    Programming makes my head burn.

Similar Threads

  1. Prob with cam
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-17-2004, 11:41 AM
  2. BIG PROB
    By in forum OpenGL: User Software
    Replies: 2
    Last Post: 10-22-2003, 11:46 PM
  3. Weird Vertex Arrays Prob
    By imported_robert in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 10-19-2002, 02:41 PM
  4. Weird prob when exiting games
    By Smelly-Finger in forum OpenGL: User Software
    Replies: 5
    Last Post: 09-03-2002, 01:40 PM
  5. OpenGL && MFC??? glReadPixels prob... || GL_SELECT prob
    By Jestor in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-17-2001, 09:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean