Example usage for org.lwjgl.opengl GL11 glEnable

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

Introduction

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

Prototype

public static void glEnable(@NativeType("GLenum") int target) 

Source Link

Document

Enables the specified OpenGL state.

Usage

From source file:com.a2client.corex.Render.java

License:Open Source License

static public void set2D(int width, int height) {
    ResetBind();/*w w w  . j a v  a 2 s.c  o  m*/
    Clear(false, true);
    setBlendType(Const.BLEND_TYPE.btNormal);
    setDepthTest(false);
    setCullFace(Const.CULL_FACE.cfNone);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);

    setDepthTest(false);

    GL11.glViewport(0, 0, width, height);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, height, 0, -1, 1);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
}

From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java

License:Open Source License

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Composite comp = new Composite(shell, SWT.NONE);
    comp.setLayout(new FillLayout());
    GLData data = new GLData();
    data.doubleBuffer = true;//from   w w w. j a  va  2  s.  c  om
    data.accumAlphaSize = 8;
    data.accumBlueSize = 8;
    data.accumGreenSize = 8;
    data.accumRedSize = 8;

    final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data);

    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    canvas.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            Rectangle bounds = canvas.getBounds();
            float fAspect = (float) bounds.width / (float) bounds.height;
            canvas.setCurrent();
            try {
                GLContext.useContext(canvas);
            } catch (LWJGLException e) {
                e.printStackTrace();
            }
            GL11.glViewport(0, 0, bounds.width, bounds.height);
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glLoadIdentity();
        }
    });

    GL11.glLineWidth(1);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glClearDepth(1.0);
    GL11.glLineWidth(2);
    GL11.glEnable(GL11.GL_DEPTH_TEST);

    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);

    shell.setText("SWT/LWJGL Example");
    shell.setSize(640, 480);
    shell.open();

    final Runnable run = new Runnable() {
        float rot = 0;

        public void run() {
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                try {
                    GLContext.useContext(canvas);
                } catch (LWJGLException e) {
                    e.printStackTrace();
                }

                int ACSIZE = 8;

                int[] viewport = getViewport();

                GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT);

                for (int jitter = 0; jitter < ACSIZE; jitter++) {
                    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

                    double jit_x = jits[jitter][0];
                    double jit_y = jits[jitter][1];

                    accPerspective(50.0, (double) viewport[2] / (double) viewport[3], 1.0, 15.0, jit_x, jit_y,
                            0.0, 0.0, 1.0);

                    {

                        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                        GL11.glClearColor(.3f, .5f, .8f, 1.0f);
                        GL11.glLoadIdentity();
                        GL11.glTranslatef(0.0f, 0.0f, -10.0f);
                        float frot = rot;
                        GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f);
                        GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f);
                        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
                        GL11.glColor3f(0.9f, 0.9f, 0.9f);
                        drawCylinder(2, 3, 50, 0);
                        drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15);
                    }

                    GL11.glAccum(GL11.GL_ACCUM, 1.0f / ACSIZE);
                }

                GL11.glAccum(GL11.GL_RETURN, 1.0f);
                GL11.glFlush();

                rot += 0.1;

                canvas.swapBuffers();
                display.asyncExec(this);
            }
        }
    };
    canvas.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event event) {
            run.run();
        }
    });
    display.asyncExec(run);

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:com.aerialmage.magnetchem.GUI.WorldgenRegeneratorGui.java

License:Open Source License

@Override
protected void drawGuiContainerForegroundLayer(int param1, int param2) {
    //draw text and stuff here
    //the parameters for drawString are: string, x, y, color
    //fontRenderer.drawString("Magnetic worldgen liquifier", 25, -10, 4210752);
    GL11.glDisable(GL11.GL_DEPTH_TEST);//from www.  j av  a 2s  . co  m
    GL11.glEnable(GL11.GL_BLEND);
    this.mc.getTextureManager().bindTexture(myBG);
    this.drawTexturedModalRect(34 + 18 * selectedCol, -11 + 18 * selectedRow, 215, 0, 17, 17);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    //draws "Inventory" or your regional equivalent
    //fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);
}

From source file:com.ardor3d.framework.lwjgl.LwjglCanvasRenderer.java

License:Open Source License

@MainThread
public void init(final DisplaySettings settings, final boolean doSwap) {
    _doSwap = doSwap;/*from  w  ww .  j av a2  s .c  om*/

    // Look up a shared context, if a shared LwjglCanvasRenderer is given.
    // XXX: Shared contexts will probably not work... lwjgl does not seem to have a way to make a new glcontext that
    // shares lists, textures, etc.
    RenderContext sharedContext = null;
    if (settings.getShareContext() != null) {
        sharedContext = ContextManager
                .getContextForKey(settings.getShareContext().getRenderContext().getContextKey());
    }

    try {
        _canvasCallback.makeCurrent();
        GLContext.useContext(_context);
    } catch (final LWJGLException e) {
        throw new Ardor3dException("Unable to init CanvasRenderer.", e);
    }

    final ContextCapabilities caps = createContextCapabilities();
    _currentContext = new RenderContext(this, caps, sharedContext);

    ContextManager.addContext(this, _currentContext);
    ContextManager.switchContext(this);

    _renderer = createRenderer();

    if (settings.getSamples() != 0 && caps.isMultisampleSupported()) {
        GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB);
    }

    _renderer.setBackgroundColor(ColorRGBA.BLACK);

    if (_camera == null) {
        /** Set up how our camera sees. */
        _camera = new Camera(settings.getWidth(), settings.getHeight());
        _camera.setFrustumPerspective(45.0f, (float) settings.getWidth() / (float) settings.getHeight(), 1,
                1000);
        _camera.setProjectionMode(ProjectionMode.Perspective);

        final Vector3 loc = new Vector3(0.0f, 0.0f, 10.0f);
        final Vector3 left = new Vector3(-1.0f, 0.0f, 0.0f);
        final Vector3 up = new Vector3(0.0f, 1.0f, 0.0f);
        final Vector3 dir = new Vector3(0.0f, 0f, -1.0f);
        /** Move our camera to a correct place and orientation. */
        _camera.setFrame(loc, left, up, dir);
    } else {
        // use new width and height to set ratio.
        _camera.setFrustumPerspective(_camera.getFovY(),
                (float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(),
                _camera.getFrustumFar());
    }
}

From source file:com.ardor3d.framework.lwjgl.LwjglHeadlessCanvas.java

License:Open Source License

protected void init() {
    final int width = _settings.getWidth();
    final int height = _settings.getHeight();

    try {//from   ww w.  j a va2 s. co  m
        // Create a Pbuffer so we can have a valid gl context to work with
        final PixelFormat format = new PixelFormat(_settings.getAlphaBits(), _settings.getDepthBits(),
                _settings.getStencilBits());
        _buff = new Pbuffer(1, 1, format, null);
        _buff.makeCurrent();
    } catch (final LWJGLException ex) {
        ex.printStackTrace();
    }

    // Set up our Ardor3D context and capabilities objects
    final LwjglContextCapabilities caps = new LwjglContextCapabilities(GLContext.getCapabilities());
    final RenderContext currentContext = new RenderContext(this, caps, null);

    if (!caps.isFBOSupported()) {
        throw new Ardor3dException("Headless requires FBO support.");
    }

    if (caps.isFBOMultisampleSupported() && caps.isFBOBlitSupported() && _settings.getSamples() > 0) {
        _useMSAA = true;
    }

    // Init our FBO.
    final IntBuffer buffer = BufferUtils.createIntBuffer(1);
    EXTFramebufferObject.glGenFramebuffersEXT(buffer); // generate id

    // Bind the FBO
    _fboID = buffer.get(0);
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _fboID);

    // initialize our color renderbuffer
    EXTFramebufferObject.glGenRenderbuffersEXT(buffer); // generate id
    _colorRBID = buffer.get(0);
    EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _colorRBID);
    EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL11.GL_RGBA, width,
            height);

    // Attach color renderbuffer to framebuffer
    EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
            EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT,
            _colorRBID);

    // initialize our depth renderbuffer
    EXTFramebufferObject.glGenRenderbuffersEXT(buffer); // generate id
    _depthRBID = buffer.get(0);
    EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _depthRBID);
    EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
            GL11.GL_DEPTH_COMPONENT, width, height);

    // Attach depth renderbuffer to framebuffer
    EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
            EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, _depthRBID);

    // Check FBO complete
    LwjglTextureRenderer.checkFBOComplete(_fboID);

    // Now do it all again for multisample, if requested and supported
    if (_useMSAA) {

        // Init our ms FBO.
        EXTFramebufferObject.glGenFramebuffersEXT(buffer); // generate id

        // Bind the ms FBO
        _msfboID = buffer.get(0);
        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _msfboID);

        // initialize our ms color renderbuffer
        EXTFramebufferObject.glGenRenderbuffersEXT(buffer); // generate id
        _mscolorRBID = buffer.get(0);
        EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _mscolorRBID);
        EXTFramebufferMultisample.glRenderbufferStorageMultisampleEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _settings.getSamples(), GL11.GL_RGBA, width, height);

        // Attach ms color renderbuffer to ms framebuffer
        EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _mscolorRBID);

        // initialize our ms depth renderbuffer
        EXTFramebufferObject.glGenRenderbuffersEXT(buffer); // generate id
        _msdepthRBID = buffer.get(0);
        EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _msdepthRBID);
        EXTFramebufferMultisample.glRenderbufferStorageMultisampleEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _settings.getSamples(), GL11.GL_DEPTH_COMPONENT, width, height);

        // Attach ms depth renderbuffer to ms framebuffer
        EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _msdepthRBID);

        // Check MS FBO complete
        LwjglTextureRenderer.checkFBOComplete(_msfboID);

        // enable multisample
        GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB);
    }

    // Setup our data buffer for storing rendered image data.
    _data = ByteBuffer.allocateDirect(width * height * 4).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer();

    // Add context to manager and set as active.
    ContextManager.addContext(this, currentContext);
    ContextManager.switchContext(this);

    // Setup a default bg color.
    _renderer.setBackgroundColor(ColorRGBA.BLACK);

    // Setup a default camera
    _camera = new Camera(width, _settings.getHeight());
    _camera.setFrustumPerspective(45.0f, (float) width / (float) _settings.getHeight(), 1, 1000);
    _camera.setProjectionMode(ProjectionMode.Perspective);

    // setup camera orientation and position.
    final Vector3 loc = new Vector3(0.0f, 0.0f, 0.0f);
    final Vector3 left = new Vector3(-1.0f, 0.0f, 0.0f);
    final Vector3 up = new Vector3(0.0f, 1.0f, 0.0f);
    final Vector3 dir = new Vector3(0.0f, 0f, -1.0f);
    _camera.setFrame(loc, left, up, dir);

    // release our FBO(s) until used.
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
}

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

License:Open Source License

public void clearBuffers(final int buffers, final boolean strict) {

    int clear = 0;

    if ((buffers & Renderer.BUFFER_COLOR) != 0) {
        clear |= GL11.GL_COLOR_BUFFER_BIT;
    }// ww w.j  a  v  a2  s. co m

    if ((buffers & Renderer.BUFFER_DEPTH) != 0) {
        clear |= GL11.GL_DEPTH_BUFFER_BIT;

        // make sure no funny business is going on in the z before clearing.
        if (defaultStateList.containsKey(RenderState.StateType.ZBuffer)) {
            defaultStateList.get(RenderState.StateType.ZBuffer).setNeedsRefresh(true);
            doApplyState(defaultStateList.get(RenderState.StateType.ZBuffer));
        }
    }

    if ((buffers & Renderer.BUFFER_STENCIL) != 0) {
        clear |= GL11.GL_STENCIL_BUFFER_BIT;

        GL11.glClearStencil(_stencilClearValue);
        GL11.glStencilMask(~0);
        GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
    }

    if ((buffers & Renderer.BUFFER_ACCUMULATION) != 0) {
        clear |= GL11.GL_ACCUM_BUFFER_BIT;
    }

    final RenderContext context = ContextManager.getCurrentContext();
    final RendererRecord record = context.getRendererRecord();

    if (strict) {
        // grab our camera to get width and height info.
        final Camera cam = Camera.getCurrentCamera();

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(0, 0, cam.getWidth(), cam.getHeight());
        record.setClippingTestEnabled(true);
    }

    GL11.glClear(clear);

    if (strict) {
        // put us back.
        LwjglRendererUtil.applyScissors(record);
    }
}

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

License:Open Source License

public void applyNormalsMode(final NormalsMode normalsMode, final ReadOnlyTransform worldTransform) {
    final RenderContext context = ContextManager.getCurrentContext();
    final RendererRecord rendRecord = context.getRendererRecord();
    if (normalsMode != NormalsMode.Off) {
        final ContextCapabilities caps = context.getCapabilities();
        switch (normalsMode) {
        case NormalizeIfScaled:
            if (worldTransform.isRotationMatrix()) {
                final ReadOnlyVector3 scale = worldTransform.getScale();
                if (!(scale.getX() == 1.0 && scale.getY() == 1.0 && scale.getZ() == 1.0)) {
                    if (scale.getX() == scale.getY() && scale.getY() == scale.getZ()
                            && caps.isOpenGL1_2Supported()
                            && rendRecord.getNormalMode() != GL12.GL_RESCALE_NORMAL) {
                        if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                            GL11.glDisable(GL11.GL_NORMALIZE);
                        }/*from www .  j a  v  a 2  s.  c  o m*/
                        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
                        rendRecord.setNormalMode(GL12.GL_RESCALE_NORMAL);
                    } else if (rendRecord.getNormalMode() != GL11.GL_NORMALIZE) {
                        if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                        }
                        GL11.glEnable(GL11.GL_NORMALIZE);
                        rendRecord.setNormalMode(GL11.GL_NORMALIZE);
                    }
                } else {
                    if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                    } else if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                        GL11.glDisable(GL11.GL_NORMALIZE);
                    }
                    rendRecord.setNormalMode(GL11.GL_ZERO);
                }
            } else {
                if (!worldTransform.getMatrix().isIdentity()) {
                    // *might* be scaled...
                    if (rendRecord.getNormalMode() != GL11.GL_NORMALIZE) {
                        if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                        }
                        GL11.glEnable(GL11.GL_NORMALIZE);
                        rendRecord.setNormalMode(GL11.GL_NORMALIZE);
                    }
                } else {
                    // not scaled
                    if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                    } else if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                        GL11.glDisable(GL11.GL_NORMALIZE);
                    }
                    rendRecord.setNormalMode(GL11.GL_ZERO);
                }
            }
            break;
        case AlwaysNormalize:
            if (rendRecord.getNormalMode() != GL11.GL_NORMALIZE) {
                if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                }
                GL11.glEnable(GL11.GL_NORMALIZE);
                rendRecord.setNormalMode(GL11.GL_NORMALIZE);
            }
            break;
        case UseProvided:
        default:
            if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            } else if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                GL11.glDisable(GL11.GL_NORMALIZE);
            }
            rendRecord.setNormalMode(GL11.GL_ZERO);
            break;
        }
    } else {
        if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        } else if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
            GL11.glDisable(GL11.GL_NORMALIZE);
        }
        rendRecord.setNormalMode(GL11.GL_ZERO);
    }
}

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);//from   ww  w.  ja va2s  . co  m
        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:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

@Override
public void setupPointParameters(final float pointSize, final boolean antialiased, final boolean isSprite,
        final boolean useDistanceAttenuation, final FloatBuffer attenuationCoefficients,
        final float minPointSize, final float maxPointSize) {
    final RenderContext context = ContextManager.getCurrentContext();

    // TODO: make a record for point states
    GL11.glPointSize(pointSize);/*from   www  . j av  a 2s . c  o m*/

    if (isSprite && context.getCapabilities().isPointSpritesSupported()) {
        GL11.glEnable(ARBPointSprite.GL_POINT_SPRITE_ARB);
        GL11.glTexEnvi(ARBPointSprite.GL_POINT_SPRITE_ARB, ARBPointSprite.GL_COORD_REPLACE_ARB, GL11.GL_TRUE);
    }

    if (useDistanceAttenuation && context.getCapabilities().isPointParametersSupported()) {
        ARBPointParameters.glPointParameterARB(ARBPointParameters.GL_POINT_DISTANCE_ATTENUATION_ARB,
                attenuationCoefficients);
        ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MIN_ARB, minPointSize);
        ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MAX_ARB, maxPointSize);
    }

    if (antialiased) {
        GL11.glEnable(GL11.GL_POINT_SMOOTH);
        GL11.glHint(GL11.GL_POINT_SMOOTH_HINT, GL11.GL_NICEST);
    }
}

From source file:com.ardor3d.scene.state.lwjgl.LwjglBlendStateUtil.java

License:Open Source License

protected static void applyBlendEquations(final boolean enabled, final BlendState state,
        final BlendStateRecord record, final ContextCapabilities caps) {
    if (record.isValid()) {
        if (enabled) {
            if (!record.blendEnabled) {
                GL11.glEnable(GL11.GL_BLEND);
                record.blendEnabled = true;
            }/*from w w  w .j  a v  a 2 s  .  c  om*/
            final int blendEqRGB = getGLEquationValue(state.getBlendEquationRGB(), caps);
            if (caps.isSeparateBlendEquationsSupported()) {
                final int blendEqAlpha = getGLEquationValue(state.getBlendEquationAlpha(), caps);
                if (record.blendEqRGB != blendEqRGB || record.blendEqAlpha != blendEqAlpha) {
                    EXTBlendEquationSeparate.glBlendEquationSeparateEXT(blendEqRGB, blendEqAlpha);
                    record.blendEqRGB = blendEqRGB;
                    record.blendEqAlpha = blendEqAlpha;
                }
            } else if (caps.isBlendEquationSupported()) {
                if (record.blendEqRGB != blendEqRGB) {
                    ARBImaging.glBlendEquation(blendEqRGB);
                    record.blendEqRGB = blendEqRGB;
                }
            }
        } else if (record.blendEnabled) {
            GL11.glDisable(GL11.GL_BLEND);
            record.blendEnabled = false;
        }

    } else {
        if (enabled) {
            GL11.glEnable(GL11.GL_BLEND);
            record.blendEnabled = true;
            final int blendEqRGB = getGLEquationValue(state.getBlendEquationRGB(), caps);
            if (caps.isSeparateBlendEquationsSupported()) {
                final int blendEqAlpha = getGLEquationValue(state.getBlendEquationAlpha(), caps);
                EXTBlendEquationSeparate.glBlendEquationSeparateEXT(blendEqRGB, blendEqAlpha);
                record.blendEqRGB = blendEqRGB;
                record.blendEqAlpha = blendEqAlpha;
            } else if (caps.isBlendEquationSupported()) {
                ARBImaging.glBlendEquation(blendEqRGB);
                record.blendEqRGB = blendEqRGB;
            }
        } else {
            GL11.glDisable(GL11.GL_BLEND);
            record.blendEnabled = false;
        }
    }
}