示例#1
0
 public Desktop(Display display) {
   mDisplay = display;
   mVertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, VERTEX_SHADER);
   mFragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER);
   mProgramHandle =
       ShaderHelper.createAndLinkProgram(
           mVertexShaderHandle,
           mFragmentShaderHandle,
           new String[] {"a_Position", "a_TexCoordinate", "u_CombinedMatrix", "u_Texture"});
   mCombinedMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_CombinedMatrix");
   mTextureUniformHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_Texture");
   mPositionHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Position");
   mTransparentHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_transparency");
   mTextureCoordinateHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_TexCoordinate");
   mTextureDataHandle = TextureHelper.createTextureHandle();
 }
示例#2
0
文件: Vorxel.java 项目: Pitzik4/Geode
  public static void init(VorxelSettings set, Geode gamep) {
    world = new World();
    game = gamep;
    try {
      DisplayMode d[] = Display.getAvailableDisplayModes();
      DisplayMode displayMode = d[0];
      Display.setDisplayMode(displayMode);
      Display.create();

      Mouse.create();
      Keyboard.create();

      GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping
      GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
      GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
      GL11.glClearDepth(1.0); // Depth Buffer Setup
      GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
      GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do

      GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
      GL11.glLoadIdentity(); // Reset The Projection Matrix
      // Calculate The Aspect Ratio Of The Window
      GLU.gluPerspective(
          45.0f, (float) displayMode.getWidth() / (float) displayMode.getHeight(), 0.1f, 100.0f);
      GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix

      // Really Nice Perspective Calculations
      GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
      TextureHelper.init();
      Cube.dirt.texture = new VTex(4);
      Cube.grass.texture = Cube.dirt.texture;
      Cube.grass.toptexture = new VTex(1);
      Mouse.setGrabbed(true);
      world.createSpawn();
    } catch (LWJGLException e) {
      e.printStackTrace();
    }
  }
示例#3
0
  /**
   * Update the desktop frame data based on the mVideoFrame. Note here we fix the height of the
   * desktop and vary width accordingly.
   */
  private void updateVideoFrame(Bitmap videoFrame) {
    float newHalfDesktopWidth;
    synchronized (mVideoFrameLock) {
      mVideoFrame = videoFrame;
      TextureHelper.linkTexture(mTextureDataHandle, videoFrame);
      newHalfDesktopWidth = videoFrame.getWidth() * HALF_HEIGHT / videoFrame.getHeight();
    }

    synchronized (mHalfWidthLock) {
      if (Math.abs(mHalfWidth - newHalfDesktopWidth) > 0.0001) {
        mHalfWidth = newHalfDesktopWidth;
        mPosition =
            makeFloatBuffer(
                new float[] {
                  // Desktop model coordinates.
                  -mHalfWidth,
                  HALF_HEIGHT,
                  0.0f,
                  -mHalfWidth,
                  -HALF_HEIGHT,
                  0.0f,
                  mHalfWidth,
                  HALF_HEIGHT,
                  0.0f,
                  -mHalfWidth,
                  -HALF_HEIGHT,
                  0.0f,
                  mHalfWidth,
                  -HALF_HEIGHT,
                  0.0f,
                  mHalfWidth,
                  HALF_HEIGHT,
                  0.0f
                });
      }
    }
  }
  public static void renderTooltip(
      int x,
      int y,
      List<String> tooltipData,
      Color color,
      Color colorFade,
      FontRenderer fontRenderer) {
    TextureHelper.setActiveTextureToAtlasSprite();
    boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
    if (lighting) RenderHelper.disableStandardItemLighting();

    if (!tooltipData.isEmpty()) {
      int esWidth = 0;
      for (String toolTip : tooltipData) {
        int width = fontRenderer.getStringWidth(toolTip);
        if (width > esWidth) esWidth = width;
      }
      int pX = x + 12;
      int pY = y - 12;
      int sumLineHeight = 8;
      if (tooltipData.size() > 1) sumLineHeight += 2 + (tooltipData.size() - 1) * 10;
      float z = 300F;

      drawGradientRect(pX - 3, pY - 4, z, pX + esWidth + 3, pY - 3, color, colorFade);
      drawGradientRect(
          pX - 3,
          pY + sumLineHeight + 3,
          z,
          pX + esWidth + 3,
          pY + sumLineHeight + 4,
          color,
          colorFade);
      drawGradientRect(
          pX - 3, pY - 3, z, pX + esWidth + 3, pY + sumLineHeight + 3, color, colorFade);
      drawGradientRect(pX - 4, pY - 3, z, pX - 3, pY + sumLineHeight + 3, color, colorFade);
      drawGradientRect(
          pX + esWidth + 3, pY - 3, z, pX + esWidth + 4, pY + sumLineHeight + 3, color, colorFade);

      int rgb = color.getRGB();
      int col = (rgb & 0x00FFFFFF) | rgb & 0xFF000000;
      Color colOp = new Color(col);
      drawGradientRect(pX - 3, pY - 3 + 1, z, pX - 3 + 1, pY + sumLineHeight + 3 - 1, color, colOp);
      drawGradientRect(
          pX + esWidth + 2,
          pY - 3 + 1,
          z,
          pX + esWidth + 3,
          pY + sumLineHeight + 3 - 1,
          color,
          colOp);
      drawGradientRect(pX - 3, pY - 3, z, pX + esWidth + 3, pY - 3 + 1, colOp, colOp);
      drawGradientRect(
          pX - 3,
          pY + sumLineHeight + 2,
          z,
          pX + esWidth + 3,
          pY + sumLineHeight + 3,
          color,
          color);

      GL11.glDisable(GL11.GL_DEPTH_TEST);
      for (int i = 0; i < tooltipData.size(); ++i) {
        String var14 = tooltipData.get(i);
        fontRenderer.drawString(var14, pX, pY, Color.WHITE.getRGB());
        if (i == 0) pY += 2;
        pY += 10;
      }
      GL11.glEnable(GL11.GL_DEPTH_TEST);
    }

    if (lighting) RenderHelper.enableStandardItemLighting();
    GL11.glColor4f(1F, 1F, 1F, 1F);
  }