@Override protected void init() { // don't call super here, as we don't want to init LWJGL ctx.init(); }
/** * Changes the size of the PlayN window. */ public void setSize(int pixelWidth, int pixelHeight, boolean fullscreen) { setDisplayMode(pixelWidth, pixelHeight, fullscreen); ctx.setSize(pixelWidth, pixelHeight); }
public void paint(GroupLayerGL rootLayer) { if (rootLayer.size() > 0) { checkGLError("paint"); bindFramebuffer(); gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear to transparent rootLayer.paint(rootXform, Tint.NOOP_TINT, null); // paint all the layers useShader(null); // flush any pending shader } if (STATS_ENABLED) stats.frames++; }
@Override public boolean startClipped(int x, int y, int width, int height) { flush(); // flush any pending unclipped calls Rectangle r = pushScissorState(x, curFbufHeight - y - height, width, height); gl.glScissor(r.x, r.y, r.width, r.height); if (getScissorDepth() == 1) gl.glEnable(GL_SCISSOR_TEST); return !r.isEmpty(); }
@Override public void endClipped() { flush(); // flush our clipped calls with SCISSOR_TEST still enabled Rectangle r = popScissorState(); if (r == null) gl.glDisable(GL_SCISSOR_TEST); else gl.glScissor(r.x, r.y, r.width, r.height); }
public void init() { gl.glDisable(GL_CULL_FACE); gl.glEnable(GL_BLEND); gl.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); gl.glClearColor(0, 0, 0, 1); if (quadShader != null) { quadShader.clearProgram(); } if (trisShader != null) { trisShader.clearProgram(); } quadShader = createQuadShader(); trisShader = new IndexedTrisShader(this); checkGLError("initGL"); }
@Override public void texImage2D(Image image, int target, int level, int internalformat, int format, int type) { gl.glTexImage2D(target, level, internalformat, (int) image.width(), (int) image.height(), 0, format, type, getRgba(image)); }
public JavaGraphics(JavaPlatform platform, JavaPlatform.Config config) { this.platform = platform; // if we're being run in headless mode, create a stub GL context which does not trigger the // initialization of LWJGL; this allows tests to run against non-graphics services without // needing to configure LWJGL native libraries this.ctx = config.headless ? new GL20Context(platform, null, config.scaleFactor, false) : new JavaGLContext(platform, config.scaleFactor); this.rootLayer = new GroupLayerGL(ctx); // set up the dummy font contexts Graphics2D aaGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics(); aaGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); aaFontContext = aaGfx.getFontRenderContext(); Graphics2D aGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics(); aGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); aFontContext = aGfx.getFontRenderContext(); if (!config.headless) { setDisplayMode(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height), config.fullscreen); } }
public GL20Context(AbstractPlatform platform, GL20 gl, float scaleFactor, boolean checkErrors) { super(platform, scaleFactor); this.gl = gl; this.checkErrors = checkErrors; // create our root transform with our scale factor rootXform = createTransform(); rootXform.uniformScale(scaleFactor); }
@Override public int createTexture(int width, int height, boolean repeatX, boolean repeatY, boolean mm) { int tex = createTexture(repeatX, repeatY, mm); gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); return tex; }
@Override public void destroyTexture(int tex) { flush(); // flush in case this texture is queued up to be drawn gl.glDeleteTextures(1, new int[] { tex }, 0); }
@Override public void texSubImage2D(Image image, int target, int level, int xOffset, int yOffset, int format, int type) { gl.glTexSubImage2D(target, level, xOffset, yOffset, (int) image.width(), (int) image.height(), format, type, getRgba(image)); }
public JavaGraphics(JavaPlatform platform, JavaPlatform.Config config) { this.platform = platform; // if we're being run in headless mode, create a stub GL context which does not trigger the // initialization of LWJGL; this allows tests to run against non-graphics services without // needing to configure LWJGL native libraries this.ctx = config.headless ? new GL20Context(platform, null, config.scaleFactor, false) : new JavaGLContext(platform, config.scaleFactor); this.rootLayer = new GroupLayerGL(ctx); // set up the dummy font contexts Graphics2D aaGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics(); aaGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); aaFontContext = aaGfx.getFontRenderContext(); Graphics2D aGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics(); aGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); aFontContext = aGfx.getFontRenderContext(); if (!config.headless) { setDisplayMode(ctx.scale.scaledCeil(config.width), ctx.scale.scaledCeil(config.height), config.fullscreen); } }
/** * Changes the size of the PlayN window. */ public void setSize(int pixelWidth, int pixelHeight, boolean fullscreen) { setDisplayMode(pixelWidth, pixelHeight, fullscreen); ctx.setSize(pixelWidth, pixelHeight); }
@Override protected void init() { // don't call super here, as we don't want to init LWJGL ctx.init(); }
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); makeCurrent(); // SWTGraphics.this.platform.log().info("Resized " + bounds.width + "x" + bounds.height); ctx.setSize(ctx.scale.invScaledFloor(bounds.width), ctx.scale.invScaledFloor(bounds.height)); } });
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); makeCurrent(); // SWTGraphics.this.platform.log().info("Resized " + bounds.width + "x" + bounds.height); ctx.setSize(ctx.scale.invScaledFloor(bounds.width), ctx.scale.invScaledFloor(bounds.height)); } });