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:
parent
cf9ffb0d27
commit
6bd654b854
@ -292,7 +292,7 @@ public :
|
|||||||
/// \param index2 Index of the third vertex of the triangle
|
/// \param index2 Index of the third vertex of the triangle
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void AddTriangle(std::size_t index0, std::size_t index1, std::size_t index2);
|
void AddTriangle(std::size_t index0, std::size_t index1, std::size_t index2);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Render the content of the whole queue
|
/// \brief Render the content of the whole queue
|
||||||
@ -330,7 +330,7 @@ private :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
typedef std::vector<priv::Batch> BatchArray;
|
typedef std::vector<priv::Batch> BatchArray;
|
||||||
typedef std::vector<float> VertexArray;
|
typedef std::vector<float> VertexArray;
|
||||||
typedef std::vector<std::size_t> IndexArray;
|
typedef std::vector<Uint32> IndexArray;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
@ -343,7 +343,7 @@ private :
|
|||||||
Blend::Mode myCurrentBlendMode; ///< Current blending mode
|
Blend::Mode myCurrentBlendMode; ///< Current blending mode
|
||||||
IntRect myCurrentViewport; ///< Current target viewport
|
IntRect myCurrentViewport; ///< Current target viewport
|
||||||
Vector2f myCurrentViewportSize; ///< Size of the current viewport (for vertex calculations)
|
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::GeometryRenderer* myRenderer; ///< Optimized geometry renderer
|
||||||
priv::Batch* myCurrentBatch; ///< Current geometry block
|
priv::Batch* myCurrentBatch; ///< Current geometry block
|
||||||
BatchArray myBatches; ///< Blocks of geometry to render
|
BatchArray myBatches; ///< Blocks of geometry to render
|
||||||
|
@ -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;
|
myStart = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Batch::End(std::size_t index)
|
void Batch::End(Uint32 index)
|
||||||
{
|
{
|
||||||
myCount = index - myStart;
|
myCount = index - myStart;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public :
|
|||||||
/// \param index Start index
|
/// \param index Start index
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Begin(std::size_t index);
|
void Begin(Uint32 index);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Setup the end index of the batch
|
/// \brief Setup the end index of the batch
|
||||||
@ -86,7 +86,7 @@ public :
|
|||||||
/// \param index End index
|
/// \param index End index
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void End(std::size_t index);
|
void End(Uint32 index);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Render the contents of the batch
|
/// \brief Render the contents of the batch
|
||||||
@ -105,8 +105,8 @@ private :
|
|||||||
const Shader* myShader; ///< Pixel shader used by the batch
|
const Shader* myShader; ///< Pixel shader used by the batch
|
||||||
Blend::Mode myBlendMode; ///< Blending mode used by the batch
|
Blend::Mode myBlendMode; ///< Blending mode used by the batch
|
||||||
IntRect myViewport; ///< Target viewport for the batch
|
IntRect myViewport; ///< Target viewport for the batch
|
||||||
std::size_t myStart; ///< Index of the first index to render with this batch
|
Uint32 myStart; ///< Index of the first index to render with this batch
|
||||||
std::size_t myCount; ///< Number of indices to render with this batch
|
Uint32 myCount; ///< Number of indices to render with this batch
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -75,7 +75,7 @@ public :
|
|||||||
/// \param indicesCount Number of indices to render
|
/// \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
|
/// \brief Stop rendering geometry
|
||||||
@ -95,7 +95,7 @@ public :
|
|||||||
/// \param count Number of indices to be rendered
|
/// \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
|
} // namespace priv
|
||||||
|
@ -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
|
// Store the geometry informations for later rendering
|
||||||
myVertices = vertices;
|
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
|
// Caculate the bounds of the geometry range to render
|
||||||
const std::size_t* begin = myIndices + start;
|
const Uint32* begin = myIndices + start;
|
||||||
const std::size_t* end = begin + count;
|
const Uint32* end = begin + count;
|
||||||
|
|
||||||
// Begin rendering
|
// Begin rendering
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
// Send the vertices one by one
|
// 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;
|
const float* vertex = myVertices + *index * 8;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public :
|
|||||||
/// \param indicesCount Number of indices to render
|
/// \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
|
/// \brief Stop rendering geometry
|
||||||
@ -91,13 +91,13 @@ public :
|
|||||||
/// \param count Number of indices to be rendered
|
/// \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
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const float* myVertices; ///< Pointer to the vertices to render
|
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
|
} // namespace priv
|
||||||
|
@ -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);
|
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));
|
GLCheck(glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(count), GL_UNSIGNED_INT, myIndices + start));
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public :
|
|||||||
/// \param indicesCount Number of indices to render
|
/// \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
|
/// \brief Stop rendering geometry
|
||||||
@ -91,12 +91,12 @@ public :
|
|||||||
/// \param count Number of indices to be rendered
|
/// \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
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const std::size_t* myIndices; ///< Pointer to the indices to render
|
const Uint32* myIndices; ///< Pointer to the indices to render
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -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)
|
// Update the vertex buffer data (make it grow if it is not large enough)
|
||||||
GLCheck(glBindBufferARB(GL_ARRAY_BUFFER_ARB, myVertexBuffer));
|
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));
|
GLCheck(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, myIndexBuffer));
|
||||||
if (indicesCount > myIndexBufferSize)
|
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;
|
myIndexBufferSize = indicesCount;
|
||||||
}
|
}
|
||||||
else
|
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);
|
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;
|
static const std::size_t* pointer = NULL;
|
||||||
GLCheck(glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(count), GL_UNSIGNED_INT, pointer + start));
|
GLCheck(glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(count), GL_UNSIGNED_INT, pointer + start));
|
||||||
|
@ -78,7 +78,7 @@ public :
|
|||||||
/// \param indicesCount Number of indices to render
|
/// \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
|
/// \brief Stop rendering geometry
|
||||||
@ -98,15 +98,15 @@ public :
|
|||||||
/// \param count Number of indices to be rendered
|
/// \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
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GLuint myVertexBuffer;
|
GLuint myVertexBuffer; ///< Identifier of the vertex buffer
|
||||||
GLuint myIndexBuffer;
|
GLuint myIndexBuffer; ///< Identifier of the index buffer
|
||||||
std::size_t myVertexBufferSize;
|
Uint32 myVertexBufferSize; ///< Size of the vertex buffer
|
||||||
std::size_t myIndexBufferSize;
|
Uint32 myIndexBufferSize; ///< Size of the index buffer
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -270,9 +270,9 @@ void RenderQueue::AddTriangle(std::size_t index0, std::size_t index1, std::size_
|
|||||||
myIndices.resize(size + size / 2);
|
myIndices.resize(size + size / 2);
|
||||||
|
|
||||||
// Copy the index data
|
// Copy the index data
|
||||||
myIndices[myCurrentIndexCount + 0] = index0 + myBaseIndex;
|
myIndices[myCurrentIndexCount + 0] = static_cast<Uint32>(index0 + myBaseIndex);
|
||||||
myIndices[myCurrentIndexCount + 1] = index1 + myBaseIndex;
|
myIndices[myCurrentIndexCount + 1] = static_cast<Uint32>(index1 + myBaseIndex);
|
||||||
myIndices[myCurrentIndexCount + 2] = index2 + myBaseIndex;
|
myIndices[myCurrentIndexCount + 2] = static_cast<Uint32>(index2 + myBaseIndex);
|
||||||
|
|
||||||
// Increase the index count
|
// Increase the index count
|
||||||
myCurrentIndexCount += 3;
|
myCurrentIndexCount += 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user