Java Code Examples for com.watabou.glwrap.Quad#createSet()
The following examples show how to use
com.watabou.glwrap.Quad#createSet() .
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: 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 2
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 3
Source File: NinePatch.java From remixed-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]; 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 4
Source File: NinePatch.java From PD-classes 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: 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 6
Source File: RenderedText.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void draw(Texture texture, float[] spriteVertices, int offset, int count) { Visual v = textBeingRendered; FloatBuffer toOpenGL; if (buffers.containsKey(count/20)){ toOpenGL = buffers.get(count/20); toOpenGL.position(0); } else { toOpenGL = Quad.createSet(count / 20); buffers.put(count/20, toOpenGL); } for (int i = 0; i < count; i += 20){ vertices[0] = spriteVertices[i+0]; vertices[1] = spriteVertices[i+1]; vertices[2] = spriteVertices[i+3]; vertices[3] = spriteVertices[i+4]; vertices[4] = spriteVertices[i+5]; vertices[5] = spriteVertices[i+6]; vertices[6] = spriteVertices[i+8]; vertices[7] = spriteVertices[i+9]; vertices[8] = spriteVertices[i+10]; vertices[9] = spriteVertices[i+11]; vertices[10] = spriteVertices[i+13]; vertices[11] = spriteVertices[i+14]; vertices[12] = spriteVertices[i+15]; vertices[13] = spriteVertices[i+16]; vertices[14] = spriteVertices[i+18]; vertices[15] = spriteVertices[i+19]; toOpenGL.put(vertices); } toOpenGL.position(0); NoosaScript script = NoosaScript.get(); texture.bind(); com.watabou.glwrap.Texture.clear(); script.camera( v.camera() ); script.uModel.valueM4( v.matrix ); script.lighting( v.rm, v.gm, v.bm, v.am, v.ra, v.ga, v.ba, v.aa ); script.drawQuadSet( toOpenGL, count/20 ); }
Example 7
Source File: KeyDisplay.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
private void updateVertices(){ //assumes shorter key sprite int maxRows = (int)(height +1) / 5; //1 pixel of padding between each key int maxPerRow = (int)(width + 1) / 4; int maxKeys = maxPerRow * maxRows; while (totalKeys > maxKeys){ Class<? extends Key> mostType = null; int mostNum = 0; for (Class<?extends Key> k : keyMap.keySet()){ if (keys[keyMap.get(k)] >= mostNum){ mostType = k; mostNum = keys[keyMap.get(k)]; } } keys[keyMap.get(mostType)]--; totalKeys--; } int rows = (int)Math.ceil(totalKeys / (float)maxPerRow); boolean shortKeys = (rows * 8) > height; float left; if (totalKeys > maxPerRow){ left = 0; } else { left = (width + 1 - (totalKeys*4))/2; } float top = (height + 1 - (rows * (shortKeys ? 5 : 8)))/2; quads = Quad.createSet(totalKeys); for (int i = 0; i < totalKeys; i++){ int keyIdx = 0; if (i == 0 && keys[0] > 0){ //black key keyIdx = 0; } else { for (int j = 1; j < keys.length; j++){ if (keys[j] > 0){ keys[j]--; keyIdx = j; break; } } } //texture coordinates RectF r = tx.uvRect(43 + 3*keyIdx, shortKeys ? 8 : 0, 46 + 3*keyIdx, shortKeys ? 12 : 7); vertices[2] = r.left; vertices[3] = r.top; vertices[6] = r.right; vertices[7] = r.top; vertices[10] = r.right; vertices[11] = r.bottom; vertices[14] = r.left; vertices[15] = r.bottom; //screen coordinates vertices[0] = left; vertices[1] = top; vertices[4] = left + 3; vertices[5] = top; vertices[8] = left + 3; vertices[9] = top + (shortKeys ? 4 : 7); vertices[12] = left; vertices[13] = top + (shortKeys ? 4 : 7); quads.put(vertices); //move to the right for more keys, drop down if the row is done left += 4; if (left + 3 > width){ left = 0; top += (shortKeys ? 5 : 8); } } dirty = false; }
Example 8
Source File: Tilemap.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
public void map( int[] data, int cols ) { this.data = data; mapWidth = cols; int mapHeight = data.length / cols; size = mapWidth * mapHeight; width = cellW * mapWidth; height = cellH * mapHeight; quads = Quad.createSet( size ); updated.set( 0, 0, mapWidth, mapHeight); }
Example 9
Source File: RenderedText.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override public void draw(Texture texture, float[] spriteVertices, int offset, int count) { Visual v = textBeingRendered; FloatBuffer toOpenGL; if (buffers.containsKey(count/20)){ toOpenGL = buffers.get(count/20); toOpenGL.position(0); } else { toOpenGL = Quad.createSet(count / 20); buffers.put(count/20, toOpenGL); } for (int i = 0; i < count; i += 20){ vertices[0] = spriteVertices[i+0]; vertices[1] = spriteVertices[i+1]; vertices[2] = spriteVertices[i+3]; vertices[3] = spriteVertices[i+4]; vertices[4] = spriteVertices[i+5]; vertices[5] = spriteVertices[i+6]; vertices[6] = spriteVertices[i+8]; vertices[7] = spriteVertices[i+9]; vertices[8] = spriteVertices[i+10]; vertices[9] = spriteVertices[i+11]; vertices[10] = spriteVertices[i+13]; vertices[11] = spriteVertices[i+14]; vertices[12] = spriteVertices[i+15]; vertices[13] = spriteVertices[i+16]; vertices[14] = spriteVertices[i+18]; vertices[15] = spriteVertices[i+19]; toOpenGL.put(vertices); } toOpenGL.position(0); NoosaScript script = NoosaScript.get(); texture.bind(); com.watabou.glwrap.Texture.clear(); script.camera( v.camera() ); script.uModel.valueM4( v.matrix ); script.lighting( v.rm, v.gm, v.bm, v.am, v.ra, v.ga, v.ba, v.aa ); script.drawQuadSet( toOpenGL, count/20 ); }
Example 10
Source File: KeyDisplay.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
private void updateVertices(){ //assumes shorter key sprite int maxRows = (int)(height +1) / 5; //1 pixel of padding between each key int maxPerRow = (int)(width + 1) / 4; int maxKeys = maxPerRow * maxRows; while (totalKeys > maxKeys){ Class<? extends Key> mostType = null; int mostNum = 0; for (Class<?extends Key> k : keyMap.keySet()){ if (keys[keyMap.get(k)] >= mostNum){ mostType = k; mostNum = keys[keyMap.get(k)]; } } keys[keyMap.get(mostType)]--; totalKeys--; } int rows = (int)Math.ceil(totalKeys / (float)maxPerRow); boolean shortKeys = (rows * 8) > height; float left; if (totalKeys > maxPerRow){ left = 0; } else { left = (width + 1 - (totalKeys*4))/2; } float top = (height + 1 - (rows * (shortKeys ? 5 : 8)))/2; quads = Quad.createSet(totalKeys); for (int i = 0; i < totalKeys; i++){ int keyIdx = 0; if (i == 0 && keys[0] > 0){ //black key keyIdx = 0; } else { for (int j = 1; j < keys.length; j++){ if (keys[j] > 0){ keys[j]--; keyIdx = j; break; } } } //texture coordinates RectF r = tx.uvRect(43 + 3*keyIdx, shortKeys ? 8 : 0, 46 + 3*keyIdx, shortKeys ? 12 : 7); vertices[2] = r.left; vertices[3] = r.top; vertices[6] = r.right; vertices[7] = r.top; vertices[10] = r.right; vertices[11] = r.bottom; vertices[14] = r.left; vertices[15] = r.bottom; //screen coordinates vertices[0] = left; vertices[1] = top; vertices[4] = left + 3; vertices[5] = top; vertices[8] = left + 3; vertices[9] = top + (shortKeys ? 4 : 7); vertices[12] = left; vertices[13] = top + (shortKeys ? 4 : 7); quads.put(vertices); //move to the right for more keys, drop down if the row is done left += 4; if (left + 3 > width){ left = 0; top += (shortKeys ? 5 : 8); } } dirty = false; }
Example 11
Source File: Tilemap.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 3 votes |
public void map( int[] data, int cols ) { this.data = data; mapWidth = cols; mapHeight = data.length / cols; size = mapWidth * mapHeight; width = cellW * mapWidth; height = cellH * mapHeight; quads = Quad.createSet( size ); updated.set( 0, 0, mapWidth, mapHeight ); }
Example 12
Source File: Tilemap.java From shattered-pixel-dungeon with GNU General Public License v3.0 | 3 votes |
public void map( int[] data, int cols ) { this.data = data; mapWidth = cols; mapHeight = data.length / cols; size = mapWidth * mapHeight; width = cellW * mapWidth; height = cellH * mapHeight; quads = Quad.createSet( size ); updateMap(); }
Example 13
Source File: Tilemap.java From PD-classes with GNU General Public License v3.0 | 3 votes |
public void map( int[] data, int cols ) { this.data = data; mapWidth = cols; mapHeight = data.length / cols; size = mapWidth * mapHeight; width = cellW * mapWidth; height = cellH * mapHeight; quads = Quad.createSet( size ); updated.set( 0, 0, mapWidth, mapHeight ); }
Example 14
Source File: Tilemap.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 3 votes |
public void map( int[] data, int cols ) { this.data = data; mapWidth = cols; mapHeight = data.length / cols; size = mapWidth * mapHeight; width = cellW * mapWidth; height = cellH * mapHeight; quads = Quad.createSet( size ); updateMap(); }