1 // taken from Texample,
2 // http://fractiousg.blogspot.com/201/4/rendering-text-in-opengl-on-android.html
3 
4 package com.android.texample;
5 
6 class TextureRegion {
7 
8    //--Members--//
9    public float u1, v1;                               // Top/Left U,V Coordinates
10    public float u2, v2;                               // Bottom/Right U,V Coordinates
11 
12    //--Constructor--//
13    // D: calculate U,V coordinates from specified texture coordinates
14    // A: texWidth, texHeight - the width and height of the texture the region is for
15    //    x, y - the top/left (x,y) of the region on the texture (in pixels)
16    //    width, height - the width and height of the region on the texture (in pixels)
TextureRegion(float texWidth, float texHeight, float x, float y, float width, float height)17    public TextureRegion(float texWidth, float texHeight, float x, float y, float width, float height)  {
18       this.u1 = x / texWidth;                         // Calculate U1
19       this.v1 = y / texHeight;                        // Calculate V1
20       this.u2 = this.u1 + ( width / texWidth );       // Calculate U2
21       this.v2 = this.v1 + ( height / texHeight );     // Calculate V2
22    }
23 }
24