OpenGL2: Fix world VAO cache drawing when glIndex_t is unsigned short
OpenGL ES is only required to support unsigned short for element buffer values. R_DrawElements() firstIndex argument was glIndex_t which caused element indexes to wrap around to 0 when glIndex_t is an unsigned short. (glIndex_t is an index into the vertexes buffer, not element buffer.) Change it to 'int' like tess.firstIndex which is passed to R_DrawElements(). World VAO cache buffer size allowed storing more vertexes than unsigned short glIndex_t could reference. This resulted in the vertex indexes in the element buffer wrapping around to 0.
This commit is contained in:
parent
658165cfbb
commit
14cc4cc6cb
3 changed files with 7 additions and 2 deletions
|
@ -687,8 +687,13 @@ vcq;
|
|||
// srfVert_t is 60 bytes
|
||||
// assuming each vert is referenced 4 times, need 16 bytes (4 glIndex_t) per vert
|
||||
// -> need about 4/15ths the space for indexes as vertexes
|
||||
#if GL_INDEX_TYPE == GL_UNSIGNED_SHORT
|
||||
#define VAOCACHE_VERTEX_BUFFER_SIZE (sizeof(srfVert_t) * USHRT_MAX)
|
||||
#define VAOCACHE_INDEX_BUFFER_SIZE (sizeof(glIndex_t) * USHRT_MAX * 4)
|
||||
#else // GL_UNSIGNED_INT
|
||||
#define VAOCACHE_VERTEX_BUFFER_SIZE (16 * 1024 * 1024)
|
||||
#define VAOCACHE_INDEX_BUFFER_SIZE (5 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
typedef struct buffered_s
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue