本文整理汇总了Java中javax.media.opengl.GLCanvas.getGL方法的典型用法代码示例。如果您正苦于以下问题:Java GLCanvas.getGL方法的具体用法?Java GLCanvas.getGL怎么用?Java GLCanvas.getGL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.opengl.GLCanvas
的用法示例。
在下文中一共展示了GLCanvas.getGL方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: renderHalo
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
public void renderHalo( GLCanvas canvas, Renderer renderer )
{
GL gl = canvas.getGL();
if( renderer.getCamera().getScale() > 1 )
{
float elapsed_seconds = (renderer.getSystemTime() - start_time ) / 1000000000.0f;
float x = -(float)Math.sin( Math.toRadians(root.angle) );
float y = (float)Math.cos( Math.toRadians(root.angle) );
float alpha = 1;
if( renderer.getCamera().getScale() > 20 )
alpha = 1;
else
alpha = Math.min(1 - ( 20 - renderer.getCamera().getScale()) / 19.0f, 1 );
halo_size += grow_direction * 0.3f * elapsed_seconds;
if( halo_size < 0.49f )
grow_direction = 1;
if( halo_size > 1 )
grow_direction = -1;
float size = 0.11f + 0.66f * halo_size;
gl.glColor4f( col.getR(), col.getG(), col.getB(), scale * alpha );
gl.glTexCoord2f( 0, 0 );
gl.glVertex2f( pos.x - 100 * x, pos.y - 100 * y );
gl.glTexCoord2f( 1, 0 );
gl.glVertex2f( pos.x + 100 * x, pos.y + 100 * y );
gl.glTexCoord2f( 1, 1 );
gl.glVertex2f( pos.x + 100 * x + y * 2000 * size, pos.y + 100 * y - x * 2000 * size );
gl.glTexCoord2f( 0, 1 );
gl.glVertex2f( pos.x - 100 * x + y * 2000 * size, pos.y - 100 * y - x * 2000 * size);
start_time = renderer.getSystemTime();
}
}
示例3: renderTreeButton
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
private void renderTreeButton( GLCanvas canvas, Planet planet )
{
if( planet == null )
return;
if( is_replay )
return;
tmp.set( 1, 1 ).nor().mul( selected_planet.getRadius() * 1.2f);
float a_x = cam.getWorldToScreenX( selected_planet.getPosition().x + tmp.x + tmp.x / 3);
float a_y = cam.getWorldToScreenY( selected_planet.getPosition().y + tmp.y + tmp.y / 3);
float p_x = cam.getWorldToScreenX( selected_planet.getPosition().x + tmp.x );
float p_y = cam.getWorldToScreenY( selected_planet.getPosition().y + tmp.y );
GL gl = canvas.getGL();
if( selected_planet.owner == loop.getClient().getPlayer().getId() )
{
if( selected_planet.getMoveableCreatures( loop.getClient().getPlayer().getId() ) >= Constants.TREE_COST )
{
gl.glColor3f( 0.7f, 0.7f, 1 );
gl.glBegin( GL.GL_LINES );
gl.glVertex2f( p_x, p_y );
gl.glVertex2f( a_x, a_y );
gl.glVertex2f( a_x, a_y );
gl.glVertex2f( a_x + 20, a_y );
gl.glEnd();
a_x += 25;
a_y -= font.getHeight();
if( tree_button == null )
tree_button = new Button( );
tree_button.render( a_x, a_y + 32 );
}
}
}
示例4: renderMarks
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
private void renderMarks(GLCanvas canvas)
{
for( Planet planet: sim.getPlanets() )
{
if( planet.getResources() == 0 && planet.getOwner() == loop.getClient().getPlayer().getId() )
{
tmp.set( -1, 1 ).nor().mul( planet.getRadius() * 1.4f);
float a_x = cam.getWorldToScreenX( planet.getPosition().x + tmp.x );
float a_y = cam.getWorldToScreenY( planet.getPosition().y + tmp.y );
GL gl = canvas.getGL();
gl.glColor3f( 1, 1, 1 );
mark.bind(0);
gl.glBegin( GL.GL_QUADS );
gl.glTexCoord2f( 0, 0 );
gl.glVertex2f( a_x, a_y );
gl.glTexCoord2f( 1, 0 );
gl.glVertex2f( a_x - 16, a_y );
gl.glTexCoord2f( 1, 1 );
gl.glVertex2f( a_x - 16, a_y - 16 );
gl.glTexCoord2f( 0, 1 );
gl.glVertex2f( a_x, a_y - 16 );
gl.glEnd( );
mark.unbind();
}
}
}
示例5: render
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
public void render( GLCanvas canvas )
{
GL gl = canvas.getGL();
gl.glColor3f( 0, 0.8f, 0 );
float angle_rad = (float)Math.toRadians( angle );
gl.glNormal3f( angle_rad, pos.x, pos.y );
gl.glVertex2f( -1 * Constants.BOID_SIZE, 0.5f * Constants.BOID_SIZE );
gl.glVertex2f( -1 * Constants.BOID_SIZE, -0.5f * Constants.BOID_SIZE );
gl.glVertex2f( 1 * Constants.BOID_SIZE, 0 );
}
示例6: render
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
@Override
public void render(GLCanvas canvas)
{
GL gl = canvas.getGL();
gl.glColor4f( bg_col.getR(), bg_col.getG(), bg_col.getB(), bg_col.getA() );
renderQuad( pos.x, pos.y, width, height );
gl.glColor4f( fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA() );
float scale = 0;
if( max_value != min_value )
scale = ( value - min_value )/ ( max_value - min_value );
renderQuad( pos.x, pos.y, width * scale, height );
}
示例7: render
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
public void render( GLCanvas canvas )
{
GL gl = canvas.getGL();
gl.glColor4f( bg_col.getR(), bg_col.getG(), bg_col.getB(), bg_col.getA() );
renderQuad( pos.x, pos.y, width, height );
gl.glColor4f( border_col.getR(), border_col.getG(), border_col.getB(), border_col.getA() );
renderOutlinedQuad( pos.x, pos.y, width, height );
super.render( canvas );
}
示例8: render
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
@Override
public void render(GLCanvas canvas)
{
gui.getGL().glColor4f( bg_col.getR(), bg_col.getG(), bg_col.getB(), bg_col.getA() );
renderQuad(pos.x, pos.y, width, height);
GL gl = canvas.getGL();
if( texture != null )
{
texture.bind(0);
gl.glColor4f( fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA() );
gl.glBegin( GL.GL_QUADS );
gl.glTexCoord2f( 0, 0 );
gl.glVertex2f( pos.x, pos.y );
gl.glTexCoord2f( texture.getImageWidth() / texture.getWidth(), 0 );
gl.glVertex2f( pos.x + width, pos.y );
gl.glTexCoord2f( texture.getImageWidth() / texture.getWidth(), texture.getImageHeight() / texture.getHeight() );
gl.glVertex2f( pos.x + width, pos.y - height );
gl.glTexCoord2f( 0, texture.getImageHeight() / texture.getHeight() );
gl.glVertex2f( pos.x, pos.y - height );
gl.glEnd();
texture.unbind();
}
gui.getGL().glColor4f( border_col.getR(), border_col.getG(), border_col.getB(), border_col.getA() );
renderOutlinedQuad( pos.x, pos.y, width, height );
}
示例9: render
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
public void render( GLCanvas canvas, boolean use_lod )
{
GL gl = canvas.getGL();
float angle_rad = (float)Math.toRadians( angle );
if( !dead )
{
gl.glColor3f( r, g, b );
if( !use_lod )
{
gl.glNormal3f( angle_rad, pos.x, pos.y );
for( int i = 0; i < 18; i+=2 )
gl.glVertex3f( points[i], points[i+1], scale );
}
else
gl.glVertex2f( pos.x, pos.y );
}
else
{
float dx = vel.x * death_time;
float dy = vel.y * death_time;
gl.glColor4f( r, g, b, scale );
if( !use_lod )
{
gl.glNormal3f( angle_rad, pos.x, pos.y );
for( int i = 0; i < 6; i+= 2 )
gl.glVertex3f( points[i] + dx, points[i+1] + dy, 1 );
for( int i = 6; i < 12; i+= 2 )
gl.glVertex3f( points[i] + dy, points[i+1] + dx, 1 );
for( int i = 12; i < 18; i+= 2 )
gl.glVertex3f( points[i] + dy, points[i+1] - dx, 1 );
}
else
gl.glVertex2f( pos.x, pos.y );
}
}
示例10: readSimulation
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
private void readSimulation( GLCanvas canvas )
{
Message msg = null;
try {
msg = quantum.getClient().readMessage();
} catch (Exception e)
{
Log.println( "[GameMenu] error while reading message from server: " + e.getMessage() );
hideMenu( );
cont = new ScreenAlignementContainer( gui, HorizontalAlignement.CENTER, VerticalAlignement.CENTER );
cont.setZOrder( 10000 );
ConfirmDialog dialog = new ConfirmDialog( gui, "Disconnected!\n" + e.getMessage(), "Error", new ClickedListener() {
public void clicked(Widget widget) {
removeBots( );
quantum.closeServerAndClient();
quantum.removeDisplayListener( self );
gui.getCanvas().removeKeyListener( self );
loop.dispose();
gui.remove( cont );
hideMenu( );
removeChat( );
SoundManager.stopAll();
new StartMenu(quantum, gui);
}
});
cont.addWidget( dialog );
gui.add( cont );
return;
}
if( msg != null )
{
if( msg instanceof SimulationMessage )
{
SimulationMessage sim_msg = (SimulationMessage)msg;
this.sim = sim_msg.getSimulation();
this.sim.setClient(quantum.getClient());
if( loop == null )
loop = new GameLoop( quantum.getClient(), sim );
else
loop.setSimulation( sim );
}
}
GL gl = canvas.getGL();
gl.glClear( GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT );
ortho_mat.setToOrtho2D(0, 0, canvas.getWidth(), canvas.getHeight() );
gl.glLoadMatrixf( ortho_mat.toFloatBuffer() );
gui.getDefaultFont().renderText( 10, canvas.getHeight(), "Awaiting game state" );
}
示例11: render
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
@Override
public void render(GLCanvas canvas)
{
GL gl = canvas.getGL();
gui.getGL().glColor4f( bg_col.getR(), bg_col.getG(), bg_col.getB(), bg_col.getA() );
renderQuad(pos.x, pos.y, width, height);
gl.glColor4f( border_col.getR(), border_col.getG(), border_col.getB(), border_col.getA() );
renderOutlinedQuad( pos.x, pos.y, width, height );
renderOutlinedQuad( pos.x + width - SCROLL_SIZE, pos.y, SCROLL_SIZE, height );
renderOutlinedQuad( pos.x + width - SCROLL_SIZE, pos.y, SCROLL_SIZE, SCROLL_SIZE);
renderOutlinedQuad( pos.x + width - SCROLL_SIZE, pos.y - height + SCROLL_SIZE, SCROLL_SIZE, SCROLL_SIZE );
if( !upper_hover )
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_LINE );
gl.glBegin( GL.GL_TRIANGLES );
gl.glVertex2f( pos.x + width - SCROLL_SIZE, pos.y - SCROLL_SIZE );
gl.glVertex2f( pos.x + width, pos.y - SCROLL_SIZE);
gl.glVertex2f( pos.x + width - SCROLL_SIZE / 2, pos.y);
gl.glEnd();
if( !upper_hover )
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL );
if( !lower_hover )
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_LINE );
gl.glBegin( GL.GL_TRIANGLES );
gl.glVertex2f( pos.x + width - SCROLL_SIZE, pos.y - height + SCROLL_SIZE );
gl.glVertex2f( pos.x + width, pos.y - height + SCROLL_SIZE );
gl.glVertex2f( pos.x + width - SCROLL_SIZE / 2, pos.y - height );
gl.glEnd( );
if( !lower_hover )
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL );
gl.glColor4f( fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA() );
if( scroll_pos >= 0 && scroll_pos < lines.size() )
{
for( int i = scroll_pos, j = 0; i < lines.size() && i < scroll_pos + (int)Math.floor( height / font.getHeight()); i++, j++ )
font.renderText( (int)(pos.x + 5), (int)(pos.y - j * font.getHeight() + font.getDescent()), lines.get(i) );
}
if( uper_hold )
{
if( scroll_timer.getElapsedSeconds() > 0.1 )
{
scroll_pos = Math.max( 0, scroll_pos-1 );
scroll_timer.stop();
scroll_timer.start();
}
}
if( lower_hold )
{
if( scroll_timer.getElapsedSeconds() > 0.1 )
{
scroll_pos = Math.min( scroll_pos+1, lines.size() - 1 );
scroll_timer.stop();
scroll_timer.start();
}
}
}
示例12: render
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
@Override
public void render(GLCanvas canvas)
{
GL gl = canvas.getGL();
gui.getGL().glColor4f( bg_col.getR(), bg_col.getG(), bg_col.getB(), bg_col.getA() );
renderQuad(pos.x, pos.y, width, height);
gl.glColor4f( border_col.getR(), border_col.getG(), border_col.getB(), border_col.getA() );
renderOutlinedQuad( pos.x, pos.y, width, height );
renderOutlinedQuad( pos.x + width - SCROLL_SIZE, pos.y, SCROLL_SIZE, height );
renderOutlinedQuad( pos.x + width - SCROLL_SIZE, pos.y, SCROLL_SIZE, SCROLL_SIZE);
renderOutlinedQuad( pos.x + width - SCROLL_SIZE, pos.y - height + SCROLL_SIZE, SCROLL_SIZE, SCROLL_SIZE );
if( !upper_hover )
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_LINE );
gl.glBegin( GL.GL_TRIANGLES );
gl.glVertex2f( pos.x + width - SCROLL_SIZE, pos.y - SCROLL_SIZE );
gl.glVertex2f( pos.x + width, pos.y - SCROLL_SIZE);
gl.glVertex2f( pos.x + width - SCROLL_SIZE / 2, pos.y);
gl.glEnd();
if( !upper_hover )
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL );
if( !lower_hover )
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_LINE );
gl.glBegin( GL.GL_TRIANGLES );
gl.glVertex2f( pos.x + width - SCROLL_SIZE, pos.y - height + SCROLL_SIZE );
gl.glVertex2f( pos.x + width, pos.y - height + SCROLL_SIZE );
gl.glVertex2f( pos.x + width - SCROLL_SIZE / 2, pos.y - height );
gl.glEnd( );
if( !lower_hover )
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL );
gl.glColor4f( fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA() );
gui.enableScissor( pos.x, pos.y - height, width - SCROLL_SIZE, height - 1 );
for( int i = scroll_pos, j = 0; i >= 0 && i < items.size() && i < scroll_pos + (int)Math.floor( height / font.getHeight()); i++, j++ )
{
if( items.get(i) == selected_item )
{
gl.glColor4f( fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA() );
renderQuad(pos.x, pos.y - j * font.getHeight(), width, font.getHeight());
gl.glColor4f( bg_col.getR(), bg_col.getG(), bg_col.getB(), bg_col.getA() );
}
else
{
gl.glColor4f( fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA() );
}
font.renderText( (int)(pos.x + 5), (int)(pos.y - j * font.getHeight() + font.getDescent()), items.get(i).toString() );
}
gui.disableScissor();
if( uper_hold )
{
if( scroll_timer.getElapsedSeconds() > 0.1 )
{
scroll_pos = Math.max( 0, scroll_pos-1 );
scroll_timer.stop();
scroll_timer.start();
}
}
if( lower_hold )
{
if( scroll_timer.getElapsedSeconds() > 0.1 )
{
scroll_pos = Math.min( scroll_pos+1, items.size() - 1 );
scroll_timer.stop();
scroll_timer.start();
}
}
}
示例13: render
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
@Override
public void render(GLCanvas canvas)
{
GL gl = canvas.getGL();
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_LINE );
gl.glLineWidth( 1.5f );
gl.glColor4f( border_col.getR(), border_col.getG(), border_col.getB(), border_col.getA() );
gl.glBegin( GL.GL_LINES );
gl.glVertex2f( pos.x, pos.y );
gl.glVertex2f( pos.x + 16, pos.y );
gl.glVertex2f( pos.x + 16, pos.y );
gl.glVertex2f( pos.x + 16, pos.y - 16);
gl.glVertex2f( pos.x + 16, pos.y - 16);
gl.glVertex2f( pos.x, pos.y - 16);
gl.glVertex2f( pos.x, pos.y - 16);
gl.glVertex2f( pos.x, pos.y );
gl.glEnd();
if( checked )
{
gl.glBegin( GL.GL_LINES );
gl.glVertex2f( pos.x, pos.y - 8 );
gl.glVertex2f( pos.x + 8, pos.y - 16 );
gl.glVertex2f( pos.x + 8, pos.y - 16);
gl.glVertex2f( pos.x + 16, pos.y );
gl.glEnd();
}
gl.glLineWidth( 1 );
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL.GL_FILL );
gl.glColor4f( fg_col.getR(), fg_col.getG(), fg_col.getB(), fg_col.getA() );
if( caption != null )
font.renderText( (int)(pos.x + 20), (int)(pos.y - 8 + font.getHeight() / 2), caption);
width = 16 + 20 + font.getWidth( caption );
}
示例14: initGLCanvas
import javax.media.opengl.GLCanvas; //导入方法依赖的package包/类
protected void initGLCanvas(){
device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
GLCapabilities caps = new GLCapabilities();
caps.setHardwareAccelerated(true);
caps.setDoubleBuffered(true);
caps.setStencilBits(settings.getStencilBits());
caps.setDepthBits(settings.getDepthBits());
if (settings.getSamples() > 1){
caps.setSampleBuffers(true);
caps.setNumSamples(settings.getSamples());
}
canvas = new GLCanvas(caps){
@Override
public void addNotify(){
super.addNotify();
onCanvasAdded();
}
@Override
public void removeNotify(){
onCanvasRemoved();
super.removeNotify();
}
};
if (settings.isVSync()){
canvas.getGL().setSwapInterval(1);
}
canvas.setFocusable(true);
canvas.setIgnoreRepaint(true);
canvas.addGLEventListener(this);
GL gl = canvas.getGL();
// if (false){
// trace mode
// jME already uses err stream, use out instead
// gl = new TraceGL(gl, System.out);
// }else if (false){
// debug mode
// gl = new DebugGL(gl);
// }else{
// production mode
// }
renderer = new JoglRenderer(gl);
}