Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

burnt_casadilla

Member Since 10 Jul 2011
Offline Last Active Today, 10:26 AM
-----

Posts I've Made

In Topic: reuse 3d primitives

Today, 12:52 AM

I think I need to make an indices buffer, but I have no clue how to pass my vertex buffer to it. When I'm drawing the cubes, I'll be drawing from the indices list so hopefully it'll make the fps jump

 

I changed the class to this so the vb is only being called once but nothing changed

 

    public void setVB()
    {
        device.SetVertexBuffer(cubeVertexBuffer);
    }

    public void Draw(BasicEffect effect)
    {
        setVB();

        foreach (EffectPass pass in effect.CurrentTechnique.Passes)
        {
            pass.Apply();
            device.DrawPrimitives(PrimitiveType.TriangleList, 0, cubeVertexBuffer.VertexCount / 3);
        }
    }

 

 


In Topic: reuse 3d primitives

18 May 2013 - 03:36 PM

Would it make more sense for me to just combine the two classes?


In Topic: reuse 3d primitives

18 May 2013 - 11:59 AM

I used this line of code

 

graphics.SynchronizeWithVerticalRetrace = false;

 

To disable VSync and it didn't help the fps while running a 50x50. When you're talking about only calling the Vbuffers once, I'm assuming you mean create an object VBuffer and replace it with the foreach loop in each draw method? I'm a little confused on what you mean at your first bullet point


In Topic: reuse 3d primitives

17 May 2013 - 11:39 AM

10x10 works fine, fps stays at 60. How do I check if the vertex buffer is only being called once?

 

public override void Draw(GameTime gameTime)
            {
                base.Draw(gameTime);

                foreach (var item in entities)
                {

                    effect.VertexColorEnabled = false;
                    effect.TextureEnabled = true;
                    effect.Texture = item.Texture;

                    Matrix center = Matrix.CreateTranslation(new Vector3(-0.5f, -0.5f, -0.5f));
                    Matrix scale = Matrix.CreateScale(1f);
                    Matrix translate = Matrix.CreateTranslation(item.Position);

                    effect.World = center * scale * translate;
                    effect.View = camera.View;
                    effect.Projection = camera.Projection;

                    cube.Draw(effect);
                }

 

That method is getting called in my draw method in my game class

 

 public void Draw(BasicEffect effect)
    {
        foreach (EffectPass pass in effect.CurrentTechnique.Passes)
        {
            pass.Apply();
            device.SetVertexBuffer(cubeVertexBuffer);
            device.DrawPrimitives(PrimitiveType.TriangleList, 0, cubeVertexBuffer.VertexCount / 3);
        }
    }

And this method is getting called by the method above. I think this one is the problem. Its setting the VB every time its called I think


In Topic: reuse 3d primitives

16 May 2013 - 09:51 PM

I successfully drew a 50x50 area one cube high. FPS is at a whopping 11 -.- so I obviously did something very wrong lol


PARTNERS