/* This calls the appropriate vertex pointer based on the given capability. */ static void _setVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLenum capability) { switch(capability) { case GL_VERTEX_ARRAY: glVertexPointer(size, type, stride, pointer); break; case GL_NORMAL_ARRAY: glNormalPointer(type, stride, pointer); break; case GL_COLOR_ARRAY: glColorPointer(size, type, stride, pointer); break; case GL_INDEX_ARRAY: glIndexPointer(type, stride, pointer); break; case GL_TEXTURE_COORD_ARRAY: glTexCoordPointer(size, type, stride, pointer); break; case GL_EDGE_FLAG_ARRAY: glEdgeFlagPointer(stride, pointer); break; default: fatalUnreportableError("Unexpected capabilitity passed to _setVertexPointer"); break; } }
void Mesh::r_vbo(GLenum surface) { if(nv==0) return; if(nf==0) return; if(!has_vbo) return; //setup VBOs array pointers glEnableClientState(GL_NORMAL_ARRAY); glextensions->glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo1_name); glNormalPointer(GL_FLOAT, 0, (void*)(sizeof(GLfloat)*nv*3)); glEnableClientState(GL_VERTEX_ARRAY); glextensions->glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo1_name); glVertexPointer(3, GL_FLOAT, 0, 0); glEnableClientState(GL_INDEX_ARRAY); glextensions->glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo2_name); glIndexPointer(GL_UNSIGNED_INT, 0, 0); // start to render polygons glDrawElements(GL_TRIANGLES, nf*3, GL_UNSIGNED_INT, 0); // it is good idea to release VBOs with ID 0 after use. // Once bound with 0, all pointers in gl*Pointer() behave as real // pointer, so, normal vertex array operations are re-activated glDisableClientState(GL_NORMAL_ARRAY); glextensions->glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); glDisableClientState(GL_VERTEX_ARRAY); glextensions->glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); glEnableClientState(GL_INDEX_ARRAY); glextensions->glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); }
void VBO::draw() { glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); // glBindBuffer(GL_ARRAY_BUFFER, _vbo); glVertexPointer(3, GL_FLOAT, _vertexSize, 0); glEnableClientState(GL_VERTEX_ARRAY); if (_hasNormals) { glNormalPointer(GL_FLOAT, _vertexSize, BUFFER_OFFSET(_normalOffset)); glEnableClientState(GL_NORMAL_ARRAY); } if (_hasTextures) { glTexCoordPointer(2, GL_FLOAT, _vertexSize, BUFFER_OFFSET(_textureOffset)); glEnableClientState(GL_TEXTURE_COORD_ARRAY); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo); glIndexPointer(GL_INT, 0, 0); glDrawElements(_mode, _numOfIndices, GL_UNSIGNED_INT, 0); // unbind glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glPopClientAttrib(); // }
void piglit_init(int argc, char **argv) { bool pass = true; GLubyte dummy[100]; glVertexPointer(2, GL_FLOAT, 12, dummy); glNormalPointer(GL_FLOAT, 0, dummy); glColorPointer(4, GL_UNSIGNED_BYTE, 16, dummy); glSecondaryColorPointer(3, GL_SHORT, 32, dummy); glTexCoordPointer(3, GL_SHORT, 18, dummy); glEdgeFlagPointer(4, dummy); glIndexPointer(GL_SHORT, 10, dummy); glFogCoordPointer(GL_FLOAT, 8, dummy); pass = test_get(GL_VERTEX_ARRAY_SIZE, 2) && pass; pass = test_get(GL_VERTEX_ARRAY_TYPE, GL_FLOAT) && pass; pass = test_get(GL_VERTEX_ARRAY_STRIDE, 12) && pass; pass = test_get(GL_NORMAL_ARRAY_TYPE, GL_FLOAT) && pass; pass = test_get(GL_NORMAL_ARRAY_STRIDE, 0) && pass; pass = test_get(GL_COLOR_ARRAY_SIZE, 4) && pass; pass = test_get(GL_COLOR_ARRAY_TYPE, GL_UNSIGNED_BYTE) && pass; pass = test_get(GL_COLOR_ARRAY_STRIDE, 16) && pass; pass = test_get(GL_SECONDARY_COLOR_ARRAY_SIZE, 3) && pass; pass = test_get(GL_SECONDARY_COLOR_ARRAY_TYPE, GL_SHORT) && pass; pass = test_get(GL_SECONDARY_COLOR_ARRAY_STRIDE, 32) && pass; pass = test_get(GL_TEXTURE_COORD_ARRAY_SIZE, 3) && pass; pass = test_get(GL_TEXTURE_COORD_ARRAY_TYPE, GL_SHORT) && pass; pass = test_get(GL_TEXTURE_COORD_ARRAY_STRIDE, 18) && pass; pass = test_get(GL_EDGE_FLAG_ARRAY_STRIDE, 4) && pass; pass = test_get(GL_INDEX_ARRAY_TYPE, GL_SHORT) && pass; pass = test_get(GL_INDEX_ARRAY_STRIDE, 10) && pass; pass = test_get(GL_FOG_COORD_ARRAY_TYPE, GL_FLOAT) && pass; pass = test_get(GL_FOG_COORD_ARRAY_STRIDE, 8) && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void ShapeGenerator::GeneratePane() { glEnableClientState(GL_INDEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glIndexPointer (GL_INT, 0, pane_indices); glVertexPointer (2, GL_FLOAT, 0, pane_verts); glNormalPointer (GL_FLOAT, 0, pane_normals); glTexCoordPointer(2, GL_FLOAT, 0, pane_texture_coords); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, pane_indices); glDisableClientState(GL_INDEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); }
static bool test_legacy_vertex_attribs() { bool pass = true; /* "The error INVALID_ENUM is generated by VertexPointer, NormalPointer, * ColorPointer, SecondaryColorPointer, IndexPointer, EdgeFlagPointer, * FogCoordPointer, or TexCoordPointer if <type> is * UNSIGNED_INT_10F_11F_11F_REV. */ glVertexPointer(3, GL_UNSIGNED_INT_10F_11F_11F_REV, 0, (GLvoid *)0); TEST("VertexPointer-not-allowed", GL_INVALID_ENUM); glNormalPointer(GL_UNSIGNED_INT_10F_11F_11F_REV, 0, (GLvoid *)0); TEST("NormalPointer-not-allowed", GL_INVALID_ENUM); glColorPointer(3, GL_UNSIGNED_INT_10F_11F_11F_REV, 0, (GLvoid *)0); TEST("ColorPointer-not-allowed", GL_INVALID_ENUM); glSecondaryColorPointer(3, GL_UNSIGNED_INT_10F_11F_11F_REV, 0, (GLvoid *)0); TEST("SecondaryColorPointer-not-allowed", GL_INVALID_ENUM); glIndexPointer(GL_UNSIGNED_INT_10F_11F_11F_REV, 0, (GLvoid *)0); TEST("IndexPointer-not-allowed", GL_INVALID_ENUM); /* spec lists EdgeFlagPointer, but this is a bug -- it does not take a <type> param */ glFogCoordPointer(GL_UNSIGNED_INT_10F_11F_11F_REV, 0, (GLvoid *)0); TEST("FogCoordPointer-not-allowed", GL_INVALID_ENUM); glTexCoordPointer(3, GL_UNSIGNED_INT_10F_11F_11F_REV, 0, (GLvoid *)0); TEST("TexCoordPointer-not-allowed", GL_INVALID_ENUM); return pass; }
void glIndexPointerEXT( GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr ) { (void) count; glIndexPointer( type, stride, ptr ); }
void GLVertexBuffer::Render(unsigned int type, unsigned int nItems, unsigned int offset, IndexBuffer* ib) { GLIndexBuffer* glIb = (GLIndexBuffer*)ib; if(glIb) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, glIb->GetGLHandle()); glEnableClientState(GL_INDEX_ARRAY); glIndexPointer(glIb->GetGLFormat(), 0, (unsigned char*)0 + offset); } else { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); glDisableClientState(GL_INDEX_ARRAY); } glBindBuffer(GL_ARRAY_BUFFER_ARB, glVb); unsigned int size = 0; if(format & VF_XYZ) { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, vSize, (unsigned char*)0 + size); size += 3*sizeof(float); } if(format & VF_COLOR) { glEnableClientState(GL_COLOR_ARRAY); glColorPointer(4, GL_FLOAT, vSize, (unsigned char*)0 + size); size += 4*sizeof(float); } if(format & VF_NORMAL) { glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, vSize, (unsigned char*)0 + size); size += 3*sizeof(float); } unsigned int nTS = (format & VF_TEXMASK) >> 8; for(unsigned int i = 0; i < nTS; i++) { unsigned int tc = (format >> (i*2+16)) & 0x03; if(tc == TEXCOORD1) tc = 1; else if(tc == TEXCOORD2) tc = 2; else if(tc == TEXCOORD3) tc = 3; else if(tc == TEXCOORD4) tc = 4; glActiveTexture(GL_TEXTURE0+i); glClientActiveTexture(GL_TEXTURE0+i); glEnable(GL_TEXTURE_2D); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(tc, GL_FLOAT, vSize, (unsigned char*)0 + size); size += tc * sizeof(float); } if(ib) glDrawElements(GetGLPrimitiveType(type), nItems, GL_UNSIGNED_INT, (char*)offset); else glDrawArrays(GetGLPrimitiveType(type), 0, nItems); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_INDEX_ARRAY); glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); }
void __glXDispSwap_DrawArrays(GLbyte * pc) { __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *) pc; __GLXdispatchDrawArraysComponentHeader *compHeader; GLint numVertexes = hdr->numVertexes; GLint numComponents = hdr->numComponents; GLenum primType = hdr->primType; GLint stride = 0; int i; __GLX_DECLARE_SWAP_VARIABLES; __GLX_SWAP_INT(&numVertexes); __GLX_SWAP_INT(&numComponents); __GLX_SWAP_INT(&primType); pc += sizeof(__GLXdispatchDrawArraysHeader); compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc; /* compute stride (same for all component arrays) */ for (i = 0; i < numComponents; i++) { GLenum datatype = compHeader[i].datatype; GLint numVals = compHeader[i].numVals; GLenum component = compHeader[i].component; __GLX_SWAP_INT(&datatype); __GLX_SWAP_INT(&numVals); __GLX_SWAP_INT(&component); stride += __GLX_PAD(numVals * __glXTypeSize(datatype)); } pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader); /* set up component arrays */ for (i = 0; i < numComponents; i++) { GLenum datatype = compHeader[i].datatype; GLint numVals = compHeader[i].numVals; GLenum component = compHeader[i].component; __GLX_SWAP_INT(&datatype); __GLX_SWAP_INT(&numVals); __GLX_SWAP_INT(&component); swapArray(numVals, datatype, stride, numVertexes, pc); switch (component) { case GL_VERTEX_ARRAY: glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(numVals, datatype, stride, pc); break; case GL_NORMAL_ARRAY: glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(datatype, stride, pc); break; case GL_COLOR_ARRAY: glEnableClientState(GL_COLOR_ARRAY); glColorPointer(numVals, datatype, stride, pc); break; case GL_INDEX_ARRAY: glEnableClientState(GL_INDEX_ARRAY); glIndexPointer(datatype, stride, pc); break; case GL_TEXTURE_COORD_ARRAY: glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(numVals, datatype, stride, pc); break; case GL_EDGE_FLAG_ARRAY: glEnableClientState(GL_EDGE_FLAG_ARRAY); glEdgeFlagPointer(stride, (const GLboolean *) pc); break; case GL_SECONDARY_COLOR_ARRAY: { PFNGLSECONDARYCOLORPOINTERPROC SecondaryColorPointerEXT = __glGetProcAddress("glSecondaryColorPointerEXT"); glEnableClientState(GL_SECONDARY_COLOR_ARRAY); SecondaryColorPointerEXT(numVals, datatype, stride, pc); break; } case GL_FOG_COORD_ARRAY: { PFNGLFOGCOORDPOINTERPROC FogCoordPointerEXT = __glGetProcAddress("glFogCoordPointerEXT"); glEnableClientState(GL_FOG_COORD_ARRAY); FogCoordPointerEXT(datatype, stride, pc); break; } default: break; } pc += __GLX_PAD(numVals * __glXTypeSize(datatype)); } glDrawArrays(primType, 0, numVertexes); /* turn off anything we might have turned on */ glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_INDEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_EDGE_FLAG_ARRAY); glDisableClientState(GL_SECONDARY_COLOR_ARRAY); glDisableClientState(GL_FOG_COORD_ARRAY); }
void TrailRenderer::render() { if(!m_vertices.isCreated() || !m_indices.isCreated()) return; if(m_nbQuads > 0) { if(m_material.isValid()) { m_material->apply(0); // program = m_material->program(); } else { debug( "RENDERING" , "TrailRenderer : no material to apply for " << node()->getName()); } if(m_texcoords.isCreated()) { glEnable(GL_TEXTURE_2D); glEnableClientState(GL_TEXTURE_COORD_ARRAY); m_texcoords.bind(); glTexCoordPointer(2, GL_FLOAT, 0, 0); } else { glDisable(GL_TEXTURE_2D); } if(m_colors.isCreated()) { glEnable(GL_COLOR_MATERIAL); glEnableClientState(GL_COLOR_ARRAY); m_colors.bind(); glColorPointer(4, GL_FLOAT, 0, 0); } else { glDisable(GL_COLOR_MATERIAL); } if(m_normals.isCreated()) { glEnable(GL_LIGHTING); glShadeModel(GL_SMOOTH); glEnableClientState(GL_NORMAL_ARRAY); m_normals.bind(); glNormalPointer(GL_FLOAT, 0, 0); } else { glDisable(GL_LIGHTING); glColor3f(1,1,1); } glEnableClientState(GL_VERTEX_ARRAY); m_vertices.bind(); glVertexPointer(3, GL_FLOAT, 0, 0); glEnableClientState(GL_INDEX_ARRAY); m_indices.bind(); glIndexPointer(GL_SHORT, 0, 0); glDrawElements(GL_TRIANGLES, 6*m_nbQuads, GL_UNSIGNED_SHORT, 0); m_indices.release(); m_vertices.release(); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_INDEX_ARRAY); debugGL("while rendering TrailRenderer on " << node()->getName()); if(m_material.isValid()) { m_material->unset(0); } } }
M(void, glIndexPointer, jint type, jint stride, jobject ptr) { glIndexPointer(type, stride, BUFF(GLvoid, ptr)); }
void IndexOffset( int size, unsigned int type, int offset ) { glIndexPointer( type, 0, (const GLvoid*)offset ); }