Fix glDrawElements
This commit is contained in:
parent
434f316526
commit
30f8564298
42
GL/draw.c
42
GL/draw.c
|
@ -638,11 +638,8 @@ static inline void _readUVData(const GLuint first, const GLuint count, Vertex* o
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _readSTData(const GLuint first, const GLuint count, SubmissionTarget* target) {
|
static inline void _readSTData(const GLuint first, const GLuint count, VertexExtra* extra) {
|
||||||
assert(target->extras->size == count);
|
|
||||||
|
|
||||||
if((ENABLED_VERTEX_ATTRIBUTES & ST_ENABLED_FLAG) != ST_ENABLED_FLAG) {
|
if((ENABLED_VERTEX_ATTRIBUTES & ST_ENABLED_FLAG) != ST_ENABLED_FLAG) {
|
||||||
VertexExtra* extra = aligned_vector_at(target->extras, 0);
|
|
||||||
_fillZero2fVE(count, extra->st);
|
_fillZero2fVE(count, extra->st);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -651,7 +648,6 @@ static inline void _readSTData(const GLuint first, const GLuint count, Submissio
|
||||||
const void* stptr = ((GLubyte*) ST_POINTER.ptr + (first * ststride));
|
const void* stptr = ((GLubyte*) ST_POINTER.ptr + (first * ststride));
|
||||||
|
|
||||||
if(ST_POINTER.size == 2) {
|
if(ST_POINTER.size == 2) {
|
||||||
VertexExtra* extra = aligned_vector_at(target->extras, 0);
|
|
||||||
switch(ST_POINTER.type) {
|
switch(ST_POINTER.type) {
|
||||||
case GL_FLOAT:
|
case GL_FLOAT:
|
||||||
_readVertexData2f2fVE(stptr, count, ststride, extra->st);
|
_readVertexData2f2fVE(stptr, count, ststride, extra->st);
|
||||||
|
@ -676,11 +672,8 @@ static inline void _readSTData(const GLuint first, const GLuint count, Submissio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _readNormalData(const GLuint first, const GLuint count, SubmissionTarget* target) {
|
static inline void _readNormalData(const GLuint first, const GLuint count, VertexExtra* extra) {
|
||||||
assert(target->extras->size == count);
|
|
||||||
|
|
||||||
if((ENABLED_VERTEX_ATTRIBUTES & NORMAL_ENABLED_FLAG) != NORMAL_ENABLED_FLAG) {
|
if((ENABLED_VERTEX_ATTRIBUTES & NORMAL_ENABLED_FLAG) != NORMAL_ENABLED_FLAG) {
|
||||||
VertexExtra* extra = aligned_vector_at(target->extras, 0);
|
|
||||||
_fillWithNegZVE(count, extra->nxyz);
|
_fillWithNegZVE(count, extra->nxyz);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -689,7 +682,6 @@ static inline void _readNormalData(const GLuint first, const GLuint count, Submi
|
||||||
const void* nptr = ((GLubyte*) NORMAL_POINTER.ptr + (first * nstride));
|
const void* nptr = ((GLubyte*) NORMAL_POINTER.ptr + (first * nstride));
|
||||||
|
|
||||||
if(NORMAL_POINTER.size == 3) {
|
if(NORMAL_POINTER.size == 3) {
|
||||||
VertexExtra* extra = aligned_vector_at(target->extras, 0);
|
|
||||||
switch(NORMAL_POINTER.type) {
|
switch(NORMAL_POINTER.type) {
|
||||||
case GL_FLOAT:
|
case GL_FLOAT:
|
||||||
_readVertexData3f3fVE(nptr, count, nstride, extra->nxyz);
|
_readVertexData3f3fVE(nptr, count, nstride, extra->nxyz);
|
||||||
|
@ -787,8 +779,11 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei
|
||||||
profiler_checkpoint("diffuse");
|
profiler_checkpoint("diffuse");
|
||||||
|
|
||||||
if(doTexture) _readUVData(first, count, _glSubmissionTargetStart(target));
|
if(doTexture) _readUVData(first, count, _glSubmissionTargetStart(target));
|
||||||
if(doLighting) _readNormalData(first, count, target);
|
|
||||||
if(doTexture && doMultitexture) _readSTData(first, count, target);
|
VertexExtra* ve = aligned_vector_at(target->extras, 0);
|
||||||
|
|
||||||
|
if(doLighting) _readNormalData(first, count, ve);
|
||||||
|
if(doTexture && doMultitexture) _readSTData(first, count, ve);
|
||||||
profiler_checkpoint("others");
|
profiler_checkpoint("others");
|
||||||
|
|
||||||
it = _glSubmissionTargetStart(target);
|
it = _glSubmissionTargetStart(target);
|
||||||
|
@ -821,19 +816,24 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei
|
||||||
profiler_pop();
|
profiler_pop();
|
||||||
} else {
|
} else {
|
||||||
const IndexParseFunc indexFunc = _calcParseIndexFunc(type);
|
const IndexParseFunc indexFunc = _calcParseIndexFunc(type);
|
||||||
it = _glSubmissionTargetStart(target);
|
|
||||||
|
|
||||||
GLuint j;
|
GLuint j;
|
||||||
const GLubyte* idx = indices;
|
const GLubyte* idx = indices;
|
||||||
|
|
||||||
|
Vertex* vertices = _glSubmissionTargetStart(target);
|
||||||
|
VertexExtra* extras = aligned_vector_at(target->extras, 0);
|
||||||
|
|
||||||
ITERATE(count) {
|
ITERATE(count) {
|
||||||
j = indexFunc(idx);
|
j = indexFunc(idx);
|
||||||
_readPositionData(j, 1, it);
|
|
||||||
_readDiffuseData(j, 1, it);
|
_readPositionData(j, 1, vertices);
|
||||||
if(doTexture) _readUVData(j, 1, it);
|
_readDiffuseData(j, 1, vertices);
|
||||||
//FIXME: Need to think about how we can share this */
|
if(doTexture) _readUVData(j, 1, vertices);
|
||||||
//if(doLighting) _readNormalData(j, 1, it);
|
if(doLighting) _readNormalData(j, 1, extras);
|
||||||
//if(doTexture && doMultitexture) _readSTData(j, 1, it);
|
if(doTexture && doMultitexture) _readSTData(j, 1, extras);
|
||||||
++it;
|
|
||||||
|
++vertices;
|
||||||
|
++extras;
|
||||||
|
|
||||||
idx += istride;
|
idx += istride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ void InitGL(int Width, int Height) // We call this right after our OpenG
|
||||||
{
|
{
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
|
||||||
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
|
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
|
||||||
glDepthFunc(GL_LESS); // The Type Of Depth Test To Do
|
glDepthFunc(GL_LEQUAL); // The Type Of Depth Test To Do
|
||||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
||||||
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
|
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user