• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GLCanvas类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.swt.opengl.GLCanvas的典型用法代码示例。如果您正苦于以下问题:Java GLCanvas类的具体用法?Java GLCanvas怎么用?Java GLCanvas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GLCanvas类属于org.eclipse.swt.opengl包,在下文中一共展示了GLCanvas类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: drawScene

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
@Override
public void drawScene(float mouseX, float mouseY) {
    final GLCanvas canvas = cp.getCanvas();

    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(cp.getCapabilities());
    }
    
    GL11.glColorMask(true, true, true, true);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
    
    Rectangle bounds = cp.getBounds();
    GL11.glViewport(0, 0, bounds.width, bounds.height);
    
    shaderProgram.use();
    GL30.glBindVertexArray(VAO);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
    GL30.glBindVertexArray(0);
    
    canvas.swapBuffers();
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:24,代码来源:vboWithRGBA.java


示例2: drawScene

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
@Override
public void drawScene(float mouseX, float mouseY) {
    final GLCanvas canvas = cp.getCanvas();

    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(cp.getCapabilities());
    }
    
    GL11.glColorMask(true, true, true, true);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
    
    Rectangle bounds = cp.getBounds();
    GL11.glViewport(0, 0, bounds.width, bounds.height);
    
    shaderProgram.use();
    GL30.glBindVertexArray(VAO);
    // GL20.glEnableVertexAttribArray(POSITION_SHADER_LOCATION); // <-- Not necessary!
    GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0);
    // GL20.glDisableVertexAttribArray(POSITION_SHADER_LOCATION); // <-- Not necessary!
    GL30.glBindVertexArray(0);
    
    canvas.swapBuffers();
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:26,代码来源:vboWithIndices.java


示例3: disposeOldTextures

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
/**
 * Disposes old textures
 */
public synchronized void disposeOldTextures() {
    final GLCanvas canvas = c3d.getCanvas();
    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(c3d.getCapabilities());
    }
    Iterator<GTexture> ti = textureSet.iterator();
    for (GTexture tex = null; ti.hasNext() && (tex = ti.next()) != null;) {
        if (tex.isTooOld()) {
            NLogger.debug(getClass(), "Dispose old texture: {0}", tex); //$NON-NLS-1$
            tex.dispose(this);
            ti.remove();
        }
    }
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:19,代码来源:OpenGLRenderer.java


示例4: setup

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
private static void setup( GLCanvas glcanvas, GLContext glcontext ) {
    Rectangle rectangle = glcanvas.getClientArea();

    glcanvas.setCurrent();
    glcontext.makeCurrent();

    GL2 gl = glcontext.getGL().getGL2();
    gl.glMatrixMode( GL2.GL_PROJECTION );
    gl.glLoadIdentity();

    // coordinate system origin at lower left with width and height same as the window
    GLU glu = new GLU();
    glu.gluOrtho2D( 0.0f, rectangle.width, 0.0f, rectangle.height );

    gl.glMatrixMode( GL2.GL_MODELVIEW );
    gl.glLoadIdentity();

    gl.glViewport( 0, 0, rectangle.width, rectangle.height );
    glcontext.release();
}
 
开发者ID:momega,项目名称:spacesimulator,代码行数:21,代码来源:Main.java


示例5: render

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
private static void render( GLCanvas glcanvas, GLContext glcontext ) {
    Rectangle rectangle = glcanvas.getClientArea();

    glcanvas.setCurrent();
    glcontext.makeCurrent();

    GL2 gl = glcontext.getGL().getGL2();
    gl.glClear( GL.GL_COLOR_BUFFER_BIT );

    // draw a triangle filling the window
    gl.glLoadIdentity();
    gl.glBegin( GL.GL_TRIANGLES );
    gl.glColor3f( 1, 0, 0 );
    gl.glVertex2f( 0, 0 );
    gl.glColor3f( 0, 1, 0 );
    gl.glVertex2f( rectangle.width, 0 );
    gl.glColor3f( 0, 0, 1 );
    gl.glVertex2f( rectangle.width / 2, rectangle.height );
    gl.glEnd();

    glcanvas.swapBuffers();
    glcontext.release();
}
 
开发者ID:momega,项目名称:spacesimulator,代码行数:24,代码来源:Main.java


示例6: createPartControl

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
@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);
}
 
开发者ID:vobject,项目名称:maru,代码行数:27,代码来源:GLMapView.java


示例7: getTexture

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
/**
 * Load a texture into OpenGL from a image reference on disk.
 * 
 * @param context
 *            The location of the resource to load
 * @param bufferedImage Das Image
 * @param target
 *            The GL target to load the texture against
 * @return The loaded texture.
 * @throws LWJGLException 
 */
public static Texture getTexture(GLCanvas context, BufferedImage bufferedImage, int target) throws LWJGLException
{
	// System.out.println("Textur: " + textureID);
	Texture texture = new Texture(context);
	
	texture.width = bufferedImage.getWidth();
	texture.height = bufferedImage.getHeight();

	// convert that image into a byte buffer of texture data
	texture.buffer = convertImageData(bufferedImage, texture);
	texture.target = target;
	
	if (bufferedImage.getColorModel().hasAlpha())
		texture.pixelFormat = GL_RGBA;
	else
		texture.pixelFormat = GL_RGB;

	createTexture(texture);
	
	return texture;
}
 
开发者ID:TheWhiteShadow3,项目名称:cuina,代码行数:33,代码来源:TextureLoader.java


示例8: SWTGraphics

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
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);
}
 
开发者ID:playn,项目名称:playn,代码行数:35,代码来源:SWTGraphics.java


示例9: convertToBacking

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
@Override public void convertToBacking (GLCanvas canvas, Rectangle bounds) {
  // the below is the way we're *supposed* to handle Retina displays, but for whatever unknown
  // reason it just returns a 1x size regardless of the actual backing scale

  // NSSize backingSize = new NSSize();
  // backingSize.width = bounds.width;
  // backingSize.height = bounds.height;
  // convertSizeToBacking(canvas.view, backingSize);

  // so instead we use the deprecated API above (getting the screen backing scale factor) and
  // then forcibly apply that to the bounds
  bounds.width = FloatMath.iceil(bounds.width * screenScale);
  bounds.height = FloatMath.iceil(bounds.height * screenScale);
}
 
开发者ID:playn,项目名称:playn,代码行数:15,代码来源:SWTMacHack.java


示例10: isDrawable

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
public boolean isDrawable() {
  GLCanvas canvas = scene.getContext();
  if (canvas == null) {
    return false;
  }
  return !canvas.isDisposed();
}
 
开发者ID:google,项目名称:depan,代码行数:8,代码来源:Refresher.java


示例11: disposeAllTextures

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
/**
 * Disposes all textures
 */
public void disposeAllTextures() {
    final GLCanvas canvas = c3d.getCanvas();
    if (!canvas.isCurrent()) {
        canvas.setCurrent();
        GL.setCapabilities(c3d.getCapabilities());
    }
    for (Iterator<GTexture> it = textureSet.iterator() ; it.hasNext();) {
        GTexture tex = it.next();
        NLogger.debug(getClass(), "Dispose texture: {0}", tex); //$NON-NLS-1$
        tex.dispose(this);
        it.remove();
    }
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:17,代码来源:OpenGLRenderer.java


示例12: Texture

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
Texture(GLCanvas context, Texture source)
{
	this(context);
	buffer = source.buffer;
	target = source.target;
	width = source.width;
	height = source.height;
	texWidth = source.texWidth;
	texHeight = source.texHeight;
	pixelFormat = source.pixelFormat;
}
 
开发者ID:TheWhiteShadow3,项目名称:cuina,代码行数:12,代码来源:Texture.java


示例13: hackCanvas

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
@Override public void hackCanvas (GLCanvas canvas) {
  OS.objc_msgSend(canvas.view.id, sel_setWantsBestResolutionOpenGLSurface_, true);
}
 
开发者ID:playn,项目名称:playn,代码行数:4,代码来源:SWTMacHack.java


示例14: getContext

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
public GLCanvas getContext() {
  return canvas;
}
 
开发者ID:google,项目名称:depan,代码行数:4,代码来源:GLScene.java


示例15: getCanvas

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
/**
 * @return the canvas
 */
public GLCanvas getCanvas() {
    return canvas;
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:7,代码来源:Composite3D.java


示例16: getCanvas

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
public GLCanvas getCanvas() {
    return canvas;
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:4,代码来源:CompositePrimitive.java


示例17: Editor3DWindow

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
/**
 * Create the application window.
 */
public Editor3DWindow() {
    super();
    final int[] i = new int[1];
    final int[] j = new int[1];
    final GLCanvas[] first1 = ViewIdleManager.firstCanvas;
    final OpenGLRenderer[] first2 = ViewIdleManager.firstRender;
    final int[] intervall = new int[] { 10 };
    Display.getCurrent().asyncExec(new Runnable() {
        @Override
        public void run() {
            if (ViewIdleManager.pause[0].get()) {
                ViewIdleManager.pause[0].set(false);
                intervall[0] = 500;
            } else {
                final int cs = canvasList.size();
                if (i[0] < cs && cs > 0) {
                    GLCanvas canvas;
                    if (!canvasList.get(i[0]).equals(first1[0])) {
                        canvas = first1[0];
                        if (canvas != null && !canvas.isDisposed()) {
                            first2[0].drawScene();
                            first1[0] = null;
                            first2[0] = null;
                        }
                    }
                    canvas = canvasList.get(i[0]);
                    if (!canvas.isDisposed()) {
                        boolean stdMode = ViewIdleManager.renderLDrawStandard[0].get();
                        // FIXME Needs workaround since SWT upgrade to 4.5!
                        if (renders.get(i[0]).getC3D().getRenderMode() != 5 || cs == 1 || stdMode) {
                            renders.get(i[0]).drawScene();
                            if (stdMode) {
                                j[0]++;
                            }
                        }
                    } else {
                        canvasList.remove(i[0]);
                        renders.remove(i[0]);
                    }
                    i[0]++;
                } else {
                    i[0] = 0;
                    if (j[0] > cs) {
                        j[0] = 0;
                        ViewIdleManager.renderLDrawStandard[0].set(false);
                    }
                }
            }
            Display.getCurrent().timerExec(intervall[0], this);
            intervall[0] = 10;
        }
    });
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:57,代码来源:Editor3DWindow.java


示例18: main

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
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();
}
 
开发者ID:momega,项目名称:spacesimulator,代码行数:46,代码来源:Main.java


示例19: main

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
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();
    }
 
开发者ID:momega,项目名称:spacesimulator,代码行数:62,代码来源:OneTriangleSWT.java


示例20: getContainer

import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
@Override
public GLCanvas getContainer()
{
    return (GLCanvas) super.getContainer();
}
 
开发者ID:vobject,项目名称:maru,代码行数:6,代码来源:GLMapView.java



注:本文中的org.eclipse.swt.opengl.GLCanvas类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SerialPortException类代码示例发布时间:2022-05-23
下一篇:
Java AttachmentEx类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap