Example usage for org.lwjgl.opengl GL11 glLineStipple

List of usage examples for org.lwjgl.opengl GL11 glLineStipple

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glLineStipple.

Prototype

public static native void glLineStipple(@NativeType("GLint") int factor, @NativeType("GLushort") short pattern);

Source Link

Document

Defines a line stipple.

Usage

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * Sets the line style// w w  w  .  j  a v  a  2s.c  o m
 * 
 * @param lineStyle
 *            The line style
 */
public void setLineStyle(int lineStyle) {

    if (lineStyle == CONTINUOUS_LINE) {
        GL11.glDisable(GL11.GL_LINE_STIPPLE);
    } else {
        GL11.glEnable(GL11.GL_LINE_STIPPLE);
        GL11.glLineStipple(2, (short) 0xAAAA);
    }
}

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

public void setupLineParameters(final float lineWidth, final int stippleFactor, final short stipplePattern,
        final boolean antialiased) {
    final LineRecord lineRecord = ContextManager.getCurrentContext().getLineRecord();

    if (!lineRecord.isValid() || lineRecord.width != lineWidth) {
        GL11.glLineWidth(lineWidth);/* www.j av  a  2  s  .com*/
        lineRecord.width = lineWidth;
    }

    if (stipplePattern != (short) 0xFFFF) {
        if (!lineRecord.isValid() || !lineRecord.stippled) {
            GL11.glEnable(GL11.GL_LINE_STIPPLE);
            lineRecord.stippled = true;
        }

        if (!lineRecord.isValid() || stippleFactor != lineRecord.stippleFactor
                || stipplePattern != lineRecord.stipplePattern) {
            GL11.glLineStipple(stippleFactor, stipplePattern);
            lineRecord.stippleFactor = stippleFactor;
            lineRecord.stipplePattern = stipplePattern;
        }
    } else if (!lineRecord.isValid() || lineRecord.stippled) {
        GL11.glDisable(GL11.GL_LINE_STIPPLE);
        lineRecord.stippled = false;
    }

    if (antialiased) {
        if (!lineRecord.isValid() || !lineRecord.smoothed) {
            GL11.glEnable(GL11.GL_LINE_SMOOTH);
            lineRecord.smoothed = true;
        }
        if (!lineRecord.isValid() || lineRecord.smoothHint != GL11.GL_NICEST) {
            GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
            lineRecord.smoothHint = GL11.GL_NICEST;
        }
    } else if (!lineRecord.isValid() || lineRecord.smoothed) {
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        lineRecord.smoothed = false;
    }

    if (!lineRecord.isValid()) {
        lineRecord.validate();
    }
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DBox.java

License:Open Source License

@Override
protected void doDisplay(I3dCamera camera) {
    float x0 = -size.x / 2;
    float x1 = size.x / 2;
    float y0 = -size.y / 2;
    float y1 = size.y / 2;
    float z0 = -size.z / 2;
    float z1 = size.z / 2;

    if (renderMode == RenderMode.PLAIN) {

        //GL11.glEnable(GL11.GL_LIGHTING);

        GL11.glBegin(GL11.GL_QUADS);//from ww  w .java  2 s  .  c  o  m

        GL11.glNormal3f(0, 1, 0);
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y0, z1);

        GL11.glNormal3f(1, 0, 0);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x0, y0, z1);

        GL11.glNormal3f(0, -1, 0);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y1, z1);

        GL11.glNormal3f(-1, 0, 0);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x1, y1, z1);

        GL11.glNormal3f(0, 0, 1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x1, y0, z0);

        GL11.glNormal3f(0, 0, -1);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y1, z1);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_LIGHTING);
    }
    if (renderMode == RenderMode.SOLID) {

        GL11.glLineWidth(thickness);

        GL11.glEnable(GL11.GL_LINE_STIPPLE);
        GL11.glLineStipple(stippleFactor, stipplePattern);

        GL11.glBegin(GL11.GL_LINE_LOOP);

        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y0, z1);

        GL11.glEnd();

        GL11.glBegin(GL11.GL_LINE_LOOP);

        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z0);

        GL11.glEnd();

        GL11.glBegin(GL11.GL_LINES);

        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y1, z0);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_LINE_STIPPLE);
    }
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DLine.java

License:Open Source License

@Override
protected void doDisplay(I3dCamera camera) {

    GL11.glLineWidth(thickness);//  ww  w  .j a va2 s  .  c om

    GL11.glEnable(GL11.GL_LINE_STIPPLE);
    GL11.glLineStipple(stippleFactor, stipplePattern);

    GL11.glBegin(GL11.GL_LINES);

    GL11.glVertex3d(locationA.x, locationA.y, locationA.z);
    GL11.glVertex3d(locationB.x, locationB.y, locationB.z);

    GL11.glEnd();

    GL11.glDisable(GL11.GL_LINE_STIPPLE);
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DRectangle.java

License:Open Source License

@Override
protected void doDisplay(I3dCamera camera) {
    float x0 = -size.x / 2;
    float y0 = -size.y / 2;
    float x1 = size.x / 2;
    float y1 = size.y / 2;

    GL11.glLineWidth(thickness);/*from   ww w  .  j ava 2 s  .c om*/

    if (renderMode == RenderMode.SOLID) {
        GL11.glEnable(GL11.GL_LINE_STIPPLE);
        GL11.glLineStipple(stippleFactor, stipplePattern);

        GL11.glBegin(GL11.GL_LINE_LOOP);

        GL11.glVertex3d(x0, y1, 0);
        GL11.glVertex3d(x0, y0, 0);
        GL11.glVertex3d(x1, y0, 0);
        GL11.glVertex3d(x1, y1, 0);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_LINE_STIPPLE);
    } else {
        GL11.glBegin(GL11.GL_QUADS);

        GL11.glVertex3d(x0, y1, 0);
        GL11.glVertex3d(x0, y0, 0);
        GL11.glVertex3d(x1, y0, 0);
        GL11.glVertex3d(x1, y1, 0);

        GL11.glEnd();
    }
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DTriangle.java

License:Open Source License

@Override
protected void doDisplay(I3dCamera camera) {
    float x0 = -size.x / 2;
    float y0 = -size.y / 2;
    float x1 = size.x / 2;
    float y1 = size.y / 2;

    GL11.glLineWidth(thickness);// w  w  w.  j  av a2  s . co  m

    if (renderMode == RenderMode.SOLID) {
        GL11.glEnable(GL11.GL_LINE_STIPPLE);
        GL11.glLineStipple(stippleFactor, stipplePattern);

        GL11.glBegin(GL11.GL_LINE_LOOP);

        GL11.glVertex3d(x0, y1, 0);
        GL11.glVertex3d((x1 + x0) / 2, y0, 0);
        GL11.glVertex3d(x1, y1, 0);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_LINE_STIPPLE);
    } else {
        GL11.glBegin(GL11.GL_TRIANGLES);

        GL11.glVertex3d(x0, y1, 0);
        GL11.glVertex3d((x1 + x0) / 2, y0, 0);
        GL11.glVertex3d(x1, y1, 0);

        GL11.glEnd();
    }
}

From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void lineStipple(int stretch, short pattern) {
    GL11.glLineStipple(stretch, pattern);
}

From source file:org.jogamp.glg2d.impl.gl2.FastLineVisitor.java

License:Apache License

@Override
public void setStroke(BasicStroke stroke) {
    GL11.glLineWidth(glLineWidth);//from ww w  .  j  a  v  a2  s  .  com
    GL11.glPointSize(glLineWidth);

    /*
     * Not perfect copy of the BasicStroke implementation, but it does get
     * decently close. The pattern is pretty much the same. I think it's pretty
     * much impossible to do with out a fragment shader and only the fixed
     * function pipeline.
     */
    float[] dash = stroke.getDashArray();
    if (dash != null) {
        float totalLength = 0;
        for (float f : dash) {
            totalLength += f;
        }

        float lengthSoFar = 0;
        int prevIndex = 0;
        int mask = 0;
        for (int i = 0; i < dash.length; i++) {
            lengthSoFar += dash[i];

            int nextIndex = (int) (lengthSoFar / totalLength * 16);
            for (int j = prevIndex; j < nextIndex; j++) {
                mask |= (~i & 1) << j;
            }

            prevIndex = nextIndex;
        }

        /*
         * XXX Should actually use the stroke phase, but not sure how yet.
         */

        GL11.glEnable(GL11.GL_LINE_STIPPLE);
        int factor = (int) totalLength;
        GL11.glLineStipple(factor >> 4, (short) mask);
    } else {
        GL11.glDisable(GL11.GL_LINE_STIPPLE);
    }

    this.stroke = stroke;
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glLineStipple(int a, short b) {
    GL11.glLineStipple(a, b);
}