CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Posts
    1

    Lightbulb need help with C# (open gl) -

    hello everyone

    iam trying to delete individual particles, i tryed pos.x & pos.y aswell as the mouse position. but everything i tried gets an error.

    will really appreciate any contribution.

    code for particles:



    float timeStep = m_Timer.Seconds;



    foreach (Particle particle in m_Particles)
    {
    particle.Update(timeStep);
    }
    m_TimeToNewParticle -= timeStep;
    while (m_TimeToNewParticle <= 0f)
    {
    float velXbl = (float)(randomNumberGenerator.NextDouble() + 0.1);
    float velYbl = (float)(randomNumberGenerator.NextDouble() + 0.1);

    float velXtr = (float)(randomNumberGenerator.NextDouble() - 1);
    float velYtr = (float)(randomNumberGenerator.NextDouble() - 1);

    m_Particles.Add(new Particle(new Vector2d(-2f, -2f), new Vector2d(velXbl, velYbl)));//bottom left
    m_Particles.Add(new Particle(new Vector2d(2f, 2f), new Vector2d(velXtr, velYtr))); //top right

    m_TimeToNewParticle += 2f / m_ParticlesPerSecond; //* and if there are too many, remove the oldest ones */
    if (m_Particles.Count > 2000)
    {
    m_Particles.RemoveAt(0);
    }




    second part of my particle code:



    public Vector2d m_Position = new Vector2d(1.0f, 0.0f);
    public Vector2d m_Velocity = new Vector2d(0.0f, 0.0f);

    public float halfSize = 0.12f;


    public Particle(Vector2d pPosition, Vector2d pVelocity)
    {
    m_Position = pPosition;
    m_Velocity = pVelocity;

    }

    public void Update(float pTimeStep)
    {
    m_Position = m_Position.Add(m_Velocity.Multiply(pTimeStep));
    }

    public void Draw()
    {

    GL.glTexCoord2f(0.0f, 0.0f);
    GL.glVertex2f(-halfSize + m_Position.X, -halfSize + m_Position.Y);
    GL.glTexCoord2f(0.0f, 1.0f);
    GL.glVertex2f(-halfSize + m_Position.X, halfSize + m_Position.Y);
    GL.glTexCoord2f(1.0f, 1.0f);
    GL.glVertex2f(halfSize + m_Position.X, halfSize + m_Position.Y);
    GL.glTexCoord2f(1.0f, 0.0f);
    GL.glVertex2f(halfSize + m_Position.X, -halfSize + m_Position.Y);


    }

    public Vector2d GetPosition()
    {
    return m_Position;
    }

  2. #2
    Join Date
    Jan 2010
    Posts
    1,133

    Re: need help with C# (open gl) -

    Sry, couldn't really see anything that could cause an error, but maybe I missed something - the code you posted is hard to read since the formatting wasn't preserved. Please repost using the [code][/code] tags (note: these won't format the code, but will preserve existing formatting).

    Also, it would help us help you if you provided more detail on the error. Is it a compiler error, an exception, a bug? On what line of code? Is there an error message, and what does it say? If the code runs, what did you expect to happen, and what is actually happening? How did you test it?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured