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 5997841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:19:17+00:00 2026-05-23T00:19:17+00:00

I have a problem in the game I wrote with XNA. I recently added

  • 0

I have a problem in the game I wrote with XNA. I recently added Textured polygons, and saw that every textured polygon shared the same texture although I changed it before calling. The code I am using:

      if (countMeshes > 0)
        {

            for (int i = 0; i < countMeshes; i++)
            {

                TexturedMesh curMesh = listMeshes[i];

                if (curMesh.tex == null)
                {

                    drawEffect.Texture = WHITE_TEXTURE;

                }
                else
                {
                    drawEffect.Texture = curMesh.tex;
                }

                drawEffect.Techniques[0].Passes[0].Apply();
                graphics.DrawUserPrimitives(PrimitiveType.TriangleList, curMesh.verts, 0, curMesh.count);

            }
        }

Now, the first that came into my mind would be to create a BasicEffect for each Texture I need to draw. But I think that would be a bit of a overkill so my question is: How should I do it?

PS: I double checked everything, the UV Coords are fine, and it is 2D.

  • 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-23T00:19:17+00:00Added an answer on May 23, 2026 at 12:19 am

    It seems to be the only way, the way I did it was to create a Dictionary with the texture as the key and a struct of a basic effect and a list of Vertexs as the value.

    Something like this:

    public struct MeshEffect
    {
    
        public TexturedMesh mesh;
        public BasicEffect effect;
    
    }
    

    and the Dictionary:

     private Dictionary<Texture2D, MeshEffect> texturedMeshes = new Dictionary<Texture2D, MeshEffect>();
    

    But it all really depends on how you handle drawing, but one thing is sure, you can’t use more than one texture on one BasicEffect.

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

Sidebar

Related Questions

I have written a game that uses GLUT, OpenGL and FMOD. The problem is
I have a trivial little game I wrote in javascript that creates a wave
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with fancybox. I want to write a function that will run
I am new to ObC and have a problem that i just cant fix.
Problem I want ot write a simple 1D RTS game and have the following
I have a logical statement that says If everyone plays the game, we will
I'm new to XNA game development and I have just started to write a
Hi dear developers! I'm just wrote my first iphone game. But i have faced
Im creating a game in Flash and I have a class that have some

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.