Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8075209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:54:50+00:00 2026-06-05T14:54:50+00:00

I’m creating a bounding box and for debugging would like to see where it

  • 0

I’m creating a bounding box and for debugging would like to see where it is. It is define as four corners and I simply want to draw line in between these 4 corners.

I managed to Google how to do this:

    public void Draw(GraphicsDevice graphicsDevice)
    {
        int num = mCorners.Length;
        VertexPositionColor[] primitiveList = new VertexPositionColor[num];

        for (int i = 0; i < num; ++i)
        {
            primitiveList[i] = new VertexPositionColor(new Vector3(mCorners[i], 0), Color.White);
        }

        short[] triangleStripIndices = new short[] { 0, 1, 2, 3, };
        graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, primitiveList, 0, 4, triangleStripIndices, 0, 3);
    }

However, when this code is ran the app just closes. It is in debug mode but there is no stack trace, crash message, error log etc. It just closes, making it very hard to debug.

I’ve found a similar question that doesn’t have an answer:
XNA 4.0 app closes suddenly when it hits a method without throwing any exceptions. The suggestion was is it being initialised properly, and yes mine is. The GraphicsDevice is passed around as a parameter and not obtained statically.

Does anybody know what may be causing this?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:54:51+00:00Added an answer on June 5, 2026 at 2:54 pm

    Ok, figured it out. Code is as follows:

        private BasicEffect mBasicEffect;
    
        public void Draw(GraphicsDevice graphicsDevice)
        {
            // If we haven't set this up yet then do so now
            if (mBasicEffect == null)
            {
                CreateBasicEffect(graphicsDevice);
            }
    
            foreach (EffectPass pass in mBasicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
    
                int num = mCorners.Length + 1;
                short[] triangleStripIndices = new short[num];
                VertexPositionColor[] primitiveList = new VertexPositionColor[num];
    
                for (int i = 0; i < num; ++i)
                {
                    int index = i % mCorners.Length;
                    Vector2 vec = mCorners[index];
                    primitiveList[index] = new VertexPositionColor(new Vector3(vec, 0), Color.White);
                    triangleStripIndices[i] = (short)i;
                }
    
                graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, primitiveList, 0, 5, triangleStripIndices, 0, 4);
            }
        }
    
        private void CreateBasicEffect(GraphicsDevice device)
        {
            mBasicEffect = new BasicEffect(device);
            mBasicEffect.VertexColorEnabled = true;
    
            Matrix viewMatrix = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.Up);
            Matrix worldMatrix = Matrix.CreateTranslation(0, 0, 0);
            Matrix projectionMatrix = Matrix.CreateOrthographicOffCenter(0, device.Viewport.Width, device.Viewport.Height, 0, 1, 1000);
    
            mBasicEffect.World = worldMatrix;
            mBasicEffect.View = viewMatrix;
            mBasicEffect.Projection = projectionMatrix;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.