decal = genTexture(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, decal); BufferedImage img = readPNGImage("demos/data/images/decal_image.png"); makeRGBTexture(gl, img, GL.GL_TEXTURE_2D, true); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);  light_image = genTexture(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, light_image); img = readPNGImage("demos/data/images/nvlogo_spot.png"); makeRGBTexture(gl, img, GL.GL_TEXTURE_2D, true); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
try { decal = TextureIO.newTexture(getClass().getClassLoader().getResourceAsStream("demos/data/images/decal_image.png"), true, TextureIO.PNG); decal.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); decal.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); light_image = TextureIO.newTexture(getClass().getClassLoader().getResourceAsStream("demos/data/images/nvlogo_spot.png"), true, TextureIO.PNG); } catch (IOException e) { throw new GLException(e); }
  public void init(GLAutoDrawable drawable) {    // Use debug pipeline    // drawable.setGL(new DebugGL(drawable.getGL()));    GL gl = drawable.getGL();    glu = new GLU();    glut = new GLUT();    try {      checkExtension(gl, "GL_VERSION_1_3"); // For multitexture      checkExtension(gl, "GL_ARB_depth_texture");      checkExtension(gl, "GL_ARB_shadow");      checkExtension(gl, "GL_ARB_pbuffer");      checkExtension(gl, "GL_ARB_pixel_format");    } catch (GLException e) {      e.printStackTrace();      throw(e);    }          gl.glClearColor(.5f, .5f, .5f, .5f);    decal = genTexture(gl);    gl.glBindTexture(GL.GL_TEXTURE_2D, decal);    BufferedImage img = readPNGImage("demos/data/images/decal_image.png");    makeRGBTexture(gl, img, GL.GL_TEXTURE_2D, true);    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR);    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);    light_image = genTexture(gl);    gl.glBindTexture(GL.GL_TEXTURE_2D, light_image);    img = readPNGImage("demos/data/images/nvlogo_spot.png");    makeRGBTexture(gl, img, GL.GL_TEXTURE_2D, true);    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);    quad = gl.glGenLists(1);    gl.glNewList(quad, GL.GL_COMPILE);    gl.glPushMatrix();    gl.glRotatef(-90, 1, 0, 0);    gl.glScalef(4,4,4);    gl.glBegin(GL.GL_QUADS);    gl.glNormal3f(0, 0, 1);    gl.glVertex2f(-1, -1);    gl.glVertex2f(-1,  1);    gl.glVertex2f( 1,  1);    gl.glVertex2f( 1, -1);    gl.glEnd();    gl.glPopMatrix();    gl.glEndList();    wirecube = gl.glGenLists(1);    gl.glNewList(wirecube, GL.GL_COMPILE);    glut.glutWireCube(2);    gl.glEndList();    geometry = gl.glGenLists(1);    gl.glNewList(geometry, GL.GL_COMPILE);    gl.glPushMatrix();    glut.glutSolidTeapot(0.8f);    gl.glPopMatrix();    gl.glEndList();    gl.glEnable(GL.GL_LIGHT0);    gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, light_ambient, 0);    gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, light_intensity, 0);    gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, light_intensity, 0);    gl.glEnable(GL.GL_DEPTH_TEST);    // init pbuffer    GLCapabilities caps = new GLCapabilities();    caps.setDoubleBuffered(false);          if (!GLDrawableFactory.getFactory().canCreateGLPbuffer()) {      unavailableExtension("Can not create pbuffer");    }    if (pbuffer != null) {      pbuffer.destroy();      pbuffer = null;    }    pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(caps, null, TEX_SIZE, TEX_SIZE, drawable.getContext());    pbuffer.addGLEventListener(new PbufferListener());    doViewAll = true;    // Register the window with the ManipManager    ManipManager manager = ManipManager.getManipManager();    manager.registerWindow(drawable);    this.drawable = drawable;    object = new HandleBoxManip();    object.setTranslation(new Vec3f(0, 0.7f, 1.8f));    object.setGeometryScale(new Vec3f(0.7f, 0.7f, 0.7f));    manager.showManipInWindow(object, drawable);    spotlight = new HandleBoxManip();    spotlight.setScale(new Vec3f(0.5f, 0.5f, 0.5f));    spotlight.setTranslation(new Vec3f(-0.25f, 2.35f, 5.0f));    spotlight.setRotation(new Rotf(Vec3f.X_AXIS, (float) Math.toRadians(-30.0f)));    manager.showManipInWindow(spotlight, drawable);    viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons());    viewer.attach(drawable, new BSphereProvider() {        public BSphere getBoundingSphere() {          return new BSphere(object.getTranslation(), 2.0f);        }      });    viewer.setOrientation(new Rotf(Vec3f.Y_AXIS, (float) Math.toRadians(45.0f)).times                          (new Rotf(Vec3f.X_AXIS, (float) Math.toRadians(-15.0f))));    viewer.setVertFOV((float) Math.toRadians(lightshaper_fovy / 2.0f));    viewer.setZNear(zNear);    viewer.setZFar(zFar);    float bias = 1/((float) Math.pow(2.0,16.0)-1);    tweaks.add(new Tweak("r coordinate scale",    0.5f, bias));    tweaks.add(new Tweak("r coordinate bias",     0.5f, bias));    tweaks.add(new Tweak("polygon offset scale",  2.5f, 0.5f));    tweaks.add(new Tweak("polygon offset bias",  10.0f, 1.0f));    drawable.addKeyListener(new KeyAdapter() {        public void keyPressed(KeyEvent e) {          dispatchKey(e.getKeyChar());          demoListener.repaint();        }      });  }