Handle<Value> GLESglGetVertexAttribCallback(const Arguments& args) { if (args.Length() != 2) return v8::Undefined(); //get arguments unsigned index = args[0]->Uint32Value(); unsigned pname = args[1]->Uint32Value(); switch(pname) { //1 int value case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: case GL_VERTEX_ATTRIB_ARRAY_SIZE: case GL_VERTEX_ATTRIB_ARRAY_STRIDE: case GL_VERTEX_ATTRIB_ARRAY_TYPE: { GLint ans = 0; glGetVertexAttribiv((GLuint)index, (GLenum)pname, &ans); return Integer::New(ans); } //1 boolean value case GL_VERTEX_ATTRIB_ARRAY_ENABLED: case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: { GLint ans = 0; glGetVertexAttribiv((GLuint)index, (GLenum)pname, &ans); return Boolean::New(ans != GL_FALSE); } //4 float values case GL_CURRENT_VERTEX_ATTRIB: //(?) { GLfloat* ans = new GLfloat[4]; glGetVertexAttribfv((GLuint)index, (GLenum)pname, ans); Local<Array> res = Array::New(4); for (int i = 0; i < 4; ++i) { res->Set(Integer::New(i), Integer::New(ans[i])); } delete[] ans; return res; } } return v8::Undefined(); }
static int GetEnum(lua_State *L, GLuint index, GLenum pname) { GLint param; glGetVertexAttribiv(index, pname, ¶m); CheckError(L); return pushtype(L, param); }
static PyObject* py_glGetVertexAttrib(PyObject *, PyObject *args) { CHECK_ARG_COUNT(args, 2); PyObject *rv = 0; Uint attrib(PyTuple_GetItem(args, 0)); Enum pname(PyTuple_GetItem(args, 1)); switch (pname) { case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: case GL_VERTEX_ATTRIB_ARRAY_ENABLED: case GL_VERTEX_ATTRIB_ARRAY_SIZE: case GL_VERTEX_ATTRIB_ARRAY_STRIDE: case GL_VERTEX_ATTRIB_ARRAY_TYPE: case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: { GLint value; glGetVertexAttribiv(attrib, pname, &value); rv = PyInt_FromLong(value); break; } case GL_CURRENT_VERTEX_ATTRIB: { Array1D<Float> values(4); glGetVertexAttribfv(attrib, pname, values); rv = values.toPy(); break; } default: PyErr_SetString(PyExc_RuntimeError, "gl.GetVertexAttrib: invalid parameter name"); } return rv; }
void StateSystem::VertexEnableState::getGL() { enabled = 0; for (GLuint i = 0; i < MAX_VERTEXATTRIBS; i++){ GLint status; glGetVertexAttribiv(i,GL_VERTEX_ATTRIB_ARRAY_ENABLED, (GLint*)&status); setBitState(enabled,i, (GLboolean) status); } }
void QSGRenderer::renderScene(const QSGBindable &bindable) { if (!m_root_node) return; m_is_rendering = true; #ifdef QSG_RENDERER_TIMING frameTimer.start(); #endif m_bindable = &bindable; preprocess(); bindable.bind(); #ifdef QSG_RENDERER_TIMING int bindTime = frameTimer.elapsed(); #endif #ifndef QT_NO_DEBUG // Sanity check that attribute registers are disabled { GLint count; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &count); GLint enabled; for (int i=0; i<count; ++i) { glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled); if (enabled) { qWarning("QSGRenderer: attribute %d is enabled, this can lead to memory corruption and crashes.", i); } } } #endif render(); #ifdef QSG_RENDERER_TIMING int renderTime = frameTimer.elapsed(); #endif glDisable(GL_SCISSOR_TEST); m_is_rendering = false; m_changed_emitted = false; m_bindable = 0; #ifdef QSG_RENDERER_TIMING printf(" - Breakdown of frametime: preprocess=%d, updates=%d, binding=%d, render=%d, total=%d\n", preprocessTime, updatePassTime - preprocessTime, bindTime - updatePassTime, renderTime - bindTime, renderTime); #endif }
static int GetInt_(lua_State *L, GLuint index, GLenum pname, int boolean) #define GetInt(L, index, pname) GetInt_((L), (index), (pname), 0) #define GetBoolean(L, index, pname) GetInt_((L), (index), (pname), 1) { GLint param; glGetVertexAttribiv(index, pname, ¶m); CheckError(L); if(boolean) lua_pushboolean(L, param); else lua_pushinteger(L, param); return 1; }
void say_buffer_unbind() { say_context_ensure(); if (say_has_vao()) say_vao_make_current(0); else { /* disable vertex attribs */ for (size_t i = 1; i < GL_MAX_VERTEX_ATTRIBS; i++) { GLint enabled; glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled); if (enabled) glDisableVertexAttribArray(i); else break; } } }
// バッファ破棄 void Figure::destroy() { if (!vaoName) return; #ifdef USE_VAO GLuint index; GLuint bufName; //Bind the VAO so we can get data from it glBindVertexArrayOES(vaoName); // For every possible attribute set in the VAO for(index = 0; index < 16; index++) { // Get the VBO set for that attibute glGetVertexAttribiv(index , GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, (GLint*)&bufName); // If there was a VBO set... if(bufName) { //...delete the VBO glDeleteBuffers(1, &bufName); } } // Get any element array VBO set in the VAO glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint*)&bufName); // If there was a element array VBO set in the VAO if(bufName) { //...delete the VBO glDeleteBuffers(1, &bufName); } // Finally, delete the VAO glDeleteVertexArraysOES(1, &vaoName); #else for (int i = 0; i < NUM_VBO; i++) { glDeleteBuffers(1, &vboNames[i]); vboNames[i] = 0; } #endif // 初期化 vaoName = 0; }
PIGLIT_GL_TEST_CONFIG_END void piglit_init(int argc, char **argv) { static const GLubyte ubytes[4] = { 255, 0, 0, 127 }; bool pass = true; GLint size; piglit_require_gl_version(20); piglit_require_extension("GL_ARB_vertex_array_bgra"); glColorPointer(GL_BGRA, GL_UNSIGNED_BYTE, sizeof ubytes, ubytes); size = 0; glGetIntegerv(GL_COLOR_ARRAY_SIZE, &size); if (size != GL_BGRA) { fprintf(stderr, "glGetIntegerv(GL_COLOR_ARRAY_SIZE) returned %i, GL_BGRA expected\n", size); pass = false; } glSecondaryColorPointer(GL_BGRA, GL_UNSIGNED_BYTE, sizeof ubytes, ubytes); size = 0; glGetIntegerv(GL_SECONDARY_COLOR_ARRAY_SIZE, &size); if (size != GL_BGRA) { fprintf(stderr, "glGetIntegerv(GL_SECONDARY_COLOR_ARRAY_SIZE) returned %i, GL_BGRA expected\n", size); pass = false; } glVertexAttribPointer(1, GL_BGRA, GL_UNSIGNED_BYTE, GL_TRUE, sizeof ubytes, ubytes); size = 0; glGetVertexAttribiv(1, GL_VERTEX_ATTRIB_ARRAY_SIZE, &size); if (size != GL_BGRA) { fprintf(stderr, "glGetVertexAttribiv(GL_VERTEX_ATTRIB_ARRAY_SIZE) returned %i, GL_BGRA expected\n", size); pass = false; } piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void StateSystem::VertexFormatState::getGL() { for (GLuint i = 0; i < MAX_VERTEXATTRIBS; i++){ GLint status = 0; glGetVertexAttribiv(i,GL_VERTEX_ATTRIB_RELATIVE_OFFSET, (GLint*)&formats[i].relativeoffset); glGetVertexAttribiv(i,GL_VERTEX_ATTRIB_ARRAY_SIZE, (GLint*)&formats[i].size); glGetVertexAttribiv(i,GL_VERTEX_ATTRIB_ARRAY_TYPE, (GLint*)&formats[i].type); glGetVertexAttribiv(i,GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, (GLint*)&status); formats[i].normalized = (GLboolean) status; glGetVertexAttribiv(i,GL_VERTEX_ATTRIB_ARRAY_INTEGER, (GLint*)&status); if (status){ formats[i].mode = VERTEXMODE_INT; } else{ formats[i].mode = VERTEXMODE_FLOAT; } glGetVertexAttribiv(i,GL_VERTEX_ATTRIB_BINDING, (GLint*)&formats[i].binding); } for (GLuint i = 0; i < MAX_VERTEXBINDINGS; i++){ glGetIntegeri_v(GL_VERTEX_BINDING_DIVISOR,i,(GLint*)&bindings[i].divisor); glGetIntegeri_v(GL_VERTEX_BINDING_STRIDE, i,(GLint*)&bindings[i].stride); } }
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; }
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_attribiv(gl::uint_t index, vertex_attrib_property_arb_t pname, gl::int_t * params) { glGetVertexAttribiv(index, static_cast<GLenum>(pname), params); }
void GraphicsContext3D::getVertexAttribiv(GC3Duint index, GC3Denum paramName, GC3Dint* value) { makeContextCurrent(); glGetVertexAttribiv(index, paramName, value); }
static void say_buffer_setup_pointer(say_buffer *buf) { say_vbo_make_current(buf->vbo); say_vertex_type *type = say_get_vertex_type(buf->vtype); size_t count = say_vertex_type_get_elem_count(type); if (count == 0) /* No attrbutes to set */ return; size_t stride = say_vertex_type_get_size(type); size_t offset = 0; size_t instance_stride = say_vertex_type_get_instance_size(type); size_t instance_offset = 0; /* * This fixes a bug on OSX (with OpenGL 2.1). Nothing is drawn unless vertex * attribute 0 is enabled. * * We set its data to the same as those used by the first element to ensure * memory we do not own isn't accessed. */ say_vertex_elem_type t = say_vertex_type_get_type(type, 0); if (say_vertex_type_is_per_instance(type, 0)) { say_vbo_make_current(buf->instance_vbo); say_buffer_register_pointer(0, t, instance_stride, instance_offset); } else { say_vbo_make_current(buf->vbo); say_buffer_register_pointer(0, t, stride, offset); } glEnableVertexAttribArray(0); size_t i = 0; for (; i < count; i++) { t = say_vertex_type_get_type(type, i); if (say_vertex_type_is_per_instance(type, i)) { say_vbo_make_current(buf->instance_vbo); instance_offset = say_buffer_register_pointer(i + 1, t, instance_stride, instance_offset); } else { say_vbo_make_current(buf->vbo); offset = say_buffer_register_pointer(i + 1, t, stride, offset); } glEnableVertexAttribArray(i + 1); if (glVertexAttribDivisor) { if (say_vertex_type_is_per_instance(type, i)) glVertexAttribDivisor(i + 1, 1); else glVertexAttribDivisor(i + 1, 0); } } /* * Say will always use all the attribs. Disable all of them until * finding one that is already disabled. */ for (; i < GL_MAX_VERTEX_ATTRIBS - 1; i++) { GLint enabled; glGetVertexAttribiv(i + 1, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled); if (enabled) glDisableVertexAttribArray(i + 1); else break; } }
/*! * \qmlmethod string GLStateDumpExt::getGLStateDump(stateDumpEnums options) * \return OpenGL driver state with given options as a human readable string that can be printed. * Optional paremeter \a options may contain bitfields masked together from following options: * \list * \li \c{GLStateDumpExt.DUMP_BASIC_ONLY} Includes only very basic OpenGL state information. * \li \c{GLStateDumpExt.DUMP_VERTEX_ATTRIB_ARRAYS_BIT} Includes all vertex attribute array * information. * \li \c{GLStateDumpExt.DUMP_VERTEX_ATTRIB_ARRAYS_BUFFERS_BIT} Includes size and type * from all currently active vertex attribute arrays (including the currently bound element array) * to verify that there are actual values in the array. * \li \c{GLStateDumpExt.DUMP_FULL} Includes everything. * \endlist */ QString CanvasGLStateDump::getGLStateDump(CanvasGLStateDump::stateDumpEnums options) { #if !defined(QT_OPENGL_ES_2) GLint drawFramebuffer; GLint readFramebuffer; GLboolean polygonOffsetLineEnabled; GLboolean polygonOffsetPointEnabled; GLint boundVertexArray; #endif QString stateDumpStr; GLint renderbuffer; GLfloat clearColor[4]; GLfloat clearDepth; GLboolean isBlendingEnabled = glIsEnabled(GL_BLEND); GLboolean isDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST); GLint depthFunc; GLboolean isDepthWriteEnabled; GLint currentProgram; GLint *vertexAttribArrayEnabledStates = new GLint[m_maxVertexAttribs]; GLint *vertexAttribArrayBoundBuffers = new GLint[m_maxVertexAttribs]; GLint *vertexAttribArraySizes = new GLint[m_maxVertexAttribs]; GLint *vertexAttribArrayTypes = new GLint[m_maxVertexAttribs]; GLint *vertexAttribArrayNormalized = new GLint[m_maxVertexAttribs]; GLint *vertexAttribArrayStrides = new GLint[m_maxVertexAttribs]; GLint activeTexture; GLint texBinding2D; GLint arrayBufferBinding; GLint frontFace; GLboolean isCullFaceEnabled = glIsEnabled(GL_CULL_FACE); GLint cullFaceMode; GLint blendEquationRGB; GLint blendEquationAlpha; GLint blendDestAlpha; GLint blendDestRGB; GLint blendSrcAlpha; GLint blendSrcRGB; GLint scissorBox[4]; GLboolean isScissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); GLint boundElementArrayBuffer; GLboolean polygonOffsetFillEnabled; GLfloat polygonOffsetFactor; GLfloat polygonOffsetUnits; #if !defined(QT_OPENGL_ES_2) if (!m_isOpenGLES2) { glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFramebuffer); glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFramebuffer); glGetBooleanv(GL_POLYGON_OFFSET_LINE, &polygonOffsetLineEnabled); glGetBooleanv(GL_POLYGON_OFFSET_POINT, &polygonOffsetPointEnabled); glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &boundVertexArray); } #endif glGetBooleanv(GL_DEPTH_WRITEMASK, &isDepthWriteEnabled); glGetIntegerv(GL_RENDERBUFFER_BINDING, &renderbuffer); glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth); glGetIntegerv(GL_DEPTH_FUNC, &depthFunc); glGetBooleanv(GL_POLYGON_OFFSET_FILL, &polygonOffsetFillEnabled); glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &polygonOffsetFactor); glGetFloatv(GL_POLYGON_OFFSET_UNITS, &polygonOffsetUnits); glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture); glGetIntegerv(GL_TEXTURE_BINDING_2D, &texBinding2D ); glGetIntegerv(GL_FRONT_FACE, &frontFace); glGetIntegerv(GL_CULL_FACE_MODE, &cullFaceMode); glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); glGetIntegerv(GL_SCISSOR_BOX, scissorBox); glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &boundElementArrayBuffer); glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &arrayBufferBinding); #if !defined(QT_OPENGL_ES_2) if (!m_isOpenGLES2) { stateDumpStr.append("GL_DRAW_FRAMEBUFFER_BINDING....."); stateDumpStr.append(QString::number(drawFramebuffer)); stateDumpStr.append("\n"); stateDumpStr.append("GL_READ_FRAMEBUFFER_BINDING....."); stateDumpStr.append(QString::number(readFramebuffer)); stateDumpStr.append("\n"); } #endif stateDumpStr.append("GL_RENDERBUFFER_BINDING........."); stateDumpStr.append(QString::number(renderbuffer)); stateDumpStr.append("\n"); stateDumpStr.append("GL_SCISSOR_TEST................."); stateDumpStr.append(BOOL_TO_STR(isScissorTestEnabled)); stateDumpStr.append("\n"); stateDumpStr.append("GL_SCISSOR_BOX.................."); stateDumpStr.append(QString::number(scissorBox[0])); stateDumpStr.append(", "); stateDumpStr.append(QString::number(scissorBox[1])); stateDumpStr.append(", "); stateDumpStr.append(QString::number(scissorBox[2])); stateDumpStr.append(", "); stateDumpStr.append(QString::number(scissorBox[3])); stateDumpStr.append("\n"); stateDumpStr.append("GL_COLOR_CLEAR_VALUE............"); stateDumpStr.append("r:"); stateDumpStr.append(QString::number(clearColor[0])); stateDumpStr.append(" g:"); stateDumpStr.append(QString::number(clearColor[1])); stateDumpStr.append(" b:"); stateDumpStr.append(QString::number(clearColor[2])); stateDumpStr.append(" a:"); stateDumpStr.append(QString::number(clearColor[3])); stateDumpStr.append("\n"); stateDumpStr.append("GL_DEPTH_CLEAR_VALUE............"); stateDumpStr.append(QString::number(clearDepth)); stateDumpStr.append("\n"); stateDumpStr.append("GL_BLEND........................"); stateDumpStr.append(BOOL_TO_STR(isBlendingEnabled)); stateDumpStr.append("\n"); stateDumpStr.append("GL_BLEND_EQUATION_RGB..........."); stateDumpStr.append(m_map->lookUp(blendEquationRGB)); stateDumpStr.append("\n"); stateDumpStr.append("GL_BLEND_EQUATION_ALPHA........."); stateDumpStr.append(m_map->lookUp(blendEquationAlpha)); stateDumpStr.append("\n"); stateDumpStr.append("GL_DEPTH_TEST..................."); stateDumpStr.append(BOOL_TO_STR(isDepthTestEnabled)); stateDumpStr.append("\n"); stateDumpStr.append("GL_DEPTH_FUNC..................."); stateDumpStr.append(m_map->lookUp(depthFunc)); stateDumpStr.append("\n"); stateDumpStr.append("GL_DEPTH_WRITEMASK.............."); stateDumpStr.append(BOOL_TO_STR(isDepthWriteEnabled)); stateDumpStr.append("\n"); stateDumpStr.append("GL_POLYGON_OFFSET_FILL.........."); stateDumpStr.append(BOOL_TO_STR(polygonOffsetFillEnabled)); stateDumpStr.append("\n"); #if !defined(QT_OPENGL_ES_2) if (!m_isOpenGLES2) { stateDumpStr.append("GL_POLYGON_OFFSET_LINE.........."); stateDumpStr.append(BOOL_TO_STR(polygonOffsetLineEnabled)); stateDumpStr.append("\n"); stateDumpStr.append("GL_POLYGON_OFFSET_POINT........."); stateDumpStr.append(BOOL_TO_STR(polygonOffsetPointEnabled)); stateDumpStr.append("\n"); } #endif stateDumpStr.append("GL_POLYGON_OFFSET_FACTOR........"); stateDumpStr.append(QString::number(polygonOffsetFactor)); stateDumpStr.append("\n"); stateDumpStr.append("GL_POLYGON_OFFSET_UNITS........."); stateDumpStr.append(QString::number(polygonOffsetUnits)); stateDumpStr.append("\n"); stateDumpStr.append("GL_CULL_FACE...................."); stateDumpStr.append(BOOL_TO_STR(isCullFaceEnabled)); stateDumpStr.append("\n"); stateDumpStr.append("GL_CULL_FACE_MODE..............."); stateDumpStr.append(m_map->lookUp(cullFaceMode)); stateDumpStr.append("\n"); stateDumpStr.append("GL_FRONT_FACE..................."); stateDumpStr.append(m_map->lookUp(frontFace)); stateDumpStr.append("\n"); stateDumpStr.append("GL_CURRENT_PROGRAM.............."); stateDumpStr.append(QString::number(currentProgram)); stateDumpStr.append("\n"); stateDumpStr.append("GL_ACTIVE_TEXTURE..............."); stateDumpStr.append(m_map->lookUp(activeTexture)); stateDumpStr.append("\n"); stateDumpStr.append("GL_TEXTURE_BINDING_2D..........."); stateDumpStr.append(QString::number(texBinding2D)); stateDumpStr.append("\n"); stateDumpStr.append("GL_ELEMENT_ARRAY_BUFFER_BINDING."); stateDumpStr.append(QString::number(boundElementArrayBuffer)); stateDumpStr.append("\n"); stateDumpStr.append("GL_ARRAY_BUFFER_BINDING........."); stateDumpStr.append(QString::number(arrayBufferBinding)); stateDumpStr.append("\n"); #if !defined(QT_OPENGL_ES_2) if (!m_isOpenGLES2) { stateDumpStr.append("GL_VERTEX_ARRAY_BINDING........."); stateDumpStr.append(QString::number(boundVertexArray)); stateDumpStr.append("\n"); } #endif if (options && DUMP_VERTEX_ATTRIB_ARRAYS_BIT) { for (int i = 0; i < m_maxVertexAttribs; i++) { glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &vertexAttribArrayEnabledStates[i]); glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &vertexAttribArrayBoundBuffers[i]); glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_SIZE, &vertexAttribArraySizes[i]); glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_TYPE, &vertexAttribArrayTypes[i]); glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &vertexAttribArrayNormalized[i]); glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &vertexAttribArrayStrides[i]); } for (int i = 0; i < m_maxVertexAttribs; i++) { stateDumpStr.append("GL_VERTEX_ATTRIB_ARRAY_"); stateDumpStr.append(QString::number(i)); stateDumpStr.append("\n"); stateDumpStr.append("GL_VERTEX_ATTRIB_ARRAY_ENABLED........."); stateDumpStr.append(BOOL_TO_STR(vertexAttribArrayEnabledStates[i])); stateDumpStr.append("\n"); stateDumpStr.append("GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING.."); stateDumpStr.append(QString::number(vertexAttribArrayBoundBuffers[i])); stateDumpStr.append("\n"); stateDumpStr.append("GL_VERTEX_ATTRIB_ARRAY_SIZE............"); stateDumpStr.append(QString::number(vertexAttribArraySizes[i])); stateDumpStr.append("\n"); stateDumpStr.append("GL_VERTEX_ATTRIB_ARRAY_TYPE............"); stateDumpStr.append(m_map->lookUp(vertexAttribArrayTypes[i])); stateDumpStr.append("\n"); stateDumpStr.append("GL_VERTEX_ATTRIB_ARRAY_NORMALIZED......"); stateDumpStr.append(QString::number(vertexAttribArrayNormalized[i])); stateDumpStr.append("\n"); stateDumpStr.append("GL_VERTEX_ATTRIB_ARRAY_STRIDE.........."); stateDumpStr.append(QString::number(vertexAttribArrayStrides[i])); stateDumpStr.append("\n"); } } if (options && DUMP_VERTEX_ATTRIB_ARRAYS_BUFFERS_BIT) { if (boundElementArrayBuffer != 0) { stateDumpStr.append("GL_ELEMENT_ARRAY_BUFFER................"); stateDumpStr.append(QString::number(boundElementArrayBuffer)); stateDumpStr.append("\n"); stateDumpStr.append(getGLArrayObjectDump(GL_ELEMENT_ARRAY_BUFFER, boundElementArrayBuffer, GL_UNSIGNED_SHORT)); } for (int i = 0; i < m_maxVertexAttribs; i++) { if (vertexAttribArrayEnabledStates[i]) { stateDumpStr.append("GL_ARRAY_BUFFER........................"); stateDumpStr.append(QString::number(vertexAttribArrayBoundBuffers[i])); stateDumpStr.append("\n"); stateDumpStr.append(getGLArrayObjectDump(GL_ARRAY_BUFFER, vertexAttribArrayBoundBuffers[i], vertexAttribArrayTypes[i])); } } } delete[] vertexAttribArrayEnabledStates; delete[] vertexAttribArrayBoundBuffers; delete[] vertexAttribArraySizes; delete[] vertexAttribArrayTypes; delete[] vertexAttribArrayNormalized; delete[] vertexAttribArrayStrides; return stateDumpStr; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL20_nglGetVertexAttribiv(JNIEnv *env, jclass clazz, jint index, jint pname, jlong params, jlong function_pointer) { GLint *params_address = (GLint *)(intptr_t)params; glGetVertexAttribivPROC glGetVertexAttribiv = (glGetVertexAttribivPROC)((intptr_t)function_pointer); glGetVertexAttribiv(index, pname, params_address); }
uintptr_t processFn(struct fnargs* args, char* parg) { uintptr_t ret = 0; switch (args->fn) { case glfnUNDEFINED: abort(); // bad glfn break; case glfnActiveTexture: glActiveTexture((GLenum)args->a0); break; case glfnAttachShader: glAttachShader((GLint)args->a0, (GLint)args->a1); break; case glfnBindAttribLocation: glBindAttribLocation((GLint)args->a0, (GLint)args->a1, (GLchar*)args->a2); break; case glfnBindBuffer: glBindBuffer((GLenum)args->a0, (GLuint)args->a1); break; case glfnBindFramebuffer: glBindFramebuffer((GLenum)args->a0, (GLint)args->a1); break; case glfnBindRenderbuffer: glBindRenderbuffer((GLenum)args->a0, (GLint)args->a1); break; case glfnBindTexture: glBindTexture((GLenum)args->a0, (GLint)args->a1); break; case glfnBlendColor: glBlendColor(*(GLfloat*)&args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2, *(GLfloat*)&args->a3); break; case glfnBlendEquation: glBlendEquation((GLenum)args->a0); break; case glfnBlendEquationSeparate: glBlendEquationSeparate((GLenum)args->a0, (GLenum)args->a1); break; case glfnBlendFunc: glBlendFunc((GLenum)args->a0, (GLenum)args->a1); break; case glfnBlendFuncSeparate: glBlendFuncSeparate((GLenum)args->a0, (GLenum)args->a1, (GLenum)args->a2, (GLenum)args->a3); break; case glfnBufferData: glBufferData((GLenum)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg, (GLenum)args->a2); break; case glfnBufferSubData: glBufferSubData((GLenum)args->a0, (GLint)args->a1, (GLsizeiptr)args->a2, (GLvoid*)parg); break; case glfnCheckFramebufferStatus: ret = glCheckFramebufferStatus((GLenum)args->a0); break; case glfnClear: glClear((GLenum)args->a0); break; case glfnClearColor: glClearColor(*(GLfloat*)&args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2, *(GLfloat*)&args->a3); break; case glfnClearDepthf: glClearDepthf(*(GLfloat*)&args->a0); break; case glfnClearStencil: glClearStencil((GLint)args->a0); break; case glfnColorMask: glColorMask((GLboolean)args->a0, (GLboolean)args->a1, (GLboolean)args->a2, (GLboolean)args->a3); break; case glfnCompileShader: glCompileShader((GLint)args->a0); break; case glfnCompressedTexImage2D: glCompressedTexImage2D((GLenum)args->a0, (GLint)args->a1, (GLenum)args->a2, (GLint)args->a3, (GLint)args->a4, (GLint)args->a5, (GLsizeiptr)args->a6, (GLvoid*)parg); break; case glfnCompressedTexSubImage2D: glCompressedTexSubImage2D((GLenum)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3, (GLint)args->a4, (GLint)args->a5, (GLenum)args->a6, (GLsizeiptr)args->a7, (GLvoid*)parg); break; case glfnCopyTexImage2D: glCopyTexImage2D((GLenum)args->a0, (GLint)args->a1, (GLenum)args->a2, (GLint)args->a3, (GLint)args->a4, (GLint)args->a5, (GLint)args->a6, (GLint)args->a7); break; case glfnCopyTexSubImage2D: glCopyTexSubImage2D((GLenum)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3, (GLint)args->a4, (GLint)args->a5, (GLint)args->a6, (GLint)args->a7); break; case glfnCreateProgram: ret = glCreateProgram(); break; case glfnCreateShader: ret = glCreateShader((GLenum)args->a0); break; case glfnCullFace: glCullFace((GLenum)args->a0); break; case glfnDeleteBuffer: glDeleteBuffers(1, (const GLuint*)(&args->a0)); break; case glfnDeleteFramebuffer: glDeleteFramebuffers(1, (const GLuint*)(&args->a0)); break; case glfnDeleteProgram: glDeleteProgram((GLint)args->a0); break; case glfnDeleteRenderbuffer: glDeleteRenderbuffers(1, (const GLuint*)(&args->a0)); break; case glfnDeleteShader: glDeleteShader((GLint)args->a0); break; case glfnDeleteTexture: glDeleteTextures(1, (const GLuint*)(&args->a0)); break; case glfnDepthFunc: glDepthFunc((GLenum)args->a0); break; case glfnDepthMask: glDepthMask((GLboolean)args->a0); break; case glfnDepthRangef: glDepthRangef(*(GLfloat*)&args->a0, *(GLfloat*)&args->a1); break; case glfnDetachShader: glDetachShader((GLint)args->a0, (GLint)args->a1); break; case glfnDisable: glDisable((GLenum)args->a0); break; case glfnDisableVertexAttribArray: glDisableVertexAttribArray((GLint)args->a0); break; case glfnDrawArrays: glDrawArrays((GLenum)args->a0, (GLint)args->a1, (GLint)args->a2); break; case glfnDrawElements: glDrawElements((GLenum)args->a0, (GLint)args->a1, (GLenum)args->a2, (void*)args->a3); break; case glfnEnable: glEnable((GLenum)args->a0); break; case glfnEnableVertexAttribArray: glEnableVertexAttribArray((GLint)args->a0); break; case glfnFinish: glFinish(); break; case glfnFlush: glFlush(); break; case glfnFramebufferRenderbuffer: glFramebufferRenderbuffer((GLenum)args->a0, (GLenum)args->a1, (GLenum)args->a2, (GLint)args->a3); break; case glfnFramebufferTexture2D: glFramebufferTexture2D((GLenum)args->a0, (GLenum)args->a1, (GLenum)args->a2, (GLint)args->a3, (GLint)args->a4); break; case glfnFrontFace: glFrontFace((GLenum)args->a0); break; case glfnGenBuffer: glGenBuffers(1, (GLuint*)&ret); break; case glfnGenFramebuffer: glGenFramebuffers(1, (GLuint*)&ret); break; case glfnGenRenderbuffer: glGenRenderbuffers(1, (GLuint*)&ret); break; case glfnGenTexture: glGenTextures(1, (GLuint*)&ret); break; case glfnGenerateMipmap: glGenerateMipmap((GLenum)args->a0); break; case glfnGetActiveAttrib: glGetActiveAttrib( (GLuint)args->a0, (GLuint)args->a1, (GLsizei)args->a2, NULL, (GLint*)&ret, (GLenum*)args->a3, (GLchar*)parg); break; case glfnGetActiveUniform: glGetActiveUniform( (GLuint)args->a0, (GLuint)args->a1, (GLsizei)args->a2, NULL, (GLint*)&ret, (GLenum*)args->a3, (GLchar*)parg); break; case glfnGetAttachedShaders: glGetAttachedShaders((GLuint)args->a0, (GLsizei)args->a1, (GLsizei*)&ret, (GLuint*)parg); break; case glfnGetAttribLocation: ret = glGetAttribLocation((GLint)args->a0, (GLchar*)args->a1); break; case glfnGetBooleanv: glGetBooleanv((GLenum)args->a0, (GLboolean*)parg); break; case glfnGetBufferParameteri: glGetBufferParameteriv((GLenum)args->a0, (GLenum)args->a1, (GLint*)&ret); break; case glfnGetFloatv: glGetFloatv((GLenum)args->a0, (GLfloat*)parg); break; case glfnGetIntegerv: glGetIntegerv((GLenum)args->a0, (GLint*)parg); break; case glfnGetError: ret = glGetError(); break; case glfnGetFramebufferAttachmentParameteriv: glGetFramebufferAttachmentParameteriv((GLenum)args->a0, (GLenum)args->a1, (GLenum)args->a2, (GLint*)&ret); break; case glfnGetProgramiv: glGetProgramiv((GLint)args->a0, (GLenum)args->a1, (GLint*)&ret); break; case glfnGetProgramInfoLog: glGetProgramInfoLog((GLuint)args->a0, (GLsizei)args->a1, 0, (GLchar*)parg); break; case glfnGetRenderbufferParameteriv: glGetRenderbufferParameteriv((GLenum)args->a0, (GLenum)args->a1, (GLint*)&ret); break; case glfnGetShaderiv: glGetShaderiv((GLint)args->a0, (GLenum)args->a1, (GLint*)&ret); break; case glfnGetShaderInfoLog: glGetShaderInfoLog((GLuint)args->a0, (GLsizei)args->a1, 0, (GLchar*)parg); break; case glfnGetShaderPrecisionFormat: glGetShaderPrecisionFormat((GLenum)args->a0, (GLenum)args->a1, (GLint*)parg, &((GLint*)parg)[2]); break; case glfnGetShaderSource: glGetShaderSource((GLuint)args->a0, (GLsizei)args->a1, 0, (GLchar*)parg); break; case glfnGetString: ret = (uintptr_t)glGetString((GLenum)args->a0); break; case glfnGetTexParameterfv: glGetTexParameterfv((GLenum)args->a0, (GLenum)args->a1, (GLfloat*)parg); break; case glfnGetTexParameteriv: glGetTexParameteriv((GLenum)args->a0, (GLenum)args->a1, (GLint*)parg); break; case glfnGetUniformfv: glGetUniformfv((GLuint)args->a0, (GLint)args->a1, (GLfloat*)parg); break; case glfnGetUniformiv: glGetUniformiv((GLuint)args->a0, (GLint)args->a1, (GLint*)parg); break; case glfnGetUniformLocation: ret = glGetUniformLocation((GLint)args->a0, (GLchar*)args->a1); break; case glfnGetVertexAttribfv: glGetVertexAttribfv((GLuint)args->a0, (GLenum)args->a1, (GLfloat*)parg); break; case glfnGetVertexAttribiv: glGetVertexAttribiv((GLuint)args->a0, (GLenum)args->a1, (GLint*)parg); break; case glfnHint: glHint((GLenum)args->a0, (GLenum)args->a1); break; case glfnIsBuffer: ret = glIsBuffer((GLint)args->a0); break; case glfnIsEnabled: ret = glIsEnabled((GLenum)args->a0); break; case glfnIsFramebuffer: ret = glIsFramebuffer((GLint)args->a0); break; case glfnIsProgram: ret = glIsProgram((GLint)args->a0); break; case glfnIsRenderbuffer: ret = glIsRenderbuffer((GLint)args->a0); break; case glfnIsShader: ret = glIsShader((GLint)args->a0); break; case glfnIsTexture: ret = glIsTexture((GLint)args->a0); break; case glfnLineWidth: glLineWidth(*(GLfloat*)&args->a0); break; case glfnLinkProgram: glLinkProgram((GLint)args->a0); break; case glfnPixelStorei: glPixelStorei((GLenum)args->a0, (GLint)args->a1); break; case glfnPolygonOffset: glPolygonOffset(*(GLfloat*)&args->a0, *(GLfloat*)&args->a1); break; case glfnReadPixels: glReadPixels((GLint)args->a0, (GLint)args->a1, (GLsizei)args->a2, (GLsizei)args->a3, (GLenum)args->a4, (GLenum)args->a5, (void*)parg); break; case glfnReleaseShaderCompiler: glReleaseShaderCompiler(); break; case glfnRenderbufferStorage: glRenderbufferStorage((GLenum)args->a0, (GLenum)args->a1, (GLint)args->a2, (GLint)args->a3); break; case glfnSampleCoverage: glSampleCoverage(*(GLfloat*)&args->a0, (GLboolean)args->a1); break; case glfnScissor: glScissor((GLint)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3); break; case glfnShaderSource: #if defined(os_ios) || defined(os_osx) glShaderSource((GLuint)args->a0, (GLsizei)args->a1, (const GLchar *const *)args->a2, NULL); #else glShaderSource((GLuint)args->a0, (GLsizei)args->a1, (const GLchar **)args->a2, NULL); #endif break; case glfnStencilFunc: glStencilFunc((GLenum)args->a0, (GLint)args->a1, (GLuint)args->a2); break; case glfnStencilFuncSeparate: glStencilFuncSeparate((GLenum)args->a0, (GLenum)args->a1, (GLint)args->a2, (GLuint)args->a3); break; case glfnStencilMask: glStencilMask((GLuint)args->a0); break; case glfnStencilMaskSeparate: glStencilMaskSeparate((GLenum)args->a0, (GLuint)args->a1); break; case glfnStencilOp: glStencilOp((GLenum)args->a0, (GLenum)args->a1, (GLenum)args->a2); break; case glfnStencilOpSeparate: glStencilOpSeparate((GLenum)args->a0, (GLenum)args->a1, (GLenum)args->a2, (GLenum)args->a3); break; case glfnTexImage2D: glTexImage2D( (GLenum)args->a0, (GLint)args->a1, (GLint)args->a2, (GLsizei)args->a3, (GLsizei)args->a4, 0, // border (GLenum)args->a5, (GLenum)args->a6, (const GLvoid*)parg); break; case glfnTexSubImage2D: glTexSubImage2D( (GLenum)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3, (GLsizei)args->a4, (GLsizei)args->a5, (GLenum)args->a6, (GLenum)args->a7, (const GLvoid*)parg); break; case glfnTexParameterf: glTexParameterf((GLenum)args->a0, (GLenum)args->a1, *(GLfloat*)&args->a2); break; case glfnTexParameterfv: glTexParameterfv((GLenum)args->a0, (GLenum)args->a1, (GLfloat*)parg); break; case glfnTexParameteri: glTexParameteri((GLenum)args->a0, (GLenum)args->a1, (GLint)args->a2); break; case glfnTexParameteriv: glTexParameteriv((GLenum)args->a0, (GLenum)args->a1, (GLint*)parg); break; case glfnUniform1f: glUniform1f((GLint)args->a0, *(GLfloat*)&args->a1); break; case glfnUniform1fv: glUniform1fv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg); break; case glfnUniform1i: glUniform1i((GLint)args->a0, (GLint)args->a1); break; case glfnUniform1iv: glUniform1iv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg); break; case glfnUniform2f: glUniform2f((GLint)args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2); break; case glfnUniform2fv: glUniform2fv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg); break; case glfnUniform2i: glUniform2i((GLint)args->a0, (GLint)args->a1, (GLint)args->a2); break; case glfnUniform2iv: glUniform2iv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg); break; case glfnUniform3f: glUniform3f((GLint)args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2, *(GLfloat*)&args->a3); break; case glfnUniform3fv: glUniform3fv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg); break; case glfnUniform3i: glUniform3i((GLint)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3); break; case glfnUniform3iv: glUniform3iv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg); break; case glfnUniform4f: glUniform4f((GLint)args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2, *(GLfloat*)&args->a3, *(GLfloat*)&args->a4); break; case glfnUniform4fv: glUniform4fv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg); break; case glfnUniform4i: glUniform4i((GLint)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3, (GLint)args->a4); break; case glfnUniform4iv: glUniform4iv((GLint)args->a0, (GLsizeiptr)args->a1, (GLvoid*)parg); break; case glfnUniformMatrix2fv: glUniformMatrix2fv((GLint)args->a0, (GLsizeiptr)args->a1, 0, (GLvoid*)parg); break; case glfnUniformMatrix3fv: glUniformMatrix3fv((GLint)args->a0, (GLsizeiptr)args->a1, 0, (GLvoid*)parg); break; case glfnUniformMatrix4fv: glUniformMatrix4fv((GLint)args->a0, (GLsizeiptr)args->a1, 0, (GLvoid*)parg); break; case glfnUseProgram: glUseProgram((GLint)args->a0); break; case glfnValidateProgram: glValidateProgram((GLint)args->a0); break; case glfnVertexAttrib1f: glVertexAttrib1f((GLint)args->a0, *(GLfloat*)&args->a1); break; case glfnVertexAttrib1fv: glVertexAttrib1fv((GLint)args->a0, (GLfloat*)parg); break; case glfnVertexAttrib2f: glVertexAttrib2f((GLint)args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2); break; case glfnVertexAttrib2fv: glVertexAttrib2fv((GLint)args->a0, (GLfloat*)parg); break; case glfnVertexAttrib3f: glVertexAttrib3f((GLint)args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2, *(GLfloat*)&args->a3); break; case glfnVertexAttrib3fv: glVertexAttrib3fv((GLint)args->a0, (GLfloat*)parg); break; case glfnVertexAttrib4f: glVertexAttrib4f((GLint)args->a0, *(GLfloat*)&args->a1, *(GLfloat*)&args->a2, *(GLfloat*)&args->a3, *(GLfloat*)&args->a4); break; case glfnVertexAttrib4fv: glVertexAttrib4fv((GLint)args->a0, (GLfloat*)parg); break; case glfnVertexAttribPointer: glVertexAttribPointer((GLuint)args->a0, (GLint)args->a1, (GLenum)args->a2, (GLboolean)args->a3, (GLsizei)args->a4, (const GLvoid*)args->a5); break; case glfnViewport: glViewport((GLint)args->a0, (GLint)args->a1, (GLint)args->a2, (GLint)args->a3); break; } return ret; }
void QSGRenderer::renderScene(const QSGBindable &bindable) { if (!m_root_node) return; m_is_rendering = true; #ifndef QSG_NO_RENDER_TIMING bool profileFrames = qsg_render_timing || QQmlProfilerService::enabled; if (profileFrames) frameTimer.start(); qint64 bindTime = 0; qint64 renderTime = 0; #endif m_bindable = &bindable; preprocess(); bindable.bind(); #ifndef QSG_NO_RENDER_TIMING if (profileFrames) bindTime = frameTimer.nsecsElapsed(); #endif #ifndef QT_NO_DEBUG // Sanity check that attribute registers are disabled { GLint count = 0; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &count); GLint enabled; for (int i=0; i<count; ++i) { glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled); if (enabled) { qWarning("QSGRenderer: attribute %d is enabled, this can lead to memory corruption and crashes.", i); } } } #endif render(); #ifndef QSG_NO_RENDER_TIMING if (profileFrames) renderTime = frameTimer.nsecsElapsed(); #endif glDisable(GL_SCISSOR_TEST); m_is_rendering = false; m_changed_emitted = false; m_bindable = 0; if (m_vertex_buffer_bound) { glBindBuffer(GL_ARRAY_BUFFER, 0); m_vertex_buffer_bound = false; } if (m_index_buffer_bound) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); m_index_buffer_bound = false; } #ifndef QSG_NO_RENDER_TIMING if (qsg_render_timing) { printf(" - Breakdown of render time: preprocess=%d, updates=%d, binding=%d, render=%d, total=%d\n", int(preprocessTime / 1000000), int((updatePassTime - preprocessTime) / 1000000), int((bindTime - updatePassTime) / 1000000), int((renderTime - bindTime) / 1000000), int(renderTime / 1000000)); } if (QQmlProfilerService::enabled) { QQmlProfilerService::sceneGraphFrame( QQmlProfilerService::SceneGraphRendererFrame, preprocessTime, updatePassTime - preprocessTime, bindTime - updatePassTime, renderTime - bindTime); } #endif }
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; }
static void gub_copy_texture_egl(GUBGraphicContextEGL *gcontext, GstVideoInfo *video_info, GstBuffer *buffer, void *native_texture_ptr) { if (!gcontext) return; if (native_texture_ptr) { GLint previous_vp[4]; GLint previous_prog; GLint previous_fbo; GLint previous_tex; GLint previous_ab; GLint previous_rbo; GLint previous_vaenabled[2]; GLenum status; GLuint unity_tex = (GLuint)(size_t)(native_texture_ptr); GstVideoFrame video_frame; GLuint gst_tex; gst_video_frame_map(&video_frame, video_info, buffer, GST_MAP_READ | GST_MAP_GL); gst_tex = *(guint *)GST_VIDEO_FRAME_PLANE_DATA(&video_frame, 0); glGetIntegerv(GL_VIEWPORT, previous_vp); glGetIntegerv(GL_CURRENT_PROGRAM, &previous_prog); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previous_fbo); glGetIntegerv(GL_TEXTURE_BINDING_2D, &previous_tex); glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previous_ab); glGetIntegerv(GL_RENDERBUFFER_BINDING, &previous_rbo); glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &previous_vaenabled[0]); glGetVertexAttribiv(1, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &previous_vaenabled[1]); glBindFramebuffer(GL_FRAMEBUFFER, gcontext->fbo); glViewport( -video_info->width * gcontext->crop_left, -video_info->height * gcontext->crop_top, video_info->width, video_info->height); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, unity_tex, 0); status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { gub_log("Frame buffer not complete, status 0x%x, unity_tex %d", status, unity_tex); } glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glPolygonOffset(0.0f, 0.0f); glDisable(GL_POLYGON_OFFSET_FILL); glUseProgram(gcontext->po); if (gcontext->gl->gl_vtable->BindVertexArray) gcontext->gl->gl_vtable->BindVertexArray(gcontext->vao); glBindBuffer(GL_ARRAY_BUFFER, gcontext->vbo); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (const GLvoid *)(0)); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (const GLvoid *)(2 * sizeof(GLfloat))); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, gst_tex); glUniform1i(gcontext->samplerLoc, 0); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindFramebuffer(GL_FRAMEBUFFER, previous_fbo); glViewport(previous_vp[0], previous_vp[1], previous_vp[2], previous_vp[3]); if (gcontext->gl->gl_vtable->BindVertexArray) gcontext->gl->gl_vtable->BindVertexArray(0); glUseProgram(previous_prog); glBindBuffer(GL_ARRAY_BUFFER, previous_ab); glBindRenderbuffer(GL_RENDERBUFFER, previous_rbo); if (!previous_vaenabled[0]) glDisableVertexAttribArray(0); if (!previous_vaenabled[1]) glDisableVertexAttribArray(1); glBindTexture(GL_TEXTURE_2D, previous_tex); gst_video_frame_unmap(&video_frame); } }