more fixes for my last commit, player problem in twin snakes is fixed

This commit is contained in:
rodolfoosvaldobogado 2012-11-11 22:39:27 -03:00
parent 53b62ab169
commit 3936c06ee8
2 changed files with 51 additions and 36 deletions

View File

@ -218,43 +218,51 @@ void VertexManager::PrepareDrawBuffers(u32 stride)
void VertexManager::DrawVertexBuffer(int stride)
{
if (IndexGenerator::GetNumTriangles() > 0)
int triangles = IndexGenerator::GetNumTriangles();
int lines = IndexGenerator::GetNumLines();
int points = IndexGenerator::GetNumPoints();
int numverts = IndexGenerator::GetNumVerts();
int StartIndex = m_index_buffer_cursor;
int basevertex = m_vertex_buffer_cursor / stride;
if (triangles > 0)
{
if (FAILED(D3D::dev->DrawIndexedPrimitive(
D3DPT_TRIANGLELIST,
m_vertex_buffer_cursor / stride,
basevertex,
0,
IndexGenerator::GetNumVerts(),
m_index_buffer_cursor,
IndexGenerator::GetNumTriangles())))
numverts,
StartIndex,
triangles)))
{
DumpBadShaders();
}
StartIndex += IndexGenerator::GetTriangleindexLen();
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (IndexGenerator::GetNumLines() > 0)
if (lines > 0)
{
if (FAILED(D3D::dev->DrawIndexedPrimitive(
D3DPT_LINELIST,
m_vertex_buffer_cursor / stride,
basevertex,
0,
IndexGenerator::GetNumVerts(),
m_index_buffer_cursor + IndexGenerator::GetTriangleindexLen(),
numverts,
StartIndex,
IndexGenerator::GetNumLines())))
{
DumpBadShaders();
}
StartIndex += IndexGenerator::GetLineindexLen();
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (IndexGenerator::GetNumPoints() > 0)
if (points > 0)
{
if (FAILED(D3D::dev->DrawIndexedPrimitive(
D3DPT_POINTLIST,
m_vertex_buffer_cursor / stride,
basevertex,
0,
IndexGenerator::GetNumVerts(),
m_index_buffer_cursor + IndexGenerator::GetTriangleindexLen() + IndexGenerator::GetLineindexLen(),
IndexGenerator::GetNumPoints())))
numverts,
StartIndex,
points)))
{
DumpBadShaders();
}
@ -264,12 +272,16 @@ void VertexManager::DrawVertexBuffer(int stride)
}
void VertexManager::DrawVertexArray(int stride)
{
if (IndexGenerator::GetNumTriangles() > 0)
{
int triangles = IndexGenerator::GetNumTriangles();
int lines = IndexGenerator::GetNumLines();
int points = IndexGenerator::GetNumPoints();
int numverts = IndexGenerator::GetNumVerts();
if (triangles > 0)
{
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
D3DPT_TRIANGLELIST,
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumTriangles(),
0, numverts, triangles,
TIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,
@ -279,11 +291,11 @@ void VertexManager::DrawVertexArray(int stride)
}
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (IndexGenerator::GetNumLines() > 0)
if (lines > 0)
{
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
D3DPT_LINELIST,
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumLines(),
0, numverts, lines,
LIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,
@ -293,11 +305,11 @@ void VertexManager::DrawVertexArray(int stride)
}
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (IndexGenerator::GetNumPoints() > 0)
if (points > 0)
{
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
D3DPT_POINTLIST,
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumPoints(),
0, numverts, points,
PIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,

View File

@ -68,7 +68,6 @@ void VertexManager::CreateDeviceObjects()
m_buffers_count = 0;
m_vertex_buffers = NULL;
m_index_buffers = NULL;
glEnableClientState(GL_VERTEX_ARRAY);
GL_REPORT_ERRORD();
int max_Index_size = 0;
@ -243,17 +242,20 @@ void VertexManager::PrepareDrawBuffers(u32 stride)
void VertexManager::DrawVertexArray()
{
if (IndexGenerator::GetNumTriangles() > 0)
int triangle_index_size = IndexGenerator::GetTriangleindexLen();
int line_index_size = IndexGenerator::GetLineindexLen();
int point_index_size = IndexGenerator::GetPointindexLen();
if (triangle_index_size > 0)
{
glDrawElements(GL_TRIANGLES, IndexGenerator::GetTriangleindexLen(), GL_UNSIGNED_SHORT, TIBuffer);
glDrawElements(GL_TRIANGLES, triangle_index_size, GL_UNSIGNED_SHORT, TIBuffer);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (IndexGenerator::GetNumLines() > 0)
if (line_index_size > 0)
{
glDrawElements(GL_LINES, IndexGenerator::GetLineindexLen(), GL_UNSIGNED_SHORT, LIBuffer);
glDrawElements(GL_LINES, line_index_size, GL_UNSIGNED_SHORT, LIBuffer);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (IndexGenerator::GetNumPoints() > 0)
if (point_index_size > 0)
{
glDrawElements(GL_POINTS, IndexGenerator::GetPointindexLen(), GL_UNSIGNED_SHORT, PIBuffer);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
@ -269,17 +271,17 @@ void VertexManager::DrawVertexBufferObject()
if (triangle_index_size > 0)
{
glDrawElements(GL_TRIANGLES, triangle_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex);
StartIndex += triangle_index_size * sizeof(u16);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (line_index_size > 0)
{
StartIndex += triangle_index_size * sizeof(u16);
{
glDrawElements(GL_LINES, line_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex);
StartIndex += line_index_size * sizeof(u16);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (point_index_size > 0)
{
StartIndex += line_index_size * sizeof(u16);
{
glDrawElements(GL_POINTS, point_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
@ -291,21 +293,22 @@ void VertexManager::DrawVertexBufferObjectBase(u32 stride)
int line_index_size = IndexGenerator::GetLineindexLen();
int point_index_size = IndexGenerator::GetPointindexLen();
int StartIndex = m_index_buffer_cursor;
int basevertex = m_vertex_buffer_cursor / stride;
if (triangle_index_size > 0)
{
glDrawElementsBaseVertex(GL_TRIANGLES, triangle_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex, m_vertex_buffer_cursor / stride);
glDrawElementsBaseVertex(GL_TRIANGLES, triangle_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex, basevertex);
StartIndex += triangle_index_size * sizeof(u16);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (line_index_size > 0)
{
StartIndex += triangle_index_size * sizeof(u16);
glDrawElementsBaseVertex(GL_LINES, line_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex, m_vertex_buffer_cursor / stride);
glDrawElementsBaseVertex(GL_LINES, line_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex, basevertex);
StartIndex += line_index_size * sizeof(u16);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
if (point_index_size > 0)
{
StartIndex += line_index_size * sizeof(u16);
glDrawElementsBaseVertex(GL_POINTS, point_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex, m_vertex_buffer_cursor / stride);
glDrawElementsBaseVertex(GL_POINTS, point_index_size, GL_UNSIGNED_SHORT, (GLvoid*)StartIndex, basevertex);
INCSTAT(stats.thisFrame.numIndexedDrawCalls);
}
}