private boolean enableVertexAttribArray(final GL2ES2 gl, final String name, int location) { activedAttribEnabledMap.put(name, Boolean.TRUE); if(0>location) { location = getAttribLocation(gl, name); if(0>location) { if(verbose) { System.err.println("ShaderState: glEnableVertexAttribArray failed, no index for: "+name); if(DEBUG) { Thread.dumpStack(); } } return false; } } if(DEBUG) { System.err.println("ShaderState: glEnableVertexAttribArray: "+name+", loc: "+location); } gl.glEnableVertexAttribArray(location); return true; }
private static void enableVertexAttribute(final ShaderVariable var, final ShaderObjectsStateRecord record) { if (!record.enabledAttributes.contains(var)) { if (var.getSize() == 1) { GLContext.getCurrentGL().getGL2ES2().glEnableVertexAttribArray(var.variableID); } else { final GL gl = GLContext.getCurrentGL(); for (int i = 0, max = var.getSize(); i < max; i++) { gl.getGL2ES2().glEnableVertexAttribArray(var.variableID + i); } } record.enabledAttributes.add(var); } }
public void prepare() { buffer.bind(); GL2ES2 gl = gc.getGL().getGL2ES2(); for (AttributConfig ac : configs) { gl.glEnableVertexAttribArray(ac.index); gl.glVertexAttribPointer(ac.index, ac.size, ac.glconst, false, ac.stride, ac.offset); } buffer.disable(); }
private final void relocateAttribute(final GL2ES2 gl, final GLArrayData attribute) { // get new location .. note: 'activeAttribLocationMap' is cleared before final String name = attribute.getName(); final int loc = attribute.setLocation(gl, shaderProgram.program()); if(0<=loc) { activeAttribLocationMap.put(name, Integer.valueOf(loc)); if(DEBUG) { System.err.println("ShaderState: relocateAttribute: "+name+", loc: "+loc); } if(isVertexAttribArrayEnabled(name)) { // enable attrib, VBO and pass location/data gl.glEnableVertexAttribArray(loc); } if( attribute.isVBO() ) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, attribute.getVBOName()); gl.glVertexAttribPointer(attribute); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } else { gl.glVertexAttribPointer(attribute); } } }
@Override public final void enableState(final GL gl, final boolean enable, final Object ext) { final GL2ES2 glsl = gl.getGL2ES2(); if( null != ext ) { final ShaderState st = (ShaderState)ext; if(enable) { st.enableVertexAttribArray(glsl, ad); } else { st.disableVertexAttribArray(glsl, ad); } } else { final int location = ad.getLocation(); if( 0 <= location ) { if(enable) { glsl.glEnableVertexAttribArray(location); } else { glsl.glDisableVertexAttribArray(location); } } } } }
glsl.glEnableVertexAttribArray(vArrayData.getLocation()); glsl.glVertexAttribPointer(vArrayData); } else { glsl.glEnableVertexAttribArray(cArrayData.getLocation()); glsl.glVertexAttribPointer(cArrayData); } else { glsl.glEnableVertexAttribArray(nArrayData.getLocation()); glsl.glVertexAttribPointer(nArrayData); } else { glsl.glEnableVertexAttribArray(tArrayData.getLocation()); glsl.glVertexAttribPointer(tArrayData); } else {
private final void setAttribute(final GL2ES2 gl, final GLArrayData attribute) { // get new location .. final String name = attribute.getName(); final int loc = attribute.getLocation(); if(0<=loc) { bindAttribLocation(gl, loc, name); if(isVertexAttribArrayEnabled(name)) { // enable attrib, VBO and pass location/data gl.glEnableVertexAttribArray(loc); } if( attribute.isVBO() ) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, attribute.getVBOName()); gl.glVertexAttribPointer(attribute); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } else { gl.glVertexAttribPointer(attribute); } } }
gl.glUniform1i( handles.HIGHLIGHT_SET, highlightSetTextureUnit ); gl.glEnableVertexAttribArray( handles.inAreaVertex ); gl.glBindBuffer( GL_ARRAY_BUFFER, dChunk.verticesHandle ); gl.glVertexAttribPointer( handles.inAreaVertex, coordsPerRenderTriangleVertex, GL_FLOAT, false, 0, group.trianglesCoordFirst * SIZEOF_FLOAT ); gl.glUniform1f( handles.HIGHLIGHT_EXTRA_THICKNESS_PX, lineHighlightExtraThickness_PX ); gl.glEnableVertexAttribArray( handles.inLineVertex ); gl.glBindBuffer( GL_ARRAY_BUFFER, dChunk.verticesHandle ); gl.glVertexAttribPointer( handles.inLineVertex, coordsPerRenderLineVertex, GL_FLOAT, false, 0, group.linesCoordFirst * SIZEOF_FLOAT ); gl.glEnableVertexAttribArray( handles.inIconVertex ); gl.glBindBuffer( GL_ARRAY_BUFFER, dChunk.verticesHandle ); gl.glVertexAttribPointer( handles.inIconVertex, coordsPerRenderIconVertex, GL_FLOAT, false, 0, group.iconsCoordFirst * SIZEOF_FLOAT ); gl.glEnableVertexAttribArray( handles.inLabelVertex ); gl.glBindBuffer( GL_ARRAY_BUFFER, dChunk.verticesHandle ); gl.glVertexAttribPointer( handles.inLabelVertex, coordsPerRenderLabelVertex, GL_FLOAT, false, 0, group.labelsCoordFirst * SIZEOF_FLOAT ); gl.glEnableVertexAttribArray( handles.inImageAlign ); gl.glBindBuffer( GL_ARRAY_BUFFER, dLabelAtlas.entriesAlignHandle ); gl.glVertexAttribPointer( handles.inImageAlign, coordsPerLabelAtlasAlign, GL_FLOAT, false, 0, group.labelFirst * coordsPerLabelAtlasAlign * SIZEOF_FLOAT ); gl.glEnableVertexAttribArray( handles.inImageBounds ); gl.glBindBuffer( GL_ARRAY_BUFFER, dLabelAtlas.entriesBoundsHandle ); gl.glVertexAttribPointer( handles.inImageBounds, coordsPerLabelAtlasBounds, GL_FLOAT, false, 0, group.labelFirst * coordsPerLabelAtlasBounds * SIZEOF_FLOAT );
glsl.glEnableVertexAttribArray(location); } else { glsl.glDisableVertexAttribArray(location);