Example usage for org.lwjgl.opengl GL11 glHint

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

Introduction

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

Prototype

public static void glHint(@NativeType("GLenum") int target, @NativeType("GLenum") int hint) 

Source Link

Document

Certain aspects of GL behavior, when there is room for variation, may be controlled with this function.

Usage

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setProjectionPerspective(float fovy, float aspectratio, float zNear, float zFar) {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    matrix.setPerspective(fovy, aspectratio, zNear, zFar).toFloatBuffer(matrixBuffer);
    matrixBuffer.flip();/*from ww  w  .  j a v a2s  . co  m*/
    loadMatrix(matrixBuffer);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    return this;
}

From source file:org.eclipse.swt.opengl.examples.LWJGLExample.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  ww  w . ja v a  2s  .c o m*/
    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.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);

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

    display.asyncExec(new Runnable() {
        int rot = 0;

        public void run() {
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                try {
                    GLContext.useContext(canvas);
                } catch (LWJGLException e) {
                    e.printStackTrace();
                }
                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);
                rot++;
                GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
                GL11.glColor3f(0.9f, 0.9f, 0.9f);
                drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15);
                canvas.swapBuffers();
                display.asyncExec(this);
            }
        }
    });

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

From source file:org.eclipse.swt.snippets.Snippet195.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;//ww  w. j  a va  2 s. c o m
    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() {
        @Override
        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.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);

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

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

        @Override
        public void run() {
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                try {
                    GLContext.useContext(canvas);
                } catch (LWJGLException e) {
                    e.printStackTrace();
                }
                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);
                rot++;
                GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
                GL11.glColor3f(0.9f, 0.9f, 0.9f);
                drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15);
                canvas.swapBuffers();
                display.asyncExec(this);
            }
        }
    };
    canvas.addListener(SWT.Paint, new Listener() {
        @Override
        public void handleEvent(Event event) {
            run.run();
        }
    });
    display.asyncExec(run);

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

From source file:org.eclipse.swt.snippets.Snippet341.java

License:Open Source License

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    GLData data = new GLData();
    data.doubleBuffer = true;// www . j a  v a2  s . co  m
    final GLCanvas canvas = new GLCanvas(shell, SWT.NONE, data);
    canvas.setLayoutData(new GridData(640, 480));

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

    canvas.addListener(SWT.Resize, new Listener() {
        @Override
        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.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);

    Button button = new Button(shell, SWT.PUSH);
    button.setText("Capture");
    button.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event event) {
            capture(canvas);
        }
    });
    shell.pack();
    shell.open();

    display.asyncExec(new Runnable() {
        int rot = 0;

        @Override
        public void run() {
            if (!canvas.isDisposed()) {
                canvas.setCurrent();
                try {
                    GLContext.useContext(canvas);
                } catch (LWJGLException e) {
                    e.printStackTrace();
                }
                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);
                rot++;
                GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
                GL11.glColor3f(0.9f, 0.9f, 0.9f);
                drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15);
                canvas.swapBuffers();
                display.asyncExec(this);
            }
        }
    });

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

From source file:org.geekygoblin.nedetlesmaki.game.systems.DrawSystem.java

License:Open Source License

@Override
protected void processEntities(ImmutableBag<Entity> entities) {
    GL11.glClearColor(99f / 255f, 201f / 255f, 183f / 255f, 1f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    Sort.instance().sort(sprites, zComparator);

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT
            | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();//www. j a  va 2 s  .com
    GL11.glLoadIdentity();

    updateViewPort();
    GL11.glViewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height);
    GLU.gluOrtho2D(-VirtualResolution.WIDTH / 2.0f, VirtualResolution.WIDTH / 2.0f,
            VirtualResolution.HEIGHT / 2.0f, -VirtualResolution.HEIGHT / 2.0f);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

    NedGame game = (NedGame) world;
    Entity ned = game.getNed();
    if (null != ned) {
        Sprite nedSprite = spriteMapper.get(ned);
        Vector nedPos = spriteProjector.project(nedSprite.getPosition());
        GL11.glTranslatef(-nedPos.x, -nedPos.y, 0.0f);
    }

    for (Entity e : backgrounds) {
        LevelBackground level = levelBackgroundMapper.getSafe(e);
        if (null != level) {
            drawLevel(level);
        }
    }

    GL11.glPushMatrix();
    GL11.glScalef(spriteGlobalScale, spriteGlobalScale, 1.0f);
    spriteBatcher.begin();
    for (Entity e : sprites) {
        spriteBatcher.draw(spriteMapper.getSafe(e));
    }
    spriteBatcher.end();
    for (Entity e : sprites) {
        drawSpriteLabel(spriteMapper.getSafe(e));
    }
    GL11.glPopMatrix();

    for (Entity e : uis) {
        MainMenu mainMenu = mainMenuMapper.getSafe(e);
        if (null != mainMenu) {
            nuitRenderer.render(mainMenu.getRoot());
        }
        DialogComponent dialog = dialogMapper.getSafe(e);
        if (null != dialog) {
            nuitRenderer.render(dialog.getRoot());
        }
        InGameUI inGameUI = inGameUIMapper.getSafe(e);
        if (null != inGameUI) {
            nuitRenderer.render(inGameUI.getRoot());
        }
    }
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glPopAttrib();

}

From source file:org.lwjgl.info.LWJGLTestView.java

License:Open Source License

/** 
 * {@inheritDoc}/*from w ww. jav a2 s . c o m*/
 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createPartControl(Composite parent) {

    String strVersion = getFeatureVersion("org.lwjgl");
    this.setPartName("org.lwjgl " + strVersion);

    IStatusLineManager statusLine = this.getViewSite().getActionBars().getStatusLineManager();

    fpsstatuslineitem = new FpsStatusLineItem();
    statusLine.add(fpsstatuslineitem);

    GLData data = new GLData();
    data.doubleBuffer = true;
    canvas = new GLCanvas(parent, 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.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);

    Display.getCurrent().asyncExec(initRunnable());

}

From source file:org.mkdev.ai.langton3d.core.App.java

License:GNU General Public License

private boolean initGL() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*w  ww .j  a  v  a 2s.co m*/

    GLU.gluPerspective(FOV, ((float) targetWidth) / ((float) targetHeight), 0.1f, 100.0f);

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

    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glCullFace(GL11.GL_BACK);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_FASTEST);

    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

    setupLights();
    setupFog(Settings.FOG_DENSITY, Settings.FOG_START, Settings.FOG_END);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    return true;
}

From source file:org.mkdev.ai.langton3d.core.App.java

License:GNU General Public License

private void setupFog(float density, float start, float end) {
    GL11.glEnable(GL11.GL_FOG);//from w w  w . j  a v  a 2 s.c o m

    FloatBuffer fogColor = BufferUtils.createFloatBuffer(4);
    fogColor.put(Settings.FOG_COLOR_RED).put(Settings.FOG_COLOR_GREEN).put(Settings.FOG_COLOR_BLUE)
            .put(Settings.FOG_COLOR_ALPHA).flip();

    int fogMode = GL11.GL_LINEAR;
    GL11.glFogi(GL11.GL_FOG_MODE, fogMode);
    GL11.glFog(GL11.GL_FOG_COLOR, fogColor);
    GL11.glFogf(GL11.GL_FOG_DENSITY, density);
    GL11.glHint(GL11.GL_FOG_HINT, GL11.GL_NICEST);
    GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glFogf(GL11.GL_FOG_START, start);
    GL11.glFogf(GL11.GL_FOG_END, end);
}

From source file:org.oscim.gdx.LwjglGL20.java

License:Apache License

public void hint(int target, int mode) {
    GL11.glHint(target, mode);
}

From source file:org.voxels.platform.LWJGLOpenGLAdapter.java

License:Open Source License

@Override
public void glHint(final int target, final int mode) {
    GL11.glHint(target, mode);
}