There are couple ways. One is orthographic projection which I'll provide code and the other is to align by the projection/camera a textured quad (triangle strip, etc.). This can be done with free form rotation translation (you can animate the image rotating / flipping etc) or even by moving / orienting a camera differently. Also look up billboarding (plenty of OpenGL tutorials online) as there is a way to align textures to the eye space such that the textured quad always faces the direction the camera is facing.
check out orthographic projection as essentially you'll be working in 2D space though this may not be what you want.. Sounds like you want the 3D case.
-------------------
The following Typhon4Android framework code sets ortho mode binds a texture and draws a triangle strip that repeats. The x2 texture coordinate being 3.75 because 128 * 3.75 is 480. The texture size is 128x128.
glUtil.setOrtho(480, 320);
backgroundTexture.setTexParameters();
Texture.drawTexturedQuad(0, 0, 480, 320, 0, 0, 3.75f, 2.5f);
glUtil.resetOrtho();
-------------------------
full code in methods still..
Using java Syntax Highlighting
public void setOrtho(int width, int height)
{
gl.glMatrixMode(GL_PROJECTION); // Select Projection
gl.glPushMatrix(); // Push The Matrix
gl.glLoadIdentity(); // Reset The Matrix
gl.glOrthof( 0, width, height, 0, -1, 1 ); // Select Ortho Mode
gl.glMatrixMode(GL_MODELVIEW); // Select Modelview Matrix
gl.glPushMatrix(); // Push The Matrix
gl.glLoadIdentity(); // Reset The Matrix
}
public void resetOrtho()
{
gl.glMatrixMode(GL_PROJECTION); // Select Projection
gl.glPopMatrix(); // Pop The Matrix
gl.glMatrixMode(GL_MODELVIEW); // Select Modelview
gl.glPopMatrix(); // Pop The Matrix
}
//NOTE this is a method of a larger Texture class/object in Typhon. It presumes you have a texture ID and the wrap / //min/mag filter settings, etc.
public void setTexParameters()
{
gl.glBindTexture(GL_TEXTURE_2D, id);
gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS);
gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT);
gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter);
gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
}
// NOTE - vertexBuffer and textureBuffer are VectorBuffer3f and VectorBuffer2f additional NIO buffer wrappers from the //Typhon framework. These are backed by underlying NIO FloatBuffers (so you could create a FloatBuffer and fill it //sequentially)
public static void drawTexturedQuad(float x, float y, float width, float height, float tx, float ty, float tw,
float th)
{
vertexBuffer.put(x, y, 0);
vertexBuffer.put(x + width, y, 0);
vertexBuffer.put(x, y + height, 0);
vertexBuffer.put(x + width, y + height, 0);
vertexBuffer.rewindWrite();
textureBuffer.put(tx, ty);
textureBuffer.put(tx + tw, ty);
textureBuffer.put(tx, ty + th);
textureBuffer.put(tx + tw, ty + th);
textureBuffer.rewindWrite();
gl.glVertexPointer(3, 0, vertexBuffer.getReadBuffer());
gl.glTexCoordPointer(2, 0, textureBuffer.getReadBuffer());
gl.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
Parsed in 0.038 seconds, using
GeSHi 1.0.8.4