Example usage for org.eclipse.swt.opengl GL glViewport

List of usage examples for org.eclipse.swt.opengl GL glViewport

Introduction

In this page you can find the example usage for org.eclipse.swt.opengl GL glViewport.

Prototype

public static native void glViewport(int x, int y, int width, int height);

Source Link

Usage

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

static void resize(GLCanvas canvas) {
    canvas.setCurrent();// w ww  .  j a  v  a 2 s.c om
    Rectangle rect = canvas.getClientArea();
    int width = rect.width;
    int height = Math.max(rect.height, 1);
    GL.glViewport(0, 0, width, height);
    GL.glMatrixMode(GL.GL_PROJECTION);
    GL.glLoadIdentity();
    float aspect = (float) width / (float) height;
    GLU.gluPerspective(45.0f, aspect, 0.5f, 400.0f);
    GL.glMatrixMode(GL.GL_MODELVIEW);
    GL.glLoadIdentity();
}

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

static void resize(Canvas canvas) {
    Rectangle rect = canvas.getClientArea();
    int width = rect.width;
    int height = Math.max(rect.height, 1);
    GL.glViewport(0, 0, width, height);
    GL.glMatrixMode(GL.GL_PROJECTION);/*w ww  .  j  a  v  a2s .c o m*/
    GL.glLoadIdentity();
    float aspect = (float) width / (float) height;
    GLU.gluPerspective(45.0f, aspect, 0.5f, 400.0f);
    GL.glMatrixMode(GL.GL_MODELVIEW);
    GL.glLoadIdentity();
}