Many updates, see CHANGLOG diff
[rokon:rokon.git] / src / com / stickycoding / rokon / GLHelper.java
1 package com.stickycoding.rokon;\r
2 \r
3 import javax.microedition.khronos.opengles.GL10;\r
4 import javax.microedition.khronos.opengles.GL11;\r
5 import javax.microedition.khronos.opengles.GL11Ext;\r
6 \r
7 import android.opengl.GLUtils;\r
8 \r
9 import com.stickycoding.rokon.vbo.ArrayVBO;\r
10 \r
11 /**\r
12  * GLHelper.java\r
13  * Contains various functions that help minimize and optimize OpenGL calls and state changes.\r
14  * The aim is to have all OpenGL calls were made from this class.\r
15  * \r
16  * @author Richard\r
17  */\r
18 \r
19 public class GLHelper {\r
20         \r
21         private static GL10 gl;\r
22         private static boolean glVertexArray, glTexCoordArray, glTexture2D, glColorArray;\r
23         private static int textureIndex = -1, arrayBuffer = -1, elementBuffer = -1, srcBlendMode = -1, dstBlendMode = -1;\r
24         private static float glColor4fRed = -1, glColor4fGreen = -1, glColor4fBlue = -1, glColor4fAlpha = -1;\r
25     private static BufferObject lastVertexPointerBuffer;\r
26     private static BufferObject lastTexCoordPointerBuffer;\r
27     private static ColourBuffer lastColourBufferObject;\r
28     private static float lineWidth;\r
29     \r
30     public static void enableColourArray() {\r
31         if(!glColorArray) {\r
32                 gl.glEnableClientState(GL10.GL_COLOR_ARRAY);\r
33                 glColorArray = true;\r
34         }\r
35     }\r
36     \r
37     public static void disableColourArray() {\r
38         if(glColorArray) {\r
39                 gl.glEnableClientState(GL10.GL_COLOR_ARRAY);\r
40                 glColorArray = false;\r
41         }\r
42     }\r
43     \r
44     public static void colourPointer(ColourBuffer colourBuffer) {\r
45         if(lastColourBufferObject != colourBuffer) {\r
46                 gl.glColorPointer(4, GL10.GL_FLOAT, 0, colourBuffer.get());\r
47             lastColourBufferObject = colourBuffer;\r
48         }\r
49     }\r
50     \r
51     /**\r
52      * Resets what GLHelper thinks is going on, forces everything to be put through\r
53      */\r
54     public static void reset() {\r
55         glVertexArray = false;\r
56         glTexCoordArray = false;\r
57         glTexture2D = false;\r
58         textureIndex = -1;\r
59         arrayBuffer = -1;\r
60         elementBuffer = -1;\r
61         srcBlendMode = -1;\r
62         dstBlendMode = -1;\r
63         glColor4fRed = -1;\r
64         glColor4fGreen = -1;\r
65         glColor4fBlue = -1;\r
66         glColor4fAlpha = -1;\r
67         lastVertexPointerBuffer = null;\r
68         lastTexCoordPointerBuffer = null;\r
69         lastColourBufferObject = null;\r
70         glColorArray = false;\r
71         lineWidth = 1;\r
72     }\r
73     \r
74     /**\r
75      * Sets the line width\r
76      * \r
77      * @param lineWidth float value, > 0\r
78      */\r
79     public static void lineWidth(float lineWidth) {\r
80         if(lineWidth == GLHelper.lineWidth) return;\r
81         GLHelper.lineWidth = lineWidth;\r
82         gl.glLineWidth(lineWidth);\r
83     }\r
84         \r
85         protected static void setGL(GL10 gl) {\r
86                 GLHelper.gl = gl;\r
87         }\r
88         \r
89         /**\r
90          * Enables the GL_VERTEX_ARRAY state\r
91          */\r
92         public static void enableVertexArray() {\r
93                 if(!glVertexArray) {\r
94                         gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);\r
95                         glVertexArray = true;\r
96                 }\r
97         }\r
98         \r
99         /**\r
100          * Disables the GL_VERTEX_ARRAY state\r
101          */\r
102         public static void disableVertexArray() {\r
103                 if(glVertexArray) {\r
104                         gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);\r
105                         glVertexArray = false;\r
106                 }\r
107         }\r
108         \r
109         /**\r
110          * Enables the GL_TEXTURE_COORD_ARRAY state\r
111          */\r
112         public static void enableTexCoordArray() {\r
113                 if(!glTexCoordArray) {\r
114                         gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);\r
115                         glTexCoordArray = true;\r
116                 }\r
117         }\r
118         \r
119         /**\r
120          * Disables the GL_TEXTURE_COORD_ARRAY state\r
121          */\r
122         public static void disableTexCoordArray() {\r
123                 if(glTexCoordArray) {\r
124                         gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);\r
125                         glTexCoordArray = false;\r
126                 }\r
127         }\r
128         \r
129         /**\r
130          * Enables the GL_TEXTURE_2D state\r
131          */\r
132         public static void enableTextures() {\r
133                 if(!glTexture2D) {\r
134                         gl.glEnable(GL10.GL_TEXTURE_2D);\r
135                         glTexture2D = true;\r
136                 }\r
137         }\r
138         \r
139         /**\r
140          * Disables the GL_TEXTURE_2D state\r
141          */\r
142         public static void disableTextures() {\r
143                 if(glTexture2D) {\r
144                         gl.glDisable(GL10.GL_TEXTURE_2D);\r
145                         glTexture2D = false;\r
146                 }\r
147         }\r
148         \r
149         /**\r
150          * Binds a GL_ARRAY_BUFFER\r
151          * \r
152          * @param bufferIndex index of the buffer to bind\r
153          */\r
154         public static void bindBuffer(int bufferIndex, boolean force) {\r
155                 if(bufferIndex != arrayBuffer || force) {\r
156                         ((GL11)gl).glBindBuffer(GL11.GL_ARRAY_BUFFER, bufferIndex);\r
157                         arrayBuffer = bufferIndex;\r
158                 }\r
159         }\r
160         \r
161         /**\r
162          * Binds a GL_ELEMENT_ARRAY_BUFFER\r
163          * \r
164          * @param elementBufferIndex index of the buffer to bind\r
165          */\r
166         public static void bindElementBuffer(int elementBufferIndex) {\r
167                 if(elementBufferIndex != elementBuffer) {\r
168                         ((GL11)gl).glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, elementBufferIndex);\r
169                         elementBuffer = elementBufferIndex;\r
170                 }\r
171         }\r
172         \r
173         /**\r
174          * Binds a texture, given by texture index\r
175          * \r
176          * @param textureIndex index of the texture to bind\r
177          */\r
178         public static void bindTexture(int textureIndex) {\r
179                 if(GLHelper.textureIndex != textureIndex) {\r
180                         gl.glBindTexture(GL10.GL_TEXTURE_2D, textureIndex);\r
181                         GLHelper.textureIndex = textureIndex;\r
182                 }\r
183         }\r
184         \r
185         /**\r
186          * Binds a Texture\r
187          * \r
188          * @param texture valid Texture object\r
189          */\r
190         public static void bindTexture(Texture texture) {\r
191                 checkTextureValid(texture);\r
192                 bindTexture(texture.getTextureIndex());\r
193         }\r
194         \r
195         /**\r
196          * Checks whether a Texture has been loaded onto the hardware\r
197          * If it hasn't, it loads\r
198          * \r
199          * @param texture valid Texture object\r
200          */\r
201         public static void checkTextureValid(Texture texture) {\r
202                 if(texture.getTextureIndex() == -1 && texture.parentAtlas == null) {\r
203                         texture.onLoadTexture(gl);\r
204                 } else {\r
205                         if(texture.getTextureIndex() == -1) {\r
206                                 texture.parentAtlas.onLoadTexture(gl);\r
207                         }\r
208                 }\r
209                 if(texture.reload) {\r
210                         if(texture.parentAtlas == null) {\r
211                                 texture.onLoadTexture(gl);\r
212                         } else {\r
213                                 texture.parentAtlas.onLoadTexture(gl);\r
214                         }\r
215                         texture.setReloaded();\r
216                 }\r
217         }\r
218         \r
219         /**\r
220          * Sets the glBlendFunc, by custom parameters\r
221          * \r
222          * @param srcBlendMode\r
223          * @param dstBlendMode\r
224          */\r
225         public static void blendMode(int srcBlendMode, int dstBlendMode) {\r
226                 if(GLHelper.srcBlendMode != srcBlendMode || GLHelper.dstBlendMode != dstBlendMode) {\r
227                         gl.glBlendFunc(srcBlendMode, dstBlendMode);\r
228                         GLHelper.srcBlendMode = srcBlendMode;\r
229                         GLHelper.dstBlendMode = dstBlendMode;\r
230                 }\r
231         }\r
232         \r
233         /**\r
234          * Sets the glBlendFunc\r
235          * \r
236          * @param blendFunction valid BlendFunction object\r
237          */\r
238         public static void blendMode(BlendFunction blendFunction) {\r
239                 if(blendFunction.getSrc() != srcBlendMode || blendFunction.getDst() != dstBlendMode) {\r
240                         gl.glBlendFunc(blendFunction.getSrc(), blendFunction.getDst());\r
241                         srcBlendMode = blendFunction.getSrc();\r
242                         dstBlendMode = blendFunction.getDst();\r
243                 }\r
244         }\r
245 \r
246     /**\r
247      * Sets the colour and alpha values\r
248      * \r
249      * @param red 0f to 1f\r
250      * @param green 0f to 1f\r
251      * @param blue 0f to 1f\r
252      * @param alpha 0f to 1f\r
253      */\r
254     public static void color4f(float red, float green, float blue, float alpha) {\r
255         if(alpha != glColor4fAlpha || red != glColor4fRed || green != glColor4fGreen || blue != glColor4fBlue) {\r
256             gl.glColor4f(red, green, blue, alpha);\r
257             glColor4fRed = red;\r
258             glColor4fGreen = green;\r
259             glColor4fBlue = blue;\r
260             glColor4fAlpha = alpha;\r
261         }\r
262     }\r
263 \r
264     /**\r
265      * Passes a buffer for drawing textures\r
266      * \r
267      * @param buffer valid BufferObject\r
268      * @param type coordinate type, eg GL_FLOAT\r
269      */\r
270     public static void texCoordPointer(BufferObject buffer, int type) {\r
271         if(!buffer.equals(lastTexCoordPointerBuffer)) {\r
272                 gl.glTexCoordPointer(2, type, 0, buffer.get());\r
273             lastTexCoordPointerBuffer = buffer;\r
274         }\r
275     }\r
276     \r
277     /**\r
278      * Passes an empty buffer for vertices, for use with VBO\r
279      * \r
280      * @param type coordinate type, eg GL_FLOAT\r
281      */\r
282     public static void vertexPointer(int type) {\r
283         lastVertexPointerBuffer = null;\r
284         ((GL11)gl).glVertexPointer(2, type, 0, 0);\r
285     }\r
286     \r
287     /**\r
288      * Passes an empty buffer for textures, for use with VBO\r
289      * \r
290      * @param type coordinate type, eg GL_FLOAT\r
291      */\r
292     public static void texCoordPointer(int type) {\r
293         lastTexCoordPointerBuffer = null;\r
294         ((GL11)gl).glTexCoordPointer(2, type, 0, 0);\r
295     }\r
296 \r
297     /**\r
298      * Passes a buffer for vertices\r
299      * \r
300      * @param buffer valid BufferObject\r
301      * @param type coordinate type, eg GL_FLOAT\r
302      */\r
303     public static void vertexPointer(BufferObject buffer, int type) {\r
304         if(!buffer.equals(lastVertexPointerBuffer)) {\r
305                 gl.glVertexPointer(2, type, 0, buffer.get());\r
306             lastVertexPointerBuffer = buffer;\r
307         }\r
308     }\r
309     \r
310     /**\r
311      * Draws a polygon, with optional border using standard vertex techniques\r
312      * \r
313      * @param fill TRUE if drawing with a fill, FALSE otherwise\r
314      * @param red red value for fill, 0f to 1f\r
315      * @param green green value for fill, 0f to 1f\r
316      * @param blue blue value for fill, 0f to 1f\r
317      * @param alpha alpha value for fill, 0f to 1f\r
318      * @param blendFunction valid BlendFunction object\r
319      * @param vertexBuffer valid BufferObject\r
320      * @param vertexMode method for drawing vertices, eg GL_TRIANGLE_STRIP \r
321      * @param x x-coordinate to draw from, top left\r
322      * @param y y-coordinate to draw from, top left\r
323      * @param width width of the shape to draw\r
324      * @param height height of the shape to draw\r
325      * @param rotation rotation, in degrees\r
326      * @param rotateAboutPivot TRUE if rotating about a given pivot, FALSE if central\r
327      * @param rotationPivotX x-coordinate of rotation pivot, if rotateAboutPivot TRUE\r
328      * @param rotationPivotY y-coordinate of rotation pivot, if rotateAboutPivot FALSE\r
329      * @param border TRUE if drawing a border, FALSE otherwise\r
330      * @param borderBuffer valid BufferObject for the border shape, if border TRUE\r
331      * @param borderRed red value for border, 0f to 1f, if border TRUE\r
332      * @param borderGreen green value for border, 0f to 1f, if border TRUE\r
333      * @param borderBlue blue value for border, 0f to 1f, if border TRUE\r
334      * @param borderAlpha alpha value for border, 0f to 1f, if border TRUE\r
335      * @param lineWidth -1 to use default\r
336      * @param hasTexture TRUE if a Texture is being passed, FALSE otherwise\r
337      * @param texture valid Texture object to be rendered\r
338      * @param textureTile the index of the tile inside the Texture\r
339      */\r
340     public static void drawNormal(boolean fill, float red, float green, float blue, float alpha, BlendFunction blendFunction, BufferObject vertexBuffer, int vertexMode, float x, float y, float width, float height, float rotation, boolean rotateAboutPivot, float rotationPivotX, float rotationPivotY, boolean border, BufferObject borderBuffer, float borderRed, float borderGreen, float borderBlue, float borderAlpha, float lineWidth, boolean hasTexture, Texture texture, int textureTile, ColourBuffer colourBuffer) {\r
341         if(alpha == 0 && (borderAlpha == 0 || border == false)) return;\r
342         if(!fill && !border) return;\r
343                 if(blendFunction != null) {\r
344                         GLHelper.blendMode(blendFunction);\r
345                 } else {\r
346                         GLHelper.blendMode(Rokon.blendFunction);\r
347                 }\r
348                 gl.glPushMatrix();\r
349                 enableVertexArray();\r
350                 bindBuffer(0, false);\r
351                 if(rotation != 0) {\r
352                         if(!rotateAboutPivot) {\r
353                                 gl.glTranslatef(x + width / 2, y + height / 2, 0);\r
354                                 gl.glRotatef(rotation, 0, 0, 1);\r
355                                 gl.glTranslatef(-width / 2, - height / 2, 0);\r
356                         } else {\r
357                                 gl.glTranslatef(x + rotationPivotX, y + rotationPivotY, 0);\r
358                                 gl.glRotatef(rotation, 0, 0, 1);\r
359                                 gl.glTranslatef(-rotationPivotX, -rotationPivotY, 0);\r
360                         }\r
361                 } else {\r
362                         gl.glTranslatef(x, y, 0);\r
363                 }\r
364                 if(width != 1 || height != 1) {\r
365                         gl.glScalef(width, height, 0);\r
366                 }\r
367                 if(texture != null) {\r
368                         if(fill) {\r
369                                 enableTextures();\r
370                                 enableTexCoordArray();\r
371                                 bindTexture(texture);\r
372                                 color4f(red, green, blue, alpha);\r
373                                 if(colourBuffer != null) {\r
374                                         enableColourArray();\r
375                                         colourPointer(colourBuffer);\r
376                                 } else {\r
377                                         disableColourArray();\r
378                                 }\r
379                                 try {\r
380                                         texCoordPointer(texture.buffer[textureTile], GL10.GL_FLOAT);                                    \r
381                                 } catch (ArrayIndexOutOfBoundsException e) {\r
382                                         Debug.error("ARRAY INDEX OUT OF BOUNDS");\r
383                                         Debug.print("textureTile=" + textureTile);\r
384                                         Debug.print("texture=" + texture.path + " tiles=" + texture.tileCount);\r
385                                         System.exit(0);\r
386                                 }\r
387                                 vertexPointer(vertexBuffer, GL10.GL_FLOAT);\r
388                                 gl.glDrawArrays(vertexMode, 0, vertexBuffer.getSize() / 2);\r
389                         }\r
390                         if(border) {\r
391                                 disableTexCoordArray();\r
392                                 disableTextures();\r
393                                 disableColourArray();\r
394                                 color4f(borderRed, borderGreen, borderBlue, borderAlpha);\r
395                                 vertexPointer(borderBuffer, GL10.GL_FLOAT);\r
396                                 if(lineWidth != -1) {\r
397                                         lineWidth(lineWidth);\r
398                                 } else {\r
399                                         lineWidth(RokonActivity.currentScene.defaultLineWidth);\r
400                                 }\r
401                                 gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, borderBuffer.getSize() / 2);\r
402                         }\r
403                 } else {\r
404                         disableTexCoordArray();\r
405                         disableTextures();\r
406                         if(fill) {\r
407                                 color4f(red, green, blue, alpha);\r
408                                 if(colourBuffer != null) {\r
409                                         enableColourArray();\r
410                                         colourPointer(colourBuffer);\r
411                                 } else {\r
412                                         disableColourArray();\r
413                                 }\r
414                                 vertexPointer(vertexBuffer, GL10.GL_FLOAT);\r
415                                 gl.glDrawArrays(vertexMode, 0, vertexBuffer.getSize() / 2);\r
416                         }\r
417                         if(border) {\r
418                                 disableColourArray();\r
419                                 color4f(borderRed, borderGreen, borderBlue, borderAlpha);\r
420                                 vertexPointer(borderBuffer, GL10.GL_FLOAT);\r
421                                 if(lineWidth != -1) {\r
422                                         lineWidth(lineWidth);\r
423                                 } else {\r
424                                         lineWidth(RokonActivity.currentScene.defaultLineWidth);\r
425                                 }\r
426                                 gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, borderBuffer.getSize() / 2);\r
427                         }\r
428                 }\r
429                 gl.glPopMatrix();       \r
430     }\r
431 \r
432     /** Draws a polygon, using VBOs\r
433     * @param fill TRUE if drawing with a fill, FALSE otherwise\r
434     * @param red red value for fill, 0f to 1f\r
435     * @param green green value for fill, 0f to 1f\r
436     * @param blue blue value for fill, 0f to 1f\r
437     * @param alpha alpha value for fill, 0f to 1f\r
438     * @param blendFunction valid BlendFunction object\r
439     * @param arrayVBO valid ArrayVBO for the shape\r
440     * @param vertexMode method for drawing vertices, eg GL_TRIANGLE_STRIP \r
441     * @param x x-coordinate to draw from, top left\r
442     * @param y y-coordinate to draw from, top left\r
443     * @param width width of the shape to draw\r
444     * @param height height of the shape to draw\r
445     * @param rotation rotation, in degrees\r
446     * @param rotateAboutPivot TRUE if rotating about a given pivot, FALSE if central\r
447     * @param rotationPivotX x-coordinate of rotation pivot, if rotateAboutPivot TRUE\r
448     * @param rotationPivotY y-coordinate of rotation pivot, if rotateAboutPivot FALSE\r
449     * @param border TRUE if drawing a border, FALSE otherwise\r
450     * @param borderVBO valid ArrayVBO for the border shape, if border TRUE\r
451     * @param borderRed red value for border, 0f to 1f, if border TRUE\r
452     * @param borderGreen green value for border, 0f to 1f, if border TRUE\r
453     * @param borderBlue blue value for border, 0f to 1f, if border TRUE\r
454     * @param borderAlpha alpha value for border, 0f to 1f, if border TRUE\r
455     * @param lineWidth -1 to use default\r
456     * @param hasTexture TRUE if a Texture is being passed, FALSE otherwise\r
457     * @param texture valid Texture object to be rendered\r
458     * @param textureTile the index of the tile inside the Texture\r
459     */\r
460     public static void drawVBO(boolean fill, float red, float green, float blue, float alpha, BlendFunction blendFunction, ArrayVBO arrayVBO, int vertexMode, float x, float y, float width, float height, float rotation, boolean rotateAboutPivot, float rotationPivotX, float rotationPivotY, boolean border, ArrayVBO borderVBO, float borderRed, float borderGreen, float borderBlue, float borderAlpha, float lineWidth, boolean hasTexture, Texture texture, int textureTile, ColourBuffer colourBuffer) {\r
461         if(alpha == 0 && (borderAlpha == 0 || border == false)) return;\r
462         if(!fill && !border) return;\r
463                 if(!arrayVBO.isLoaded()) {\r
464                         //Debug.print("Vertex VBO isn't loaded");\r
465                         arrayVBO.load(gl);\r
466                 }\r
467                 if(border && !borderVBO.isLoaded()) {\r
468                         //Debug.print("Border VBO isn't loaded");\r
469                         borderVBO.load(gl);\r
470                 }\r
471                 if(hasTexture) {\r
472                         checkTextureValid(texture);\r
473                         if(!texture.vbo[textureTile].isLoaded()) {\r
474                                 //Debug.print("Texture VBO isn't loaded");\r
475                                 texture.vbo[textureTile].load(gl);\r
476                         }\r
477                 }\r
478                 \r
479                 if(blendFunction != null) {\r
480                         GLHelper.blendMode(blendFunction);\r
481                 } else {\r
482                         GLHelper.blendMode(Rokon.blendFunction);\r
483                 }\r
484                 gl.glPushMatrix();\r
485                 enableVertexArray();\r
486                 if(x != 0 || y != 0) {\r
487                         gl.glTranslatef(x, y, 0);\r
488                 }\r
489                 if(rotation != 0) {\r
490                         if(!rotateAboutPivot) {\r
491                                 gl.glTranslatef(width / 2, height / 2, 0);\r
492                                 gl.glRotatef(rotation, 0, 0, 1);\r
493                                 gl.glTranslatef(-width / 2, -height / 2, 0);\r
494                         } else {\r
495                                 gl.glTranslatef(rotationPivotX, rotationPivotY, 0);\r
496                                 gl.glRotatef(rotation, 0, 0, 1);\r
497                                 gl.glTranslatef(-rotationPivotX, -rotationPivotY, 0);\r
498                         }\r
499                 }\r
500                 if(width != 1 || height != 1) {\r
501                         gl.glScalef(width, height, 0);\r
502                 }\r
503                 if(hasTexture) {\r
504                         enableTextures();\r
505                         enableTexCoordArray();\r
506                         bindTexture(texture);\r
507                         color4f(red, green, blue, alpha);\r
508                         texCoordPointer(texture.buffer[textureTile], GL10.GL_FLOAT);\r
509                         bindBuffer(arrayVBO.getBufferIndex(), false);\r
510                         if(colourBuffer != null) {\r
511                                 enableColourArray();\r
512                                 colourPointer(colourBuffer);\r
513                         } else {\r
514                                 disableColourArray();\r
515                         }\r
516                         vertexPointer(GL10.GL_FLOAT);\r
517                         bindBuffer(texture.vbo[textureTile].getBufferIndex(), false);\r
518                         texCoordPointer(GL10.GL_FLOAT);\r
519                         gl.glDrawArrays(vertexMode, 0, arrayVBO.getBufferObject().getSize() / 2);\r
520                 } else {\r
521                         disableTexCoordArray();\r
522                         disableTextures();\r
523                         if(fill) {\r
524                                 color4f(red, green, blue, alpha);\r
525                                 bindBuffer(arrayVBO.getBufferIndex(), false);\r
526                                 vertexPointer(GL10.GL_FLOAT);\r
527                                 if(colourBuffer != null) {\r
528                                         enableColourArray();\r
529                                         colourPointer(colourBuffer);\r
530                                 } else {\r
531                                         disableColourArray();\r
532                                 }\r
533                                 gl.glDrawArrays(vertexMode, 0, arrayVBO.getBufferObject().getSize() / 2);\r
534                         }\r
535                         if(border) {\r
536                                 disableColourArray();\r
537                                 if(lineWidth != -1) {\r
538                                         lineWidth(lineWidth);\r
539                                 } else {\r
540                                         lineWidth(RokonActivity.currentScene.defaultLineWidth);\r
541                                 }\r
542                                 color4f(borderRed, borderGreen, borderBlue, borderAlpha);\r
543                                 bindBuffer(borderVBO.getBufferIndex(), false);\r
544                                 vertexPointer(GL10.GL_FLOAT);\r
545                                 gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, borderVBO.getBufferObject().getSize() / 2);\r
546                         }\r
547                 }\r
548                 gl.glPopMatrix();       \r
549     }\r
550 \r
551     /**\r
552      * Removes a set of Textures from the hardware\r
553      * \r
554      * @param texture an array of Texture objects\r
555      */\r
556     public static void removeTextures(Texture[] texture) {\r
557         for(int i = 0; i < texture.length; i++) {\r
558                 if(texture[i] != null) {\r
559                         int[] textureId = new int[] { texture[i].getTextureIndex() };\r
560                 gl.glDeleteTextures(1, textureId, 0);\r
561                 }\r
562         }\r
563     }\r
564     \r
565     public static void drawTex(Texture texture, float screenX, float screenY, float screenWidth, float screenHeight) {\r
566         //GL11Ext gl11 = (GL11Ext)gl;\r
567         //gl11.glDrawTexfOES(screenX, screenY, 0, screenWidth, screenHeight);\r
568     }\r
569     \r
570     public static void refreshTexture(Texture texture) {\r
571         bindTexture(texture);\r
572         GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, texture.getBitmap());\r
573     }\r
574 \r
575 }\r