Fixed wrong type for OpenGL indices (std::size_t could be 64 bits on 64 bits platforms -- now using sf::Uint32)

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1297 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-12-02 20:45:53 +00:00
parent cf9ffb0d27
commit 6bd654b854
11 changed files with 38 additions and 38 deletions

View File

@ -330,7 +330,7 @@ private :
////////////////////////////////////////////////////////////
typedef std::vector<priv::Batch> BatchArray;
typedef std::vector<float> VertexArray;
typedef std::vector<std::size_t> IndexArray;
typedef std::vector<Uint32> IndexArray;
////////////////////////////////////////////////////////////
// Member data
@ -343,7 +343,7 @@ private :
Blend::Mode myCurrentBlendMode; ///< Current blending mode
IntRect myCurrentViewport; ///< Current target viewport
Vector2f myCurrentViewportSize; ///< Size of the current viewport (for vertex calculations)
std::size_t myBaseIndex; ///< Base vertex index for the current batch
Uint32 myBaseIndex; ///< Base vertex index for the current batch
priv::GeometryRenderer* myRenderer; ///< Optimized geometry renderer
priv::Batch* myCurrentBatch; ///< Current geometry block
BatchArray myBatches; ///< Blocks of geometry to render

View File

@ -62,14 +62,14 @@ bool Batch::Matches(const Image* texture, const Shader* shader, Blend::Mode blen
////////////////////////////////////////////////////////////
void Batch::Begin(std::size_t index)
void Batch::Begin(Uint32 index)
{
myStart = index;
}
////////////////////////////////////////////////////////////
void Batch::End(std::size_t index)
void Batch::End(Uint32 index)
{
myCount = index - myStart;
}

View File

@ -78,7 +78,7 @@ public :
/// \param index Start index
///
////////////////////////////////////////////////////////////
void Begin(std::size_t index);
void Begin(Uint32 index);
////////////////////////////////////////////////////////////
/// \brief Setup the end index of the batch
@ -86,7 +86,7 @@ public :
/// \param index End index
///
////////////////////////////////////////////////////////////
void End(std::size_t index);
void End(Uint32 index);
////////////////////////////////////////////////////////////
/// \brief Render the contents of the batch
@ -105,8 +105,8 @@ private :
const Shader* myShader; ///< Pixel shader used by the batch
Blend::Mode myBlendMode; ///< Blending mode used by the batch
IntRect myViewport; ///< Target viewport for the batch
std::size_t myStart; ///< Index of the first index to render with this batch
std::size_t myCount; ///< Number of indices to render with this batch
Uint32 myStart; ///< Index of the first index to render with this batch
Uint32 myCount; ///< Number of indices to render with this batch
};
} // namespace priv

View File

@ -75,7 +75,7 @@ public :
/// \param indicesCount Number of indices to render
///
////////////////////////////////////////////////////////////
virtual void Begin(const float* vertices, std::size_t verticesCount, const std::size_t* indices, std::size_t indicesCount) = 0;
virtual void Begin(const float* vertices, std::size_t verticesCount, const Uint32* indices, std::size_t indicesCount) = 0;
////////////////////////////////////////////////////////////
/// \brief Stop rendering geometry
@ -95,7 +95,7 @@ public :
/// \param count Number of indices to be rendered
///
////////////////////////////////////////////////////////////
virtual void RenderTriangles(std::size_t start, std::size_t count) = 0;
virtual void RenderTriangles(Uint32 start, Uint32 count) = 0;
};
} // namespace priv

View File

@ -51,7 +51,7 @@ myIndices (NULL)
////////////////////////////////////////////////////////////
void GeometryRendererIM::Begin(const float* vertices, std::size_t, const std::size_t* indices, std::size_t)
void GeometryRendererIM::Begin(const float* vertices, std::size_t, const Uint32* indices, std::size_t)
{
// Store the geometry informations for later rendering
myVertices = vertices;
@ -67,17 +67,17 @@ void GeometryRendererIM::End()
////////////////////////////////////////////////////////////
void GeometryRendererIM::RenderTriangles(std::size_t start, std::size_t count)
void GeometryRendererIM::RenderTriangles(Uint32 start, Uint32 count)
{
// Caculate the bounds of the geometry range to render
const std::size_t* begin = myIndices + start;
const std::size_t* end = begin + count;
const Uint32* begin = myIndices + start;
const Uint32* end = begin + count;
// Begin rendering
glBegin(GL_TRIANGLES);
// Send the vertices one by one
for (const std::size_t* index = begin; index != end; index++)
for (const Uint32* index = begin; index != end; index++)
{
const float* vertex = myVertices + *index * 8;

View File

@ -71,7 +71,7 @@ public :
/// \param indicesCount Number of indices to render
///
////////////////////////////////////////////////////////////
virtual void Begin(const float* vertices, std::size_t verticesCount, const std::size_t* indices, std::size_t indicesCount);
virtual void Begin(const float* vertices, std::size_t verticesCount, const Uint32* indices, std::size_t indicesCount);
////////////////////////////////////////////////////////////
/// \brief Stop rendering geometry
@ -91,13 +91,13 @@ public :
/// \param count Number of indices to be rendered
///
////////////////////////////////////////////////////////////
virtual void RenderTriangles(std::size_t start, std::size_t count);
virtual void RenderTriangles(Uint32 start, Uint32 count);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
const float* myVertices; ///< Pointer to the vertices to render
const std::size_t* myIndices; ///< Pointer to the indices to render
const Uint32* myIndices; ///< Pointer to the indices to render
};
} // namespace priv

View File

@ -51,7 +51,7 @@ myIndices(NULL)
////////////////////////////////////////////////////////////
void GeometryRendererVA::Begin(const float* vertices, std::size_t verticesCount, const std::size_t* indices, std::size_t)
void GeometryRendererVA::Begin(const float* vertices, std::size_t verticesCount, const Uint32* indices, std::size_t)
{
static const GLsizei stride = 8 * sizeof(float);
@ -87,7 +87,7 @@ void GeometryRendererVA::End()
////////////////////////////////////////////////////////////
void GeometryRendererVA::RenderTriangles(std::size_t start, std::size_t count)
void GeometryRendererVA::RenderTriangles(Uint32 start, Uint32 count)
{
GLCheck(glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(count), GL_UNSIGNED_INT, myIndices + start));
}

View File

@ -71,7 +71,7 @@ public :
/// \param indicesCount Number of indices to render
///
////////////////////////////////////////////////////////////
virtual void Begin(const float* vertices, std::size_t verticesCount, const std::size_t* indices, std::size_t indicesCount);
virtual void Begin(const float* vertices, std::size_t verticesCount, const Uint32* indices, std::size_t indicesCount);
////////////////////////////////////////////////////////////
/// \brief Stop rendering geometry
@ -91,12 +91,12 @@ public :
/// \param count Number of indices to be rendered
///
////////////////////////////////////////////////////////////
virtual void RenderTriangles(std::size_t start, std::size_t count);
virtual void RenderTriangles(Uint32 start, Uint32 count);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
const std::size_t* myIndices; ///< Pointer to the indices to render
const Uint32* myIndices; ///< Pointer to the indices to render
};
} // namespace priv

View File

@ -64,7 +64,7 @@ GeometryRendererVBO::~GeometryRendererVBO()
////////////////////////////////////////////////////////////
void GeometryRendererVBO::Begin(const float* vertices, std::size_t verticesCount, const std::size_t* indices, std::size_t indicesCount)
void GeometryRendererVBO::Begin(const float* vertices, std::size_t verticesCount, const Uint32* indices, std::size_t indicesCount)
{
// Update the vertex buffer data (make it grow if it is not large enough)
GLCheck(glBindBufferARB(GL_ARRAY_BUFFER_ARB, myVertexBuffer));
@ -82,12 +82,12 @@ void GeometryRendererVBO::Begin(const float* vertices, std::size_t verticesCount
GLCheck(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, myIndexBuffer));
if (indicesCount > myIndexBufferSize)
{
GLCheck(glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indicesCount * sizeof(std::size_t), indices, GL_DYNAMIC_DRAW_ARB));
GLCheck(glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indicesCount * sizeof(Uint32), indices, GL_DYNAMIC_DRAW_ARB));
myIndexBufferSize = indicesCount;
}
else
{
GLCheck(glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, indicesCount * sizeof(std::size_t), indices));
GLCheck(glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, indicesCount * sizeof(Uint32), indices));
}
static const GLsizei stride = 8 * sizeof(float);
@ -116,7 +116,7 @@ void GeometryRendererVBO::End()
////////////////////////////////////////////////////////////
void GeometryRendererVBO::RenderTriangles(std::size_t start, std::size_t count)
void GeometryRendererVBO::RenderTriangles(Uint32 start, Uint32 count)
{
static const std::size_t* pointer = NULL;
GLCheck(glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(count), GL_UNSIGNED_INT, pointer + start));

View File

@ -78,7 +78,7 @@ public :
/// \param indicesCount Number of indices to render
///
////////////////////////////////////////////////////////////
virtual void Begin(const float* vertices, std::size_t verticesCount, const std::size_t* indices, std::size_t indicesCount);
virtual void Begin(const float* vertices, std::size_t verticesCount, const Uint32* indices, std::size_t indicesCount);
////////////////////////////////////////////////////////////
/// \brief Stop rendering geometry
@ -98,15 +98,15 @@ public :
/// \param count Number of indices to be rendered
///
////////////////////////////////////////////////////////////
virtual void RenderTriangles(std::size_t start, std::size_t count);
virtual void RenderTriangles(Uint32 start, Uint32 count);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
GLuint myVertexBuffer;
GLuint myIndexBuffer;
std::size_t myVertexBufferSize;
std::size_t myIndexBufferSize;
GLuint myVertexBuffer; ///< Identifier of the vertex buffer
GLuint myIndexBuffer; ///< Identifier of the index buffer
Uint32 myVertexBufferSize; ///< Size of the vertex buffer
Uint32 myIndexBufferSize; ///< Size of the index buffer
};
} // namespace priv

View File

@ -270,9 +270,9 @@ void RenderQueue::AddTriangle(std::size_t index0, std::size_t index1, std::size_
myIndices.resize(size + size / 2);
// Copy the index data
myIndices[myCurrentIndexCount + 0] = index0 + myBaseIndex;
myIndices[myCurrentIndexCount + 1] = index1 + myBaseIndex;
myIndices[myCurrentIndexCount + 2] = index2 + myBaseIndex;
myIndices[myCurrentIndexCount + 0] = static_cast<Uint32>(index0 + myBaseIndex);
myIndices[myCurrentIndexCount + 1] = static_cast<Uint32>(index1 + myBaseIndex);
myIndices[myCurrentIndexCount + 2] = static_cast<Uint32>(index2 + myBaseIndex);
// Increase the index count
myCurrentIndexCount += 3;