Example usage for org.lwjgl.opengl GL11 glClearAccum

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

Introduction

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

Prototype

public static native void glClearAccum(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha);

Source Link

Document

Sets the clear values for the accumulation buffer.

Usage

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;/* w  ww  .  j ava 2s  .  com*/
    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:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glClearAccum(float a, float b, float c, float d) {
    GL11.glClearAccum(a, b, c, d);
}