Android Open Source - NotATop Draw Background






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.module;
/*from  www .  jav a 2  s  . c  om*/
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import javax.microedition.khronos.opengles.GL10;

import com.gg.util.Constant;

public class DrawBackground
{  
    private FloatBuffer   mVertexBuffer;//???????????????
      
      private FloatBuffer mTextureBuffer;//???????????????
  
      private int vCount;//?????????????????????
      
      int drawableId;//????ID 
      
      public float mAngleX;//??X?????????
      public float mAngleY;//??Y?????????
      public float mAngleZ;//??Z?????????    
      
      public DrawBackground(int drawableId)
      {
        this.drawableId=drawableId;
        
        //???????????????
        initVertex();
  
        //???????????????
        initTexture();
      }
      
     
      public void initVertex()
    {
      float x=Constant.LOGIC_WIDTH/2;//??????X??????????
      
      float y=1f*2/2;//??????Y??????????
      
      float z=0;//??????Z??????????

      float[] vertices=
      {//??????????????????????????????????????
        -x,y,z,
        -x,-y,z,
        x,y,z,
        
        -x,-y,z,
        x,-y,z,
        x,y,z,
    
      };
      
      vCount=vertices.length/3;//????????
      //???????????????????
      //vertices.length*4????????Float??????
      ByteBuffer vbb=ByteBuffer.allocateDirect(vertices.length*4);  
      vbb.order(ByteOrder.nativeOrder());//??????????
      mVertexBuffer=vbb.asFloatBuffer();//????float?????
      mVertexBuffer.put(vertices);//????????????????????
      mVertexBuffer.position(0);//??????????????      
      
    }
     
  
      public void initTexture()
    {//??????????
      float[] textures=new float[vCount*2];//?????????????????????2??
      
      int temp=0;
      
      //????????????????????
      textures[temp++]=0;
      textures[temp++]=0;
      
      textures[temp++]=0;
      textures[temp++]=1;
      
      textures[temp++]=1;
      textures[temp++]=0;
      
      
      //???????????????????
      textures[temp++]=0;
      textures[temp++]=1;
      
      textures[temp++]=1;
      textures[temp++]=1;
      
      textures[temp++]=1;
      textures[temp++]=0;
    
      //???????????????????
      //vertices.length*4????????Float??????
      ByteBuffer tbb=ByteBuffer.allocateDirect(textures.length*4);  
      tbb.order(ByteOrder.nativeOrder());//??????????
      mTextureBuffer=tbb.asFloatBuffer();//????float?????
      mTextureBuffer.put(textures);//????????????????????
      mTextureBuffer.position(0);//??????????????  
    }
    
      
    public void drawSelf(GL10 gl)
    {
      gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);//??????????
      gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);//????????????????????
  
      gl.glEnable(GL10.GL_TEXTURE_2D);//????????
      gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);//????????????
      gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureBuffer);//??????????????????
      gl.glBindTexture(GL10.GL_TEXTURE_2D, drawableId);//????
    
      gl.glRotatef(mAngleX, 1, 0, 0);//??X?????mAngleX??
       gl.glRotatef(mAngleY, 0, 1, 0);//??Y?????mAngleY??
       gl.glRotatef(mAngleZ, 0, 0, 1);//??Z?????mAngleZ??
      
      gl.glDrawArrays(GL10.GL_TRIANGLES, 0, vCount);//???????
      
      gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    }


    public int getDrawableId() {
      return drawableId;
    }


    public void setDrawableId(int drawableId) {
      this.drawableId = drawableId;
    }
    
    
    
      
  }




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