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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:11:58+00:00 2026-06-10T15:11:58+00:00

I do not know where I make mistake. I have seen some demos on

  • 0

I do not know where I make mistake. I have seen some demos on youtube which render about 1 milion particles in realtime (amazing). But when I want to render only 2500 small sqares (Texture2D), the system falls on the knees – everything is going slow and jerky. Here I present the loop as it is – simple tile to tile rendering. The grid is 50 x 50 and the Texture2D Tile is only 5×5 large png image and GridNode 3×3. I am very new in XNA, so please do not beat me too much… 🙂

Can anybody tell me, what do I do wrong?

Thanx a lot

for (x = FromCol; x <= ToCol; x++)
            {
                for (y = FromRow; y <= ToRow; y++)
                {
                    Color aColor = new Color((byte)(x * 20), (byte)(y * 15), (byte)(60 + x));

                    CoordX = DisplayArea.Left + (int)Math.Round((x - FromCol) * zoomWidth - (restCol * ZoomingX) - indent_x);//
                    CoordY = DisplayArea.Top + (int)Math.Round((y - FromRow) * zoomHeight - (restRow * ZoomingY) - indent_y);//

                    dodraw = ((CoordX) > DisplayArea.Left) & (CoordX < (DisplayArea.Right - indent_x)) & ((CoordY) > DisplayArea.Top) & (CoordY < (DisplayArea.Bottom-indent_y));


                    l = CoordX + indent_x;
                    t = CoordY + indent_y; 
                    r = l + (int)Math.Round(ColWidth * ZoomingX);
                    b = t + (int)Math.Round(RowHeight * ZoomingY);

                    if (l < DisplayArea.Left) l = DisplayArea.Left;
                    if (t < DisplayArea.Top)  t = DisplayArea.Top;
                    if (r > (DisplayArea.Left + DisplayArea.Width)) r = DisplayArea.Left + DisplayArea.Width;
                    if (b > DisplayArea.Top + DisplayArea.Height) b = DisplayArea.Top + DisplayArea.Height;

                    SpriteBatch.Draw(Tile, new Rectangle(l, t, r - l, b - t), aColor);

                    if (dodraw) SpriteBatch.Draw(GridNode, new Vector2(CoordX, CoordY), Color.White);
                }
  • 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-10T15:11:59+00:00Added an answer on June 10, 2026 at 3:11 pm

    Seth’s answer is almost correct. When you send a batch to the GPU – when you draw something – it takes up a relatively large amount of CPU time. Effectivly you’re limited to sending a few hundred batches per frame – your “batch limit”.

    SpriteBatch gets around this problem by packing as many sprites as possible into a single batch. It only actually draws things in End()[1]. However it can only batch sprites together if they share a texture.

    You’ve pretty much got the worst-case scenario here: It looks like you’re interleaving textures, forcing SpriteBatch to start a new batch for each sprite.

    So the first thing to do is to check if this is actually the cause of your problem. A quick way to do this is to set SpriteSortMode.Texture (in SpriteBatch.Begin) and see if performance improves. This will do exactly what it sounds like – grouping your sprites by texture in the draw order, reducing the number of texture changes and therefore batches.

    Then you can start working on fixing the issue. If you can continue using SpriteSortMode.Texture, then that’s fine. You could also convert your loop into two separate loops. Or you could fill two separate SpriteBatch objects within the one loop – as SpriteBatch basically acts as a buffer[1].

    Or, if you really need those textures interleaved, then use a sprite sheet.

    Finally, I’ve written this rather popular answer on the GameDev site which covers this topic in more detail.


    [1] Except when using SpriteSortMode.Immediate

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

Sidebar

Related Questions

I know I could just make all the Mix_Musics public, and not worry about
I'm not expert about css menus. But I know basic system to make css
I'm trying to make a Dynamic Grid class (where I do not know any
does anybody know how to make EJBTimers persistent not in filesystem, but in selected
I know what I asking might not make a lot of sense for C#
Do anyone know a way to make: com.mchange.v2.c3p0.management.ManagementCoordinator=com.mchange.v2.c3p0.management.NullManagementCoordinator using Spring and not a c3p0.properties
In Oracle, this returns 03/01/2010. That does not make sense to me. Anybody know
I have a big XML file but I do not know its schema. I
I have an existing app in which I made the mistake of using String.GetHashCode
I have some problems with making a stacked bar chart in ggplot2. I know

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.