Package org.newdawn.slick.opengl

Examples of org.newdawn.slick.opengl.Texture


    FBO = buffer.get();

    // for some reason FBOs won't work on textures unless you've absolutely just
    // created them.
    try {
      Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight());
     
      EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, FBO);
      EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                               EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT,
                               GL11.GL_TEXTURE_2D, tex.getTextureID(), 0);
     
     
      completeCheck();
      unbind();
     
View Full Code Here


   *
   * @throws SlickException
   */
  private void init() throws SlickException {
    try {
      Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight());

      pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), null, null);
      // Initialise state of the pbuffer context.
      pbuffer.makeCurrent();

      initGL();
      image.draw(0,0);
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
      GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0,
                  tex.getTextureWidth(),
                  tex.getTextureHeight(), 0);
      image.setTexture(tex);
     
      Display.makeCurrent();
    } catch (Exception e) {
      Log.error(e);
View Full Code Here

   *
   * @throws SlickException
   */
  private void init() throws SlickException {
    try {
      Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight());
     
      final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
      pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);

      // Initialise state of the pbuffer context.
      pbuffer.makeCurrent();

      initGL();
      GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
      pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
      image.draw(0,0);
      image.setTexture(tex);
     
      Display.makeCurrent();
View Full Code Here

       
       
        @Override
        protected void performGLOperations() throws SlickException{
          //Bind Texture
          Texture tex = img.getTexture(); //get Texture ref from Image
          tex.bind(); //binds the texture
         
          GL11.glMatrixMode(GL11.GL_PROJECTION);
          GL11.glLoadIdentity();
          GL11.glFrustum(-1.0, 1, -1.0, 1.0, 5, 100);
          GL11.glMatrixMode(GL11.GL_MODELVIEW);
View Full Code Here

  public void init() throws IOException {
    mercury = new Planet(2000, 5000);
    mercury.setPosition(new Vector(-20000, 0, -40000));
    //mercury.setRotation(new Vector(0, 0.02f, 0));
    Texture texMercury = TextureLoader.getTexture("JPG",
        ResourceLoader.getResourceAsStream("res/mercury.jpg"));
    mercury.setTexture(texMercury);
   
    mercury2 = new Planet(2000, 5000);
    mercury2.setPosition(new Vector(0, -5000, -40000));
    //mercury2.setRotation(new Vector(0, 0.01f, 0));
    mercury2.setTexture(texMercury);
   
    earth = new Planet(3000, 5000);
    earth.setPosition(new Vector(10000, 0, -40000))
    //earth.setRotation(new Vector(0, -0.006f, 0));
    Texture texEarth = TextureLoader.getTexture("JPG",
        ResourceLoader.getResourceAsStream("res/earth.jpg"))
    earth.setTexture(texEarth);
   
    sun = new Star(7000, 500);
    sun.setPosition(new Vector(-30000, 20000, -40000))
    //sun.setRotation(new Vector(0, -0.006f, 0));
    Texture texSun = TextureLoader.getTexture("JPG",
        ResourceLoader.getResourceAsStream("res/sun.jpg"))
    sun.setTexture(texSun);

    universe = new Sector(null, new Vector(), new Vector(1e9f, 1e9f, 1e9f));
    universe.addObject(mercury);
View Full Code Here

        glDisable(GL_TEXTURE_2D);
    }

    public static Texture loadTexture(String filename) {
        Texture t = null;
        try {
            t = TextureLoader.getTexture("png", new FileInputStream(new File(filename)));
        } catch (IOException ex) {
            Logger.getLogger(Textures.class.getName()).log(Level.SEVERE, "Error loading texture: " + filename, ex);
        }
View Full Code Here

    imageWidth = width / (float) tex.getTextureWidth();
    imageHeight = height / (float) tex.getTextureHeight();
  }
 
  public static Texture loadTexture(String path) {
    Texture tex;
    if (!mapTexture.containsKey(path)) {
      ADXGame.postString("Loading texture " + path + "...");
      try {
        tex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(path), GL11.GL_NEAREST);
      } catch (IOException e) {
View Full Code Here

  public void render(int x, int y, int width, int height) {
    MCRenderDelegate r = (MCRenderDelegate) Spoutcraft.getRenderDelegate();
    if (databaseId != -1) {
      String iconUrl = "http://solder.inspirenxe.org/resources/spoutcraft/servers/images/" + databaseId + ".png";
      Texture icon = CustomTextureManager.getTextureFromUrl("Spoutcraft", iconUrl);
      if (icon == null) {
        CustomTextureManager.downloadTexture("Spoutcraft", iconUrl, true);
        icon = CustomTextureManager.getTextureFromPath(FileUtil.getAssetsDir().getPath()+"/icon/unknown_server.png");
      }
      GL11.glPushMatrix();
      GL11.glTranslated(x + 2, y + 2, 0);
      r.drawTexture(icon, 25, 25);
      GL11.glPopMatrix();
    }

    int marginleft = 29;

    int ping = getPing();

    FontRenderer font = SpoutClient.getHandle().fontRenderer;

    int margin1 = 0;
    int margin2 = 0;

    if (getPing() > 0 && (!isPolling() || showPingWhilePolling)) {
      if (isShowPing()) {
        String sping = getPing() + " ms";
        int pingwidth = font.getStringWidth(sping);
        margin1 = pingwidth + 14;
        font.drawStringWithShadow(sping, x + width - pingwidth - 14, y + 2, 0xaaaaaa);
      }
      String sPlayers = getPlayers() + " / " + getMaxPlayers() + " players";
      int playerswidth = font.getStringWidth(sPlayers);
      margin2 = playerswidth;
      font.drawStringWithShadow(sPlayers, x + width - playerswidth - 2, y + 11, 0xaaaaaa);
    }

    font.drawStringWithShadow(r.getFittingText(title, width - margin1 - marginleft), x + marginleft, y + 2, 0xffffff);
    String sMotd = "";
    if ((getPing() == PollResult.PING_POLLING || isPolling()) && !showPingWhilePolling) {
      sMotd = showPing ? "Polling ..." : "Retrieving MOTD";
    } else if (!showPingWhilePolling) {
      switch (getPing()) {
        case PollResult.PING_UNKNOWN:
          sMotd = ChatColor.RED + "Unknown Host!";
          break;
        case PollResult.PING_TIMEOUT:
          sMotd = ChatColor.RED + "Operation timed out!";
          break;
        case PollResult.PING_BAD_MESSAGE:
          sMotd = ChatColor.RED + "Bad Message (Server version likely outdated)!";
          break;
        default:
          sMotd = ChatColor.GREEN + getMotd();
          break;
      }
    }

    int color = 0xffffff;
    if ((getPing() == PollResult.PING_POLLING || isPolling()) && !showPingWhilePolling) {
      Color c1 = new Color(0, 0, 0);
      double darkness = 0;
      long t = System.currentTimeMillis() % 1000;
      darkness = Math.cos(t * 2 * Math.PI / 1000) * 0.2 + 0.2;
      c1.setBlue(1f - (float)darkness);
      color = c1.toInt();
    }

    font.drawStringWithShadow(r.getFittingText(sMotd, width - 10 - margin2 - marginleft), x + marginleft, y + 11, color);

    GL11.glColor4f(1f, 1f, 1f, 1f);

    // Fancy icons
    int xOffset = 0;
    int yOffset = 0;
    if (isPolling() && isShowPing()) {
      xOffset = 1;
      yOffset = (int)(System.currentTimeMillis() / 100L & 7L);
      if (yOffset > 4) {
        yOffset = 8 - yOffset;
      }
    } else if (isShowPing()) {
      xOffset = 0;
      if (ping < 0L) {
        yOffset = 5;
      } else if (ping < 150L) {
        yOffset = 0;
      } else if (ping < 300L) {
        yOffset = 1;
      } else if (ping < 600L) {
        yOffset = 2;
      } else if (ping < 1000L) {
        yOffset = 3;
      } else {
        yOffset = 4;
      }
    }
    if (isShowPing()) {
      Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/icons.png"));     
      RenderUtil.drawTexturedModalRectangle(x + width - 2 - 10, y + 2, 0 + xOffset * 10, 176 + yOffset * 8, 10, 8, 0f);
    }
    if (port != DEFAULT_PORT) {
      font.drawStringWithShadow(ip + ":" +port, x+marginleft, y+20, 0xaaaaaa);
    } else {
      font.drawStringWithShadow(ip, x+marginleft, y+20, 0xaaaaaa);
    }

    // Icon drawing
    int iconMargin = 2;

    if (country != null) {
      String url = "http://cdn.spout.org/img/flag/" + country.toLowerCase() + ".png";
      Texture icon = CustomTextureManager.getTextureFromUrl("Spoutcraft", url);
      if (icon != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(x + width - iconMargin - 16, y + 20, 0);
        r.drawTexture(icon, 16, 11);
        GL11.glPopMatrix();
        iconMargin += 5 + 16;
      } else {
        CustomTextureManager.downloadTexture("Spoutcraft", url);
      }
    }

    if (accessType != OPEN) {
      String name = "lock";
      switch(accessType) {
      case WHITELIST:
        name = "whitelist";
        break;
      case GRAYLIST:
        name = "graylist";
        break;
      case BLACKLIST:
        name = "blacklist";
        break;
      }
      Texture lockIcon = CustomTextureManager.getTextureFromPath(FileUtil.getAssetsDir().getPath()+"/" + name + ".png");
      GL11.glPushMatrix();
      GL11.glTranslatef(x + width - iconMargin - 7, y + 20, 0);
      r.drawTexture(lockIcon, 7, 11);
      GL11.glPopMatrix();
      iconMargin += 5 + 7;
View Full Code Here

  public static Texture getTextureFromPath(String path) {
    if (textures.containsKey(path)) {
      return textures.get(path);
    }
    Texture texture = null;
    try {
      FileInputStream stream = new FileInputStream(path);
      if (stream.available() > 0) {
        texture = TextureLoader.getTexture(path.toLowerCase().endsWith(".png") ? "PNG" : "JPG", stream, true,  GL11.GL_NEAREST);
      }
View Full Code Here

  public static Texture getTextureFromJar(String path) {
    if (textures.containsKey(path)) {
      return textures.get(path);
    }
   
    Texture texture = null;
    // Check inside jar
    try {
      InputStream stream = Minecraft.class.getResourceAsStream(path);
      texture = TextureLoader.getTexture(path.toLowerCase().endsWith(".png") ? "PNG" : "JPG", stream, true,  GL11.GL_NEAREST);
      stream.close();
View Full Code Here

TOP

Related Classes of org.newdawn.slick.opengl.Texture

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.