Added support for GL_INT and GL_UNSIGNED_INT vertex attributes.

TRAC #22693 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2119 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 8de4e6af
...@@ -2537,7 +2537,7 @@ bool Context::skipDraw(GLenum drawMode) ...@@ -2537,7 +2537,7 @@ bool Context::skipDraw(GLenum drawMode)
return false; return false;
} }
void Context::setVertexAttrib(GLuint index, const GLfloat *values) void Context::setVertexAttribf(GLuint index, const GLfloat values[4])
{ {
ASSERT(index < gl::MAX_VERTEX_ATTRIBS); ASSERT(index < gl::MAX_VERTEX_ATTRIBS);
...@@ -2546,6 +2546,31 @@ void Context::setVertexAttrib(GLuint index, const GLfloat *values) ...@@ -2546,6 +2546,31 @@ void Context::setVertexAttrib(GLuint index, const GLfloat *values)
mState.vertexAttribute[index].mCurrentValue.FloatValues[2] = values[2]; mState.vertexAttribute[index].mCurrentValue.FloatValues[2] = values[2];
mState.vertexAttribute[index].mCurrentValue.FloatValues[3] = values[3]; mState.vertexAttribute[index].mCurrentValue.FloatValues[3] = values[3];
mState.vertexAttribute[index].mCurrentValue.Type = GL_FLOAT; mState.vertexAttribute[index].mCurrentValue.Type = GL_FLOAT;
mState.vertexAttribute[index].mPureInteger = false;
}
void Context::setVertexAttribu(GLuint index, const GLuint values[4])
{
ASSERT(index < gl::MAX_VERTEX_ATTRIBS);
mState.vertexAttribute[index].mCurrentValue.UnsignedIntValues[0] = values[0];
mState.vertexAttribute[index].mCurrentValue.UnsignedIntValues[1] = values[1];
mState.vertexAttribute[index].mCurrentValue.UnsignedIntValues[2] = values[2];
mState.vertexAttribute[index].mCurrentValue.UnsignedIntValues[3] = values[3];
mState.vertexAttribute[index].mCurrentValue.Type = GL_UNSIGNED_INT;
mState.vertexAttribute[index].mPureInteger = true;
}
void Context::setVertexAttribi(GLuint index, const GLint values[4])
{
ASSERT(index < gl::MAX_VERTEX_ATTRIBS);
mState.vertexAttribute[index].mCurrentValue.IntValues[0] = values[0];
mState.vertexAttribute[index].mCurrentValue.IntValues[1] = values[1];
mState.vertexAttribute[index].mCurrentValue.IntValues[2] = values[2];
mState.vertexAttribute[index].mCurrentValue.IntValues[3] = values[3];
mState.vertexAttribute[index].mCurrentValue.Type = GL_INT;
mState.vertexAttribute[index].mPureInteger = true;
} }
void Context::setVertexAttribDivisor(GLuint index, GLuint divisor) void Context::setVertexAttribDivisor(GLuint index, GLuint divisor)
......
...@@ -89,14 +89,16 @@ class VertexAttribute ...@@ -89,14 +89,16 @@ class VertexAttribute
{ {
switch (mType) switch (mType)
{ {
case GL_BYTE: return mSize * sizeof(GLbyte); case GL_BYTE: return mSize * sizeof(GLbyte);
case GL_UNSIGNED_BYTE: return mSize * sizeof(GLubyte); case GL_UNSIGNED_BYTE: return mSize * sizeof(GLubyte);
case GL_SHORT: return mSize * sizeof(GLshort); case GL_SHORT: return mSize * sizeof(GLshort);
case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort); case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort);
case GL_FIXED: return mSize * sizeof(GLfixed); case GL_INT: return mSize * sizeof(GLint);
case GL_HALF_FLOAT: return mSize * sizeof(GLhalf); case GL_UNSIGNED_INT: return mSize * sizeof(GLuint);
case GL_FLOAT: return mSize * sizeof(GLfloat); case GL_FIXED: return mSize * sizeof(GLfixed);
default: UNREACHABLE(); return mSize * sizeof(GLfloat); case GL_HALF_FLOAT: return mSize * sizeof(GLhalf);
case GL_FLOAT: return mSize * sizeof(GLfloat);
default: UNREACHABLE(); return mSize * sizeof(GLfloat);
} }
} }
...@@ -340,7 +342,9 @@ class Context ...@@ -340,7 +342,9 @@ class Context
void setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples); void setRenderbufferStorage(GLsizei width, GLsizei height, GLenum internalformat, GLsizei samples);
void setVertexAttrib(GLuint index, const GLfloat *values); void setVertexAttribf(GLuint index, const GLfloat values[4]);
void setVertexAttribu(GLuint index, const GLuint values[4]);
void setVertexAttribi(GLuint index, const GLint values[4]);
void setVertexAttribDivisor(GLuint index, GLuint divisor); void setVertexAttribDivisor(GLuint index, GLuint divisor);
Buffer *getBuffer(GLuint handle); Buffer *getBuffer(GLuint handle);
......
...@@ -6561,7 +6561,7 @@ void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) ...@@ -6561,7 +6561,7 @@ void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
if (context) if (context)
{ {
GLfloat vals[4] = { x, 0, 0, 1 }; GLfloat vals[4] = { x, 0, 0, 1 };
context->setVertexAttrib(index, vals); context->setVertexAttribf(index, vals);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6586,7 +6586,7 @@ void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) ...@@ -6586,7 +6586,7 @@ void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
if (context) if (context)
{ {
GLfloat vals[4] = { values[0], 0, 0, 1 }; GLfloat vals[4] = { values[0], 0, 0, 1 };
context->setVertexAttrib(index, vals); context->setVertexAttribf(index, vals);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6611,7 +6611,7 @@ void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) ...@@ -6611,7 +6611,7 @@ void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
if (context) if (context)
{ {
GLfloat vals[4] = { x, y, 0, 1 }; GLfloat vals[4] = { x, y, 0, 1 };
context->setVertexAttrib(index, vals); context->setVertexAttribf(index, vals);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6636,7 +6636,7 @@ void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) ...@@ -6636,7 +6636,7 @@ void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
if (context) if (context)
{ {
GLfloat vals[4] = { values[0], values[1], 0, 1 }; GLfloat vals[4] = { values[0], values[1], 0, 1 };
context->setVertexAttrib(index, vals); context->setVertexAttribf(index, vals);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6661,7 +6661,7 @@ void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) ...@@ -6661,7 +6661,7 @@ void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
if (context) if (context)
{ {
GLfloat vals[4] = { x, y, z, 1 }; GLfloat vals[4] = { x, y, z, 1 };
context->setVertexAttrib(index, vals); context->setVertexAttribf(index, vals);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6686,7 +6686,7 @@ void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) ...@@ -6686,7 +6686,7 @@ void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
if (context) if (context)
{ {
GLfloat vals[4] = { values[0], values[1], values[2], 1 }; GLfloat vals[4] = { values[0], values[1], values[2], 1 };
context->setVertexAttrib(index, vals); context->setVertexAttribf(index, vals);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6711,7 +6711,7 @@ void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, G ...@@ -6711,7 +6711,7 @@ void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, G
if (context) if (context)
{ {
GLfloat vals[4] = { x, y, z, w }; GLfloat vals[4] = { x, y, z, w };
context->setVertexAttrib(index, vals); context->setVertexAttribf(index, vals);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6735,7 +6735,7 @@ void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) ...@@ -6735,7 +6735,7 @@ void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
if (context) if (context)
{ {
context->setVertexAttrib(index, values); context->setVertexAttribf(index, values);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -6797,8 +6797,9 @@ void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo ...@@ -6797,8 +6797,9 @@ void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo
case GL_FIXED: case GL_FIXED:
case GL_FLOAT: case GL_FLOAT:
break; break;
case GL_HALF_FLOAT: case GL_HALF_FLOAT:
case GL_INT:
case GL_UNSIGNED_INT:
if (context && context->getClientVersion() < 3) if (context && context->getClientVersion() < 3)
{ {
return gl::error(GL_INVALID_ENUM); return gl::error(GL_INVALID_ENUM);
...@@ -6807,7 +6808,6 @@ void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo ...@@ -6807,7 +6808,6 @@ void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo
{ {
break; break;
} }
default: default:
return gl::error(GL_INVALID_ENUM); return gl::error(GL_INVALID_ENUM);
} }
...@@ -7931,7 +7931,39 @@ void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs ...@@ -7931,7 +7931,39 @@ void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs
} }
} }
UNIMPLEMENTED(); if (index >= gl::MAX_VERTEX_ATTRIBS)
{
return gl::error(GL_INVALID_VALUE);
}
if (size < 1 || size > 4)
{
return gl::error(GL_INVALID_VALUE);
}
switch (type)
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
break;
default:
return gl::error(GL_INVALID_ENUM);
}
if (stride < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (context)
{
context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true,
stride, pointer);
}
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
{ {
...@@ -8004,9 +8036,15 @@ void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint ...@@ -8004,9 +8036,15 @@ void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
}
UNIMPLEMENTED(); if (index >= gl::MAX_VERTEX_ATTRIBS)
{
return gl::error(GL_INVALID_VALUE);
}
GLint vals[4] = { x, y, z, w };
context->setVertexAttribi(index, vals);
}
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
{ {
...@@ -8029,9 +8067,15 @@ void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GL ...@@ -8029,9 +8067,15 @@ void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GL
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
}
UNIMPLEMENTED(); if (index >= gl::MAX_VERTEX_ATTRIBS)
{
return gl::error(GL_INVALID_VALUE);
}
GLuint vals[4] = { x, y, z, w };
context->setVertexAttribu(index, vals);
}
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
{ {
...@@ -8053,9 +8097,14 @@ void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) ...@@ -8053,9 +8097,14 @@ void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
}
UNIMPLEMENTED(); if (index >= gl::MAX_VERTEX_ATTRIBS)
{
return gl::error(GL_INVALID_VALUE);
}
context->setVertexAttribi(index, v);
}
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
{ {
...@@ -8077,9 +8126,14 @@ void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) ...@@ -8077,9 +8126,14 @@ void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
}
UNIMPLEMENTED(); if (index >= gl::MAX_VERTEX_ATTRIBS)
{
return gl::error(GL_INVALID_VALUE);
}
context->setVertexAttribu(index, v);
}
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment