11package cleargl ;
22
3+ import java .awt .Color ;
34import java .awt .Font ;
45import java .awt .Graphics2D ;
56import java .awt .RenderingHints ;
@@ -65,17 +66,17 @@ public void init(GL pGL)
6566 }
6667 }
6768
68- public void drawTextAtPosition ( String text ,
69- int screenX ,
70- int screenY ,
71- Font font ,
72- FloatBuffer color ,
73- boolean antiAliased )
69+ public void drawTextAtPosition ( String pText ,
70+ int pWindowPositionX ,
71+ int pWindowPositionY ,
72+ Font pFont ,
73+ Color pColor ,
74+ boolean pAntiAliased )
7475 {
75- if (font == null )
76+ if (pFont == null )
7677 {
77- System .err .println ("Font invalid for text \" " + text + "\" " );
78- font = new JLabel ().getFont ();
78+ System .err .println ("Font invalid for text \" " + pText + "\" " );
79+ pFont = new JLabel ().getFont ();
7980 }
8081
8182 final int scaleFactor = ClearGLWindow .isRetina (mGL ) ? 2 : 1 ;
@@ -87,16 +88,16 @@ public void drawTextAtPosition( String text,
8788 .getGLDrawable ()
8889 .getSurfaceHeight () / scaleFactor ;
8990
90- final int width = text .length () * font .getSize ();
91- final int height = font .getSize ();
91+ final int width = pText .length () * pFont .getSize ();
92+ final int height = pFont .getSize ();
9293
9394 // don't store more then 50 textures
9495 if (textureCache .size () > 50 )
9596 {
9697 textureCache .clear ();
9798 }
9899
99- if (!mShouldCache || (mShouldCache && !textureCache .containsKey (text )))
100+ if (!mShouldCache || (mShouldCache && !textureCache .containsKey (pText )))
100101 {
101102 ByteBuffer imageBuffer ;
102103
@@ -113,7 +114,7 @@ public void drawTextAtPosition( String text,
113114 WritableRaster raster ;
114115
115116 raster = Raster .createInterleavedRaster (DataBuffer .TYPE_BYTE ,
116- font .getSize () * text .length (),
117+ pFont .getSize () * pText .length (),
117118 18 ,
118119 4 ,
119120 null );
@@ -124,17 +125,18 @@ public void drawTextAtPosition( String text,
124125 new Hashtable ());
125126
126127 g2d = image .createGraphics ();
127- g2d .setFont (font );
128+ g2d .setFont (pFont );
129+ g2d .setColor (pColor );
128130
129- if (antiAliased )
131+ if (pAntiAliased )
130132 {
131133 final RenderingHints rh = new RenderingHints ( RenderingHints .KEY_TEXT_ANTIALIASING ,
132134 RenderingHints .VALUE_TEXT_ANTIALIAS_GASP );
133135
134136 g2d .setRenderingHints (rh );
135137 }
136138
137- g2d .drawString (text , 0 , font .getSize ());
139+ g2d .drawString (pText , 0 , pFont .getSize ());
138140
139141 final byte [] data = ((DataBufferByte ) image .getRaster ()
140142 .getDataBuffer ()).getData ();
@@ -149,7 +151,7 @@ public void drawTextAtPosition( String text,
149151 textureCache .clear ();
150152 }
151153
152- textureCache .put (text , imageBuffer );
154+ textureCache .put (pText , imageBuffer );
153155 }
154156
155157 mGL .glClear (GL .GL_DEPTH_BUFFER_BIT | GL .GL_STENCIL_BUFFER_BIT );
@@ -166,8 +168,8 @@ public void drawTextAtPosition( String text,
166168
167169 final float w = width ;
168170 final float h = height ;
169- final float x = screenX ;
170- final float y = screenY ;
171+ final float x = pWindowPositionX ;
172+ final float y = pWindowPositionY ;
171173
172174 final FloatBuffer vertices = FloatBuffer .wrap (new float []
173175 { x , y + h , 0.0f , x + w , y + h , 0.0f , x , y , 0.0f , x + w , y , 0.0f });
@@ -257,7 +259,7 @@ public void drawTextAtPosition( String text,
257259 0 ,
258260 GL .GL_RGBA ,
259261 GL .GL_UNSIGNED_BYTE ,
260- textureCache .get (text ));
262+ textureCache .get (pText ));
261263
262264 mProg .getUniform ("uitex" ).setInt (1 );
263265 ModelMatrix .mult (ViewMatrix );
0 commit comments