Spritebatch

This is for anyone that may find this interesting and wasn’t aware this was still available (it was all removed from microsofts website)

Shawn Hargreaves (was one of the developers of xna) has kept all his blogging on xna Shawn Hargreaves Blog Index

One of the interesting things I picked up was using spritebatch for drawing layers as long as each layer comes from 1 texture.

Spritebatch only does that actual draw when spritebatch.end is called (if immediate is selected or if the texture is changed)

So rather than using spritebatch sorting (which is slow and uses array.sort) use multiple spritebatches before calling all your draws and end them in the correct order.

Batchlayer0.end
Batchlayer1.end
Batchlayer2.end

However im not sure if the batch gets drawn if the batch gets too big before end is called

Those articles are great, I had forgotten what the links were. They used to be hosted by Microsoft but at some point they went offline and could only be found with the wayback machine.

image
:woman_facepalming:

Thanks for sharing!

EDIT

Pasting the page here for future, the one from the CodePlex site:

This project migrated to GitHub - microsoft/DirectXTK: The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++

DirectXTK is a shared source library of helpers for Direct3D 11 C++ applications.

home issues discussions

NEWS: This project is now hosted on GitHub GitHub - microsoft/DirectXTK: The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++. DirectX Tool Kit for DirectX 12 is also on GitHub GitHub - microsoft/DirectXTK12: The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++. Please move to using GitHub.

Project Description
The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++.

Supported platforms:

  • Universal Windows Platform apps
  • Windows Store apps for Windows 8.1 / RT 8.1
  • Windows Phone 8.1
  • Windows desktop
  • Windows 7
  • Windows Vista Service Pack 2 with KB 971644
  • Windows Server equivalents of the above
  • Xbox One

Features:

  • Audio - low-level audio API using XAudio2
  • CommonStates - factory providing commonly used D3D state objects
  • DirectXHelpers - misc C++ helpers for D3D programming
  • DDSTextureLoader - light-weight DDS file texture loader
  • Effects - set of built-in shaders for common rendering tasks
  • GamePad - gamepad controller helper using XInput
  • GeometricPrimitive - draws basic shapes such as cubes and spheres
  • GraphicsMemory - helper for managing dynamic graphics memory allocation
  • Keyboard - keyboard state tracking helper
  • Model - draws meshes loaded from .CMO, .SDKMESH, or .VBO files
  • Mouse - mouse helper
  • PrimitiveBatch - simple and efficient way to draw user primitives
  • ScreenGrab - light-weight screen shot saver
  • SimpleMath - simplified C++ wrapper for DirectXMath
  • SpriteBatch - simple & efficient 2D sprite rendering
  • SpriteFont - bitmap based text rendering
  • VertexTypes - structures for commonly used vertex data formats
  • WICTextureLoader - WIC-based image file texture loader
  • XboxDDSTextureLoader - Xbox One exclusive apps variant of DDSTextureLoader

windows8logo.jpg
windowsphone8logo.jpg
xboxonelogo.png