本文整理汇总了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();
}
示例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();
}
示例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();
}
}
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例10: isDrawable
import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
public boolean isDrawable() {
GLCanvas canvas = scene.getContext();
if (canvas == null) {
return false;
}
return !canvas.isDisposed();
}
示例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();
}
}
示例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;
}
示例13: hackCanvas
import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
@Override public void hackCanvas (GLCanvas canvas) {
OS.objc_msgSend(canvas.view.id, sel_setWantsBestResolutionOpenGLSurface_, true);
}
示例14: getContext
import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
public GLCanvas getContext() {
return canvas;
}
示例15: getCanvas
import org.eclipse.swt.opengl.GLCanvas; //导入依赖的package包/类
/**
* @return the canvas
*/
public GLCanvas getCanvas() {
return canvas;
}