Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 73: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 74: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 75: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 76: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 77: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 78: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.mgoelz.drakengardmobile; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.opengl.GLUtils; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import javax.microedition.khronos.opengles.GL10; /** * * @author Mike.Goelz */ public class TextRenderer { /** The buffer holding the vertices */ private FloatBuffer vertexBuffer; /** The buffer holding the texture coordinates */ private FloatBuffer textureBuffer; /** The buffer holding the indices */ private ByteBuffer indexBuffer; /** Our texture pointer */ private int[] textures = new int[1]; /** * The initial vertex definition * * Note that each face is defined, even * if indices are available, because * of the texturing we want to achieve */ float[][] texcoords = { { 0.0f, 0.0f, 0.0f, 0.0625f, 0.0625f, 0.0f, 0.0625f, 0.0625f } }; float quad[] = { 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; byte indices[] = { 0, 1, 2, 3 }; private float width; private float height; float fontsize = 32; public float getTop() { return height / fontsize - 1.0f; } public float getRight() { return width / fontsize - 1.0f; } public TextRenderer(GL10 gl, Context ctx) { texcoords = new float[16*16][4*2];//16 by 16 tiles by 4 vertices per quad by 2 coords per vertex for(int y = 0; y < 16; y++) { for(int x = 0; x < 16; x++) { texcoords[(x)+(y*16)][0] = ((float)x + 1.0f) / 16.0f; texcoords[(x)+(y*16)][1] = ((float)y + 1.0f) / 16.0f; texcoords[(x)+(y*16)][2] = ((float)x + 1.0f) / 16.0f; texcoords[(x)+(y*16)][3] = (float)y / 16.0f; texcoords[(x)+(y*16)][4] = (float)x / 16.0f; texcoords[(x)+(y*16)][5] = ((float)y + 1.0f) / 16.0f; texcoords[(x)+(y*16)][6] = (float)x / 16.0f; texcoords[(x)+(y*16)][7] = (float)y / 16.0f; } } // ByteBuffer byteBuf = ByteBuffer.allocateDirect(quad.length * 4); byteBuf.order(ByteOrder.nativeOrder()); vertexBuffer = byteBuf.asFloatBuffer(); vertexBuffer.put(quad); vertexBuffer.position(0); // byteBuf = ByteBuffer.allocateDirect(texcoords[0].length * 4); byteBuf.order(ByteOrder.nativeOrder()); textureBuffer = byteBuf.asFloatBuffer(); textureBuffer.put(texcoords[0]); textureBuffer.position(0); // indexBuffer = ByteBuffer.allocateDirect(indices.length); indexBuffer.put(indices); indexBuffer.position(0); //Get the texture from the Android resource directory InputStream is = ctx.getResources().openRawResource(R.drawable.berlin); Bitmap bitmap = null; Bitmap alpha = null; try { //BitmapFactory is an Android graphics utility for images bitmap = BitmapFactory.decodeStream(is); /*alpha = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ALPHA_8); for(int y = 0; y < bitmap.getHeight(); y++) { for(int x = 0; x < bitmap.getWidth(); x++) { int pix = bitmap.getPixel(x, y); alpha.setPixel(x, y, (Color.red(pix) + Color.green(pix) + Color.blue(pix)) / 3); } }*/ } finally { //Always clear and close try { is.close(); is = null; } catch (IOException e) { } } //Generate one texture pointer... gl.glGenTextures(1, textures, 0); //...and bind it to our array gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); //Create Nearest Filtered Texture gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); //Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT); //Use the Android GLUtils to specify a two-dimensional texture image from our bitmap GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); //GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, gl.GL_ALPHA, bitmap, 0); //Clean up //alpha.recycle(); bitmap.recycle(); } public void drawText(GL10 gl, float x, float y, String text) { gl.glPushMatrix();//save off the modelview gl.glLoadIdentity();//reset modelview gl.glMatrixMode(gl.GL_PROJECTION); gl.glPushMatrix();//save off the projection gl.glLoadIdentity();//reset projection gl.glOrthof(0.0f, width / fontsize, 0.0f, height / fontsize, 0.1f, 10.0f);//set to ortho perspective gl.glMatrixMode(gl.GL_MODELVIEW); //set state for text render gl.glEnable(gl.GL_TEXTURE_2D); gl.glDisable(gl.GL_DEPTH_TEST); gl.glEnable(gl.GL_BLEND); gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); //Bind our only previously generated texture gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); float drawx = x; float drawy = y; for(int i = 0; i < text.length(); i++) { int ascii = text.codePointAt(i); textureBuffer.put(texcoords[ascii]); textureBuffer.position(0); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); gl.glPushMatrix(); gl.glTranslatef(drawx, drawy, -1.0f); gl.glDrawElements(gl.GL_TRIANGLE_STRIP, indices.length, gl.GL_UNSIGNED_BYTE, indexBuffer); gl.glPopMatrix(); drawx += 0.6; } //Disable the client state before leaving gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); //reset rendering gl.glDisable(gl.GL_BLEND); gl.glEnable(gl.GL_DEPTH_TEST); gl.glDisable(gl.GL_TEXTURE_2D); gl.glPopMatrix(); gl.glMatrixMode(gl.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(gl.GL_MODELVIEW); } public void resize(float w, float h) { width = w; height = h; } }