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

  • Home
  • SEARCH
  • 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 6794957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:17:05+00:00 2026-05-26T18:17:05+00:00

I’m trying to draw a textured quad in XNA using the sample code from

  • 0

I’m trying to draw a textured quad in XNA using the sample code from MSDN http://msdn.microsoft.com/en-us/library/bb464051.aspx

but instead of drawing it on XY plane i’m drawing it in XZ plane

I initialize that quad with this
this.quad = new Quad(Vector3.Zero, Vector3.Up, Vector3.Backward, 1, 1);

I’ve tried almost every combination of Normal and Left vector, no matter where the quad is drawn, the quad is completely black.

what am i doing wrong here? is the texture’s information lost when i’m passing it around? am i mapping the texture positions wrong?

ps: Texture, lighting are enabled.

public class Quad
{
    public VertexPositionNormalTexture[] Vertices;
    public Vector3 Origin;
    public Vector3 Up;
    public Vector3 Normal;
    public Vector3 Left;
    public Vector3 UpperLeft;
    public Vector3 UpperRight;
    public Vector3 LowerLeft;
    public Vector3 LowerRight;
    public int[] Indexes;


    public Quad(Vector3 origin, Vector3 normal, Vector3 up,
             float width, float height)
    {
            this.Vertices = new VertexPositionNormalTexture[4];
            this.Indexes = new int[6];
            this.Origin = origin;
            this.Normal = normal;
            this.Up = up;

            // Calculate the quad corners
            this.Left = Vector3.Cross(normal, this.Up);
            Vector3 uppercenter = (this.Up * height / 2) + origin;
            this.UpperLeft = uppercenter + (this.Left * width / 2);
            this.UpperRight = uppercenter - (this.Left * width / 2);
            this.LowerLeft = this.UpperLeft - (this.Up * height);
            this.LowerRight = this.UpperRight - (this.Up * height);

            this.FillVertices();
    }

    private void FillVertices()
    {
            Vector2 textureUpperLeft = new Vector2(0.0f, 0.0f);
            Vector2 textureUpperRight = new Vector2(1.0f, 0.0f);
            Vector2 textureLowerLeft = new Vector2(0.0f, 1.0f);
            Vector2 textureLowerRight = new Vector2(1.0f, 1.0f);

            for (int i = 0; i < this.Vertices.Length; i++)
            {
                    this.Vertices[i].Normal = this.Normal;
            }

            this.Vertices[0].Position = this.LowerLeft;
            this.Vertices[0].TextureCoordinate = textureLowerLeft;
            this.Vertices[1].Position = this.UpperLeft;
            this.Vertices[1].TextureCoordinate = textureUpperLeft;
            this.Vertices[2].Position = this.LowerRight;
            this.Vertices[2].TextureCoordinate = textureLowerRight;
            this.Vertices[3].Position = this.UpperRight;
            this.Vertices[3].TextureCoordinate = textureUpperRight;

            this.Indexes[0] = 0;
            this.Indexes[1] = 1;
            this.Indexes[2] = 2;
            this.Indexes[3] = 2;
            this.Indexes[4] = 1;
            this.Indexes[5] = 3;
    }
}

my draw method:

        graphicsDevice.BlendState = BlendState.AlphaBlend;

        Effect.World = Matrix.Identity;
        Effect.View = Camera.View;
        Effect.Projection = Camera.Projection;
        Effect.TextureEnabled = true;
        Effect.Texture = OilTexture;

        Effect.EnableDefaultLighting();
        Effect.PreferPerPixelLighting = true;


        foreach (EffectPass pass in oilEffect.CurrentTechnique.Passes)
        {
            pass.Apply();

            graphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>
                    (PrimitiveType.TriangleList,
                    Vertices,
                    0,
                    4,
                    Indexes,
                    0,
                    2);
        }

–i solved my problem. something went wrong when i was passing the texture2d across 3 places, now i’m drawing it from the main draw and the texture shows up fine now.

  • 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-05-26T18:17:06+00:00Added an answer on May 26, 2026 at 6:17 pm

    There are lots of reasons the quad could be black, here are a few things I like to do to debug:

    • Turn off lightning and set on vert color to ensure the orientation of the quad is as I expected.
    • User a sample texture, if possible, to ensure texture data is valid (I get a lot of issues with different versions of pipelines failing
      to load textures because the formats wasn’t what I expected. DDS has
      sub formats that can be tricky if you are making your own data)
    • Check if the texture is visible with lightning off
    • Once you flip lightning on you want to make sure you have lightning values set for all the vertices
    • Try turning up the ambient value of your system to full

    If none of this works look closely at the area where you are passing the vertex lightning values, the vertex normal values, and the lighting down to the hardware.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.