当前位置: 首页>>代码示例>>Java>>正文


Java GLCanvas类代码示例

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


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


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