Android Open Source - opengl Tex Cube Small G L U T From Project Back to project page opengl .
License The source code is released under:
Apache License
If you think the Android project opengl listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package com.androidbook.opengl;
/ / f r o m w w w . j a v a 2 s . c o m
import java.nio.FloatBuffer;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.opengl.GLUtils;
public class TexCubeSmallGLUT extends CubeSmallGLUT {
TexCubeSmallGLUT(float size) throws IllegalArgumentException {
super (size);
}
FloatBuffer mCoordBuffer;
float texCoords[] = {
1,0, 1,1, 0,1, 0,0,
1,0, 1,1, 0,1, 0,0,
1,0, 1,1, 0,1, 0,0,
1,0, 1,1, 0,1, 0,0,
1,0, 1,1, 0,1, 0,0,
1,0, 1,1, 0,1, 0,0,
};
int mTextureID;
boolean texEnabled = false;
void setTex (GL10 gl, Context c, int textureID, int drawableID) {
mCoordBuffer = getFloatBufferFromFloatArray(texCoords);
mTextureID = textureID;
gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
Bitmap bitmap = BitmapFactory.decodeResource(c.getResources(), drawableID);
Bitmap bitmap256 = Bitmap.createScaledBitmap(bitmap, 256, 256, false);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap256, 0);
bitmap.recycle();
bitmap256.recycle();
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);
texEnabled = true;
}
void draw(GL10 gl) {
if (texEnabled) {
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mCoordBuffer);
}
super.draw(gl);
if (texEnabled) {
gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glDisable(GL10.GL_TEXTURE_2D);
}
}
}
Java Source Code List book.BouncyCube.BouncyCubeActivity.java book.BouncyCube.BouncyCubeActivity.java book.BouncyCube.BouncyCubeRenderer.java book.BouncyCube.BouncyCubeRenderer.java book.BouncyCube.Cube.java book.BouncyCube.Cube.java book.SolarSystem.Cube.java book.SolarSystem.Cube.java book.SolarSystem.Planet.java book.SolarSystem.Planet.java book.SolarSystem.SolarSystemActivity.java book.SolarSystem.SolarSystemActivity.java book.SolarSystem.SolarSystemRenderer.java book.SolarSystem.SolarSystemRenderer.java com.androidbook.opengl.AndroidOpenGL.java com.androidbook.opengl.AndroidOpenGL.java com.androidbook.opengl.BasicGLCube.java com.androidbook.opengl.BasicGLCube.java com.androidbook.opengl.BasicGL.java com.androidbook.opengl.BasicGL.java com.androidbook.opengl.CubeSmallGLUT.java com.androidbook.opengl.CubeSmallGLUT.java com.androidbook.opengl.Menu.java com.androidbook.opengl.Menu.java com.androidbook.opengl.OpenGLPlay.java com.androidbook.opengl.OpenGLPlay.java com.androidbook.opengl.SimpleFPSDisplay.java com.androidbook.opengl.SimpleFPSDisplay.java com.androidbook.opengl.SimpleLitGLCube.java com.androidbook.opengl.SimpleLitGLCube.java com.androidbook.opengl.SmallGLUT.java com.androidbook.opengl.SmallGLUT.java com.androidbook.opengl.TexCubeSmallGLUT.java com.androidbook.opengl.TexCubeSmallGLUT.java com.androidbook.opengl.TextureGL.java com.androidbook.opengl.TextureGL.java com.androidbook.opengl.TriangleSmallGLUT.java com.androidbook.opengl.TriangleSmallGLUT.java com.droidnova.android.games.vortex.VortexRenderer.java com.droidnova.android.games.vortex.VortexRenderer.java com.droidnova.android.games.vortex.VortexView.java com.droidnova.android.games.vortex.VortexView.java com.droidnova.android.games.vortex.Vortex.java com.droidnova.android.games.vortex.Vortex.java com.example.android.opengl.MyGLRenderer.java com.example.android.opengl.MyGLRenderer.java com.example.android.opengl.MyGLSurfaceView.java com.example.android.opengl.MyGLSurfaceView.java com.example.android.opengl.OpenGLES20Activity.java com.example.android.opengl.OpenGLES20Activity.java com.example.android.opengl.Square.java com.example.android.opengl.Square.java com.example.android.opengl.Triangle.java com.example.android.opengl.Triangle.java edu.cs4730.OpenGlDemo1.OpenGlDemo1Activity.java edu.cs4730.OpenGlDemo1.OpenGlDemo1Activity.java edu.cs4730.OpenGlDemo1.SquareRenderer.java edu.cs4730.OpenGlDemo1.SquareRenderer.java edu.cs4730.OpenGlDemo1.Square.java edu.cs4730.OpenGlDemo1.Square.java edu.cs4730.OpenGlDemo.OpenGLRenderer.java edu.cs4730.OpenGlDemo.OpenGLRenderer.java edu.cs4730.OpenGlDemo.OpenGlDemo.java edu.cs4730.OpenGlDemo.OpenGlDemo.java edu.cs4730.OpenGlDemo.Square.java edu.cs4730.OpenGlDemo.Square.java edu.cs4730.opengl2ex1.LessonOneRenderer.java edu.cs4730.opengl2ex1.LessonOneRenderer.java edu.cs4730.opengl2ex1.MainActivity.java edu.cs4730.opengl2ex1.MainActivity.java edu.cs4730.opengl2ex2.LessonOneRenderer.java edu.cs4730.opengl2ex2.LessonOneRenderer.java edu.cs4730.opengl2ex2.MainActivity.java edu.cs4730.opengl2ex2.MainActivity.java edu.cs4730.opengl2ex2.myGlSurfaceView.java edu.cs4730.opengl2ex2.myGlSurfaceView.java