Search in sources :

Example 6 with GLU

use of com.jogamp.opengl.glu.GLU in project artisynth_core by artisynth.

the class GL2PrimitiveFactory method createSphere.

public static GL2DisplayList createSphere(GL2 gl, int slices, int levels) {
    if (glu == null) {
        glu = new GLU();
    }
    if (mySphereQuad == null) {
        mySphereQuad = glu.gluNewQuadric();
    }
    GL2DisplayList list = GL2DisplayList.allocate(gl, 1);
    list.compile(gl);
    glu.gluSphere(mySphereQuad, 1.0, slices, levels);
    list.end(gl);
    return list;
}
Also used : GLU(com.jogamp.opengl.glu.GLU)

Example 7 with GLU

use of com.jogamp.opengl.glu.GLU in project narchy by automenta.

the class Sphere method display.

@Override
public void display(GLAutoDrawable drawable) {
    GL2 gl = (GL2) drawable.getGL();
    GLU glu = GLU.createGLU(gl);
    // Kugel mittels "Quadrik"-Objekt zeichnen:
    GLUquadric quadric = glu.gluNewQuadric();
    gl.glPushMatrix();
    gl.glTranslated(center.x, center.y, center.z);
    if (RaytracerConstants.GL_GRID_MODE_ENABLED)
        glu.gluQuadricDrawStyle(quadric, GLU.GLU_LINE);
    glu.gluSphere(quadric, radius, RaytracerConstants.GL_RESOLUTION, RaytracerConstants.GL_RESOLUTION);
    gl.glPopMatrix();
    glu.gluDeleteQuadric(quadric);
}
Also used : GLU(com.jogamp.opengl.glu.GLU) GLUquadric(com.jogamp.opengl.glu.GLUquadric) GL2(com.jogamp.opengl.GL2)

Example 8 with GLU

use of com.jogamp.opengl.glu.GLU in project Universal-G-Code-Sender by winder.

the class GcodeRenderer method init.

// ------ Implement methods declared in GLEventListener ------
/**
 * Called back immediately after the OpenGL context is initialized. Can be used
 * to perform one-time initialization. Run only once.
 * GLEventListener method.
 */
@Override
public void init(GLAutoDrawable drawable) {
    logger.log(Level.INFO, "Initializing OpenGL context.");
    this.drawable = drawable;
    // TODO: Figure out scale factor / dimensions label based on GcodeRenderer
    /*
            this.scaleFactorBase = VisualizerUtils.findScaleFactor(this.xSize, this.ySize, this.objectMin, this.objectMax);
            this.scaleFactor = this.scaleFactorBase * this.zoomMultiplier;

            double objectWidth = this.objectMax.x-this.objectMin.x;
            double objectHeight = this.objectMax.y-this.objectMin.y;
            this.dimensionsLabel = Localization.getString("VisualizerCanvas.dimensions") + ": " 
                    + Localization.getString("VisualizerCanvas.width") + "=" + format.format(objectWidth) + " " 
                    + Localization.getString("VisualizerCanvas.height") + "=" + format.format(objectHeight);

        */
    this.fpsCounter = new FPSCounter(drawable, new Font("SansSerif", Font.BOLD, 12));
    this.overlay = new Overlay(drawable, new Font("SansSerif", Font.BOLD, 12));
    this.overlay.setColor(127, 127, 127, 100);
    this.overlay.setTextLocation(Overlay.LOWER_LEFT);
    // Parse random gcode file and generate something to draw.
    // get the OpenGL graphics context
    GL2 gl = drawable.getGL().getGL2();
    // get GL Utilities
    glu = new GLU();
    // blends colors nicely, and smoothes out lighting
    gl.glShadeModel(GL2.GL_SMOOTH);
    gl.glClearColor(clearColor.getRed() / 255f, clearColor.getGreen() / 255f, clearColor.getBlue() / 255f, clearColor.getAlpha() / 255f);
    // set clear depth value to farthest
    gl.glClearDepth(1.0f);
    gl.glEnable(GL2.GL_BLEND);
    gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
    gl.glEnable(GL.GL_DEPTH_TEST);
    // the type of depth test to do
    gl.glDepthFunc(GL2.GL_LEQUAL);
    // best perspective correction
    gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
    /*
        gl.glLoadIdentity();
        float[] lmodel_ambient = { 0.5f, 0.5f, 0.5f, 1.0f };
        gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, lmodel_ambient, 0);
        */
    // init lighting
    float[] ambient = { .6f, .6f, .6f, 1.f };
    float[] diffuse = { .6f, .6f, .6f, 1.0f };
    float[] position = { 0f, 0f, 20f, 1.0f };
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, 0);
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, 0);
    gl.glEnable(GL2.GL_LIGHT0);
    gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, position, 0);
    // Allow glColor to set colors
    gl.glEnable(GL2.GL_COLOR_MATERIAL);
    gl.glColorMaterial(GL.GL_FRONT, GL2.GL_DIFFUSE);
    gl.glColorMaterial(GL.GL_FRONT, GL2.GL_AMBIENT);
    // gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE);
    // gl.glColorMaterial(GL.GL_FRONT, GL2.GL_SPECULAR);
    float[] mat_specular = { 1.0f, 1.0f, 1.0f, 1.0f };
    float[] diffuseMaterial = { 0.5f, 0.5f, 0.5f, 1.0f };
    gl.glMaterialfv(GL.GL_FRONT, GL2.GL_DIFFUSE, diffuseMaterial, 0);
    // gl.glMaterialfv(GL.GL_FRONT, GL2.GL_SPECULAR, mat_specular, 0);
    // gl.glMaterialf(GL.GL_FRONT, GL2.GL_SHININESS, 25.0f);
    // gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE);
    gl.glEnable(GL2.GL_LIGHTING);
    for (Renderable r : objects) {
        r.init(drawable);
    }
}
Also used : GLU(com.jogamp.opengl.glu.GLU) FPSCounter(com.willwinder.universalgcodesender.uielements.helpers.FPSCounter) Overlay(com.willwinder.universalgcodesender.uielements.helpers.Overlay) GL2(com.jogamp.opengl.GL2)

Example 9 with GLU

use of com.jogamp.opengl.glu.GLU in project Universal-G-Code-Sender by winder.

the class Tool method init.

@Override
public void init(GLAutoDrawable drawable) {
    glu = new GLU();
    gq = glu.gluNewQuadric();
}
Also used : GLU(com.jogamp.opengl.glu.GLU)

Aggregations

GLU (com.jogamp.opengl.glu.GLU)9 GL2 (com.jogamp.opengl.GL2)6 FPSCounter (com.willwinder.universalgcodesender.uielements.helpers.FPSCounter)2 Overlay (com.willwinder.universalgcodesender.uielements.helpers.Overlay)2 GLUquadric (com.jogamp.opengl.glu.GLUquadric)1 GLUgl2 (com.jogamp.opengl.glu.gl2.GLUgl2)1 Font (java.awt.Font)1 WindowMaterial (jhelp.engine.gui.components.WindowMaterial)1 JHelpImage (jhelp.util.gui.JHelpImage)1