com.watabou.glwrap.Quad Java Examples

The following examples show how to use com.watabou.glwrap.Quad. 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: NoosaScript.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public NoosaScript() {

		super();
		compile( shader() );
		
		uCamera	= uniform( "uCamera" );
		uModel	= uniform( "uModel" );
		uTex	= uniform( "uTex" );
		uColorM	= uniform( "uColorM" );
		uColorA	= uniform( "uColorA" );
		aXY		= attribute( "aXYZW" );
		aUV		= attribute( "aUV" );

		Quad.setupIndices();
		Quad.bindIndices();
		
	}
 
Example #2
Source File: NoosaScript.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public void drawQuadSet( FloatBuffer vertices, int size ) {

		if (size == 0) {
			return;
		}

		if(vertices.limit() < 16 * size){
			throw new AssertionError();
		}

		vertices.position( 0 );
		aXY.vertexPointer( 2, 4, vertices );
		
		vertices.position( 2 );
		aUV.vertexPointer( 2, 4, vertices );

		GLES20.glDrawElements( 
			GLES20.GL_TRIANGLES, 
			Quad.SIZE * size, 
			GLES20.GL_UNSIGNED_SHORT, 
			Quad.getIndices( size ) );
		
	}
 
Example #3
Source File: NinePatch.java    From PD-classes with GNU General Public License v3.0 6 votes vote down vote up
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 remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
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: NoosaScript.java    From PD-classes with GNU General Public License v3.0 6 votes vote down vote up
public void drawQuadSet( FloatBuffer vertices, int size ) {
	
	if (size == 0) {
		return;
	}
	
	vertices.position( 0 );
	aXY.vertexPointer( 2, 4, vertices );
	
	vertices.position( 2 );
	aUV.vertexPointer( 2, 4, vertices );

	GLES20.glDrawElements( 
		GLES20.GL_TRIANGLES, 
		Quad.SIZE * size, 
		GLES20.GL_UNSIGNED_SHORT, 
		Quad.getIndices( size ) );
	
}
 
Example #6
Source File: NinePatch.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
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 #7
Source File: NoosaScript.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
public NoosaScript() {
	
	super();
	compile( shader() );
	
	uCamera	= uniform( "uCamera" );
	uModel	= uniform( "uModel" );
	uTex	= uniform( "uTex" );
	uColorM	= uniform( "uColorM" );
	uColorA	= uniform( "uColorA" );
	aXY		= attribute( "aXYZW" );
	aUV		= attribute( "aUV" );

	Quad.setupIndices();
	Quad.bindIndices();

}
 
Example #8
Source File: NinePatch.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
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 #9
Source File: NinePatch.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
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 #10
Source File: NoosaScript.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public void drawQuadSet( FloatBuffer vertices, int size ) {
	
	if (size == 0) {
		return;
	}
	
	vertices.position( 0 );
	aXY.vertexPointer( 2, 4, vertices );
	
	vertices.position( 2 );
	aUV.vertexPointer( 2, 4, vertices );

	GLES20.glDrawElements( 
		GLES20.GL_TRIANGLES, 
		Quad.SIZE * size, 
		GLES20.GL_UNSIGNED_SHORT, 
		Quad.getIndices( size ) );
	
}
 
Example #11
Source File: NoosaScript.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void drawQuadSet( FloatBuffer vertices, int size ) {
	
	if (size == 0) {
		return;
	}
	
	vertices.position( 0 );
	aXY.vertexPointer( 2, 4, vertices );
	
	vertices.position( 2 );
	aUV.vertexPointer( 2, 4, vertices );
	
	Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, Quad.SIZE * size, Gdx.gl20.GL_UNSIGNED_SHORT, 0 );
}
 
Example #12
Source File: SurfaceScene.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public Sky( boolean dayTime ) {
	super( 0, 0, 1, 1 );

	texture = new Gradient( dayTime ? day : night );
	
	float[] vertices = new float[16];
	verticesBuffer = Quad.create();
	
	vertices[2]		= 0.25f;
	vertices[6]		= 0.25f;
	vertices[10]	= 0.75f;
	vertices[14]	= 0.75f;
	
	vertices[3]		= 0;
	vertices[7]		= 1;
	vertices[11]	= 1;
	vertices[15]	= 0;
	
	
	vertices[0] 	= 0;
	vertices[1] 	= 0;
	
	vertices[4] 	= 1;
	vertices[5] 	= 0;
	
	vertices[8] 	= 1;
	vertices[9] 	= 1;
	
	vertices[12]	= 0;
	vertices[13]	= 1;
	
	verticesBuffer.position( 0 );
	verticesBuffer.put( vertices );
}
 
Example #13
Source File: NinePatch.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
protected void updateVertices() {

		verticesBuffer.position( 0 );
		
		float right = width - marginRight;
		float bottom = height - marginBottom;
		
		Quad.fill( vertices, 
			0, marginLeft, 0, marginTop, outterF.left, innerF.left, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, 0, marginTop, innerF.left, innerF.right, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, 0, marginTop, innerF.right, outterF.right, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		
		Quad.fill( vertices, 
			0, marginLeft, marginTop, bottom, outterF.left, innerF.left, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, marginTop, bottom, innerF.left, innerF.right, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, marginTop, bottom, innerF.right, outterF.right, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		
		Quad.fill( vertices, 
			0, marginLeft, bottom, height, outterF.left, innerF.left, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, bottom, height, innerF.left, innerF.right, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, bottom, height, innerF.right, outterF.right, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
	}
 
Example #14
Source File: NinePatch.java    From PD-classes with GNU General Public License v3.0 5 votes vote down vote up
protected void updateVertices() {

		verticesBuffer.position( 0 );
		
		float right = width - marginRight;
		float bottom = height - marginBottom;
		
		Quad.fill( vertices, 
			0, marginLeft, 0, marginTop, outterF.left, innerF.left, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, 0, marginTop, innerF.left, innerF.right, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, 0, marginTop, innerF.right, outterF.right, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		
		Quad.fill( vertices, 
			0, marginLeft, marginTop, bottom, outterF.left, innerF.left, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, marginTop, bottom, innerF.left, innerF.right, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, marginTop, bottom, innerF.right, outterF.right, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		
		Quad.fill( vertices, 
			0, marginLeft, bottom, height, outterF.left, innerF.left, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, bottom, height, innerF.left, innerF.right, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, bottom, height, innerF.right, outterF.right, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
	}
 
Example #15
Source File: MaskedTilemapScript.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void drawQuadSet(FloatBuffer vertices, FloatBuffer mask, int size) {

        if (size == 0) {
            return;
        }

        if(vertices.limit() < 16 * size){
            throw new AssertionError();
        }

        if(mask.limit() < 8 * size){
            throw new AssertionError();
        }


        vertices.position(0);
        aXY.vertexPointer(2, 4, vertices);

        vertices.position(2);
        aUV.vertexPointer(2, 4, vertices);

        mask.position(0);
        //vertices.position(2);
        //aUV_mask.vertexPointer(2, 4, vertices);
        aUV_mask.vertexPointer(2, 2, mask);

        GLES20.glDrawElements(
                GLES20.GL_TRIANGLES,
                Quad.SIZE * size,
                GLES20.GL_UNSIGNED_SHORT,
                Quad.getIndices(size));
    }
 
Example #16
Source File: NinePatch.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
protected void updateVertices() {

		verticesBuffer.position( 0 );
		
		float right = width - marginRight;
		float bottom = height - marginBottom;
		
		Quad.fill( vertices, 
			0, marginLeft, 0, marginTop, outterF.left, innerF.left, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, 0, marginTop, innerF.left, innerF.right, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, 0, marginTop, innerF.right, outterF.right, outterF.top, innerF.top );
		verticesBuffer.put( vertices );
		
		Quad.fill( vertices, 
			0, marginLeft, marginTop, bottom, outterF.left, innerF.left, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, marginTop, bottom, innerF.left, innerF.right, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, marginTop, bottom, innerF.right, outterF.right, innerF.top, innerF.bottom );
		verticesBuffer.put( vertices );
		
		Quad.fill( vertices, 
			0, marginLeft, bottom, height, outterF.left, innerF.left, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			marginLeft, right, bottom, height, innerF.left, innerF.right, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
		Quad.fill( vertices, 
			right, width, bottom, height, innerF.right, outterF.right, innerF.bottom, outterF.bottom );
		verticesBuffer.put( vertices );
	}
 
Example #17
Source File: SurfaceScene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public Sky( boolean dayTime ) {
	super( 0, 0, 1, 1 );

	texture = new Gradient( dayTime ? day : night );
	
	float[] vertices = new float[16];
	verticesBuffer = Quad.create();
	
	vertices[2]		= 0.25f;
	vertices[6]		= 0.25f;
	vertices[10]	= 0.75f;
	vertices[14]	= 0.75f;
	
	vertices[3]		= 0;
	vertices[7]		= 1;
	vertices[11]	= 1;
	vertices[15]	= 0;
	
	
	vertices[0] 	= 0;
	vertices[1] 	= 0;
	
	vertices[4] 	= 1;
	vertices[5] 	= 0;
	
	vertices[8] 	= 1;
	vertices[9] 	= 1;
	
	vertices[12]	= 0;
	vertices[13]	= 1;
	
	verticesBuffer.position( 0 );
	verticesBuffer.put( vertices );
}
 
Example #18
Source File: SurfaceScene.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public Sky( boolean dayTime ) {
	super( 0, 0, 1, 1 );

	texture = TextureCache.createGradient( dayTime ? day : night );
	
	float[] vertices = new float[16];
	verticesBuffer = Quad.create();
	
	vertices[2]		= 0.25f;
	vertices[6]		= 0.25f;
	vertices[10]	= 0.75f;
	vertices[14]	= 0.75f;
	
	vertices[3]		= 0;
	vertices[7]		= 1;
	vertices[11]	= 1;
	vertices[15]	= 0;
	
	
	vertices[0] 	= 0;
	vertices[1] 	= 0;
	
	vertices[4] 	= 1;
	vertices[5] 	= 0;
	
	vertices[8] 	= 1;
	vertices[9] 	= 1;
	
	vertices[12]	= 0;
	vertices[13]	= 1;
	
	verticesBuffer.position( 0 );
	verticesBuffer.put( vertices );
}
 
Example #19
Source File: SurfaceScene.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public Sky( boolean dayTime ) {
	super( 0, 0, 1, 1 );

	texture = TextureCache.createGradient( dayTime ? day : night );
	
	float[] vertices = new float[16];
	verticesBuffer = Quad.create();
	
	vertices[2]		= 0.25f;
	vertices[6]		= 0.25f;
	vertices[10]	= 0.75f;
	vertices[14]	= 0.75f;
	
	vertices[3]		= 0;
	vertices[7]		= 1;
	vertices[11]	= 1;
	vertices[15]	= 0;
	
	
	vertices[0] 	= 0;
	vertices[1] 	= 0;
	
	vertices[4] 	= 1;
	vertices[5] 	= 0;
	
	vertices[8] 	= 1;
	vertices[9] 	= 1;
	
	vertices[12]	= 0;
	vertices[13]	= 1;
	
	verticesBuffer.position( 0 );
	verticesBuffer.put( vertices );
}
 
Example #20
Source File: SurfaceScene.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public Sky( boolean dayTime ) {
	super( 0, 0, 1, 1 );

	texture = new Gradient( dayTime ? day : night );
	
	float[] vertices = new float[16];
	verticesBuffer = Quad.create();
	
	vertices[2]		= 0.25f;
	vertices[6]		= 0.25f;
	vertices[10]	= 0.75f;
	vertices[14]	= 0.75f;
	
	vertices[3]		= 0;
	vertices[7]		= 1;
	vertices[11]	= 1;
	vertices[15]	= 0;
	
	
	vertices[0] 	= 0;
	vertices[1] 	= 0;
	
	vertices[4] 	= 1;
	vertices[5] 	= 0;
	
	vertices[8] 	= 1;
	vertices[9] 	= 1;
	
	vertices[12]	= 0;
	vertices[13]	= 1;
	
	verticesBuffer.position( 0 );
	verticesBuffer.put( vertices );
}
 
Example #21
Source File: NoosaScript.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void drawElements( FloatBuffer vertices, ShortBuffer indices, int size ) {
	
	vertices.position( 0 );
	aXY.vertexPointer( 2, 4, vertices );
	
	vertices.position( 2 );
	aUV.vertexPointer( 2, 4, vertices );

	Quad.releaseIndices();
	Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, size, Gdx.gl20.GL_UNSIGNED_SHORT, indices );
	Quad.bindIndices();
}
 
Example #22
Source File: NoosaScript.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public void drawElements( FloatBuffer vertices, ShortBuffer indices, int size ) {
	
	vertices.position( 0 );
	aXY.vertexPointer( 2, 4, vertices );
	
	vertices.position( 2 );
	aUV.vertexPointer( 2, 4, vertices );
	
	Quad.releaseIndices();
	Gdx.gl.glDrawElements( GL20.GL_TRIANGLES, size, GL20.GL_UNSIGNED_SHORT, indices );
	Quad.bindIndices();
}
 
Example #23
Source File: SurfaceScene.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public Sky( boolean dayTime ) {
	super( 0, 0, 1, 1 );

	texture = new Gradient( dayTime ? day : night );
	
	float[] vertices = new float[16];
	verticesBuffer = Quad.create();
	
	vertices[2]		= 0.25f;
	vertices[6]		= 0.25f;
	vertices[10]	= 0.75f;
	vertices[14]	= 0.75f;
	
	vertices[3]		= 0;
	vertices[7]		= 1;
	vertices[11]	= 1;
	vertices[15]	= 0;
	
	
	vertices[0] 	= 0;
	vertices[1] 	= 0;
	
	vertices[4] 	= 1;
	vertices[5] 	= 0;
	
	vertices[8] 	= 1;
	vertices[9] 	= 1;
	
	vertices[12]	= 0;
	vertices[13]	= 1;
	
	verticesBuffer.position( 0 );
	verticesBuffer.put( vertices );
}
 
Example #24
Source File: NoosaScript.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void drawQuadSet( Vertexbuffer buffer, int length, int offset ){

		if (length == 0) {
			return;
		}

		buffer.updateGLData();

		buffer.bind();

		aXY.vertexBuffer( 2, 4, 0 );
		aUV.vertexBuffer( 2, 4, 2 );

		buffer.release();

		Gdx.gl.glDrawElements( GL20.GL_TRIANGLES, Quad.SIZE * length, GL20.GL_UNSIGNED_SHORT, Quad.SIZE * Short.SIZE/8 * offset );

	}
 
Example #25
Source File: Image.java    From PD-classes with GNU General Public License v3.0 4 votes vote down vote up
public Image() {
	super( 0, 0, 0, 0 );
	
	vertices = new float[16];
	verticesBuffer = Quad.create();
}
 
Example #26
Source File: NinePatch.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
protected void updateVertices() {

		quads.position( 0 );
		
		float right = width - marginRight;
		float bottom = height - marginBottom;

		float outleft   = flipHorizontal ? outterF.right : outterF.left;
		float outright  = flipHorizontal ? outterF.left : outterF.right;
		float outtop    = flipVertical ? outterF.bottom : outterF.top;
		float outbottom = flipVertical ? outterF.top : outterF.bottom;

		float inleft    = flipHorizontal ? innerF.right : innerF.left;
		float inright   = flipHorizontal ? innerF.left : innerF.right;
		float intop     = flipVertical ? innerF.bottom : innerF.top;
		float inbottom  = flipVertical ? innerF.top : innerF.bottom;

		Quad.fill( vertices,
				0, marginLeft, 0, marginTop, outleft, inleft, outtop, intop );
		quads.put( vertices );
		Quad.fill( vertices,
				marginLeft, right, 0, marginTop, inleft, inright, outtop, intop );
		quads.put( vertices );
		Quad.fill( vertices,
				right, width, 0, marginTop, inright, outright, outtop, intop );
		quads.put( vertices );

		Quad.fill( vertices,
				0, marginLeft, marginTop, bottom, outleft, inleft, intop, inbottom );
		quads.put( vertices );
		Quad.fill( vertices,
				marginLeft, right, marginTop, bottom, inleft, inright, intop, inbottom );
		quads.put( vertices );
		Quad.fill( vertices,
				right, width, marginTop, bottom, inright, outright, intop, inbottom );
		quads.put( vertices );

		Quad.fill( vertices,
				0, marginLeft, bottom, height, outleft, inleft, inbottom, outbottom );
		quads.put( vertices );
		Quad.fill( vertices,
				marginLeft, right, bottom, height, inleft, inright, inbottom, outbottom );
		quads.put( vertices );
		Quad.fill( vertices,
				right, width, bottom, height, inright, outright, inbottom, outbottom );
		quads.put( vertices );

		dirty = true;
	}
 
Example #27
Source File: KeyDisplay.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
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 #28
Source File: RenderedText.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
@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 #29
Source File: Image.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public Image() {
	super( 0, 0, 0, 0 );
	
	vertices = new float[16];
	verticesBuffer = Quad.create();
}
 
Example #30
Source File: SystemTextLine.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public SystemTextLine() {
	super( 0, 0, 0, 0 );
	
	vertices = new float[16];
	verticesBuffer = Quad.create();
}