From 65df1bcc74d0a980a8bd1caa52d4390644990f8a Mon Sep 17 00:00:00 2001 From: gered Date: Wed, 3 Apr 2013 11:25:23 -0400 Subject: [PATCH] clean up initialization a bit and use some better default sizing --- src/framework/graphics/spritebatch.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/framework/graphics/spritebatch.cpp b/src/framework/graphics/spritebatch.cpp index 2201a21..68688e3 100644 --- a/src/framework/graphics/spritebatch.cpp +++ b/src/framework/graphics/spritebatch.cpp @@ -34,8 +34,10 @@ SpriteBatch::SpriteBatch(GraphicsDevice *graphicsDevice) { m_graphicsDevice = graphicsDevice; m_shader = NULL; - - // TODO: default size of 1 is best? + m_begunRendering = false; + m_isRenderStateOverridden = false; + m_isBlendStateOverridden = false; + m_isClipping = false; m_currentSpritePointer = 0; VERTEX_ATTRIBS attribs[] = { @@ -44,28 +46,15 @@ SpriteBatch::SpriteBatch(GraphicsDevice *graphicsDevice) VERTEX_TEXCOORD }; - // size vertices and texture storage to match m_currentSpriteCapacity - // HACK: we initialize the buffer to have a size of "1" simply because we - // can't use a size of 0 with the current VertexBuffer implementation m_vertices = new VertexBuffer(); - ASSERT(m_vertices != NULL); - m_vertices->Initialize(attribs, 3, 1, BUFFEROBJECT_USAGE_STREAM); + m_vertices->Initialize(attribs, 3, DEFAULT_SPRITE_COUNT * VERTICES_PER_SPRITE, BUFFEROBJECT_USAGE_STREAM); - m_textures.reserve(1); + m_textures.reserve(DEFAULT_SPRITE_COUNT); m_renderState = new RENDERSTATE_DEFAULT; - ASSERT(m_renderState != NULL); m_renderState->SetDepthTesting(false); m_blendState = new BLENDSTATE_ALPHABLEND; - ASSERT(m_blendState != NULL); - - m_begunRendering = false; - - m_isRenderStateOverridden = false; - m_isBlendStateOverridden = false; - - m_isClipping = false; } SpriteBatch::~SpriteBatch()