2013-07-26 00:38:58 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "WebGLContext.h"
|
2014-03-17 14:52:56 +00:00
|
|
|
|
|
|
|
#include "GLContext.h"
|
|
|
|
#include "mozilla/CheckedInt.h"
|
2013-07-26 00:38:58 +00:00
|
|
|
#include "WebGLBuffer.h"
|
|
|
|
#include "WebGLFramebuffer.h"
|
2013-08-07 00:05:51 +00:00
|
|
|
#include "WebGLProgram.h"
|
2014-03-17 14:52:56 +00:00
|
|
|
#include "WebGLRenderbuffer.h"
|
|
|
|
#include "WebGLShader.h"
|
|
|
|
#include "WebGLTexture.h"
|
|
|
|
#include "WebGLUniformInfo.h"
|
|
|
|
#include "WebGLVertexArray.h"
|
|
|
|
#include "WebGLVertexAttribData.h"
|
2013-07-26 00:38:58 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2013-08-07 00:05:51 +00:00
|
|
|
using namespace dom;
|
2013-07-26 00:38:58 +00:00
|
|
|
|
2013-08-07 00:05:51 +00:00
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttrib1f(GLuint index, GLfloat x0)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib1f(index, x0);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = x0;
|
|
|
|
mVertexAttrib0Vector[1] = 0;
|
|
|
|
mVertexAttrib0Vector[2] = 0;
|
|
|
|
mVertexAttrib0Vector[3] = 1;
|
2014-03-31 09:10:49 +00:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fVertexAttrib1f(index, x0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttrib2f(GLuint index, GLfloat x0, GLfloat x1)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib2f(index, x0, x1);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = x0;
|
|
|
|
mVertexAttrib0Vector[1] = x1;
|
|
|
|
mVertexAttrib0Vector[2] = 0;
|
|
|
|
mVertexAttrib0Vector[3] = 1;
|
2014-03-31 09:10:49 +00:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fVertexAttrib2f(index, x0, x1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttrib3f(GLuint index, GLfloat x0, GLfloat x1, GLfloat x2)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib3f(index, x0, x1, x2);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = x0;
|
|
|
|
mVertexAttrib0Vector[1] = x1;
|
|
|
|
mVertexAttrib0Vector[2] = x2;
|
|
|
|
mVertexAttrib0Vector[3] = 1;
|
2014-03-31 09:10:49 +00:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fVertexAttrib3f(index, x0, x1, x2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttrib4f(GLuint index, GLfloat x0, GLfloat x1,
|
|
|
|
GLfloat x2, GLfloat x3)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib4f(index, x0, x1, x2, x3);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = x0;
|
|
|
|
mVertexAttrib0Vector[1] = x1;
|
|
|
|
mVertexAttrib0Vector[2] = x2;
|
|
|
|
mVertexAttrib0Vector[3] = x3;
|
2014-03-31 09:10:49 +00:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fVertexAttrib4f(index, x0, x1, x2, x3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttrib1fv_base(GLuint idx, uint32_t arrayLength,
|
|
|
|
const GLfloat* ptr)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
|
|
|
if (!ValidateAttribArraySetter("VertexAttrib1fv", 1, arrayLength))
|
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
if (idx) {
|
|
|
|
gl->fVertexAttrib1fv(idx, ptr);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = ptr[0];
|
2013-09-04 12:14:43 +00:00
|
|
|
mVertexAttrib0Vector[1] = GLfloat(0);
|
|
|
|
mVertexAttrib0Vector[2] = GLfloat(0);
|
|
|
|
mVertexAttrib0Vector[3] = GLfloat(1);
|
2014-03-31 09:10:49 +00:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fVertexAttrib1fv(idx, ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttrib2fv_base(GLuint idx, uint32_t arrayLength,
|
|
|
|
const GLfloat* ptr)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
|
|
|
if (!ValidateAttribArraySetter("VertexAttrib2fv", 2, arrayLength))
|
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
if (idx) {
|
|
|
|
gl->fVertexAttrib2fv(idx, ptr);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = ptr[0];
|
|
|
|
mVertexAttrib0Vector[1] = ptr[1];
|
2013-09-04 12:14:43 +00:00
|
|
|
mVertexAttrib0Vector[2] = GLfloat(0);
|
|
|
|
mVertexAttrib0Vector[3] = GLfloat(1);
|
2014-03-31 09:10:49 +00:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fVertexAttrib2fv(idx, ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttrib3fv_base(GLuint idx, uint32_t arrayLength,
|
|
|
|
const GLfloat* ptr)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
|
|
|
if (!ValidateAttribArraySetter("VertexAttrib3fv", 3, arrayLength))
|
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
if (idx) {
|
|
|
|
gl->fVertexAttrib3fv(idx, ptr);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = ptr[0];
|
|
|
|
mVertexAttrib0Vector[1] = ptr[1];
|
|
|
|
mVertexAttrib0Vector[2] = ptr[2];
|
2013-09-04 12:14:43 +00:00
|
|
|
mVertexAttrib0Vector[3] = GLfloat(1);
|
2014-03-31 09:10:49 +00:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fVertexAttrib3fv(idx, ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttrib4fv_base(GLuint idx, uint32_t arrayLength,
|
|
|
|
const GLfloat* ptr)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
|
|
|
if (!ValidateAttribArraySetter("VertexAttrib4fv", 4, arrayLength))
|
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
if (idx) {
|
|
|
|
gl->fVertexAttrib4fv(idx, ptr);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = ptr[0];
|
|
|
|
mVertexAttrib0Vector[1] = ptr[1];
|
|
|
|
mVertexAttrib0Vector[2] = ptr[2];
|
|
|
|
mVertexAttrib0Vector[3] = ptr[3];
|
2014-03-31 09:10:49 +00:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fVertexAttrib4fv(idx, ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::EnableVertexAttribArray(GLuint index)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!ValidateAttribIndex(index, "enableVertexAttribArray"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
InvalidateBufferFetching();
|
|
|
|
|
|
|
|
gl->fEnableVertexAttribArray(index);
|
2013-10-11 13:16:44 +00:00
|
|
|
MOZ_ASSERT(mBoundVertexArray->HasAttrib(index)); // should have been validated earlier
|
|
|
|
mBoundVertexArray->mAttribs[index].enabled = true;
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::DisableVertexAttribArray(GLuint index)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!ValidateAttribIndex(index, "disableVertexAttribArray"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
InvalidateBufferFetching();
|
|
|
|
|
2014-03-31 09:10:49 +00:00
|
|
|
if (index || gl->IsGLES())
|
2013-08-07 00:05:51 +00:00
|
|
|
gl->fDisableVertexAttribArray(index);
|
|
|
|
|
2013-10-11 13:16:44 +00:00
|
|
|
MOZ_ASSERT(mBoundVertexArray->HasAttrib(index)); // should have been validated earlier
|
|
|
|
mBoundVertexArray->mAttribs[index].enabled = false;
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JS::Value
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
|
2013-08-07 00:05:51 +00:00
|
|
|
ErrorResult& rv)
|
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return JS::NullValue();
|
|
|
|
|
2013-10-11 13:16:44 +00:00
|
|
|
if (!ValidateAttribIndex(index, "getVertexAttrib"))
|
2013-08-07 00:05:51 +00:00
|
|
|
return JS::NullValue();
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
switch (pname) {
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
|
|
|
|
{
|
2013-10-11 13:16:44 +00:00
|
|
|
return WebGLObjectAsJSValue(cx, mBoundVertexArray->mAttribs[index].buf.get(), rv);
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE:
|
|
|
|
{
|
2013-10-11 13:16:44 +00:00
|
|
|
return JS::Int32Value(mBoundVertexArray->mAttribs[index].stride);
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE:
|
|
|
|
{
|
2013-10-11 13:16:44 +00:00
|
|
|
if (!mBoundVertexArray->mAttribs[index].enabled)
|
2013-08-07 00:05:51 +00:00
|
|
|
return JS::Int32Value(4);
|
2013-09-19 22:30:19 +00:00
|
|
|
|
2014-06-11 00:23:50 +00:00
|
|
|
return JS::Int32Value(mBoundVertexArray->mAttribs[index].size);
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
2014-06-11 00:23:50 +00:00
|
|
|
|
2013-08-07 00:05:51 +00:00
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_TYPE:
|
|
|
|
{
|
2014-06-11 00:23:50 +00:00
|
|
|
if (!mBoundVertexArray->mAttribs[index].enabled)
|
|
|
|
return JS::NumberValue(uint32_t(LOCAL_GL_FLOAT));
|
|
|
|
|
|
|
|
return JS::NumberValue(uint32_t(mBoundVertexArray->mAttribs[index].type));
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
|
|
|
|
{
|
2014-04-26 02:34:07 +00:00
|
|
|
if (IsExtensionEnabled(WebGLExtensionID::ANGLE_instanced_arrays))
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-10-11 13:16:44 +00:00
|
|
|
return JS::Int32Value(mBoundVertexArray->mAttribs[index].divisor);
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_CURRENT_VERTEX_ATTRIB:
|
|
|
|
{
|
2013-09-04 12:14:43 +00:00
|
|
|
GLfloat vec[4] = {0, 0, 0, 1};
|
2013-08-07 00:05:51 +00:00
|
|
|
if (index) {
|
|
|
|
gl->fGetVertexAttribfv(index, LOCAL_GL_CURRENT_VERTEX_ATTRIB, &vec[0]);
|
|
|
|
} else {
|
|
|
|
vec[0] = mVertexAttrib0Vector[0];
|
|
|
|
vec[1] = mVertexAttrib0Vector[1];
|
|
|
|
vec[2] = mVertexAttrib0Vector[2];
|
|
|
|
vec[3] = mVertexAttrib0Vector[3];
|
|
|
|
}
|
|
|
|
JSObject* obj = Float32Array::Create(cx, this, 4, vec);
|
|
|
|
if (!obj) {
|
|
|
|
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
return JS::ObjectOrNullValue(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED:
|
|
|
|
{
|
2013-10-11 13:16:44 +00:00
|
|
|
return JS::BooleanValue(mBoundVertexArray->mAttribs[index].enabled);
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
|
|
|
|
{
|
2013-10-11 13:16:44 +00:00
|
|
|
return JS::BooleanValue(mBoundVertexArray->mAttribs[index].normalized);
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ErrorInvalidEnumInfo("getVertexAttrib: parameter", pname);
|
|
|
|
|
|
|
|
return JS::NullValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
WebGLsizeiptr
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::GetVertexAttribOffset(GLuint index, GLenum pname)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!ValidateAttribIndex(index, "getVertexAttribOffset"))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (pname != LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER) {
|
|
|
|
ErrorInvalidEnum("getVertexAttribOffset: bad parameter");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-11 13:16:44 +00:00
|
|
|
return mBoundVertexArray->mAttribs[index].byteOffset;
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
|
|
|
|
WebGLboolean normalized, GLsizei stride,
|
2013-08-07 00:05:51 +00:00
|
|
|
WebGLintptr byteOffset)
|
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (mBoundArrayBuffer == nullptr)
|
|
|
|
return ErrorInvalidOperation("vertexAttribPointer: must have valid GL_ARRAY_BUFFER binding");
|
|
|
|
|
2013-09-04 12:14:43 +00:00
|
|
|
GLsizei requiredAlignment = 1;
|
2013-08-07 00:05:51 +00:00
|
|
|
switch (type) {
|
|
|
|
case LOCAL_GL_BYTE:
|
|
|
|
case LOCAL_GL_UNSIGNED_BYTE:
|
|
|
|
requiredAlignment = 1;
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_SHORT:
|
|
|
|
case LOCAL_GL_UNSIGNED_SHORT:
|
|
|
|
requiredAlignment = 2;
|
|
|
|
break;
|
|
|
|
// XXX case LOCAL_GL_FIXED:
|
|
|
|
case LOCAL_GL_FLOAT:
|
|
|
|
requiredAlignment = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return ErrorInvalidEnumInfo("vertexAttribPointer: type", type);
|
|
|
|
}
|
|
|
|
|
|
|
|
// requiredAlignment should always be a power of two.
|
2013-09-04 12:14:43 +00:00
|
|
|
GLsizei requiredAlignmentMask = requiredAlignment - 1;
|
2013-08-07 00:05:51 +00:00
|
|
|
|
2013-10-11 13:16:44 +00:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttribPointer")) {
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size < 1 || size > 4)
|
|
|
|
return ErrorInvalidValue("vertexAttribPointer: invalid element size");
|
|
|
|
|
|
|
|
if (stride < 0 || stride > 255) // see WebGL spec section 6.6 "Vertex Attribute Data Stride"
|
|
|
|
return ErrorInvalidValue("vertexAttribPointer: negative or too large stride");
|
|
|
|
|
|
|
|
if (byteOffset < 0)
|
|
|
|
return ErrorInvalidValue("vertexAttribPointer: negative offset");
|
|
|
|
|
|
|
|
if (stride & requiredAlignmentMask) {
|
|
|
|
return ErrorInvalidOperation("vertexAttribPointer: stride doesn't satisfy the alignment "
|
|
|
|
"requirement of given type");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (byteOffset & requiredAlignmentMask) {
|
|
|
|
return ErrorInvalidOperation("vertexAttribPointer: byteOffset doesn't satisfy the alignment "
|
|
|
|
"requirement of given type");
|
2013-09-19 22:30:19 +00:00
|
|
|
|
2013-08-07 00:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
InvalidateBufferFetching();
|
|
|
|
|
|
|
|
/* XXX make work with bufferSubData & heterogeneous types
|
|
|
|
if (type != mBoundArrayBuffer->GLType())
|
|
|
|
return ErrorInvalidOperation("vertexAttribPointer: type must match bound VBO type: %d != %d", type, mBoundArrayBuffer->GLType());
|
|
|
|
*/
|
|
|
|
|
2013-10-11 13:16:44 +00:00
|
|
|
WebGLVertexAttribData &vd = mBoundVertexArray->mAttribs[index];
|
2013-08-07 00:05:51 +00:00
|
|
|
|
|
|
|
vd.buf = mBoundArrayBuffer;
|
|
|
|
vd.stride = stride;
|
|
|
|
vd.size = size;
|
|
|
|
vd.byteOffset = byteOffset;
|
|
|
|
vd.type = type;
|
|
|
|
vd.normalized = normalized;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
gl->fVertexAttribPointer(index, size, type, normalized,
|
|
|
|
stride,
|
|
|
|
reinterpret_cast<void*>(byteOffset));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 12:14:43 +00:00
|
|
|
WebGLContext::VertexAttribDivisor(GLuint index, GLuint divisor)
|
2013-08-07 00:05:51 +00:00
|
|
|
{
|
2013-09-04 12:14:44 +00:00
|
|
|
if (IsContextLost())
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
|
2013-10-11 13:16:44 +00:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttribDivisor")) {
|
2013-08-07 00:05:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-11 13:16:44 +00:00
|
|
|
WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index];
|
2013-08-07 00:05:51 +00:00
|
|
|
vd.divisor = divisor;
|
|
|
|
|
|
|
|
InvalidateBufferFetching();
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
gl->fVertexAttribDivisor(index, divisor);
|
|
|
|
}
|