protected void doFlush() {
    if (!(activeShader instanceof BasicShader))
      throw new IllegalStateException("Need Basic Shader in 1.1 mode");

    GL11.glNewList(displayList, GL11.GL_COMPILE);
    ((BasicShader) activeShader).assign(true);
    GL11.glPushMatrix();
    GL11.glBegin(renderMode);
    for (int i = 0; i < numVerticies; i += 1) {
      int index = i * 4;
      if (useColors)
        GL11.glColor3f(
            colorBuffer.get(index), colorBuffer.get(index + 1), colorBuffer.get(index + 2));
      if (useNormals)
        GL11.glNormal3f(
            normalBuffer.get(index), normalBuffer.get(index + 1), normalBuffer.get(index + 2));
      if (useTextures) GL11.glTexCoord2f(uvBuffer.get((i * 2)), uvBuffer.get((i * 2) + 1));
      GL11.glVertex4f(
          vertexBuffer.get(index),
          vertexBuffer.get(index + 1),
          vertexBuffer.get(index + 2),
          vertexBuffer.get(index + 3));
    }
    GL11.glEnd();
    GL11.glPopMatrix();
    GL11.glEndList();
  }
  @Override
  public void doRender() {

    GL11.glPushMatrix();
    GL11.glCallList(displayList);
    GL11.glPopMatrix();
  }
Esempio n. 3
0
  private void drawLine(int X1, int Y1, int X2, int Y2, float color[]) {
    GL11.glColor3f(color[0], color[1], color[2]);

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(X1, Y1);
    GL11.glVertex2f(X2, Y2);
    GL11.glEnd();
  }
 private static void drawBox() {
   GL11.glBegin(GL11.GL_QUADS);
   GL11.glTexCoord2f(0.0f, 0.0f);
   GL11.glVertex3f(-1.0f, -1.0f, 0.0f);
   GL11.glTexCoord2f(1.0f, 0.0f);
   GL11.glVertex3f(1.0f, -1.0f, 0.0f);
   GL11.glTexCoord2f(1.0f, 1.0f);
   GL11.glVertex3f(1.0f, 1.0f, 0.0f);
   GL11.glTexCoord2f(0.0f, 1.0f);
   GL11.glVertex3f(-1.0f, 1.0f, 0.0f);
   GL11.glEnd();
 }
  static {
    logger.config("fbo: supported=%s", fboSupported);
    logger.config("GL13: supported=%s, enabled=%s", gl13Supported, useGL13);

    int bits =
        GL11.GL_VIEWPORT_BIT | GL11.GL_SCISSOR_BIT | GL11.GL_DEPTH_BITS | GL11.GL_LIGHTING_BIT;
    if (useGL13) {
      bits |= GL13.GL_MULTISAMPLE_BIT;
    }
    glAttributes = bits;

    GL11.glNewList(drawList, GL11.GL_COMPILE);
    drawBox();
    GL11.glEndList();
  }
Esempio n. 6
0
  private void drawVecSlider() {
    drawQuad(screenWidth - 205, 0, 200, 205, colorArray[3]);
    drawQuad(screenWidth - 200, 5, 190, 195, colorArray[0]);

    drawQuad(screenWidth - 101, 70, 60, 2, colorArray[4]);
    drawQuad(screenWidth - 130, 99, 2, 60, colorArray[4]);

    GL11.glTranslatef(screenWidth - 100, 100, 0);

    drawCircle(vecSlider.x, vecSlider.y, 11, colorArray[2]);

    GL11.glLoadIdentity();

    // drawCircle((sizeSliderVal*7) + 23, 30, 25, colorArray[2]);
  }
  protected void runLoop() {
    if (!created.get()) {
      throw new IllegalStateException();
    }

    if (pbuffer.isBufferLost()) {
      pbuffer.destroy();

      try {
        pbuffer = new Pbuffer(width, height, pixelFormat, null);
        pbuffer.makeCurrent();

        // Context MUST be reset here to avoid invalid objects!
        renderer.invalidateState();
      } catch (LWJGLException ex) {
        listener.handleError("Failed to restore pbuffer content", ex);
      }
    }

    listener.update();
    checkGLError();

    renderer.postFrame();

    // Need to flush GL commands
    // to see any result on the pbuffer's front buffer.
    GL11.glFlush();

    int frameRate = settings.getFrameRate();
    if (frameRate >= 1) {
      Display.sync(frameRate);
    }
  }
 void read(ByteBuffer buffer) {
   EXTFramebufferObject.glBindFramebufferEXT(
       EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBuffer);
   buffer.position(0);
   GL11.glReadPixels(
       x0, y0, width, height, MipmapHelper.TEX_FORMAT, MipmapHelper.TEX_DATA_TYPE, buffer);
 }
Esempio n. 9
0
  private void drawCircle(double x, double y, int radius, float color[], float alpha) {
    GL11.glColor4f(color[0], color[1], color[2], alpha);

    float incr = (float) (2 * Math.PI / slices);
    /*xCoord = xCoord + radius;
    yCoord = yCoord + radius;*/

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    for (int i = 0; i < slices; i++) {
      float angle = incr * i;

      float Xc = (float) (x + Math.cos(angle) * radius);
      float Yc = (float) (y + Math.sin(angle) * radius);

      GL11.glVertex2f(Xc, Yc);
    }
    GL11.glEnd();
  }
Esempio n. 10
0
 private void checkGLError(String s) {
   int i = GL11.glGetError();
   if (i != 0) {
     String s1 = GLU.gluErrorString(i);
     System.out.println("########## GL ERROR ##########");
     System.out.println((new StringBuilder()).append("@ ").append(s).toString());
     System.out.println((new StringBuilder()).append(i).append(": ").append(s1).toString());
   }
 }
 void delete() {
   if (!deleted) {
     deleted = true;
     if (ownTexture) {
       GL11.glDeleteTextures(texture);
     }
     EXTFramebufferObject.glDeleteFramebuffersEXT(frameBuffer);
   }
 }
  @Override
  protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glPushMatrix();
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    if (inverted) {
      this.mc.renderEngine.bindTexture(
          new ResourceLocation(
              "uncraftingTable:textures/gui/container/uncrafting_gui_redstoned.png"));
    } else
      this.mc.renderEngine.bindTexture(
          new ResourceLocation("uncraftingTable:textures/gui/container/uncrafting_gui.png"));

    int k = width / 2 - xSize / 2;
    int l = height / 2 - ySize / 2;
    this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
    GL11.glPopMatrix();
  }
  private FancyDial(TextureAtlasSprite icon, PropertiesFile properties) {
    this.icon = icon;
    this.properties = properties;
    name = IconAPI.getIconName(icon);
    x0 = IconAPI.getIconX0(icon);
    y0 = IconAPI.getIconY0(icon);
    width = IconAPI.getIconWidth(icon);
    height = IconAPI.getIconHeight(icon);
    scratchBuffer = ByteBuffer.allocateDirect(4 * width * height);

    int itemsTexture = TexturePackAPI.getTextureIfLoaded(TexturePackAPI.ITEMS_PNG);
    if (itemsTexture < 0) {
      logger.severe("could not get items texture");
      return;
    }
    itemsFBO = new FBO(itemsTexture, x0, y0, width, height);

    if (useScratchTexture) {
      logger.fine("rendering %s to %dx%d scratch texture", name, width, height);
      for (int i = 0; i < scratchFBO.length; i++) {
        scratchFBO[i] = new FBO(width, height);
      }
    } else {
      logger.fine("rendering %s directly to atlas", name);
    }

    boolean debug = false;
    for (int i = 0; ; i++) {
      Layer layer = newLayer(properties, "." + i);
      if (layer == null) {
        if (i > 0) {
          break;
        }
        continue;
      }
      layers.add(layer);
      debug |= layer.debug;
      logger.fine("  new %s", layer);
    }
    keyboard = new InputHandler(name, debug);
    if (layers.size() < 2) {
      logger.error("custom %s needs at least two layers defined", name);
      return;
    }

    outputFrames = properties.getInt("outputFrames", 0);

    int glError = GL11.glGetError();
    if (glError != 0) {
      logger.severe("%s during %s setup", GLU.gluErrorString(glError), name);
      return;
    }
    ok = true;
  }
Esempio n. 14
0
 public void render(Map<TexturedModel, List<Entity>> entities) {
   for (TexturedModel model : entities.keySet()) {
     prepareTexturedModel(model);
     List<Entity> batch = entities.get(model);
     for (Entity entity : batch) {
       prepareInstance(entity);
       GL11.glDrawElements(
           GL11.GL_TRIANGLES, model.getModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
     }
     unbindTexturedModel();
   }
 }
Esempio n. 15
0
 static void drawTorus(float r, float R, int nsides, int rings) {
   float ringDelta = 2.0f * (float) Math.PI / rings;
   float sideDelta = 2.0f * (float) Math.PI / nsides;
   float theta = 0.0f, cosTheta = 1.0f, sinTheta = 0.0f;
   for (int i = rings - 1; i >= 0; i--) {
     float theta1 = theta + ringDelta;
     float cosTheta1 = (float) Math.cos(theta1);
     float sinTheta1 = (float) Math.sin(theta1);
     GL11.glBegin(GL11.GL_QUAD_STRIP);
     float phi = 0.0f;
     for (int j = nsides; j >= 0; j--) {
       phi += sideDelta;
       float cosPhi = (float) Math.cos(phi);
       float sinPhi = (float) Math.sin(phi);
       float dist = R + r * cosPhi;
       GL11.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
       GL11.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
       GL11.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
       GL11.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
     }
     GL11.glEnd();
     theta = theta1;
     cosTheta = cosTheta1;
     sinTheta = sinTheta1;
   }
 }
Esempio n. 16
0
  private void drawQuad(int x, int y, int h, int w, float color[], float alpha) {
    GL11.glColor4f(color[0], color[1], color[2], alpha);

    // draw quad
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + w, y);
    GL11.glVertex2f(x + w, y + h);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();
  }
 void write(ByteBuffer buffer) {
   GLAPI.glBindTexture(texture);
   buffer.position(0);
   GL11.glTexSubImage2D(
       GL11.GL_TEXTURE_2D,
       0,
       x0,
       y0,
       width,
       height,
       MipmapHelper.TEX_FORMAT,
       MipmapHelper.TEX_DATA_TYPE,
       buffer);
 }
Esempio n. 18
0
  private void startDisplayLoop() {
    while (!Display.isCloseRequested()) {
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

      checkInput();
      applyPhysics();

      drawStuff();

      endThisLoop();
    }
    endProgram();
    Display.destroy();
  }
Esempio n. 19
0
  protected void printContextInitInfo() {
    logger.log(
        Level.INFO,
        "Lwjgl {0} context running on thread {1}",
        new Object[] {Sys.getVersion(), Thread.currentThread().getName()});

    logger.log(Level.INFO, "Adapter: {0}", Display.getAdapter());
    logger.log(Level.INFO, "Driver Version: {0}", Display.getVersion());

    String vendor = GL11.glGetString(GL11.GL_VENDOR);
    logger.log(Level.INFO, "Vendor: {0}", vendor);

    String version = GL11.glGetString(GL11.GL_VERSION);
    logger.log(Level.INFO, "OpenGL Version: {0}", version);

    String renderGl = GL11.glGetString(GL11.GL_RENDERER);
    logger.log(Level.INFO, "Renderer: {0}", renderGl);

    if (GLContext.getCapabilities().OpenGL20) {
      String shadingLang = GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION);
      logger.log(Level.INFO, "GLSL Ver: {0}", shadingLang);
    }
  }
Esempio n. 20
0
  private void prepareTexturedModel(TexturedModel model) {
    RawModel rawModel = model.getModel();
    GL30.glBindVertexArray(rawModel.getVaoID());
    GL20.glEnableVertexAttribArray(0); // vertices array
    GL20.glEnableVertexAttribArray(1); // textures array
    GL20.glEnableVertexAttribArray(2); // normals array

    { // Load Texture and shine
      ModelTexture texture = model.getTexture();
      shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());

      GL13.glActiveTexture(GL13.GL_TEXTURE0);
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureID());
    }
  }
 public static boolean update(TextureAtlasSprite icon, boolean itemFrameRenderer) {
   if (!initialized) {
     logger.finer("deferring %s update until initialization finishes", IconAPI.getIconName(icon));
     return false;
   }
   if (!active) {
     return false;
   }
   int oldFB = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
   if (oldFB != 0 && warnCount < 10) {
     logger.finer(
         "rendering %s while non-default framebuffer %d is active",
         IconAPI.getIconName(icon), oldFB);
     warnCount++;
   }
   int oldTexture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
   try {
     FancyDial instance = getInstance(icon);
     return instance != null && instance.render(itemFrameRenderer);
   } finally {
     EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFB);
     GLAPI.glBindTexture(oldTexture);
   }
 }
    void unbind() {
      GL11.glPopAttrib();

      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glPopMatrix();

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glPopMatrix();

      if (lightmapEnabled) {
        GL13.glActiveTexture(GL13.GL_TEXTURE1);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
      }
      GL11.glEnable(GL11.GL_BLEND);
      GLAPI.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

      EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
    }
 private void renderImpl(double angle) {
   for (Layer layer : layers) {
     layer.blendMethod.applyBlending();
     GL11.glPushMatrix();
     TexturePackAPI.bindTexture(layer.textureName);
     float offsetX = layer.offsetX;
     float offsetY = layer.offsetY;
     float scaleX = layer.scaleX;
     float scaleY = layer.scaleY;
     if (layer.debug) {
       offsetX += offsetXDelta;
       offsetY += offsetYDelta;
       scaleX += scaleXDelta;
       scaleY += scaleYDelta;
     }
     GL11.glTranslatef(offsetX, offsetY, 0.0f);
     GL11.glScalef(scaleX, scaleY, 1.0f);
     float layerAngle = (float) (angle * layer.rotationMultiplier + layer.rotationOffset);
     GL11.glRotatef(layerAngle, 0.0f, 0.0f, 1.0f);
     GL11.glCallList(drawList);
     GL11.glPopMatrix();
   }
 }
Esempio n. 24
0
  private void initGL(int width, int height) {

    try {
      // DisplayMode mode = new DisplayMode(width,height);
      // DisplayMode mode = Display.getDesktopDisplayMode(); Old code, for not-fullscreen stuff
      Display.setDisplayMode(Display.getDesktopDisplayMode());
      Display.setFullscreen(true);
      Display.create();
      Display.setVSyncEnabled(true);
    } catch (LWJGLException e) {
      System.out.println("Catched an error in intiGL");
      e.printStackTrace();
      System.exit(0);
    }

    // init OpenGL
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, 0, height, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  }
Esempio n. 25
0
  @Override
  public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) {
    String tStation = StatCollector.translateToLocal("manual.page.modifier1");
    if (icons.length > 3) tStation = StatCollector.translateToLocal("manual.page.modifier2");
    if (icons.length > 4) tStation = StatCollector.translateToLocal("manual.page.modifier3");
    if (isTranslatable) tStation = StatCollector.translateToLocal(tStation);
    manual.fonts.drawString("\u00a7n" + tStation, localWidth + 60, localHeight + 4, 0);
    GL11.glScalef(2f, 2f, 2f);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    RenderHelper.enableGUIStandardItemLighting();

    ItemStack toolstack = MantleClientRegistry.getManualIcon("ironpick");
    if (type.equals("weapon")) toolstack = MantleClientRegistry.getManualIcon("ironlongsword");
    if (type.equals("travelgoggles"))
      toolstack = MantleClientRegistry.getManualIcon("travelgoggles");
    if (type.equals("travelvest")) toolstack = MantleClientRegistry.getManualIcon("travelvest");
    if (type.equals("travelwings")) toolstack = MantleClientRegistry.getManualIcon("travelwings");
    if (type.equals("travelboots")) toolstack = MantleClientRegistry.getManualIcon("travelboots");
    if (type.equals("travelbelt")) toolstack = MantleClientRegistry.getManualIcon("travelbelt");
    if (type.equals("travelglove")) toolstack = MantleClientRegistry.getManualIcon("travelglove");
    if (type.equals("travelmulti")) toolstack = toolMulti[counter];

    // update displayed item
    if (iconsMulti != null
        && iconsMulti.length > 0
        && type.equals("travelmulti")
        && System.currentTimeMillis() - lastUpdate > 1000) {
      lastUpdate = System.currentTimeMillis();
      counter++;
      if (counter >= iconsMulti.length) counter = 0;
      icons = iconsMulti[counter];
      toolstack = toolMulti[counter];
    }

    manual.renderitem.zLevel = 100;
    if (icons.length < 4) {
      manual.renderitem.renderItemAndEffectIntoGUI(
          manual.fonts,
          manual.getMC().renderEngine,
          toolstack,
          (localWidth + 54) / 2,
          (localHeight + 54) / 2);
      manual.renderitem.renderItemAndEffectIntoGUI(
          manual.fonts,
          manual.getMC().renderEngine,
          icons[0],
          (localWidth + 130) / 2,
          (localHeight + 54) / 2);
      manual.renderitem.renderItemAndEffectIntoGUI(
          manual.fonts,
          manual.getMC().renderEngine,
          icons[1],
          (localWidth + 18) / 2,
          (localHeight + 36) / 2);
      if (icons[2] != null)
        manual.renderitem.renderItemAndEffectIntoGUI(
            manual.fonts,
            manual.getMC().renderEngine,
            icons[2],
            (localWidth + 18) / 2,
            (localHeight + 74) / 2);
    } else {
      manual.renderitem.renderItemAndEffectIntoGUI(
          manual.fonts,
          manual.getMC().renderEngine,
          toolstack,
          (localWidth + 74) / 2,
          (localHeight + 54) / 2);
      manual.renderitem.renderItemAndEffectIntoGUI(
          manual.fonts,
          manual.getMC().renderEngine,
          icons[0],
          (localWidth + 140) / 2,
          (localHeight + 54) / 2);
      manual.renderitem.renderItemAndEffectIntoGUI(
          manual.fonts,
          manual.getMC().renderEngine,
          icons[1],
          (localWidth - 2) / 2,
          (localHeight + 36) / 2);
      manual.renderitem.renderItemAndEffectIntoGUI(
          manual.fonts,
          manual.getMC().renderEngine,
          icons[2],
          (localWidth - 2) / 2,
          (localHeight + 74) / 2);
      manual.renderitem.renderItemAndEffectIntoGUI(
          manual.fonts,
          manual.getMC().renderEngine,
          icons[3],
          (localWidth + 36) / 2,
          (localHeight + 36) / 2);
      if (icons[4] != null)
        manual.renderitem.renderItemAndEffectIntoGUI(
            manual.fonts,
            manual.getMC().renderEngine,
            icons[4],
            (localWidth + 36) / 2,
            (localHeight + 74) / 2);
    }
    manual.renderitem.zLevel = 0;

    GL11.glScalef(0.5F, 0.5F, 0.5F);
    RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
  }
  protected void drawGuiContainerForegroundLayer(int par1, int par2) {
    GL11.glDisable(GL11.GL_LIGHTING);
    int xSize = this.xSize;
    int ySize = this.ySize;
    if (!inverted) {
      fontRendererObj.drawString(
          blockName, xSize / 2 - fontRendererObj.getStringWidth(blockName) / 2 + 1, 5, 4210752);
      fontRendererObj.drawString(I18n.format("container.inventory"), 6, ySize - 96 + 2, 4210752);

      Color darkGreen = new Color(75, 245, 75);
      String string1 = I18n.format("uncrafting.compute") + ":";
      fontRendererObj.drawString(
          EnumChatFormatting.DARK_GRAY + string1 + EnumChatFormatting.RESET,
          24 - fontRendererObj.getStringWidth(string1) / 2 + 1,
          22,
          0);
      fontRendererObj.drawString(
          EnumChatFormatting.GRAY + string1 + EnumChatFormatting.RESET,
          24 - fontRendererObj.getStringWidth(string1) / 2,
          21,
          0);

      fontRendererObj.drawString(
          EnumChatFormatting.DARK_GRAY
              + ""
              + EnumChatFormatting.UNDERLINE
              + ""
              + (ModUncrafting.standardLevel + container.xp)
              + " levels"
              + EnumChatFormatting.RESET,
          xSize / 2
              - fontRendererObj.getStringWidth(
                      (ModUncrafting.standardLevel + container.xp) + " levels")
                  / 2
              + 1,
          ySize - 126 - 10,
          0);
      fontRendererObj.drawString(
          EnumChatFormatting.UNDERLINE
              + ""
              + (ModUncrafting.standardLevel + container.xp)
              + " levels"
              + EnumChatFormatting.RESET,
          xSize / 2
              - fontRendererObj.getStringWidth(
                      (ModUncrafting.standardLevel + container.xp) + " levels")
                  / 2,
          ySize - 127 - 10,
          darkGreen.getRGB());

      String string = container.result;
      if (string != null) {
        State msgType = container.type;
        EnumChatFormatting format = EnumChatFormatting.GREEN;
        EnumChatFormatting shadowFormat = EnumChatFormatting.DARK_GRAY;
        if (msgType == ContainerUncraftingTable.State.ERROR) {
          format = EnumChatFormatting.WHITE;
          shadowFormat = EnumChatFormatting.DARK_RED;
        }

        fontRendererObj.drawString(
            shadowFormat + string + EnumChatFormatting.RESET,
            6 + 1,
            ySize - 95 + 2 - fontRendererObj.FONT_HEIGHT,
            0);

        fontRendererObj.drawString(
            format + string + EnumChatFormatting.RESET,
            6,
            ySize - 96 + 2 - fontRendererObj.FONT_HEIGHT,
            0);
      }
    } else {
      int height = 166 - 8;
      fontRendererObj.drawString(
          blockName,
          xSize / 2 - fontRendererObj.getStringWidth(blockName) / 2 + 1,
          height - 5,
          4210752);

      fontRendererObj.drawString(
          I18n.format("container.inventory"), 6, height - ySize - 96 + 2, 4210752);

      Color darkGreen = new Color(75, 245, 75);
      String string1 = "Calculs:";
      fontRendererObj.drawString(
          EnumChatFormatting.DARK_GRAY + string1 + EnumChatFormatting.RESET,
          24 - fontRendererObj.getStringWidth(string1) / 2 + 1,
          height - 22,
          0);
      fontRendererObj.drawString(
          EnumChatFormatting.GRAY + string1 + EnumChatFormatting.RESET,
          24 - fontRendererObj.getStringWidth(string1) / 2,
          height - 21,
          0);

      fontRendererObj.drawString(
          EnumChatFormatting.DARK_GRAY
              + ""
              + EnumChatFormatting.UNDERLINE
              + ""
              + (ModUncrafting.standardLevel + container.xp)
              + " levels"
              + EnumChatFormatting.RESET,
          xSize / 2
              - fontRendererObj.getStringWidth(
                      (ModUncrafting.standardLevel + container.xp) + " levels")
                  / 2
              + 1,
          height - (ySize - 126 - 10),
          0);
      fontRendererObj.drawString(
          EnumChatFormatting.UNDERLINE
              + ""
              + (ModUncrafting.standardLevel + container.xp)
              + " levels"
              + EnumChatFormatting.RESET,
          xSize / 2
              - fontRendererObj.getStringWidth(
                      (ModUncrafting.standardLevel + container.xp) + " levels")
                  / 2,
          height - (ySize - 127 - 10),
          darkGreen.getRGB());

      String string = container.result;
      if (string != null) {
        State msgType = container.type;
        EnumChatFormatting format = EnumChatFormatting.GREEN;
        EnumChatFormatting shadowFormat = EnumChatFormatting.DARK_GRAY;
        if (msgType == ContainerUncraftingTable.State.ERROR) {
          format = EnumChatFormatting.WHITE;
          shadowFormat = EnumChatFormatting.DARK_RED;
        }

        fontRendererObj.drawString(
            shadowFormat + string + EnumChatFormatting.RESET,
            6 + 1,
            height - (ySize - 95 + 2 - fontRendererObj.FONT_HEIGHT),
            0);

        fontRendererObj.drawString(
            format + string + EnumChatFormatting.RESET,
            6,
            height - (ySize - 96 + 2 - fontRendererObj.FONT_HEIGHT),
            0);
      }
    }
    boolean op = false; // TODO: Check if user is OP
    String optionsText = I18n.format("uncrafting.options.hit");
    if (op)
      fontRendererObj.drawString(
          EnumChatFormatting.UNDERLINE + optionsText,
          xSize - fontRendererObj.getStringWidth(optionsText) - 4,
          ySize - 96 + 2,
          0);

    GL11.glEnable(GL11.GL_LIGHTING);
  }
 private static int blankTexture(int width, int height) {
   int texture = GL11.glGenTextures();
   MipmapHelper.setupTexture(texture, width, height, "scratch");
   return texture;
 }
Esempio n. 28
0
  /** Draws the data set up in this tessellator and resets the state to prepare for new drawing. */
  public int draw() {
    if (!isDrawing) {
      throw new IllegalStateException("Not tesselating!");
    }

    isDrawing = false;

    if (vertexCount > 0) {
      intBuffer.clear();
      intBuffer.put(rawBuffer, 0, rawBufferIndex);
      byteBuffer.position(0);
      byteBuffer.limit(rawBufferIndex * 4);

      if (useVBO) {
        vboIndex = (vboIndex + 1) % vboCount;
        ARBVertexBufferObject.glBindBufferARB(
            ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, vertexBuffers.get(vboIndex));
        ARBVertexBufferObject.glBufferDataARB(
            ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,
            byteBuffer,
            ARBVertexBufferObject.GL_STREAM_DRAW_ARB);
      }

      if (hasTexture) {
        if (useVBO) {
          GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 32, 12L);
        } else {
          floatBuffer.position(3);
          GL11.glTexCoordPointer(2, 32, floatBuffer);
        }

        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
      }

      if (hasBrightness) {
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);

        if (useVBO) {
          GL11.glTexCoordPointer(2, GL11.GL_SHORT, 32, 28L);
        } else {
          shortBuffer.position(14);
          GL11.glTexCoordPointer(2, 32, shortBuffer);
        }

        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
      }

      if (hasColor) {
        if (useVBO) {
          GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 32, 20L);
        } else {
          byteBuffer.position(20);
          GL11.glColorPointer(4, true, 32, byteBuffer);
        }

        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
      }

      if (hasNormals) {
        if (useVBO) {
          GL11.glNormalPointer(GL11.GL_UNSIGNED_BYTE, 32, 24L);
        } else {
          byteBuffer.position(24);
          GL11.glNormalPointer(32, byteBuffer);
        }

        GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
      }

      if (useVBO) {
        GL11.glVertexPointer(3, GL11.GL_FLOAT, 32, 0L);
      } else {
        floatBuffer.position(0);
        GL11.glVertexPointer(3, 32, floatBuffer);
      }

      GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);

      if (drawMode == 7 && convertQuadsToTriangles) {
        GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexCount);
      } else {
        GL11.glDrawArrays(drawMode, 0, vertexCount);
      }

      GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);

      if (hasTexture) {
        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
      }

      if (hasBrightness) {
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
      }

      if (hasColor) {
        GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
      }

      if (hasNormals) {
        GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
      }
    }

    int i = rawBufferIndex * 4;
    reset();
    return i;
  }
Esempio n. 29
0
  public int func_982_a() {
    if (!field_1488_w) {
      throw new IllegalStateException("Not tesselating!");
    }
    if (renderingChunk && subTessellators.length > 0) {
      boolean flag = false;
      for (int j = 0; j < subTessellators.length; j++) {
        int k = subTextures[j];
        if (k <= 0) {
          break;
        }
        Tessellator tessellator = subTessellators[j];
        if (tessellator.field_1488_w) {
          GL11.glBindTexture(3553, k);
          tessellator.func_982_a();
          flag = true;
        }
      }

      if (flag) {
        GL11.glBindTexture(3553, getTerrainTexture());
      }
    }
    field_1488_w = false;
    if (field_1505_h > 0) {
      field_1508_e.clear();
      field_1508_e.put(field_1506_g, 0, field_1498_o);
      field_1509_d.position(0);
      field_1509_d.limit(field_1498_o * 4);
      if (field_1487_x) {
        field_1485_z = (field_1485_z + 1) % field_1496_A;
        ARBVertexBufferObject.glBindBufferARB(34962, field_1486_y.get(field_1485_z));
        ARBVertexBufferObject.glBufferDataARB(34962, field_1509_d, 35040);
      }
      if (field_1500_m) {
        if (field_1487_x) {
          GL11.glTexCoordPointer(2, 5126, 32, 12L);
        } else {
          field_1507_f.position(3);
          GL11.glTexCoordPointer(2, 32, field_1507_f);
        }
        GL11.glEnableClientState(32888);
      }
      if (field_35838_p) {
        OpenGlHelper.func_40451_b(OpenGlHelper.field_40455_b);
        if (field_1487_x) {
          GL11.glTexCoordPointer(2, 5122, 32, 28L);
        } else {
          field_35836_g.position(14);
          GL11.glTexCoordPointer(2, 32, field_35836_g);
        }
        GL11.glEnableClientState(32888);
        OpenGlHelper.func_40451_b(OpenGlHelper.field_40457_a);
      }
      if (field_1501_l) {
        if (field_1487_x) {
          GL11.glColorPointer(4, 5121, 32, 20L);
        } else {
          field_1509_d.position(20);
          GL11.glColorPointer(4, true, 32, field_1509_d);
        }
        GL11.glEnableClientState(32886);
      }
      if (field_1499_n) {
        if (field_1487_x) {
          GL11.glNormalPointer(5121, 32, 24L);
        } else {
          field_1509_d.position(24);
          GL11.glNormalPointer(32, field_1509_d);
        }
        GL11.glEnableClientState(32885);
      }
      if (field_1487_x) {
        GL11.glVertexPointer(3, 5126, 32, 0L);
      } else {
        field_1507_f.position(0);
        GL11.glVertexPointer(3, 32, field_1507_f);
      }
      GL11.glEnableClientState(32884);
      if (field_1493_r == 7 && field_1511_b) {
        GL11.glDrawArrays(4, 0, field_1505_h);
      } else {
        GL11.glDrawArrays(field_1493_r, 0, field_1505_h);
      }
      GL11.glDisableClientState(32884);
      if (field_1500_m) {
        GL11.glDisableClientState(32888);
      }
      if (field_35838_p) {
        OpenGlHelper.func_40451_b(OpenGlHelper.field_40455_b);
        GL11.glDisableClientState(32888);
        OpenGlHelper.func_40451_b(OpenGlHelper.field_40457_a);
      }
      if (field_1501_l) {
        GL11.glDisableClientState(32886);
      }
      if (field_1499_n) {
        GL11.glDisableClientState(32885);
      }
    }
    int i = field_1498_o * 4;
    func_985_d();
    return i;
  }
Esempio n. 30
0
  protected int determineMaxSamples(int requestedSamples) {
    boolean displayWasCurrent = false;
    try {
      // If we already have a valid context, determine samples using current
      // context.
      if (Display.isCreated() && Display.isCurrent()) {
        if (GLContext.getCapabilities().GL_ARB_framebuffer_object) {
          return GL11.glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES);
        } else if (GLContext.getCapabilities().GL_EXT_framebuffer_multisample) {
          return GL11.glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT);
        }
        // Doesn't support any of the needed extensions .. continue down.
        displayWasCurrent = true;
      }
    } catch (LWJGLException ex) {
      listener.handleError("Failed to check if display is current", ex);
    }

    if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
      // No pbuffer, assume everything is supported.
      return Integer.MAX_VALUE;
    } else {
      Pbuffer pb = null;

      if (!displayWasCurrent) {
        // OpenGL2 method: Create pbuffer and query samples
        // from GL_ARB_framebuffer_object or GL_EXT_framebuffer_multisample.
        try {
          pb = new Pbuffer(1, 1, new PixelFormat(0, 0, 0), null);
          pb.makeCurrent();

          if (GLContext.getCapabilities().GL_ARB_framebuffer_object) {
            return GL11.glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES);
          } else if (GLContext.getCapabilities().GL_EXT_framebuffer_multisample) {
            return GL11.glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT);
          }

          // OpenGL2 method failed.
        } catch (LWJGLException ex) {
          // Something else failed.
          return Integer.MAX_VALUE;
        } finally {
          if (pb != null) {
            pb.destroy();
            pb = null;
          }
        }
      }

      // OpenGL1 method (DOESNT WORK RIGHT NOW ..)
      requestedSamples = FastMath.nearestPowerOfTwo(requestedSamples);
      try {
        requestedSamples = Integer.MAX_VALUE;
        /*
        while (requestedSamples > 1) {
            try {
                pb = new Pbuffer(1, 1, new PixelFormat(16, 0, 8, 0, requestedSamples), null);
            } catch (LWJGLException ex) {
                if (ex.getMessage().startsWith("Failed to find ARB pixel format")) {
                    // Unsupported format, so continue.
                    requestedSamples = FastMath.nearestPowerOfTwo(requestedSamples / 2);
                } else {
                    // Something else went wrong ..
                    return Integer.MAX_VALUE;
                }
            } finally {
                if (pb != null){
                    pb.destroy();
                    pb = null;
                }
            }
        }*/
      } finally {
        if (displayWasCurrent) {
          try {
            Display.makeCurrent();
          } catch (LWJGLException ex) {
            listener.handleError("Failed to make display current after checking samples", ex);
          }
        }
      }

      return requestedSamples;
    }
  }