Java 类org.eclipse.swt.opengl.GLData 实例源码

项目:maru    文件:GLMapView.java   
@Override
public void createPartControl(Composite parent)
{
    GLData glData = new GLData();
    glData.doubleBuffer = true;

    setContainer(new GLCanvas(parent, SWT.NO_BACKGROUND, glData));
    getContainer().setLayout(new FillLayout());
    getContainer().setCurrent();

    GLProfile glProfile = GLProfile.getDefault();
    GLDrawableFactory glFactory = GLDrawableFactory.getFactory(glProfile);

    setGlContext(glFactory.createExternalGLContext());
    getGlContext().makeCurrent();
    initGLContext();

    setMapDrawer(new GLMapDrawer(this));

    addMapPaintListener();
    addMapResizeListener();
    addMouseListener();

    MaruUIPlugin.getDefault().getUiModel().addUiProjectModelListener(this);
    MaruUIPlugin.getDefault().getUiModel().addUiProjectSelectionListener(this);
}
项目:cuina    文件:GLPanel.java   
public CuinaGLCanvas(Composite parent, int style, GLData data, Runnable painter)
        {
            super(parent, SWT.NO_BACKGROUND | style, data);
            this.painter = painter;
            this.addFocusListener(this);
//          this.addListener(SWT.MouseDown, this);
//          this.addListener(SWT.MouseUp, this);
//          this.addListener(SWT.MouseExit, this);
//          this.addListener(SWT.MouseMove, this);
//          this.addListener(SWT.MouseEnter, this);

//          //XXX: Teste Drag-Support. Bisher ohne Erfolg. Keins der Events wird getriggert.
//          this.addListener(DND.DragEnter, this);
//          this.addListener(DND.DragLeave, this);
//          this.addListener(DND.DragEnd, this);
//          this.addListener(DND.DragOver, this);
//          this.addListener(DND.DragStart, this);
//          this.addListener(SWT.DragDetect, this);
        }
项目:playn    文件:SWTGraphics.java   
public SWTGraphics (SWTPlatform splat, final Composite comp) {
  super(splat);
  this.plat = splat;

  boolean isMac = "Mac OS X".equals(System.getProperty("os.name"));
  final Hack hack = isMac ? new SWTMacHack() : new Hack();

  // special scale fiddling on Mac
  scaleChanged(hack.hackScale());

  // create our GLCanvas
  GLData data = new GLData();
  data.doubleBuffer = true;
  canvas = new GLCanvas(comp, SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE, data);
  hack.hackCanvas(canvas);
  canvas.setCurrent();
  GL.createCapabilities();

  comp.addListener(SWT.Resize, new Listener() {
    public void handleEvent(Event event) {
      // resize our GLCanvas to fill the window; we do manual layout so that other SWT widgets
      // can be overlaid on top of our GLCanvas
      Rectangle bounds = comp.getBounds();
      comp.setBounds(bounds);
      canvas.setBounds(bounds);
      canvas.setCurrent();
      hack.convertToBacking(canvas, bounds);
      viewportChanged(bounds.width, bounds.height);
    }
  });

  plat.log().info("Setting size " + plat.config.width + "x" + plat.config.height);
  setSize(plat.config.width, plat.config.height, plat.config.fullscreen);
}
项目:cuina    文件:GLPanel.java   
public GLPanel(Composite parent, int swtStyle, int glStyle)
{
    if ((glStyle & LWJGL.ENABLE_3D) != 0)       use3D = true;

    if (use3D) System.err.println("3D wird (noch) nicht unterstützt!");

    GLData data = new GLData();
    data.doubleBuffer = true;
    canvas = new CuinaGLCanvas(parent, swtStyle, data, getPainter());
    canvas.setDragDetect(true);

    parent.layout();
    init();
}
项目:spacesimulator    文件:Main.java   
public static void main(String [] args) {
    GLProfile.initSingleton( );

    GLProfile glprofile = GLProfile.get( GLProfile.GL2 );

    Display display = new Display();
    Shell shell = new Shell( display );
    shell.setLayout( new FillLayout() );
    Composite composite = new Composite( shell, SWT.NONE );
    composite.setLayout( new FillLayout() );

    GLData gldata = new GLData();
    gldata.doubleBuffer = true;
    // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
    // at the wrong times (we use glClear for this instead)
    final GLCanvas glcanvas = new GLCanvas( composite, SWT.NO_BACKGROUND, gldata );
    glcanvas.setCurrent();
    final GLContext glcontext = GLDrawableFactory.getFactory( glprofile ).createExternalGLContext();

    // fix the viewport when the user resizes the window
    glcanvas.addListener( SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            setup( glcanvas, glcontext );
        }
    });

    // draw the triangle when the OS tells us that any part of the window needs drawing
    glcanvas.addPaintListener( new PaintListener() {
        public void paintControl( PaintEvent paintevent ) {
            render( glcanvas, glcontext );
        }
    });

    shell.setText( "OneTriangle" );
    shell.setSize( 640, 480 );
    shell.open();

    while( !shell.isDisposed() ) {
        if( !display.readAndDispatch() )
            display.sleep();
    }

    glcanvas.dispose();
    display.dispose();
}
项目:spacesimulator    文件:OneTriangleSWT.java   
public static void main( String [] args ) {
        Display display = new Display();
        final Shell shell = new Shell( display );
        shell.setText( "OneTriangle SWT" );
        shell.setLayout( new FillLayout() );
        shell.setSize( 640, 480 );

        final Composite composite = new Composite( shell, SWT.NONE );
        composite.setLayout( new FillLayout() );

        // canvas
        javax.media.opengl.GLProfile glprofile = GLProfile.getDefault();
        org.eclipse.swt.opengl.GLData gldata = new GLData();

        final GLCanvas glcanvas = new GLCanvas( composite, SWT.NO_BACKGROUND, gldata );
        // OpenGL context
        javax.media.opengl.GLContext glContext = GLDrawableFactory.getFactory(glprofile).
                createExternalGLContext();

        //GLData gldata = new GLData();
        //gldata.doubleBuffer = true;
        // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
        // at the wrong times (we use glClear for this instead)

        //glcanvas.setCurrent();
        //GLProfile glprofile = GLProfile.getDefault();
//        final GLContext glcontext = GLDrawableFactory.getFactory( glprofile ).createExternalGLContext();
//
//        // fix the viewport when the user resizes the window
//        glcanvas.addListener( SWT.Resize, new Listener() {
//            public void handleEvent(Event event) {
//                Rectangle rectangle = glcanvas.getClientArea();
//                glcanvas.setCurrent();
//                glcontext.makeCurrent();
//                OneTriangle.setup( glcontext.getGL().getGL2(), rectangle.width, rectangle.height );
//                glcontext.release();
//            }
//        });
//
//        // draw the triangle when the OS tells us that any part of the window needs drawing
//        glcanvas.addPaintListener( new PaintListener() {
//            public void paintControl( PaintEvent paintevent ) {
//                Rectangle rectangle = glcanvas.getClientArea();
//                glcanvas.setCurrent();
//                glcontext.makeCurrent();
//                OneTriangle.render(glcontext.getGL().getGL2(), rectangle.width, rectangle.height);
//                glcanvas.swapBuffers();
//                glcontext.release();
//            }
//        });

        shell.open();

        while( !shell.isDisposed() ) {
            if( !display.readAndDispatch() )
                display.sleep();
        }

        //glcanvas.dispose();
        display.dispose();
    }