001 package com.croftsoft.core.media.jogl; 002 003 import javax.media.opengl.GL; 004 import javax.media.opengl.GLAutoDrawable; 005 import javax.media.opengl.GLEventListener; 006 007 import com.croftsoft.core.lang.NullException; 008 import com.croftsoft.core.media.jogl.JoglRenderer; 009 010 /*********************************************************************** 011 * Adapts interface JoglRenderer to GLEventListener. 012 * 013 * @version 014 * $Id: JoglAdapter.java,v 1.4 2008/09/28 21:49:39 croft Exp $ 015 * @since 016 * 2005-08-18 017 * @author 018 * <a href="https://www.croftsoft.com/">David Wallace Croft</a> 019 ***********************************************************************/ 020 021 public final class JoglAdapter 022 implements GLEventListener 023 //////////////////////////////////////////////////////////////////////// 024 //////////////////////////////////////////////////////////////////////// 025 { 026 027 private final JoglRenderer joglRenderer; 028 029 //////////////////////////////////////////////////////////////////////// 030 // constructor methods 031 //////////////////////////////////////////////////////////////////////// 032 033 /*********************************************************************** 034 * Main constructor. 035 ***********************************************************************/ 036 public JoglAdapter ( final JoglRenderer joglRenderer ) 037 //////////////////////////////////////////////////////////////////////// 038 { 039 NullException.check ( this.joglRenderer = joglRenderer ); 040 } 041 042 //////////////////////////////////////////////////////////////////////// 043 // interface GLEventListener methods 044 //////////////////////////////////////////////////////////////////////// 045 046 public void init ( final GLAutoDrawable glAutoDrawable ) 047 //////////////////////////////////////////////////////////////////////// 048 { 049 final GL gl = glAutoDrawable.getGL ( ); 050 051 joglRenderer.init ( gl ); 052 } 053 054 public void reshape ( 055 final GLAutoDrawable glAutoDrawable, 056 final int x, 057 final int y, 058 final int width, 059 final int height ) 060 //////////////////////////////////////////////////////////////////////// 061 { 062 final GL gl = glAutoDrawable.getGL ( ); 063 064 joglRenderer.setBounds ( gl, x, y, width, height ); 065 } 066 067 public void displayChanged ( 068 final GLAutoDrawable glAutoDrawable, 069 final boolean modeChanged, 070 final boolean deviceChanged ) 071 //////////////////////////////////////////////////////////////////////// 072 { 073 // ignore 074 } 075 076 public void display ( final GLAutoDrawable glAutoDrawable ) 077 //////////////////////////////////////////////////////////////////////// 078 { 079 final GL gl = glAutoDrawable.getGL ( ); 080 081 joglRenderer.render ( gl ); 082 } 083 084 //////////////////////////////////////////////////////////////////////// 085 //////////////////////////////////////////////////////////////////////// 086 }