Package org.newdawn.slick.opengl

Examples of org.newdawn.slick.opengl.Texture


   * @param Name This is the name of the file
   */
  public static void loadTexture(String Name) throws IOException {

    // temp texture to be loaded into the textureMap
    Texture texture = null;

    // load texture into game
    texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/images/" + Name + ".png"));

    //logging message
    System.out.println("Texture loaded: " + texture);
    System.out.println(">> Image width: " + texture.getImageWidth());
    System.out.println(">> Image height: " + texture.getImageHeight());
    System.out.println(">> Texture width: " + texture.getTextureWidth());
    System.out.println(">> Texture height: " + texture.getTextureHeight());
    System.out.println(">> Texture ID: " + texture.getTextureID());

    //call the add function
    addToTextureMap(Name, texture);
  }
View Full Code Here


    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(), image.getFilter());
     
      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();
     
      // Clear our destination area before using it
View Full Code Here

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

      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(), image.getFilter());
     
      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

    GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);

    int maxWidth = 0, totalHeight = 0, lines = 0;
    int extraX = 0, extraY = ascent;
    boolean startNewLine = false;
    Texture lastBind = null;
    for (int glyphIndex = 0, n = vector.getNumGlyphs(); glyphIndex < n; glyphIndex++) {
      int charIndex = vector.getGlyphCharIndex(glyphIndex);
      if (charIndex < startIndex) continue;
      if (charIndex > endIndex) break;

      int codePoint = text.codePointAt(charIndex);

      Rectangle bounds = getGlyphBounds(vector, glyphIndex, codePoint);
      Glyph glyph = getGlyph(vector.getGlyphCode(glyphIndex), codePoint, bounds, vector, glyphIndex);

      if (startNewLine && codePoint != '\n') {
        extraX = -bounds.x;
        startNewLine = false;
      }

      Image image = glyph.getImage();
      if (image == null && missingGlyph != null && glyph.isMissing()) image = missingGlyph.getImage();
      if (image != null) {
        // Draw glyph, only binding a new glyph page texture when necessary.
        Texture texture = image.getTexture();
        if (lastBind != null && lastBind != texture) {
          GL.glEnd();
          lastBind = null;
        }
        if (lastBind == null) {
          texture.bind();
          GL.glBegin(SGL.GL_QUADS);
          lastBind = texture;
        }
        image.drawEmbedded(bounds.x + extraX, bounds.y + extraY, image.getWidth(), image.getHeight());
      }
View Full Code Here

     * The colour has to be set independently of this method.
     *
     * @param shape The shape to draw.
     */
    public static final void draw(Shape shape) {
        Texture t = TextureImpl.getLastBind();
        TextureImpl.bindNone();
       
        float points[] = shape.getPoints();
       
        LSR.start();
        for(int i=0;i<points.length;i+=2) {
          LSR.vertex(points[i], points[i + 1]);
        }
       
        if (shape.closed()) {
          LSR.vertex(points[0], points[1]);
        }
       
        LSR.end();
       
        if (t == null) {
          TextureImpl.bindNone();
        } else {
          t.bind();
        }
    }
View Full Code Here

     * @param fill The fill to apply
     */
    public static final void draw(Shape shape, ShapeFill fill) {
        float points[] = shape.getPoints();
       
        Texture t = TextureImpl.getLastBind();
        TextureImpl.bindNone();

        float center[] = shape.getCenter();
        GL.glBegin(SGL.GL_LINE_STRIP);
        for(int i=0;i<points.length;i+=2) {
            fill.colorAt(shape, points[i], points[i + 1]).bind();
            Vector2f offset = fill.getOffsetAt(shape, points[i], points[i + 1]);
            GL.glVertex2f(points[i] + offset.x, points[i + 1] + offset.y);
        }
       
        if (shape.closed()) {
          fill.colorAt(shape, points[0], points[1]).bind();
          Vector2f offset = fill.getOffsetAt(shape, points[0], points[1]);
          GL.glVertex2f(points[0] + offset.x, points[1] + offset.y);
        }
        GL.glEnd();
       
        if (t == null) {
          TextureImpl.bindNone();
        } else {
          t.bind();
        }
    }
View Full Code Here

    public static final void fill(Shape shape) {
      if (!validFill(shape)) {
        return;
      }
     
        Texture t = TextureImpl.getLastBind();
        TextureImpl.bindNone();
       
      fill(shape, new PointCallback() {
      public float[] preRenderPoint(Shape shape, float x, float y) {
        // do nothing, we're just filling the shape this time
        return null;
      }
      });
       
        if (t == null) {
          TextureImpl.bindNone();
        } else {
          t.bind();
        }
    }
View Full Code Here

    public static final void texture(Shape shape, final Image image, final float scaleX, final float scaleY) {
      if (!validFill(shape)) {
        return;
      }
     
      final Texture t = TextureImpl.getLastBind();
        image.getTexture().bind();
       
        fill(shape, new PointCallback() {
      public float[] preRenderPoint(Shape shape, float x, float y) {
        float tx = x * scaleX;
        float ty = y * scaleY;
       
        tx = image.getTextureOffsetX() + (image.getTextureWidth() * tx);
        ty = image.getTextureOffsetY() + (image.getTextureHeight() * ty);
       
        GL.glTexCoord2f(tx, ty);
              return null;
      }
      });
     
        float points[] = shape.getPoints();
       
        if (t == null) {
          TextureImpl.bindNone();
        } else {
          t.bind();
        }
    }
View Full Code Here

        return;
      }
     
        float points[] = shape.getPoints();
       
        Texture t = TextureImpl.getLastBind();
        image.getTexture().bind();
       
        final float minX = shape.getX();
        final float minY = shape.getY();
        final float maxX = shape.getMaxX() - minX;
        final float maxY = shape.getMaxY() - minY;

        fill(shape, new PointCallback() {
      public float[] preRenderPoint(Shape shape, float x, float y) {
        x -= shape.getMinX();
        y -= shape.getMinY();
       
        x /= (shape.getMaxX() - shape.getMinX());
        y /= (shape.getMaxY() - shape.getMinY());
       
        float tx = x * scaleX;
        float ty = y * scaleY;
       
        tx = image.getTextureOffsetX() + (image.getTextureWidth() * tx);
        ty = image.getTextureOffsetY() + (image.getTextureHeight() * ty);
       
        GL.glTexCoord2f(tx, ty);
              return null;
      }
      });
       
        if (t == null) {
          TextureImpl.bindNone();
        } else {
          t.bind();
        }
    }
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.