#include "glheader.h"
#include "api_validate.h"
#include "context.h"
#include "imports.h"
#include "mtypes.h"
#include "state.h"
GLboolean
_mesa_validate_DrawElements(GLcontext *ctx,
GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices)
{
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
_mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" );
return GL_FALSE;
}
if (mode > GL_POLYGON) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
return GL_FALSE;
}
if (type != GL_UNSIGNED_INT &&
type != GL_UNSIGNED_BYTE &&
type != GL_UNSIGNED_SHORT)
{
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
return GL_FALSE;
}
if (ctx->NewState)
_mesa_update_state( ctx );
if (ctx->Array.Vertex.Enabled
|| (ctx->VertexProgram.Enabled && ctx->Array.VertexAttrib[0].Enabled))
return GL_TRUE;
else
return GL_FALSE;
return GL_TRUE;
}
GLboolean
_mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
GLuint start, GLuint end,
GLsizei count, GLenum type,
const GLvoid *indices)
{
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
if (count <= 0) {
if (count < 0)
_mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" );
return GL_FALSE;
}
if (mode > GL_POLYGON) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
return GL_FALSE;
}
if (end < start) {
_mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(end<start)");
return GL_FALSE;
}
if (type != GL_UNSIGNED_INT &&
type != GL_UNSIGNED_BYTE &&
type != GL_UNSIGNED_SHORT) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
return GL_FALSE;
}
if (ctx->NewState)
_mesa_update_state( ctx );
if (ctx->Array.Vertex.Enabled
|| (ctx->VertexProgram.Enabled && ctx->Array.VertexAttrib[0].Enabled))
return GL_TRUE;
else
return GL_FALSE;
}
GLboolean
_mesa_validate_DrawArrays(GLcontext *ctx,
GLenum mode, GLint start, GLsizei count)
{
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
if (count<0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
return GL_FALSE;
}
if (mode > GL_POLYGON) {
_mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
return GL_FALSE;
}
if (ctx->NewState)
_mesa_update_state( ctx );
if (ctx->Array.Vertex.Enabled
|| (ctx->VertexProgram.Enabled && ctx->Array.VertexAttrib[0].Enabled))
return GL_TRUE;
else
return GL_FALSE;
}