2013-07-26 04:38:58 +04: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 18:52:56 +04:00
|
|
|
|
|
|
|
#include "GLContext.h"
|
|
|
|
#include "mozilla/CheckedInt.h"
|
2013-07-26 04:38:58 +04:00
|
|
|
#include "WebGLBuffer.h"
|
|
|
|
#include "WebGLFramebuffer.h"
|
2013-08-07 04:05:51 +04:00
|
|
|
#include "WebGLProgram.h"
|
2014-03-17 18:52:56 +04:00
|
|
|
#include "WebGLRenderbuffer.h"
|
|
|
|
#include "WebGLShader.h"
|
|
|
|
#include "WebGLTexture.h"
|
|
|
|
#include "WebGLVertexArray.h"
|
|
|
|
#include "WebGLVertexAttribData.h"
|
2013-07-26 04:38:58 +04:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
namespace mozilla {
|
2013-07-26 04:38:58 +04:00
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::VertexAttrib1f(GLuint index, GLfloat x0)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttrib1f"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib1f(index, x0);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = x0;
|
|
|
|
mVertexAttrib0Vector[1] = 0;
|
|
|
|
mVertexAttrib0Vector[2] = 0;
|
|
|
|
mVertexAttrib0Vector[3] = 1;
|
2014-03-31 13:10:49 +04:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 04:05:51 +04:00
|
|
|
gl->fVertexAttrib1f(index, x0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::VertexAttrib2f(GLuint index, GLfloat x0, GLfloat x1)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttrib2f"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib2f(index, x0, x1);
|
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = x0;
|
|
|
|
mVertexAttrib0Vector[1] = x1;
|
|
|
|
mVertexAttrib0Vector[2] = 0;
|
|
|
|
mVertexAttrib0Vector[3] = 1;
|
2014-03-31 13:10:49 +04:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 04:05:51 +04:00
|
|
|
gl->fVertexAttrib2f(index, x0, x1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::VertexAttrib3f(GLuint index, GLfloat x0, GLfloat x1, GLfloat x2)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttrib3f"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
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 13:10:49 +04:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 04:05:51 +04:00
|
|
|
gl->fVertexAttrib3f(index, x0, x1, x2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::VertexAttrib4f(GLuint index, GLfloat x0, GLfloat x1,
|
|
|
|
GLfloat x2, GLfloat x3)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttrib4f"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
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 13:10:49 +04:00
|
|
|
if (gl->IsGLES())
|
2013-08-07 04:05:51 +04:00
|
|
|
gl->fVertexAttrib4f(index, x0, x1, x2, x3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2014-10-24 02:10:57 +04:00
|
|
|
WebGLContext::VertexAttrib1fv_base(GLuint index, uint32_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLfloat* ptr)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
|
|
|
if (!ValidateAttribArraySetter("VertexAttrib1fv", 1, arrayLength))
|
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttrib1fv"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
MakeContextCurrent();
|
2014-10-24 02:10:57 +04:00
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib1fv(index, ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = ptr[0];
|
2013-09-04 16:14:43 +04:00
|
|
|
mVertexAttrib0Vector[1] = GLfloat(0);
|
|
|
|
mVertexAttrib0Vector[2] = GLfloat(0);
|
|
|
|
mVertexAttrib0Vector[3] = GLfloat(1);
|
2014-03-31 13:10:49 +04:00
|
|
|
if (gl->IsGLES())
|
2014-10-24 02:10:57 +04:00
|
|
|
gl->fVertexAttrib1fv(index, ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-10-24 02:10:57 +04:00
|
|
|
WebGLContext::VertexAttrib2fv_base(GLuint index, uint32_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLfloat* ptr)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
|
|
|
if (!ValidateAttribArraySetter("VertexAttrib2fv", 2, arrayLength))
|
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttrib2fv"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
MakeContextCurrent();
|
2014-10-24 02:10:57 +04:00
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib2fv(index, ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = ptr[0];
|
|
|
|
mVertexAttrib0Vector[1] = ptr[1];
|
2013-09-04 16:14:43 +04:00
|
|
|
mVertexAttrib0Vector[2] = GLfloat(0);
|
|
|
|
mVertexAttrib0Vector[3] = GLfloat(1);
|
2014-03-31 13:10:49 +04:00
|
|
|
if (gl->IsGLES())
|
2014-10-24 02:10:57 +04:00
|
|
|
gl->fVertexAttrib2fv(index, ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-10-24 02:10:57 +04:00
|
|
|
WebGLContext::VertexAttrib3fv_base(GLuint index, uint32_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLfloat* ptr)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
|
|
|
if (!ValidateAttribArraySetter("VertexAttrib3fv", 3, arrayLength))
|
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttrib3fv"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
MakeContextCurrent();
|
2014-10-24 02:10:57 +04:00
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib3fv(index, ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = ptr[0];
|
|
|
|
mVertexAttrib0Vector[1] = ptr[1];
|
|
|
|
mVertexAttrib0Vector[2] = ptr[2];
|
2013-09-04 16:14:43 +04:00
|
|
|
mVertexAttrib0Vector[3] = GLfloat(1);
|
2014-03-31 13:10:49 +04:00
|
|
|
if (gl->IsGLES())
|
2014-10-24 02:10:57 +04:00
|
|
|
gl->fVertexAttrib3fv(index, ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-10-24 02:10:57 +04:00
|
|
|
WebGLContext::VertexAttrib4fv_base(GLuint index, uint32_t arrayLength,
|
2013-09-04 16:14:43 +04:00
|
|
|
const GLfloat* ptr)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
|
|
|
if (!ValidateAttribArraySetter("VertexAttrib4fv", 4, arrayLength))
|
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttrib4fv"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
MakeContextCurrent();
|
2014-10-24 02:10:57 +04:00
|
|
|
if (index) {
|
|
|
|
gl->fVertexAttrib4fv(index, ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
} else {
|
|
|
|
mVertexAttrib0Vector[0] = ptr[0];
|
|
|
|
mVertexAttrib0Vector[1] = ptr[1];
|
|
|
|
mVertexAttrib0Vector[2] = ptr[2];
|
|
|
|
mVertexAttrib0Vector[3] = ptr[3];
|
2014-03-31 13:10:49 +04:00
|
|
|
if (gl->IsGLES())
|
2014-10-24 02:10:57 +04:00
|
|
|
gl->fVertexAttrib4fv(index, ptr);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::EnableVertexAttribArray(GLuint index)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "enableVertexAttribArray"))
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
InvalidateBufferFetching();
|
|
|
|
|
|
|
|
gl->fEnableVertexAttribArray(index);
|
2014-10-24 02:10:57 +04:00
|
|
|
|
|
|
|
MOZ_ASSERT(mBoundVertexArray);
|
|
|
|
mBoundVertexArray->EnsureAttrib(index);
|
2013-10-11 17:16:44 +04:00
|
|
|
mBoundVertexArray->mAttribs[index].enabled = true;
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::DisableVertexAttribArray(GLuint index)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "disableVertexAttribArray"))
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
InvalidateBufferFetching();
|
|
|
|
|
2014-03-31 13:10:49 +04:00
|
|
|
if (index || gl->IsGLES())
|
2013-08-07 04:05:51 +04:00
|
|
|
gl->fDisableVertexAttribArray(index);
|
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
MOZ_ASSERT(mBoundVertexArray);
|
|
|
|
mBoundVertexArray->EnsureAttrib(index);
|
2013-10-11 17:16:44 +04:00
|
|
|
mBoundVertexArray->mAttribs[index].enabled = false;
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
JS::Value
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
|
2013-08-07 04:05:51 +04:00
|
|
|
ErrorResult& rv)
|
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return JS::NullValue();
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "getVertexAttrib"))
|
2013-08-07 04:05:51 +04:00
|
|
|
return JS::NullValue();
|
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
MOZ_ASSERT(mBoundVertexArray);
|
|
|
|
mBoundVertexArray->EnsureAttrib(index);
|
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
switch (pname) {
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
|
|
|
|
{
|
2013-10-11 17:16:44 +04:00
|
|
|
return WebGLObjectAsJSValue(cx, mBoundVertexArray->mAttribs[index].buf.get(), rv);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE:
|
|
|
|
{
|
2013-10-11 17:16:44 +04:00
|
|
|
return JS::Int32Value(mBoundVertexArray->mAttribs[index].stride);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE:
|
|
|
|
{
|
2013-10-11 17:16:44 +04:00
|
|
|
if (!mBoundVertexArray->mAttribs[index].enabled)
|
2013-08-07 04:05:51 +04:00
|
|
|
return JS::Int32Value(4);
|
2013-09-20 02:30:19 +04:00
|
|
|
|
2014-06-11 04:23:50 +04:00
|
|
|
return JS::Int32Value(mBoundVertexArray->mAttribs[index].size);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
2014-06-11 04:23:50 +04:00
|
|
|
|
2013-08-07 04:05:51 +04:00
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_TYPE:
|
|
|
|
{
|
2014-06-11 04:23:50 +04: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 04:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
|
|
|
|
{
|
2014-04-26 06:34:07 +04:00
|
|
|
if (IsExtensionEnabled(WebGLExtensionID::ANGLE_instanced_arrays))
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-10-11 17:16:44 +04:00
|
|
|
return JS::Int32Value(mBoundVertexArray->mAttribs[index].divisor);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_CURRENT_VERTEX_ATTRIB:
|
|
|
|
{
|
2013-09-04 16:14:43 +04:00
|
|
|
GLfloat vec[4] = {0, 0, 0, 1};
|
2013-08-07 04:05:51 +04: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];
|
|
|
|
}
|
2015-07-15 03:37:28 +03:00
|
|
|
JSObject* obj = dom::Float32Array::Create(cx, this, 4, vec);
|
2013-08-07 04:05:51 +04:00
|
|
|
if (!obj) {
|
|
|
|
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
return JS::ObjectOrNullValue(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED:
|
|
|
|
{
|
2013-10-11 17:16:44 +04:00
|
|
|
return JS::BooleanValue(mBoundVertexArray->mAttribs[index].enabled);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case LOCAL_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
|
|
|
|
{
|
2013-10-11 17:16:44 +04:00
|
|
|
return JS::BooleanValue(mBoundVertexArray->mAttribs[index].normalized);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ErrorInvalidEnumInfo("getVertexAttrib: parameter", pname);
|
|
|
|
return JS::NullValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
WebGLsizeiptr
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::GetVertexAttribOffset(GLuint index, GLenum pname)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return 0;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "getVertexAttribOffset"))
|
2013-08-07 04:05:51 +04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (pname != LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER) {
|
|
|
|
ErrorInvalidEnum("getVertexAttribOffset: bad parameter");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
MOZ_ASSERT(mBoundVertexArray);
|
|
|
|
mBoundVertexArray->EnsureAttrib(index);
|
2013-10-11 17:16:44 +04:00
|
|
|
return mBoundVertexArray->mAttribs[index].byteOffset;
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
|
|
|
|
WebGLboolean normalized, GLsizei stride,
|
2013-08-07 04:05:51 +04:00
|
|
|
WebGLintptr byteOffset)
|
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttribPointer"))
|
2014-10-24 02:10:57 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribPointer(false, index, size, type, normalized, stride, byteOffset, "vertexAttribPointer"))
|
|
|
|
return;
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2014-10-24 02:10:57 +04:00
|
|
|
MOZ_ASSERT(mBoundVertexArray);
|
|
|
|
mBoundVertexArray->EnsureAttrib(index);
|
2013-08-07 04:05:51 +04: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());
|
|
|
|
*/
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index];
|
2013-08-07 04:05:51 +04:00
|
|
|
|
|
|
|
vd.buf = mBoundArrayBuffer;
|
|
|
|
vd.stride = stride;
|
|
|
|
vd.size = size;
|
|
|
|
vd.byteOffset = byteOffset;
|
|
|
|
vd.type = type;
|
|
|
|
vd.normalized = normalized;
|
2014-06-24 04:56:21 +04:00
|
|
|
vd.integer = false;
|
2013-08-07 04:05:51 +04:00
|
|
|
|
|
|
|
MakeContextCurrent();
|
2014-06-24 04:56:21 +04:00
|
|
|
gl->fVertexAttribPointer(index, size, type, normalized, stride,
|
2013-08-07 04:05:51 +04:00
|
|
|
reinterpret_cast<void*>(byteOffset));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::VertexAttribDivisor(GLuint index, GLuint divisor)
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-09-04 16:14:44 +04:00
|
|
|
if (IsContextLost())
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-24 04:56:21 +04:00
|
|
|
if (!ValidateAttribIndex(index, "vertexAttribDivisor"))
|
2013-08-07 04:05:51 +04:00
|
|
|
return;
|
2014-10-24 02:10:57 +04:00
|
|
|
|
|
|
|
MOZ_ASSERT(mBoundVertexArray);
|
|
|
|
mBoundVertexArray->EnsureAttrib(index);
|
2013-08-07 04:05:51 +04:00
|
|
|
|
2013-10-11 17:16:44 +04:00
|
|
|
WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index];
|
2013-08-07 04:05:51 +04:00
|
|
|
vd.divisor = divisor;
|
|
|
|
|
|
|
|
InvalidateBufferFetching();
|
|
|
|
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
gl->fVertexAttribDivisor(index, divisor);
|
|
|
|
}
|
2015-07-15 03:37:28 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|