void DrawBatchedQuads() { int numOfQuads = 0; int startIndex = 0; if (currentBatchedQuads.Count <= 0 || quadCommands.Count == 0) { return; } var quadElements = currentBatchedQuads.Elements; uint lastMaterialId = 0; bool originalDepthTestState = drawManager.DepthTest; bool usingDepthTest = originalDepthTestState; drawManager.PushMatrix(); drawManager.SetIdentityMatrix(); CCQuadCommand prevCommand = null; foreach (CCQuadCommand command in quadCommands) { var newMaterialID = command.MaterialId; bool commandUsesDepthTest = command.UsingDepthTest; if (lastMaterialId != newMaterialID || commandUsesDepthTest != usingDepthTest) { if (numOfQuads > 0 && prevCommand != null) { prevCommand.UseMaterial(drawManager); drawManager.DrawQuads(currentBatchedQuads, startIndex, numOfQuads); startIndex += numOfQuads; numOfQuads = 0; } lastMaterialId = newMaterialID; usingDepthTest = commandUsesDepthTest; drawManager.DepthTest = usingDepthTest; } numOfQuads += command.QuadCount; prevCommand = command; } // Draw any remaining quads if (numOfQuads > 0 && prevCommand != null) { prevCommand.UseMaterial(drawManager); drawManager.DrawQuads(currentBatchedQuads, startIndex, numOfQuads); } quadCommands.Clear(); currentBatchedQuads.Clear(); drawManager.PopMatrix(); drawManager.DepthTest = originalDepthTestState; }
internal void RenderCustomCommand(CCDrawManager drawManager) { bool originalDepthTestState = drawManager.DepthTest; drawManager.DepthTest = UsingDepthTest; drawManager.PushMatrix(); drawManager.SetIdentityMatrix(); if (WorldTransform != CCAffineTransform.Identity) { var worldTrans = WorldTransform.XnaMatrix; drawManager.MultMatrix(ref worldTrans); } Action(); drawManager.PopMatrix(); drawManager.DepthTest = originalDepthTestState; }
public static void PopMatrix() { drawManager.PopMatrix(); }