コード例 #1
0
  public SettingScreen(MyMainGame game) {
    // TODO Auto-generated constructor stub
    this.mGame = game;
    mBatch = new SpriteBatch();
    String music = "";
    String sound = "";
    isSelected = false;
    GameUtils.setInputProcessor(mInput);
    if (GameUtils.getInstance().music) {
      music = "Music: ON";
    } else {
      music = "Music: OFF";
    }

    if (GameUtils.getInstance().sound) {
      sound = "Sound: ON";
    } else {
      sound = "Sound: OFF";
    }
    Gdx.graphics.setContinuousRendering(false);
    Gdx.graphics.requestRendering();
    background = TextureManager.getInstance().textureBackgroundOutGame;
    selector = TextureManager.getInstance().textureMainMenuSelector;
    txtTitle = new TextWrapper("Settings", new Vector2(120, 520));
    txtMusic = new TextWrapper(music, new Vector2(150, 450));
    txtSound = new TextWrapper(sound, new Vector2(150, 400));
    txtBack = new TextWrapper("Back", new Vector2(150, 350));
    selector_Y = (int) txtMusic.position.y - 35;
  }
コード例 #2
0
 protected void clearScene() {
   Log.d("main", "clear scene");
   clearChildren();
   mTextureManager.reset();
   textureNames.clear();
   textureInfos.clear();
 }
コード例 #3
0
 public ChooseLevel(MyMainGame game) {
   this.mGame = game;
   isSelected = false;
   mSpriteBatch = new SpriteBatch();
   Gdx.graphics.setContinuousRendering(false);
   Gdx.graphics.requestRendering();
   GameUtils.setInputProcessor(mInputP);
   mTextureBackground = TextureManager.getInstance().textureBackgroundOutGame;
   mTextureSelector = TextureManager.getInstance().textureMainMenuSelector;
   mTxtChooseTitle = new TextWrapper("Choose level", new Vector2(120, 520));
   mTxtEasy = new TextWrapper("Easy", new Vector2(150, 450));
   mTxtNormal = new TextWrapper("Normal", new Vector2(150, 400));
   mTxtHard = new TextWrapper("Hard", new Vector2(150, 350));
   mTxtExit = new TextWrapper("Back", new Vector2(150, 300));
   selector_Y = (int) mTxtEasy.position.y - 35;
 }
コード例 #4
0
ファイル: MainActivity.java プロジェクト: noir-neo/FU
 @Override
 protected void onDestroy() {
   super.onDestroy();
   TextureManager.deleteAll(Global.gl);
   // mRenderer.deleteVbo(Global.gl);
   mMmdPlayer.player.dispose();
   mSpeechRecognizer.destroy();
   mTextToSpeech.destroy();
   mBot.destroy();
 }
コード例 #5
0
ファイル: Grid.java プロジェクト: gnawadawa/sunlight
  private void setupFrameBuffer(GL10 unused) {
    TextureManager textureManager = TextureManager.getSingletonObject();

    int numberOfRequiredTextures = useOneFramebuffer ? 1 : 2;

    for (int i = 0; i < numberOfRequiredTextures; ++i) {
      renderTextures[i] = textureManager.createRenderTexture(frameBufferWidth, frameBufferHeight);

      if (!renderTextures[i].load()) {
        Log.e(TAG, "Could not create render texture");
        throw new RuntimeException("Could not create render texture");
      }

      frameBuffers[i] = textureManager.createFrameBuffer(renderTextures[i]);

      if (!frameBuffers[i].load()) {
        Log.e(TAG, "Could not create frame buffer");
        throw new RuntimeException("Could not create frame buffer");
      }
    }
  }
コード例 #6
0
ファイル: SurfaceView.java プロジェクト: xiezl/cs5248
 public void startGLThread() {
   Log.d(TAG, "Thread started.");
   if (mTextureManager == null) {
     mTextureManager = new TextureManager();
   }
   if (mTextureManager.getSurfaceTexture() == null) {
     mThread = new Thread(SurfaceView.this);
     mRunning = true;
     mThread.start();
     mLock.acquireUninterruptibly();
   }
 }
コード例 #7
0
ファイル: MenuManager.java プロジェクト: joseph-roque/swip
  /**
   * Sets up a new main menu.
   *
   * @param callback instance of callback interface
   * @param textureManager to get textures to draw
   */
  public MenuManager(MenuCallback callback, TextureManager textureManager) {
    mCallback = callback;
    mTextureManager = textureManager;

    BasicBall.initialize(GameScreen.getScreenWidth(), GameScreen.getScreenHeight());
    mMenuOptionBalls = new ButtonBall[MenuBallOption.getSize()];
    mMenuOptionBalls[MenuBallOption.MusicOn.ordinal()] =
        new ButtonBall(
            MenuBallOption.MusicOn,
            TextureManager.GameColor.Green,
            textureManager.getMenuButtonIconTexture(MenuBallOption.MusicOn),
            GameScreen.getScreenWidth() / 2 - BasicBall.getDefaultBallRadius() * 2,
            GameScreen.getScreenHeight() / 2);
    mMenuOptionBalls[MenuBallOption.MusicOff.ordinal()] =
        new ButtonBall(
            MenuBallOption.MusicOff,
            TextureManager.GameColor.Red,
            textureManager.getMenuButtonIconTexture(MenuBallOption.MusicOff),
            GameScreen.getScreenWidth() / 2 - BasicBall.getDefaultBallRadius() * 2,
            GameScreen.getScreenHeight() / 2);
    mMenuOptionBalls[MenuBallOption.SoundEffectsOn.ordinal()] =
        new ButtonBall(
            MenuBallOption.SoundEffectsOn,
            TextureManager.GameColor.Green,
            textureManager.getMenuButtonIconTexture(MenuBallOption.SoundEffectsOn),
            GameScreen.getScreenWidth() / 2 + BasicBall.getDefaultBallRadius() * 2,
            GameScreen.getScreenHeight() / 2);
    mMenuOptionBalls[MenuBallOption.SoundEffectsOff.ordinal()] =
        new ButtonBall(
            MenuBallOption.SoundEffectsOff,
            TextureManager.GameColor.Red,
            textureManager.getMenuButtonIconTexture(MenuBallOption.SoundEffectsOff),
            GameScreen.getScreenWidth() / 2 + BasicBall.getDefaultBallRadius() * 2,
            GameScreen.getScreenHeight() / 2);
    for (ButtonBall ball : mMenuOptionBalls)
      ball.setScalingCompleteListener(mMenuOptionBallsListener);
  }
コード例 #8
0
ファイル: Grid.java プロジェクト: gnawadawa/sunlight
  @Override
  public void onSurfaceCreated(GL10 unused, EGLConfig config) {
    ShaderManager.getSingletonObject().unloadAll();
    ShaderManager.getSingletonObject().cleanUp();

    TextureManager.getSingletonObject().unloadAll();
    TextureManager.getSingletonObject().cleanUp();

    loadResources();

    if (phenixLineProgram != null) {
      phenixLineProgram.load();
    }

    ShaderManager.getSingletonObject().unloadAllShaders();

    renderTextures = new RenderTexture[2];
    frameBuffers = new FrameBuffer[2];

    setupFrameBuffer(unused);

    Matrix.setLookAtM(V_matrix, 0, 0, 0, 1.0f, 0f, 0f, 0f, 0f, -1.0f, 0.0f);
    Matrix.orthoM(Q_matrix, 0, 0, 1, 0, 1, -1, 1);
  }
コード例 #9
0
  public void setupVideoTexture() {

    vmaterial = new VideoMaterial();
    vt = mTextureManager.addVideoTexture();
    int textureid = vt.getTextureId();

    mTexture = new SurfaceTexture(textureid);
    mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setOnPreparedListener(this);
    mMediaPlayer.setOnBufferingUpdateListener(this);
    mMediaPlayer.setOnCompletionListener(this);
    mMediaPlayer.setOnErrorListener(this);
    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mMediaPlayer.setSurface(new Surface(mTexture));
    mMediaPlayer.setLooping(true);
  }
コード例 #10
0
  public void LoadObjects(ProjectLevel p) {
    for (int i = 0; i < p.getModels().size(); i++) {
      mParser = new ObjParser(this, p.getModels().get(i).getModel());
      mParser.parse();
      BaseObject3D obj = mParser.getParsedObject();
      obj.setDepthMaskEnabled(true);
      obj.setDepthTestEnabled(true);
      obj.setBlendingEnabled(true);
      obj.setBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
      if (p.getModels().get(i).isDoubleSided()) {
        obj.setDoubleSided(true);
      }
      if (p.getModels().get(i).isVideo()) {
        // Log.d("isvideo", "yeees");
        // obj.setMaterial(vmaterial);
        // obj.addTexture(vt);
      } else {
        obj.setMaterial(new SimpleMaterial());
        String tn = p.getModels().get(i).getTexture();
        if (!textureNames.contains(tn)) {
          textureNames.add(tn); // store texture names for unique
          // textures
          int idx = textureNames.indexOf(tn); // get index

          Bitmap mBM =
              BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + tn);
          TextureInfo ti = mTextureManager.addTexture(mBM);
          textureInfos.add(idx, ti); // store texture info with same
          // index as texture name
          obj.addTexture(ti);
        } else {
          int idx = textureNames.indexOf(tn);
          obj.addTexture(textureInfos.get(idx));
        }
      }
      addChild(obj);
      BoundingBox bb = obj.getGeometry().getBoundingBox();
      Number3D mi = bb.getMin();
      Number3D mx = bb.getMax();
      Number3D cnt = new Number3D((mi.x + mx.x) / 2, (mi.y + mx.y) / 2, (mi.z + mx.z) / 2);
      p.getModels().get(i).setCenter(cnt);
      p.getModels().get(i).setObj(obj);
    }
    Log.d("objloader", "objects in scene:" + getNumChildren());
  }
コード例 #11
0
ファイル: SurfaceView.java プロジェクト: xiezl/cs5248
  @Override
  public void run() {

    mViewSurfaceManager = new SurfaceManager(getHolder().getSurface());
    mViewSurfaceManager.makeCurrent();
    mTextureManager.createTexture().setOnFrameAvailableListener(this);

    mLock.release();

    try {
      // long ts = 0, oldts = 0;
      long startTimeUS = 0, ts;
      while (mRunning) {
        synchronized (mSyncObject) {
          // mSyncObject.wait(2500);
          // only wait for 100 ms, make it more responsive
          mSyncObject.wait(100);
          if (mFrameAvailable) {
            mFrameAvailable = false;

            mViewSurfaceManager.makeCurrent();
            mTextureManager.updateFrame();
            mTextureManager.drawFrame();
            mViewSurfaceManager.swapBuffer();

            if (mCodecSurfaceManager != null) {
              mCodecSurfaceManager.makeCurrent();
              mTextureManager.drawFrame();
              ts = mTextureManager.getSurfaceTexture().getTimestamp();
              if (mFirstFrame) {
                startTimeUS = ts;
                mFirstFrame = false;
              }
              ts = ts - startTimeUS;
              Log.d(TAG, "input presentation time: " + (ts / 1000000) + "(ms)");
              // Log.d(TAG, "FPS: "+(1000000000/(ts-oldts)));
              mCodecSurfaceManager.setPresentationTime(ts);
              mCodecSurfaceManager.swapBuffer();
            }

          } else {
            Log.e(TAG, "No frame received !");
          }
        }
      }
    } catch (InterruptedException ignore) {
    } finally {
      mViewSurfaceManager.release();
      mTextureManager.release();
    }
  }
コード例 #12
0
ファイル: BaseGame.java プロジェクト: belak/Broids
  /*
   * (non-Javadoc)
   *
   * @see com.badlogic.gdx.ApplicationListener#create()
   */
  @Override
  public void create() {

    // TODO: Put this in a better place, remove the method
    CoreLogic.setGame(this);

    exitBuffer = 1;
    multiplayer = false;
    bounds = .25f; // max of .5
    gameSize = 0;

    font =
        new BitmapFont(
            Gdx.files.internal(Settings.data_path + "smallfonts.fnt"),
            Gdx.files.internal(Settings.data_path + "smallfonts_0.png"),
            false);

    Gdx.input.setCatchBackKey(true);

    Settings.init(this);

    try {
      Net.init(this);
      SoundManager.init(this);
      TextureManager.init(this);
      ScoresManager.init(this);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    screens = new HashMap<String, Screen>();
    screens.put("splash", new SplashScreen(this));
    screens.put("main", new MainMenu(this));
    screens.put("settings", new SettingsScreen(this));
    if (connected) {
      screens.put("host", new MultiHost(this));
      screens.put("lobby", new MultiLobby(this));
    }

    screens.put("scores", new ScoresScreen(this));

    this.setScreen(BaseGame.screens.get("splash"));
  }
コード例 #13
0
ファイル: SurfaceView.java プロジェクト: xiezl/cs5248
 public SurfaceTexture getSurfaceTexture() {
   return mTextureManager.getSurfaceTexture();
 }
コード例 #14
0
ファイル: WaterLayer.java プロジェクト: scheibk/FFZ
  public void draw(StandardProgram prog, Viewport vp) {

    // get handle to vertex shader's vPosition member
    mPositionHandle = prog.getAttributeLocation("vPosition");

    // set the vertext pointer to the front of the buffer
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, buffers[0]);
    GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, buffers[1]); // draw order

    GLES20.glEnableVertexAttribArray(mPositionHandle);

    // get handle to fragment shader's vColor member
    mColorHandle = prog.getUniformLocation("vColor");

    // texture stuff

    mTextureUniformHandle = prog.getUniformLocation("u_Texture");
    mTextureCoordinateHandle = prog.getAttributeLocation("a_TexCoordinate");
    tm.setTextureToRepeat(R.drawable.blank);
    GLES20.glUniform1i(mTextureUniformHandle, 0);

    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
    GLES20.glEnable(GLES20.GL_BLEND);

    GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);

    // get handle to shape's transformation matrix
    mMVPMatrixHandle = prog.getUniformLocation("uMVPMatrix");

    // start the position at -1, -1
    Matrix.setIdentityM(mMMatrix, 0);
    Matrix.translateM(mMMatrix, 0, 0, 0, 1.0f); // z index is at the very front

    // ---- draw a puddle

    setBufferPosition(PUDDLE);
    setColor(normalColor);

    setDrawPosition(300f, -300f);

    setScale(9.0f, 7.0f);

    // set up the view matrix and projection matrix
    Matrix.multiplyMM(eyeMatrix, 0, vp.getViewMatrix(), 0, mMMatrix, 0);
    Matrix.multiplyMM(mvpMatrix, 0, vp.getProjMatrix(), 0, eyeMatrix, 0);

    // Apply the projection and view transformation
    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);

    // Draw
    GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length, GLES20.GL_UNSIGNED_SHORT, 0);

    // ---- end draw puddle

    // IMPORTANT: Unbind from the buffer when we're done with it.
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
    GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);

    // Disable vertex array
    GLES20.glDisableVertexAttribArray(mPositionHandle);
  }
コード例 #15
0
  @Override
  public void onDestroy() {
    super.onDestroy();

    TextureManager.sharedTextureManager().removeAllTextures();
  }
コード例 #16
0
ファイル: WaterLayer.java プロジェクト: scheibk/FFZ
  public static void loadGLTexture(Context context) {

    tm = new TextureManager(context);
    tm.add(R.drawable.blank);
    tm.loadTextures();
  }
コード例 #17
0
  private void drawObject_textures(Object3d $o) {
    // iterate thru object's textures

    for (int i = 0; i < RenderCaps.maxTextureUnits(); i++) {
      _gl.glActiveTexture(GL10.GL_TEXTURE0 + i);
      _gl.glClientActiveTexture(GL10.GL_TEXTURE0 + i);

      if ($o.hasUvs() && $o.texturesEnabled()) {
        $o.vertices().uvs().buffer().position(0);
        _gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, $o.vertices().uvs().buffer());

        TextureVo textureVo =
            ((i < $o.textures().size())) ? textureVo = $o.textures().get(i) : null;

        if (textureVo != null) {
          // activate texture
          int glId = _textureManager.getGlTextureId(textureVo.textureId);
          _gl.glBindTexture(GL10.GL_TEXTURE_2D, glId);
          _gl.glEnable(GL10.GL_TEXTURE_2D);
          _gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

          int minFilterType =
              _textureManager.hasMipMap(textureVo.textureId)
                  ? GL10.GL_LINEAR_MIPMAP_NEAREST
                  : GL10.GL_NEAREST;
          _gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, minFilterType);
          _gl.glTexParameterf(
              GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); // (OpenGL default)

          // do texture environment settings
          for (int j = 0; j < textureVo.textureEnvs.size(); j++) {
            _gl.glTexEnvx(
                GL10.GL_TEXTURE_ENV,
                textureVo.textureEnvs.get(j).pname,
                textureVo.textureEnvs.get(j).param);
          }

          // texture wrapping settings
          _gl.glTexParameterx(
              GL10.GL_TEXTURE_2D,
              GL10.GL_TEXTURE_WRAP_S,
              (textureVo.repeatU ? GL10.GL_REPEAT : GL10.GL_CLAMP_TO_EDGE));
          _gl.glTexParameterx(
              GL10.GL_TEXTURE_2D,
              GL10.GL_TEXTURE_WRAP_T,
              (textureVo.repeatV ? GL10.GL_REPEAT : GL10.GL_CLAMP_TO_EDGE));

          // texture offset, if any
          if (textureVo.offsetU != 0 || textureVo.offsetV != 0) {
            _gl.glMatrixMode(GL10.GL_TEXTURE);
            _gl.glLoadIdentity();
            _gl.glTranslatef(textureVo.offsetU, textureVo.offsetV, 0);
            _gl.glMatrixMode(GL10.GL_MODELVIEW); // .. restore matrixmode
          }
        } else {
          _gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
          _gl.glDisable(GL10.GL_TEXTURE_2D);
          _gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        }
      } else {
        _gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
        _gl.glDisable(GL10.GL_TEXTURE_2D);
        _gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
      }
    }
  }