void gl_getvertexattribpointerv( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { glGetVertexAttribPointerv((GLuint)mxGetScalar(prhs[0]), (GLenum)mxGetScalar(prhs[1]), (GLvoid **)mxGetData(prhs[2])); }
long WebGraphicsContext3DDefaultImpl::getVertexAttribOffset(unsigned long index, unsigned long pname) { makeContextCurrent(); void* pointer; glGetVertexAttribPointerv(index, pname, &pointer); return reinterpret_cast<long>(pointer); }
GC3Dsizeiptr GraphicsContext3D::getVertexAttribOffset(GC3Duint index, GC3Denum paramName) { makeContextCurrent(); GLvoid* pointer = 0; glGetVertexAttribPointerv(index, paramName, &pointer); return static_cast<GC3Dsizeiptr>(reinterpret_cast<intptr_t>(pointer)); }
static PyObject* py_glGetVertexAttribPointer(PyObject *, PyObject *args) { CHECK_ARG_COUNT(args, 2); Uint prg(PyTuple_GetItem(args, 0)); Enum param(PyTuple_GetItem(args, 1)); GLvoid *ptr = 0; glGetVertexAttribPointerv(prg, param, &ptr); return PyCObject_FromVoidPtr(ptr, NULL); }
static int GetVertexAttribPointer(lua_State *L) { GLuint index = luaL_checkinteger(L, 1); void *pointer; glGetVertexAttribPointerv(index, pname, &pointer); CheckError(L); lua_pushinteger(L, (GLsizeiptr)pointer); return 1; }
static void dumpVertexAttributes(StateWriter &writer, Context &context, GLint program) { if (program <= 0) { return; } GLint activeAttribs = 0; glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &activeAttribs); if (!activeAttribs) { return; } GLint max_name_length = 0; glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length); std::vector<GLchar> name(max_name_length); std::map<GLuint, BufferMapping> mappings; std::vector<VertexAttrib> attribs; unsigned count = ~0U; for (GLint index = 0; index < activeAttribs; ++index) { GLsizei length = 0; GLint shaderSize = 0; GLenum shaderType = GL_NONE; glGetActiveAttrib(program, index, max_name_length, &length, &shaderSize, &shaderType, &name[0]); if (isBuiltinName(&name[0])) { // TODO: Handle built-ins too std::cerr << "warning: dumping of built-in vertex attribute (" << &name[0] << ") not yet supported\n"; continue; } GLint location = glGetAttribLocation(program, &name[0]); if (location < 0) { continue; } GLint buffer = 0; glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &buffer); if (!buffer) { continue; } GLint size = 0; glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_SIZE, &size); GLint type = 0; glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_TYPE, &type); GLint normalized = 0; glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &normalized); GLint stride = 0; glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &stride); GLvoid * pointer = 0; glGetVertexAttribPointerv(location, GL_VERTEX_ATTRIB_ARRAY_POINTER, &pointer); GLint offset = reinterpret_cast<intptr_t>(pointer); assert(offset >= 0); GLint divisor = 0; glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, &divisor); if (divisor) { // TODO: not clear the best way of presenting instanced attibutes on the dump std::cerr << "warning: dumping of instanced attributes (" << &name[0] << ") not yet supported\n"; return; } if (size == GL_BGRA) { std::cerr << "warning: dumping of GL_BGRA attributes (" << &name[0] << ") not yet supported\n"; size = 4; } AttribDesc desc(type, size); if (!desc) { std::cerr << "warning: dumping of packed attribute (" << &name[0] << ") not yet supported\n"; // TODO: handle continue; } attribs.emplace_back(); VertexAttrib &attrib = attribs.back(); attrib.name = &name[0]; // TODO handle normalized attributes if (normalized) { std::cerr << "warning: dumping of normalized attribute (" << &name[0] << ") not yet supported\n"; } attrib.desc = desc; GLsizei attribSize = attrib.desc.arrayStride; if (stride == 0) { // tightly packed stride = attribSize; } attrib.offset = offset; attrib.stride = stride; BufferMapping &mapping = mappings[buffer]; attrib.map = (const GLbyte *)mapping.map(GL_ARRAY_BUFFER, buffer); BufferBinding bb(GL_ARRAY_BUFFER, buffer); GLint bufferSize = 0; glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &bufferSize); if (bufferSize <= offset || bufferSize <= offset + attribSize) { return; } else { unsigned attribCount = (bufferSize - offset - attribSize)/stride + 1; count = std::min(count, attribCount); } } if (count == 0 || count == ~0U || attribs.empty()) { return; } writer.beginMember("vertices"); writer.beginArray(); for (unsigned vertex = 0; vertex < count; ++vertex) { writer.beginObject(); for (auto attrib : attribs) { const AttribDesc & desc = attrib.desc; assert(desc); const GLbyte *vertex_data = attrib.map + attrib.stride*vertex + attrib.offset; dumpAttribArray(writer, attrib.name, desc, vertex_data); } writer.endObject(); } writer.endArray(); writer.endMember(); }
void get_vertex_attrib_pointerv(gl::uint_t index, vertex_attrib_pointer_property_arb_t pname, void ** pointer) { glGetVertexAttribPointerv(index, static_cast<GLenum>(pname), pointer); }
enum piglit_result piglit_display(void) { GLvoid *datap; GLint intv[] = { 1, 1, 1, 1 }; GLfloat floatv[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat quad[] = { -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0 }; GLsizei length; GLint size; GLenum type; GLchar buffer[64]; GLuint program, vShader, fShader; int maxAttribCount; /* --- valid program needed for some of the functions --- */ fShader = glCreateShader(GL_FRAGMENT_SHADER); vShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(fShader, 1, &fShaderString, NULL); glShaderSource(vShader, 1, &vShaderString, NULL); glCompileShader(vShader); glCompileShader(fShader); program = glCreateProgram(); glAttachShader(program, vShader); glAttachShader(program, fShader); glLinkProgram(program); glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribCount); /* --- tests begin here --- */ glVertexAttrib1f(maxAttribCount, floatv[0]); CHECK_GL_INVALID_VALUE; glVertexAttrib2f(maxAttribCount, floatv[0], floatv[1]); CHECK_GL_INVALID_VALUE; glVertexAttrib3f(maxAttribCount, floatv[0], floatv[1], floatv[2]); CHECK_GL_INVALID_VALUE; glVertexAttrib4f(maxAttribCount, floatv[0], floatv[1], floatv[2], floatv[3]); CHECK_GL_INVALID_VALUE; glVertexAttrib1fv(maxAttribCount, floatv); CHECK_GL_INVALID_VALUE; glVertexAttrib2fv(maxAttribCount, floatv); CHECK_GL_INVALID_VALUE; glVertexAttrib3fv(maxAttribCount, floatv); CHECK_GL_INVALID_VALUE; glVertexAttrib4fv(maxAttribCount, floatv); CHECK_GL_INVALID_VALUE; glVertexAttribPointer(maxAttribCount, 2, GL_FLOAT, GL_FALSE, 0, quad); CHECK_GL_INVALID_VALUE; glBindAttribLocation(program, maxAttribCount, "pos"); CHECK_GL_INVALID_VALUE; glEnableVertexAttribArray(maxAttribCount); CHECK_GL_INVALID_VALUE; glDisableVertexAttribArray(maxAttribCount); CHECK_GL_INVALID_VALUE; glGetVertexAttribfv(maxAttribCount, GL_CURRENT_VERTEX_ATTRIB, floatv); CHECK_GL_INVALID_VALUE; glGetVertexAttribiv(maxAttribCount, GL_CURRENT_VERTEX_ATTRIB, intv); CHECK_GL_INVALID_VALUE; glGetVertexAttribPointerv(maxAttribCount, GL_VERTEX_ATTRIB_ARRAY_POINTER, &datap); CHECK_GL_INVALID_VALUE; glGetActiveAttrib(program, maxAttribCount, 64, &length, &size, &type, buffer); CHECK_GL_INVALID_VALUE; return PIGLIT_PASS; }
bool validate(GLuint const & ProgramName) { bool Error = false; // Pipeline object validation { GLint Status(0); GLint LengthMax(0); glValidateProgramPipeline(PipelineName); glGetProgramPipelineiv(PipelineName, GL_VALIDATE_STATUS, &Status); glGetProgramPipelineiv(PipelineName, GL_INFO_LOG_LENGTH, &LengthMax); GLsizei LengthQuery(0); std::vector<GLchar> InfoLog(LengthMax + 1, '\0'); glGetProgramPipelineInfoLog(PipelineName, GLsizei(InfoLog.size()), &LengthQuery, &InfoLog[0]); glDebugMessageInsertARB( GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 76, GL_DEBUG_SEVERITY_LOW_ARB, LengthQuery, &InfoLog[0]); } GLint ActiveAttributeMaxLength(0); GLint ActiveAttribute(0); glGetProgramiv(ProgramName, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &ActiveAttributeMaxLength); glGetProgramiv(ProgramName, GL_ACTIVE_ATTRIBUTES, &ActiveAttribute); GLsizei AttribLength(0); GLint AttribSize(0); GLenum AttribType(0); std::vector<GLchar> AttribName(ActiveAttributeMaxLength, '\0'); for(GLint i = 0; i < ActiveAttribute; ++i) { glGetActiveAttrib(ProgramName, GLuint(i), GLsizei(ActiveAttributeMaxLength), &AttribLength, &AttribSize, &AttribType, &AttribName[0]); std::string NameString; NameString.insert(NameString.begin(), AttribName.begin(), AttribName.end()); std::vector<GLchar> NameSwap(ActiveAttributeMaxLength, '\0'); std::swap(AttribName, NameSwap); GLint AttribLocation = glGetAttribLocation(ProgramName, NameString.c_str()); vertexattrib VertexAttrib; glGetVertexAttribiv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &VertexAttrib.Enabled); //glGetVertexAttribiv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &VertexAttrib.Binding); glGetVertexAttribiv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_SIZE, &VertexAttrib.Size); glGetVertexAttribiv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &VertexAttrib.Stride); glGetVertexAttribiv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_TYPE, &VertexAttrib.Type); glGetVertexAttribiv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &VertexAttrib.Normalized); glGetVertexAttribiv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_INTEGER, &VertexAttrib.Integer); glGetVertexAttribiv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, &VertexAttrib.Divisor); glGetVertexAttribPointerv(AttribLocation, GL_VERTEX_ATTRIB_ARRAY_POINTER, &VertexAttrib.Pointer); if(GL_VERTEX_ATTRIB_ARRAY_INTEGER == GL_TRUE) { if(!( VertexAttrib.Type == GL_INT || VertexAttrib.Type == GL_INT_VEC2 || VertexAttrib.Type == GL_INT_VEC3 || VertexAttrib.Type == GL_INT_VEC4 || VertexAttrib.Type == GL_UNSIGNED_INT || VertexAttrib.Type == GL_UNSIGNED_INT_VEC2 || VertexAttrib.Type == GL_UNSIGNED_INT_VEC3 || VertexAttrib.Type == GL_UNSIGNED_INT_VEC4)) return true; if(!( VertexAttrib.Type == GL_BYTE || VertexAttrib.Type == GL_UNSIGNED_BYTE || VertexAttrib.Type == GL_SHORT || VertexAttrib.Type == GL_UNSIGNED_SHORT || VertexAttrib.Type == GL_INT || VertexAttrib.Type == GL_UNSIGNED_INT)) return true; //if(AttribSize > 1) //GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, and GL_DOUBLE } else if(VertexAttrib.Long == GL_TRUE) // OpenGL Spec bug { if( VertexAttrib.Type == GL_DOUBLE || VertexAttrib.Type == GL_DOUBLE_VEC2 || VertexAttrib.Type == GL_DOUBLE_VEC3 || VertexAttrib.Type == GL_DOUBLE_VEC4 || VertexAttrib.Type == GL_DOUBLE_MAT2 || VertexAttrib.Type == GL_DOUBLE_MAT3 || VertexAttrib.Type == GL_DOUBLE_MAT4 || VertexAttrib.Type == GL_DOUBLE_MAT2x3 || VertexAttrib.Type == GL_DOUBLE_MAT2x4 || VertexAttrib.Type == GL_DOUBLE_MAT3x2 || VertexAttrib.Type == GL_DOUBLE_MAT3x4 || VertexAttrib.Type == GL_DOUBLE_MAT4x2 || VertexAttrib.Type == GL_DOUBLE_MAT4x3) { if(VertexAttrib.Type != GL_DOUBLE) return true; } else// if((VertexAttrib.Normalized == GL_TRUE) || (GL_VERTEX_ATTRIB_ARRAY_FLOAT == GL_TRUE)) { if(!( VertexAttrib.Type == GL_FLOAT || VertexAttrib.Type == GL_FLOAT_VEC2 || VertexAttrib.Type == GL_FLOAT_VEC3 || VertexAttrib.Type == GL_FLOAT_VEC4 || VertexAttrib.Type == GL_FLOAT_MAT2 || VertexAttrib.Type == GL_FLOAT_MAT3 || VertexAttrib.Type == GL_FLOAT_MAT4 || VertexAttrib.Type == GL_FLOAT_MAT2x3 || VertexAttrib.Type == GL_FLOAT_MAT2x4 || VertexAttrib.Type == GL_FLOAT_MAT3x2 || VertexAttrib.Type == GL_FLOAT_MAT3x4 || VertexAttrib.Type == GL_FLOAT_MAT4x2 || VertexAttrib.Type == GL_FLOAT_MAT4x3)) return true; // It could be any vertex array attribute type } } printf("glGetActiveAttrib(\n\t%d, \n\t%d, \n\t%d, \n\t%d, \n\t%d, \n\t%s)\n", i, AttribLocation, AttribLength, AttribSize, AttribType, NameString.c_str()); } return Error; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL20_nglGetVertexAttribPointerv2(JNIEnv *env, jclass clazz, jint index, jint pname, jlong pointer, jlong function_pointer) { GLvoid *pointer_address = (GLvoid *)(intptr_t)pointer; glGetVertexAttribPointervPROC glGetVertexAttribPointerv = (glGetVertexAttribPointervPROC)((intptr_t)function_pointer); glGetVertexAttribPointerv(index, pname, pointer_address); }
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_GL20_nglGetVertexAttribPointerv(JNIEnv *env, jclass clazz, jint index, jint pname, jlong result_size, jlong function_pointer) { glGetVertexAttribPointervPROC glGetVertexAttribPointerv = (glGetVertexAttribPointervPROC)((intptr_t)function_pointer); GLvoid * __result; glGetVertexAttribPointerv(index, pname, &__result); return safeNewBuffer(env, __result, result_size); }