Пример #1
0
  @Override
  public void draw(VBOBuffers p_bufs) {
    preDraw();

    int count = p_bufs.indices.remaining();
    shaders.drawIndicedAndTexture(
        p_bufs.vertices, p_bufs.textures, p_bufs.indices, GLES20.GL_TRIANGLES, count);
  }
Пример #2
0
  @Override
  public void draw(VBOBuffers p_bufs, int start, int count) {
    preDraw();

    shaders.drawTexture(p_bufs.vertices, p_bufs.textures, GLES20.GL_TRIANGLES, start, count);
  }
  ///////////////////////////////////////////////////////////////////////////////////////
  // render
  ///////////////////////////////////////////////////////////////////////////////////////
  // Draw every sprite's primitives
  ///////////////////////////////////////////////////////////////////////////////////////
  // IN: true=render BACKground
  //	   false=render FOREground
  ///////////////////////////////////////////////////////////////////////////////////////
  @Override
  public void render(int floor, boolean backGround) {

    // Display every sprites
    GLES20.glEnable(GLES20.GL_BLEND);

    float[] color = new float[4]; // =textureEngine.graphicStuff.getFloat(GL11.GL_CURRENT_COLOR, 4);
    color[0] = 1f;
    color[1] = 1f;
    color[2] = 1f;
    color[3] = 1f;

    Vector3f ambient = ClientEngineZildo.ortho.getAmbientColor();
    if (ambient != null) {
      color[0] = ambient.x;
      color[1] = ambient.y;
      color[2] = ambient.z;
    }
    // Respect order from bankOrder
    boolean endSequence = false;
    int posBankOrder = 0;

    // Retrieve the sprite's order
    int[][][] bankOrder = ClientEngineZildo.spriteDisplay.getBankOrder();

    int phase = (backGround) ? 0 : 1;
    while (!endSequence) {
      int numBank = bankOrder[floor][phase][posBankOrder * 4];
      if (numBank == -1) {
        endSequence = true;
      } else {
        // Render the n sprites from this bank
        int nbQuads = bankOrder[floor][phase][posBankOrder * 4 + 1];
        int iCurrentFX = bankOrder[floor][phase][posBankOrder * 4 + 2];
        int alpha = bankOrder[floor][phase][posBankOrder * 4 + 3];
        EngineFX currentFX = EngineFX.values()[iCurrentFX];
        int texId = textureEngine.getNthTexture(numBank);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texId);

        // Select the right pixel shader (if needed)

        if (pixelShaderSupported) {
          switch (currentFX) {
            case NO_EFFECT:
              shaders.setCurrentShader(GLShaders.textured);
              break;
            case PERSO_HURT:
              // A sprite has been hurt
              shaders.setCurrentShader(GLShaders.wounded);
              shaders.setWoundedColor(
                  new Vector4f(
                      (float) Math.random(), (float) Math.random(), (float) Math.random(), 1));
              /*
              ARBShaderObjects.glUseProgramObjectARB(ClientEngineZildo.pixelShaders.getPixelShader(1));
              ClientEngineZildo.pixelShaders.setParameter(1, "randomColor", );
              */
              break;
            case YELLOW_HALO:
              shaders.setCurrentShader(GLShaders.goldFilter);
              shaders.setGoldFactor((float) (0.6 + 0.4 * Math.cos(3 * gamma)));
              break;
            case STAR:
              shaders.setCurrentShader(GLShaders.star);
              shaders.setStarNoise(gamma, (float) Math.random());
              break;
            default:
              if (currentFX.needPixelShader()) {
                // This is a color replacement, so get the right ones
                Vector4f[] tabColors =
                    ClientEngineZildo.pixelShaders.getConstantsForSpecialEffect(currentFX);

                // And enable the 'color replacement' pixel shader
                shaders.setCurrentShader(GLShaders.switchColor);
                shaders.setSwitchColors(tabColors);
                /*
                ClientEngineZildo.pixelShaders.setParameter(0, "Color1", tabColors[2]);
                ClientEngineZildo.pixelShaders.setParameter(0, "Color2", tabColors[3]);
                ClientEngineZildo.pixelShaders.setParameter(0, "Color3", tabColors[0].scale(color[0]));
                ClientEngineZildo.pixelShaders.setParameter(0, "Color4", tabColors[1].scale(color[0]));
                */
              } else {
                shaders.setCurrentShader(GLShaders.textured);
              }
          }
        }

        switch (currentFX) {
          case SHINY:
            GLES20.glBlendFunc(GLES20.GL_SRC_COLOR, GLES20.GL_ONE); // _MINUS_SRC_ALPHA);
            shaders.setColor(1, (float) Math.random(), 0, (float) Math.random());
            break;
          case QUAD:
            GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
            shaders.setColor(
                0.5f + 0.5f * (float) Math.random(), 0.5f * (float) Math.random(), 0, 1);
            break;
          case FOCUSED:
            GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
            // FIXME: previously color3f
            shaders.setColor(1.0f, 1.0f, 1.0f, alpha / 255.0f);
            break;
          case FONT_PEOPLENAME:
            GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
            shaders.setColor(0.9f, 0.5f, 0.2f, alpha / 255.0f);
            break;
          default:
            color[3] = alpha / 255.0f;
            shaders.setColor(color[0], color[1], color[2], color[3]);
            GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
        }
        meshSprites[numBank].render(nbQuads);
        posBankOrder++;
      }
    }

    // Deactivate pixel shader
    if (pixelShaderSupported) {
      shaders.setCurrentShader(GLShaders.textured);
    }
    GLES20.glDisable(GLES20.GL_BLEND);

    gamma = (float) ((gamma + 0.01f) % (Math.PI * 2));
  }