com.watabou.gltextures.TextureCache Java Examples
The following examples show how to use
com.watabou.gltextures.TextureCache.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WndInfoBuff.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
public WndInfoBuff(Buff buff){ super(); IconTitle titlebar = new IconTitle(); icons = TextureCache.get( Assets.BUFFS_LARGE ); film = new TextureFilm( icons, 16, 16 ); Image buffIcon = new Image( icons ); buffIcon.frame( film.get(buff.icon()) ); buff.tintIcon(buffIcon); titlebar.icon( buffIcon ); titlebar.label( Messages.titleCase(buff.toString()), Window.TITLE_COLOR ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); RenderedTextBlock txtInfo = PixelScene.renderTextBlock(buff.desc(), 6); txtInfo.maxWidth(WIDTH); txtInfo.setPos(titlebar.left(), titlebar.bottom() + 2*GAP); add( txtInfo ); resize( WIDTH, (int)txtInfo.bottom() + 2 ); }
Example #2
Source File: NinePatch.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
public NinePatch( Object tx, int x, int y, int w, int h, int left, int top, int right, int bottom ) { super( 0, 0, 0, 0 ); texture = TextureCache.get( tx ); w = w == 0 ? texture.width : w; h = h == 0 ? texture.height : h; nWidth = width = w; nHeight = height = h; vertices = new float[16]; quads = Quad.createSet( 9 ); marginLeft = left; marginRight = right; marginTop = top; marginBottom= bottom; outterF = texture.uvRect( x, y, x + w, y + h ); innerF = texture.uvRect( x + left, y + top, x + w - right, y + h - bottom ); updateVertices(); }
Example #3
Source File: CircleArc.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
public CircleArc( int triangles, float radius ) { super( 0, 0, 0, 0 ); texture = TextureCache.createSolid( 0xFFFFFFFF ); this.nTris = triangles; this.rad = radius; vertices = ByteBuffer. allocateDirect( (nTris * 2 + 1) * 4 * (Float.SIZE / 8) ). order( ByteOrder.nativeOrder() ). asFloatBuffer(); indices = ByteBuffer. allocateDirect( nTris * 3 * Short.SIZE / 8 ). order( ByteOrder.nativeOrder() ). asShortBuffer(); sweep = 1f; updateTriangles(); }
Example #4
Source File: NinePatch.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
public NinePatch( Object tx, int x, int y, int w, int h, int left, int top, int right, int bottom ) { super( 0, 0, 0, 0 ); texture = TextureCache.get( tx ); w = w == 0 ? texture.width : w; h = h == 0 ? texture.height : h; nWidth = width = w; nHeight = height = h; vertices = new float[16]; verticesBuffer = Quad.createSet( 9 ); marginLeft = left; marginRight = right; marginTop = top; marginBottom= bottom; outterF = texture.uvRect( x, y, x + w, y + h ); innerF = texture.uvRect( x + left, y + top, x + w - right, y + h - bottom ); updateVertices(); }
Example #5
Source File: Halo.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
public Halo() { super(); if (!TextureCache.contains( CACHE_KEY )) { Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 ); Canvas canvas = new Canvas( bmp ); Paint paint = new Paint(); paint.setColor( 0xFFFFFFFF ); canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint ); paint.setColor( 0x88FFFFFF ); canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint ); TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) ); } texture( CACHE_KEY ); origin.set( RADIUS ); }
Example #6
Source File: TextureFilm.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
public TextureFilm( Object tx, int width, int height ) { texture = TextureCache.get( tx ); texWidth = texture.width; texHeight = texture.height; float uw = (float)width / texWidth; float vh = (float)height / texHeight; int cols = texWidth / width; int rows = texHeight / height; for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { RectF rect = new RectF( j * uw, i * vh, (j+1) * uw, (i+1) * vh ); add( i * cols + j, rect ); } } }
Example #7
Source File: TextureFilm.java From PD-classes with GNU General Public License v3.0 | 6 votes |
public TextureFilm( Object tx, int width, int height ) { SmartTexture texture = TextureCache.get( tx ); texWidth = texture.width; texHeight = texture.height; float uw = (float)width / texWidth; float vh = (float)height / texHeight; int cols = texWidth / width; int rows = texHeight / height; for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { RectF rect = new RectF( j * uw, i * vh, (j+1) * uw, (i+1) * vh ); add( i * cols + j, rect ); } } }
Example #8
Source File: TextureFilm.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
public TextureFilm( Object tx, int width, int height ) { SmartTexture texture = TextureCache.get( tx ); texWidth = texture.width; texHeight = texture.height; float uw = (float)width / texWidth; float vh = (float)height / texHeight; int cols = texWidth / width; int rows = texHeight / height; for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { RectF rect = new RectF( j * uw, i * vh, (j+1) * uw, (i+1) * vh ); add( i * cols + j, rect ); } } }
Example #9
Source File: CircleArc.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public CircleArc( int triangles, float radius ) { super( 0, 0, 0, 0 ); texture = TextureCache.createSolid( 0xFFFFFFFF ); this.nTris = triangles; this.rad = radius; vertices = ByteBuffer. allocateDirect( (nTris * 2 + 1) * 4 * (Float.SIZE / 8) ). order( ByteOrder.nativeOrder() ). asFloatBuffer(); indices = ByteBuffer. allocateDirect( nTris * 3 * Short.SIZE / 8 ). order( ByteOrder.nativeOrder() ). asShortBuffer(); sweep = 1f; updateTriangles(); }
Example #10
Source File: WndInfoBuff.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public WndInfoBuff(Buff buff){ super(); IconTitle titlebar = new IconTitle(); icons = TextureCache.get( Assets.BUFFS_LARGE ); film = new TextureFilm( icons, 16, 16 ); Image buffIcon = new Image( icons ); buffIcon.frame( film.get(buff.icon()) ); titlebar.icon( buffIcon ); titlebar.label( Utils.capitalize(buff.toString()), Window.TITLE_COLOR ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); BitmapTextMultiline txtInfo = PixelScene.createMultiline(buff.desc(), 6); txtInfo.maxWidth = WIDTH; txtInfo.measure(); txtInfo.x = titlebar.left(); txtInfo.y = titlebar.bottom() + GAP; add( txtInfo ); resize( WIDTH, (int)(txtInfo.y + txtInfo.height()) ); }
Example #11
Source File: CircleMask.java From remixed-dungeon with GNU General Public License v3.0 | 6 votes |
public static void ensureTexture() { if (!TextureCache.contains( CACHE_KEY )) { Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 ); Canvas canvas = new Canvas( bmp ); Paint paint = new Paint(); canvas.drawColor(Color.WHITE, PorterDuff.Mode.SRC); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); paint.setColor( 0xf7ffffff); canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint ); paint.setColor( 0x77ffffff); canvas.drawCircle( RADIUS, RADIUS, RADIUS*0.75f, paint ); paint.setColor( 0x00ffffff); canvas.drawCircle( RADIUS, RADIUS, RADIUS*0.5f, paint ); TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) ); } }
Example #12
Source File: WndInfoBuff.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public WndInfoBuff(Buff buff){ super(); IconTitle titlebar = new IconTitle(); icons = TextureCache.get( Assets.Interfaces.BUFFS_LARGE ); film = new TextureFilm( icons, 16, 16 ); Image buffIcon = new Image( icons ); buffIcon.frame( film.get(buff.icon()) ); buff.tintIcon(buffIcon); titlebar.icon( buffIcon ); titlebar.label( Messages.titleCase(buff.toString()), Window.TITLE_COLOR ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); RenderedTextBlock txtInfo = PixelScene.renderTextBlock(buff.desc(), 6); txtInfo.maxWidth(WIDTH); txtInfo.setPos(titlebar.left(), titlebar.bottom() + 2*GAP); add( txtInfo ); resize( WIDTH, (int)txtInfo.bottom() + 2 ); }
Example #13
Source File: Halo.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public Halo() { super(); if (!TextureCache.contains( CACHE_KEY )) { Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 ); Canvas canvas = new Canvas( bmp ); Paint paint = new Paint(); paint.setColor( 0xFFFFFFFF ); canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint ); paint.setColor( 0x88FFFFFF ); canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint ); TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) ); } texture( CACHE_KEY ); origin.set( RADIUS ); }
Example #14
Source File: TextureFilm.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public TextureFilm( Object tx, int width, int height ) { texture = TextureCache.get( tx ); texWidth = texture.width; texHeight = texture.height; float uw = (float)width / texWidth; float vh = (float)height / texHeight; int cols = texWidth / width; int rows = texHeight / height; for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { RectF rect = new RectF( j * uw, i * vh, (j+1) * uw, (i+1) * vh ); add( i * cols + j, rect ); } } }
Example #15
Source File: Halo.java From remixed-dungeon with GNU General Public License v3.0 | 6 votes |
public Halo() { if (!TextureCache.contains( CACHE_KEY )) { Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 ); Canvas canvas = new Canvas( bmp ); Paint paint = new Paint(); paint.setColor( 0xFFFFFFFF ); canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint ); paint.setColor( 0x88FFFFFF ); canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint ); TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) ); } texture( CACHE_KEY ); origin.set( RADIUS ); }
Example #16
Source File: Halo.java From pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public Halo() { super(); if (!TextureCache.contains( CACHE_KEY )) { Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 ); Canvas canvas = new Canvas( bmp ); Paint paint = new Paint(); paint.setColor( 0xFFFFFFFF ); canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint ); paint.setColor( 0x88FFFFFF ); canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint ); TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) ); } texture( CACHE_KEY ); origin.set( RADIUS ); }
Example #17
Source File: Game.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override public void resize( int width, int height ) { Gdx.gl.glViewport( 0, 0, width, height ); if (width != Game.width || height != Game.height) { Game.width = width; Game.height = height; Scene sc = scene(); if (sc != null) { TextureCache.reload(); Camera.reset(); switchScene(sc.getClass()); } } }
Example #18
Source File: NinePatch.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public NinePatch( Object tx, int x, int y, int w, int h, int left, int top, int right, int bottom ) { super( 0, 0, 0, 0 ); texture = TextureCache.get( tx ); w = w == 0 ? texture.width : w; h = h == 0 ? texture.height : h; nWidth = width = w; nHeight = height = h; vertices = new float[16]; quads = Quad.createSet( 9 ); marginLeft = left; marginRight = right; marginTop = top; marginBottom= bottom; outterF = texture.uvRect( x, y, x + w, y + h ); innerF = texture.uvRect( x + left, y + top, x + w - right, y + h - bottom ); updateVertices(); }
Example #19
Source File: Archs.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void createChildren() { arcsBg = new SkinnedBlock( 1, 1, Assets.Interfaces.ARCS_BG ){ @Override protected NoosaScript script() { return NoosaScriptNoLighting.get(); } @Override public void draw() { //arch bg has no alpha component, this improves performance Blending.disable(); super.draw(); Blending.enable(); } }; arcsBg.autoAdjust = true; arcsBg.offsetTo( 0, offsB ); add( arcsBg ); arcsFg = new SkinnedBlock( 1, 1, Assets.Interfaces.ARCS_FG ){ @Override protected NoosaScript script() { return NoosaScriptNoLighting.get(); } }; arcsFg.autoAdjust = true; arcsFg.offsetTo( 0, offsF ); add( arcsFg ); darkness= new Image(TextureCache.createGradient(0x00000000, 0x22000000, 0x55000000, 0x99000000, 0xEE000000)); darkness.angle = 90; add(darkness); }
Example #20
Source File: Spell.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public Image image(Char caster) { val texture = TextureCache.get(texture()); var spellImage = new Image(texture); spellImage.frame(new TextureFilm(texture, 16, 16).get(getImage(caster))); return spellImage; }
Example #21
Source File: Halo.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public Halo() { super(); if (!TextureCache.contains( CACHE_KEY )) { Pixmap pixmap = new Pixmap(RADIUS * 2, RADIUS * 2, Pixmap.Format.RGBA8888); pixmap.setColor( 0xFFFFFF0A ); for (int i = 0; i < 50; i++) { pixmap.fillCircle(RADIUS, RADIUS, (int)(RADIUS * (i+1)/50f)); } TextureCache.add( CACHE_KEY, new SmartTexture( pixmap ) ); } texture( CACHE_KEY ); }
Example #22
Source File: CheckedCell.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public CheckedCell( int pos ) { super( TextureCache.createSolid( 0xFF55AAFF ) ); origin.set( 0.5f ); point( DungeonTilemap.tileToWorld( pos ).offset( DungeonTilemap.SIZE / 2, DungeonTilemap.SIZE / 2 ) ); alpha = 0.8f; }
Example #23
Source File: Game.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void resize(int width, int height) { if (width == 0 || height == 0){ return; } //If the EGL context was destroyed, we need to refresh some data stored on the GPU. // This checks that by seeing if GLVersion has a new object reference if (versionContextRef != Gdx.graphics.getGLVersion()) { versionContextRef = Gdx.graphics.getGLVersion(); Blending.useDefault(); TextureCache.reload(); Vertexbuffer.refreshAllBuffers(); } if (height != Game.height || width != Game.width) { Game.width = width; Game.height = height; //TODO might be better to put this in platform support if (Gdx.app.getType() != Application.ApplicationType.Android){ Game.dispWidth = Game.width; Game.dispHeight = Game.height; } resetScene(); } }
Example #24
Source File: HeroSprite.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public static TextureFilm tiers() { if (tiers == null) { SmartTexture texture = TextureCache.get( Assets.Sprites.ROGUE ); tiers = new TextureFilm( texture, texture.width, FRAME_HEIGHT ); } return tiers; }
Example #25
Source File: ItemSprite.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public static int pick( int index, int x, int y ) { SmartTexture tx = TextureCache.get( Assets.Sprites.ITEMS ); int rows = tx.width / SIZE; int row = index / rows; int col = index % rows; return tx.getPixel( col * SIZE + x, row * SIZE + y ); }
Example #26
Source File: ModernHeroSpriteDef.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private void applyLayersDesc(String[] lookDesc) { clearLayers(); for(int i = 0;i<layersOrder.length && i<lookDesc.length;++i){ addLayer(layersOrder[i], TextureCache.get(lookDesc[i])); } deathEffect = new CustomClipEffect(deathEffectDesc, (int)width, (int)height); }
Example #27
Source File: Halo.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
public Halo() { super(); if (!TextureCache.contains( CACHE_KEY )) { Pixmap pixmap = new Pixmap(2*RADIUS+1, 2*RADIUS+1, Pixmap.Format.RGBA8888); pixmap.setColor( 0xFFFFFF08 ); for (int i = 0; i < RADIUS; i+=2) { pixmap.fillCircle(RADIUS, RADIUS, (RADIUS - i)); } TextureCache.add( CACHE_KEY, new SmartTexture( pixmap ) ); } texture( CACHE_KEY ); }
Example #28
Source File: Game.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public void onSurfaceCreated() { Blending.useDefault(); //refreshes texture and vertex data stored on the gpu TextureCache.reload(); Vertexbuffer.refreshAllBuffers(); }
Example #29
Source File: FogOfWar.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override public void destroy() { super.destroy(); if (texture != null){ TextureCache.remove(FogOfWar.class); } }
Example #30
Source File: HealthIndicator.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void createChildren() { bg = new Image( TextureCache.createSolid( 0xFFcc0000 ) ); bg.Scale().y = HEIGHT; add( bg ); level = new Image( TextureCache.createSolid( 0xFF00cc00 ) ); level.Scale().y = HEIGHT; add( level ); }