/** * Draw a vertex buffer with texture coordinates in a given gl mode. Vertex buffers coming from the * createShapeBuffer() methods support both <code>GL.GL_TRIANGLE_FAN</code> and <code>GL.LINE_STRIP</code>. * * @param dc the current DrawContext. * @param mode the desired drawing GL mode. * @param count the number of vertices to draw. * @param verts the vertex buffer to draw. * @param coords the buffer containing the shape texture coordinates. */ public static void drawBuffer(DrawContext dc, int mode, int count, DoubleBuffer verts, DoubleBuffer coords) { if (dc == null) { String message = Logging.getMessage("nullValue.DrawContextIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } if (verts == null || coords == null) { String message = Logging.getMessage("nullValue.BufferIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. // Set up gl.glPushClientAttrib(GL2.GL_CLIENT_VERTEX_ARRAY_BIT); gl.glEnableClientState(GL2.GL_VERTEX_ARRAY); gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY); gl.glVertexPointer(2, GL2.GL_DOUBLE, 0, verts); gl.glTexCoordPointer(2, GL2.GL_DOUBLE, 0, coords); // Draw gl.glDrawArrays(mode, 0, count); // Restore gl.glPopClientAttrib(); }