Ejemplo n.º 1
0
        /**
         * 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();
        }
Ejemplo n.º 2
0
        /**
         * Renders elements from the currently bounds OpenGL coordinate buffers. This behaves exactly like {@link
         * #drawArrays(gov.nasa.worldwind.render.DrawContext, int)}, except that each sub-buffer is rendered independently.
         * The specified drawMode indicates which type of OpenGL primitives to render.
         *
         * @param dc       the current DrawContext.
         * @param drawMode the type of OpenGL primtives to render.
         *
         * @throws ArgumentException if the DrawContext is null.
         */
        public void multiDrawArrays(DrawContext dc, int drawMode)
        {
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            if (this.haveMultiDrawArrays(dc))
            {
                gl.glMultiDrawArrays(drawMode, this.offsets, this.lengths, this.count);
            }
            else
            {
                for (int i = 0; i < this.count; i++)
                {
                    gl.glDrawArrays(drawMode, this.offsets.get(i), this.lengths.get(i));
                }
            }
        }