Android Open Source - NotATop Texture Rect






From Project

Back to project page NotATop.

License

The source code is released under:

GNU General Public License

If you think the Android project NotATop 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.gg.util;
// ww w  .j a v a  2  s .  com
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import javax.microedition.khronos.opengles.GL10;

public class TextureRect {

  private float TABLE_UNIT_SIZE = 0.5f;
  private float TABLE_UNIT_HIGHT = 0.5f;
  
  private FloatBuffer   mVertexBuffer;//???????????????
    private FloatBuffer mTextureBuffer;//???????????????
    int vCount=0;
    int texId;
    
    public TextureRect(float width,float height, float length,int texId,float[] texST)
    {
      this.texId=texId;
      //?????????????????================begin============================
        vCount=6;
        float vertices[]=new float[]
        {
          -width*TABLE_UNIT_SIZE,height*TABLE_UNIT_HIGHT,-length*TABLE_UNIT_SIZE,
          -width*TABLE_UNIT_SIZE,-height*TABLE_UNIT_HIGHT,length*TABLE_UNIT_SIZE,     
          width*TABLE_UNIT_SIZE,-height*TABLE_UNIT_HIGHT,length*TABLE_UNIT_SIZE,
          
          width*TABLE_UNIT_SIZE,-height*TABLE_UNIT_HIGHT,length*TABLE_UNIT_SIZE,
          width*TABLE_UNIT_SIZE,height*TABLE_UNIT_HIGHT,-length*TABLE_UNIT_SIZE,     
          -width*TABLE_UNIT_SIZE,height*TABLE_UNIT_HIGHT,-length*TABLE_UNIT_SIZE,
        };
    
        //???????????????????
        //vertices.length*4??????????????????
        ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length*4);
        vbb.order(ByteOrder.nativeOrder());//??????????
        mVertexBuffer = vbb.asFloatBuffer();//????Float?????
        mVertexBuffer.put(vertices);//????????????????????
        mVertexBuffer.position(0);//??????????????
        //?????????????????????????????????????????????ByteBuffer
        //??????????????ByteOrder????nativeOrder()?????????????????
        //?????????????????================end============================
        ByteBuffer tbb = ByteBuffer.allocateDirect(texST.length*4);
        tbb.order(ByteOrder.nativeOrder());//??????????
        mTextureBuffer = tbb.asFloatBuffer();//????int?????
        mTextureBuffer.put(texST);//???????????????????
        mTextureBuffer.position(0);//??????????????         
        
    }

    public void drawSelf(GL10 gl)
    {        
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);//??????????????
        
    //????????????????????
        gl.glVertexPointer
        (
            3,        //????????????????3  xyz 
            GL10.GL_FLOAT,  //???????????????? GL_FLOAT
            0,         //??????????????????????
            mVertexBuffer  //????????????
        );
        
        //????????
        gl.glEnable(GL10.GL_TEXTURE_2D);   
        //???????????ST??????
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        //????????????ST??????
        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureBuffer);
        //????????
        gl.glBindTexture(GL10.GL_TEXTURE_2D, texId);
        
    
        //???????
        gl.glDrawArrays
        (
            GL10.GL_TRIANGLES,     //?????????????
            0,              //???????
            vCount          //?????????
        );
    }
}




Java Source Code List

com.gg.game.ClassicGame.java
com.gg.game.ClassicGame.java
com.gg.game.GameFrame.java
com.gg.game.GameFrame.java
com.gg.game.TimeGame.java
com.gg.game.TimeGame.java
com.gg.module.DrawBackground.java
com.gg.module.DrawBackground.java
com.gg.module.DrawScore.java
com.gg.module.DrawScore.java
com.gg.module.DrawTrack.java
com.gg.module.DrawTrack.java
com.gg.module.SelectControl.java
com.gg.module.SelectControl.java
com.gg.module.SoundControl.java
com.gg.module.SoundControl.java
com.gg.module.VoiceControl.java
com.gg.module.VoiceControl.java
com.gg.top.BasicTop.java
com.gg.top.BasicTop.java
com.gg.top.DrawCircle.java
com.gg.top.DrawCircle.java
com.gg.top.DrawCone.java
com.gg.top.DrawCone.java
com.gg.top.DrawCylinder.java
com.gg.top.DrawCylinder.java
com.gg.top.DrawTop.java
com.gg.top.DrawTop.java
com.gg.util.Circle.java
com.gg.util.Circle.java
com.gg.util.Constant.java
com.gg.util.Constant.java
com.gg.util.DateUtil.java
com.gg.util.DateUtil.java
com.gg.util.Direction.java
com.gg.util.Direction.java
com.gg.util.Line.java
com.gg.util.Line.java
com.gg.util.Point.java
com.gg.util.Point.java
com.gg.util.TextureRect.java
com.gg.util.TextureRect.java
com.gg.util.TrackPoint.java
com.gg.util.TrackPoint.java
com.gg.util.Track.java
com.gg.util.Track.java
com.gg.util.Utils.java
com.gg.util.Utils.java
com.gg.view.ClassicGameSurfaceView.java
com.gg.view.ClassicGameSurfaceView.java
com.gg.view.EndSurfaceView.java
com.gg.view.EndSurfaceView.java
com.gg.view.FirstTimeSurfaceView.java
com.gg.view.FirstTimeSurfaceView.java
com.gg.view.GameModeSurfaceView.java
com.gg.view.GameModeSurfaceView.java
com.gg.view.HelpSurfaceView.java
com.gg.view.HelpSurfaceView.java
com.gg.view.MainActivity.java
com.gg.view.MainActivity.java
com.gg.view.MainMenuSurfaceView.java
com.gg.view.MainMenuSurfaceView.java
com.gg.view.ScoreSurfaceView.java
com.gg.view.ScoreSurfaceView.java
com.gg.view.SelectSurfaceView.java
com.gg.view.SelectSurfaceView.java
com.gg.view.SurfaceViewFactory.java
com.gg.view.SurfaceViewFactory.java
com.gg.view.TimeGameSurfaceView.java
com.gg.view.TimeGameSurfaceView.java
com.gg.view.WelcomeSurfaceView.java
com.gg.view.WelcomeSurfaceView.java