本文整理汇总了Java中javax.media.opengl.GLCanvas类的典型用法代码示例。如果您正苦于以下问题:Java GLCanvas类的具体用法?Java GLCanvas怎么用?Java GLCanvas使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GLCanvas类属于javax.media.opengl包,在下文中一共展示了GLCanvas类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DockKey
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
/**
*
* Main constructor for the GUIOpenGL class
*
* @param glCanv : the OpenGL canvas to paint on
* @param h : the Hypership instance
*/
public GUIOpenGL(GLCanvas glCanv, Hypership h)
{
hyper = h;
key = new DockKey("OpenGL");
key.setName(" Membership View");
key.setTooltip("Explore the hyperbolic membership.");
key.setIcon(new ImageIcon("icons/member_view.gif"));
key.setCloseEnabled(false);
key.setAutoHideEnabled(false);
key.setFloatEnabled(false);
key.setMaximizeEnabled(true);
key.setResizeWeight(1f);
setLayout(new BorderLayout());
this.setDropTarget(new DropTarget(this, this));
add(glCanv, BorderLayout.CENTER);
}
示例2: GameInterface
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public GameInterface( GameLoop loop, GLCanvas canvas, Simulation sim, Renderer renderer )
{
this.canvas = canvas;
this.sim = sim;
this.cam = renderer.getCamera();
this.loop = loop;
this.renderer = renderer;
for( Planet planet: sim.getPlanets() )
{
if( planet.getOwner() == loop.getClient().getPlayer().getId() )
{
this.cam.setScale( 50 );
this.cam.moveToTarget( planet.getPosition().x, planet.getPosition().y, 15, 2 );
selected_planet = planet;
renderer.setSelectedPlanet( planet );
break;
}
}
}
示例3: renderHoverPlanetStats
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
private void renderHoverPlanetStats( GLCanvas canvas )
{
if( hover_timer.getElapsedSeconds() < delay )
return;
Point p = canvas.getMousePosition();
if( p == null )
return;
float x = cam.getScreenToWorldX( p.x);
float y = cam.getScreenToWorldY( p.y );
Planet selected_planet = sim.getPlanet( x, y );
renderPlanetStats( canvas, selected_planet );
}
示例4: display
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public void display(GLCanvas canvas) {
Thread.currentThread().setName("Networked Game Thread");
if (game_menu == null && save_menu_visible == false) {
loop.update(canvas);
for (Bot bot : bots)
bot.update(loop.getSimulation());
if (loop.getSimulation().getActivePlayers() == 1
&& !game_over_triggered) {
game_over_triggered = true;
showGameOverMenu();
}
}
loop.render(canvas);
loop.getGameInterface().setHoverDelay(quantum.getDelay());
// try {
// Thread.sleep( 1 );
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
示例5: display
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public void display(GLCanvas canvas)
{
if( loop != null )
{
try {
loop.update((GLCanvas)canvas);
loop.render((GLCanvas)canvas);
loop.getGameInterface().setIsReplay( true );
Thread.sleep( 0 );
} catch (InterruptedException e)
{
Log.println( "[Replay] couldn't do replay: " + Log.getStackTrace( e ) );
e.printStackTrace();
}
}
}
示例6: display
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public void display(GLCanvas canvas)
{
loop.update( canvas );
loop.render( canvas );
if( loop.getRenderer().getPlayerColor(2) == null )
loop.getRenderer().allocatePlayerColor( sim, 2 );
if( state == TutorialState.Camera )
doCamera( );
if( state == TutorialState.Move )
doSelection( );
if( state == TutorialState.PlantTree )
doPlantTree( );
if( state == TutorialState.Statistics )
doStatistics( );
if( state == TutorialState.Combat )
doCombat( );
if( state == TutorialState.Chain )
doChain( );
}
示例7: centerCamera
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public void centerCamera( GLCanvas canvas, Simulation sim )
{
Bounds b = new Bounds( );
for( Planet planet: sim.getPlanets() )
{
float x = planet.getPosition().x;
float y = planet.getPosition().y;
float r = planet.getRadius();
b.ext( new Vector( x + r, y, 0 ) );
b.ext( new Vector( x, y + r, 0 ) );
b.ext( new Vector( x - r, y, 0 ) );
b.ext( new Vector( x, y - r, 0 ) );
}
float width = b.getDimensions().getX();
float height = b.getDimensions().getY();
float scale = Math.max( width / canvas.getWidth(), height / canvas.getHeight() );
cam.setPosition( b.getCenter() );
cam.setScale( scale );
}
示例8: renderPlanetPaths
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public void renderPlanetPaths( GLCanvas canvas, Simulation sim, Planet planet )
{
if( planet == null )
return;
GL gl = GLContext.getCurrent().getGL();
gl.glEnable( GL.GL_BLEND );
gl.glBegin( GL.GL_LINES );
gl.glColor4f( 0.3f, 0.3f, 0.7f, 1 );
for( int id: planet.getReachablePlanets() )
{
Planet p = sim.getPlanet( id );
tmp.set(p.getPosition()).sub(planet.getPosition()).nor();
gl.glVertex2f( planet.getPosition().x + tmp.x * planet.getRadius(), planet.getPosition().y + tmp.y * planet.getRadius() );
gl.glVertex2f( p.getPosition().x + tmp.x * -p.getRadius(), p.getPosition().y + tmp.y * -p.getRadius() );
}
gl.glEnd();
gl.glDisable( GL.GL_BLEND );
planet.renderMesh( canvas, 0.9f, 0.7f, 0.7f, 1, circle );
}
示例9: renderPlanetPathsLight
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public void renderPlanetPathsLight( GLCanvas canvas, Simulation sim, Planet planet )
{
if( planet == null )
return;
GL gl = GLContext.getCurrent().getGL();
gl.glEnable( GL.GL_BLEND );
gl.glLineWidth( 1 );
gl.glBegin( GL.GL_LINES );
gl.glColor4f( 0.1f, 0.1f, 0.1f, 1 );
for( int id: planet.getReachablePlanets() )
{
Planet p = sim.getPlanet( id );
tmp.set(p.getPosition()).sub(planet.getPosition()).nor();
gl.glVertex2f( planet.getPosition().x + tmp.x * planet.getRadius(), planet.getPosition().y + tmp.y * planet.getRadius() );
gl.glVertex2f( p.getPosition().x + tmp.x * -p.getRadius(), p.getPosition().y + tmp.y * -p.getRadius() );
}
gl.glEnd();
gl.glLineWidth( 1.5f );
gl.glDisable( GL.GL_BLEND );
}
示例10: update
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public void update( GLCanvas canvas )
{
width = canvas.getWidth();
height = canvas.getHeight();
proj.setToOrtho2D(0, 0, (canvas.getWidth() * scale), (float)(canvas.getHeight() * scale), near, far );
model.idt();
model.setToTranslation( new Vector( (float)(-pos.getX() + (canvas.getWidth() / 2) * scale), (float)(-pos.getY() + (canvas.getHeight() / 2) * scale), (float)(-pos.getZ()) ) );
combined.set( proj );
combined.mul( model );
GL gl = canvas.getGL();
gl.glMatrixMode( GL.GL_PROJECTION );
gl.glLoadIdentity();
gl.glMatrixMode( GL.GL_MODELVIEW );
gl.glLoadMatrixf(combined.toFloatBuffer());
}
示例11: display
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public void display(GLAutoDrawable canvas) {
GL gl = canvas.getGL();
gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
// game.setLogging( true );
game.update((GLCanvas)canvas);
game.render((GLCanvas)canvas);
// bot.update( sim );
bot2.update( sim );
bot3.update( sim );
// bot3.update( sim );
// bot4.update( sim );
// game.getRenderer().setRenderAllPaths( true );
// game.getRenderer().useGlow( false );
try {
Thread.sleep( 0 );
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例12: run
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
/**
* スケッチを開始するにはこの関数をコールしてください。
*/
public void run()
{
this._frame= new Frame("NyARTK Sketch");
this._frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
this._canvas = new GLCanvas();
this._canvas.addGLEventListener(this);
this._canvas.addMouseListener(this);
this._canvas.addMouseMotionListener(this);
Insets ins = this._frame.getInsets();
this._frame.setSize(320 + ins.left + ins.right,240 + ins.top + ins.bottom);
this._canvas.setBounds(ins.left, ins.top,320,240);
this._frame.add(this._canvas);
this._frame.setVisible(true);
}
示例13: JavaSimpleLite_Quad
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public JavaSimpleLite_Quad()
{
Frame frame = new Frame("Java simpleLite with NyARToolkit");
// 3Dを描画するコンポーネント
GLCanvas canvas = new GLCanvas();
frame.add(canvas);
canvas.addGLEventListener(this);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.setVisible(true);
Insets ins = frame.getInsets();
frame.setSize(SCREEN_X + ins.left + ins.right, SCREEN_Y + ins.top + ins.bottom);
canvas.setBounds(ins.left, ins.top, SCREEN_X, SCREEN_Y);
}
示例14: JavaSimpleLite_X2
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public JavaSimpleLite_X2()
{
NyMath.initialize();
Frame frame = new Frame("Java simpleLite with NyARToolkit");
// 3Dを描画するコンポーネント
GLCanvas canvas = new GLCanvas();
frame.add(canvas);
canvas.addGLEventListener(this);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.setVisible(true);
Insets ins = frame.getInsets();
frame.setSize(SCREEN_X + ins.left + ins.right, SCREEN_Y + ins.top + ins.bottom);
canvas.setBounds(ins.left, ins.top, SCREEN_X, SCREEN_Y);
}
示例15: PongView
import javax.media.opengl.GLCanvas; //导入依赖的package包/类
public PongView( Rectangle worldRect ) {
super(worldRect);
lastUpdateTime = System.currentTimeMillis();
if(DEBUG)System.out.println("PongView: PongView() called");
//setWorldWindowRect(worldWindowRect);
//setWorldWindowChanged(false);
// get a GLCanvas
GLCapabilities capabilities = new GLCapabilities();
setCanvas(new GLCanvas());
// add a GLEventListener, which will get called when the
// canvas is resized or needs a repaint
getGLCanvas().addGLEventListener(this);
// instantiate inActive list
for(int i = 0; i < MAX_BALLS; i++)
inActiveBalls.add(new PongBall(0,0));
//add key listener
getGLCanvas().addKeyListener(this);
}