
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;

import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;

import com.jogamp.opengl.util.texture.TextureIO;

public class Mipmap {

	public static void main(String[] args) throws IllegalArgumentException,
			IOException {

		System.setProperty("jogl.texture.nonpot", "true");
		
		GLProfile glp = GLProfile.getDefault();
		GLCapabilities caps = new GLCapabilities(glp);
		final GLCanvas canvas = new GLCanvas(caps);
		final Frame frame = new Frame();
		frame.setSize(256, 256);
		frame.add(canvas, BorderLayout.CENTER);
		frame.addNotify();
		frame.setVisible(true);
		
		canvas.addGLEventListener(new GLEventListener() {
			
			public void reshape(GLAutoDrawable drawable, int x, int y, int width,
					int height) {
			}
			
			@Override
			public void init(GLAutoDrawable drawable) {
				try {
					TextureIO.newTexture(getClass().getClassLoader().getResource("com/kablab/jogl/test/tick_hor_major.png"), true, "png");
				} catch (Exception e) {
					e.printStackTrace();
				} 
			}
			
			@Override
			public void dispose(GLAutoDrawable drawable) {
			}
			
			@Override
			public void display(GLAutoDrawable drawable) {
			}
		});
		
		frame.addWindowListener(new WindowListener() {
			
			@Override
			public void windowOpened(WindowEvent e) {
			}
			
			@Override
			public void windowIconified(WindowEvent e) {
			}
			
			@Override
			public void windowDeiconified(WindowEvent e) {
			}
			
			@Override
			public void windowDeactivated(WindowEvent e) {
			}
			
			@Override
			public void windowClosing(WindowEvent e) {
				e.getWindow().dispose();
			}
			
			public void windowClosed(WindowEvent e) {
			}
			
			@Override
			public void windowActivated(WindowEvent e) {
			}
		});
	}

}