本文整理汇总了Java中javax.media.opengl.awt.GLCanvas类的典型用法代码示例。如果您正苦于以下问题:Java GLCanvas类的具体用法?Java GLCanvas怎么用?Java GLCanvas使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GLCanvas类属于javax.media.opengl.awt包,在下文中一共展示了GLCanvas类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initComponents
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
//TODO:check how to repleace this deprecated method
//gLCanvas1 = new GLCanvas(null, null, org.geoimage.viewer.core.SumoPlatform.getApplication().getGeoContext().getGLContext(), null);
gLCanvas1 = new GLCanvas();//null, null, org.geoimage.viewer.core.SumoPlatform.getApplication().getMainCanvas().getContext(), null);
jCheckBox1 = new javax.swing.JCheckBox();
setTitle("Zoom");
setAlwaysOnTop(true);
setBackground(java.awt.Color.white);
setBounds(new java.awt.Rectangle(0, 0, 256, 256));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
getContentPane().add(gLCanvas1, java.awt.BorderLayout.CENTER);
jCheckBox1.setText("Automatic Contrast");
jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox1ActionPerformed(evt);
}
});
getContentPane().add(jCheckBox1, java.awt.BorderLayout.PAGE_END);
pack();
}
示例2: Picking
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
Picking()
{
Frame frame = new Frame("Picking Example");
GLCapabilities capabilities = new GLCapabilities(null);
GLCanvas drawable = new GLCanvas(capabilities);
final Renderer renderer = new Renderer();
drawable.addGLEventListener(renderer);
drawable.addMouseListener(renderer);
drawable.addMouseMotionListener(renderer);
frame.add(drawable);
frame.setSize(400, 400);
final Animator animator = new Animator(drawable);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
animator.stop();
System.exit(0);
}
});
frame.setVisible(true);
animator.start();
}
示例3: GAIAPanel
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
public GAIAPanel(GLCanvas canvas, MarkerPanel markerPanel, PoiBar poiBar, ScreenshotLayer screenshotLayer) {
super();
// Divide panel.
setLayout(new BorderLayout());
// Create components.
this.canvas = canvas;
this.markerPanel = markerPanel;
this.poiBar = poiBar;
createComponents(screenshotLayer);
// Add components.
add(toolBar, BorderLayout.NORTH);
add(canvas, BorderLayout.CENTER);
add(poiBar, BorderLayout.EAST);
add(markerPanel, BorderLayout.WEST);
validate();
setPreferredSize(getPreferredSize());
setVisible(true);
}
示例4: MainWindow
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
public MainWindow(GLCanvas canvas, MarkerPanel markerPanel, PoiBar poiBar, ScreenshotLayer screenshotLayer) {
JFrame frame = new JFrame("GAIA");
ImageIcon frameIcon = createIcon("/sep/gaia/renderer/icons/logo.png");
//frame.setIconImage(frameIcon.getImage());
//setNativeLookAndFeel();
// Divide main frame: Menu bar in the north, "rest" in center.
frame.setLayout(new BorderLayout());
// Add menu bar.
frame.getContentPane().add(new GAIAMenu(frame, markerPanel, poiBar), BorderLayout.NORTH);
// Add main panel.
frame.getContentPane().add(new GAIAPanel(canvas, markerPanel, poiBar, screenshotLayer), BorderLayout.CENTER);
// Create and add the info-bar at the windows bottom:
infoBar = new GAIAInfoBar();
frame.getContentPane().add(infoBar, BorderLayout.SOUTH);
// Prepare main frame for getting visible.
frame.setMinimumSize(new Dimension(800, 480));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
示例5: getOpenGLProblems
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
public static String getOpenGLProblems()
{
GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
caps.setAlphaBits(8);
caps.setRedBits(8);
caps.setGreenBits(8);
caps.setBlueBits(8);
caps.setDepthBits(24);
caps.setDoubleBuffered(true);
GLCanvas canvas = new GLCanvas(caps);
OpenGLTestCapabilities testClass = new OpenGLTestCapabilities();
canvas.addGLEventListener(testClass);
return testClass.messages.toString();
}
示例6: testOpenGL
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
private static boolean testOpenGL()
{
GLCapabilities caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
caps.setAlphaBits(8);
caps.setRedBits(8);
caps.setGreenBits(8);
caps.setBlueBits(8);
caps.setDepthBits(24);
caps.setDoubleBuffered(true);
GLCanvas canvas = new GLCanvas(caps);
OpenGLTestCapabilities testClass = new OpenGLTestCapabilities();
canvas.addGLEventListener(testClass);
testedPreviously = true;
previouslyTestedAsOpenGLCapable = !testClass.fail;
return !testClass.fail;
}
示例7: initUI
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
private void initUI() {
this.width = 600;
this.height = 400;
GLCapabilities config = new GLCapabilities(GLProfile.get(GLProfile.GL2));
config.setSampleBuffers(true);
config.setNumSamples(4);
GLCanvas canvas = new GLCanvas(config);
canvas.addGLEventListener(this);
usi.init(canvas);
JFrame frame = new JFrame("JOGL-JOCL Interoperability Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(canvas);
frame.setSize(width, height);
frame.setVisible(true);
}
示例8: main
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
GLProfile.initSingleton();
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
GLCanvas canvas = new GLCanvas(caps);
Frame frame = new Frame("Test Surface rendering in JOGL 2 using nurbs or eval-mesh");
frame.setSize(300, 300);
frame.add(canvas);
frame.setVisible(true);
// by default, an AWT Frame doesn't do anything when you click
// the close button; this bit of code will terminate the program when
// the window is asked to close
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
canvas.addGLEventListener(new SurfaceTest());
FPSAnimator animator = new FPSAnimator(canvas, 5);
//animator.add(canvas);
animator.start();
}
示例9: createUI_90_OpenGL
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
private void createUI_90_OpenGL(final Composite parent) {
_glCanvas = new GLCanvas(_glCaps);
_glCanvas.addGLEventListener(new GLInfo());
_glCanvas.setSize(10, 10);
// set parent griddata, this must be done AFTER the content is created, otherwise it fails !!!
// GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
// build GUI: container(SWT) -> Frame(AWT) -> Panel(AWT) -> WorldWindowGLCanvas(AWT)
_mapContainer = _tk.createComposite(parent, SWT.EMBEDDED);
GridDataFactory.fillDefaults().hint(10, 20).applyTo(_mapContainer);
{
_awtFrame = SWT_AWT.new_Frame(_mapContainer);
final java.awt.Panel awtPanel = new java.awt.Panel(new java.awt.BorderLayout());
_awtFrame.add(awtPanel);
awtPanel.add(_glCanvas, BorderLayout.CENTER);
}
_mapContainer.setVisible(false);
parent.layout();
}
示例10: Scene
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
Scene(Kengine kengine){
this.kengine = kengine;
GLProfile glprofile = GLProfile.getDefault();
GLCapabilities glcapabilities = new GLCapabilities( glprofile );
canvas = new GLCanvas(glcapabilities);
canvas.setSize(kengine.getWidth(), kengine.getHeight());
canvas.addGLEventListener(this);
canvas.addMouseMotionListener(mkMouseAdapter());
canvas.addMouseListener(mkMouseAdapter());
canvas.addKeyListener(mkKeyAdapter());
canvas.requestFocus();
fpsa = new FPSAnimator(canvas,60,true);
fpsa.start();
kengine.add(canvas);
hideCursor();
try {
rob = new Robot();
} catch (AWTException e) {
e.printStackTrace();
}
mouseCenter = (int) (kengine.getHeight()*.5);
}
示例11: setup
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
/**
* Create the GLCanvas and set properties for the graphics device
* initialization, such as bits per channel. And advanced features for
* improved rendering performance such as the stencil buffer.
*/
private void setup() {
GLProfile glp = GLProfile.getDefault();
// Specifies a set of OpenGL capabilities, based on your profile.
GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(true);
caps.setHardwareAccelerated(true);
// create the canvas for drawing
canvas = new GLCanvas(caps);
// create the render thread
anim = new Animator();
// add the canvas to the main window
add(canvas, BorderLayout.CENTER);
// need this to receive callbacks for rendering (i.e. display() method)
canvas.addGLEventListener(this);
}
示例12: Renderer
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
public Renderer(Callback c, KeyListener k) {
callback = c;
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
canvas = new GLCanvas(caps);
setTitle("Rainbot");
setSize(camera.getDim()[0], camera.getDim()[1]);
canvas.setIgnoreRepaint(true);
canvas.addGLEventListener(this);
if(k==null)
k=this;
canvas.addKeyListener(k);
canvas.setVisible(true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
add(canvas, java.awt.BorderLayout.CENTER);
setVisible(true);
}
示例13: mouseDragged
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
@Override
public void mouseDragged(MouseEvent e)
{
this.mousePoint = e.getPoint();
calcMousePositionWorld();
calcMousePositionCamera();
double width = (double)((GLCanvas)this.wd).getWidth();
double height = (double)((GLCanvas)this.wd).getHeight();
double fovX = this.wd.getView().getFovWidtht();
double fovY = this.wd.getView().getFovHeight();
double moveX = - e.getPoint().x + this.mousePositionStart.x;
double moveY = e.getPoint().y - this.mousePositionStart.y;
Vec4 move = new Vec4(moveX, moveY);
this.mousePositionStart = e.getPoint();
Vec4 newCamPosition = this.wd.getView().getPosition()
.add3(move.transformBy3(Matrix.fromScale(2.0d * fovX/width, 2.0d * fovY/height, 0.0d)));
// System.out.println("MOUSE POS: " + e.getPoint().x + " , " + e.getPoint().y);
this.wd.getView().setPosition(newCamPosition);
this.wd.redraw();
}
示例14: MainWindow
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
public MainWindow(CSpaceViewer viewer) {
GLProfile glp = GLProfile.get(GLProfile.GL2);
GLCapabilities glc = new GLCapabilities(glp);
glc.setSampleBuffers(true);
glc.setNumSamples(8);
glc.setDepthBits(32);
canvas = new GLCanvas(glc);
animator = new FPSAnimator(canvas, 60);
toolBar = new MainToolBar(viewer);
setTitle("Configuration Space Visualization");
setLayout(new BorderLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1280, 720);
setLocationRelativeTo(null);
getContentPane().add(toolBar, BorderLayout.SOUTH);
getContentPane().add(canvas, BorderLayout.CENTER);
canvas.addGLEventListener(emptyScene);
animator.start();
}
示例15: run
import javax.media.opengl.awt.GLCanvas; //导入依赖的package包/类
@Override
public void run() {
GLCanvas canvas = new Scene();
canvas.setPreferredSize(new Dimension(Constant.CANVAS_WIDTH,
Constant.CANVAS_HEIGHT));
JFrame frame = new JFrame();
frame.getContentPane().add(canvas);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
new Thread(new CloseTask()).start();
}
});
frame.setTitle(Constant.TITLE);
frame.pack();
frame.setVisible(true);
MouseListenerImpl mouseListen = new MouseListenerImpl();
canvas.addMouseListener(mouseListen);
canvas.addMouseMotionListener(mouseListen);
while (true) {
canvas.display();
}
}