Package com.badlogic.gdx.graphics

Examples of com.badlogic.gdx.graphics.Texture


  }
 
  void generateRegions(GenerationMode mode){
    //generate regions
    texturePanel.clear();
    Texture texture = texturePanel.getTexture();
    int   rows = (int)rowSlider.getValue(), columns = (int)columnSlider.getValue(),
        yOffset = texture.getHeight()/rows, xOffset = texture.getWidth()/columns;
   
    if(mode == GenerationMode.ByRows){
      for(int j=0; j < rows; ++j){
        int rowOffset = j*yOffset;
        for(int i=0; i < columns; ++i){
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;
    int offsetX = 0;
    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);
      bounds.x += offsetX;
      Glyph glyph = getGlyph(vector.getGlyphCode(glyphIndex), codePoint, bounds, vector, glyphIndex);

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

      if (glyph.getTexture() == null && missingGlyph != null && glyph.isMissing()) glyph = missingGlyph;
      if (glyph.getTexture() != null) {
        // Draw glyph, only binding a new glyph page texture when necessary.
        Texture texture = glyph.getTexture();
        if (lastBind != null && lastBind != texture) {
          GL11.glEnd();
          lastBind = null;
        }
        if (lastBind == null) {
          texture.bind();
          GL11.glBegin(GL11.GL_QUADS);
          lastBind = texture;
        }
        int glyphX = bounds.x + extraX;
        int glyphY = bounds.y + extraY;
View Full Code Here

      emitter.setSprite(new Sprite(loadTexture(imagesDir.child(imageName))));
    }
  }

  protected Texture loadTexture (FileHandle file) {
    return new Texture(file, false);
  }
View Full Code Here

      this.yUp = parameters.yUp;
      FileHandle tmxFile = resolve(fileName);
      root = xml.parse(tmxFile);
      ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>();
      for (FileHandle textureFile : loadTilesets(root, tmxFile)) {
        Texture texture = new Texture(textureFile, parameters.generateMipMaps);
        texture.setFilter(parameters.textureMinFilter, parameters.textureMagFilter);
        textures.put(textureFile.path(), texture);
      }
      DirectImageResolver imageResolver = new DirectImageResolver(textures);
      TiledMap map = loadTilemap(root, tmxFile, imageResolver);
      map.setOwnedResources(textures.values().toArray());
View Full Code Here

        FileHandle file;
        if (imagePath.equals(ParticleEditor.DEFAULT_PARTICLE) || imagePath.equals(ParticleEditor.DEFAULT_PREMULT_PARTICLE))
          file = Gdx.files.classpath(imagePath);
        else
          file = Gdx.files.absolute(imagePath);
        emitter.setSprite(new Sprite(new Texture(file)));
      } catch (GdxRuntimeException ex) {
        ex.printStackTrace();
        EventQueue.invokeLater(new Runnable() {
          public void run () {
            JOptionPane.showMessageDialog(ParticleEditor.this, "Error loading image:\n" + imagePath);
View Full Code Here

        EventQueue.invokeLater(new Runnable() {
          public void run () {
            final ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 1024 * 4);
            buffer.order(ByteOrder.LITTLE_ENDIAN);
            fontGenerator.getTextureData(buffer.asIntBuffer());
            TextureRegion glyphRegion = new TextureRegion(new Texture(new TextureData() {
              Pixmap pixmap;

              public int getWidth () {
                return width;
              }
View Full Code Here

  GlyphPage (UnicodeFont unicodeFont, int pageWidth, int pageHeight) {
    this.unicodeFont = unicodeFont;
    this.pageWidth = pageWidth;
    this.pageHeight = pageHeight;

    texture = new Texture(pageWidth, pageHeight, Format.RGBA8888);
  }
View Full Code Here

        // renderingBackgroundColor.a);
        // fillRect(0, 0, unicodeFont.getGlyphPageWidth() + 2, unicodeFont.getGlyphPageHeight() + 2);
        int index = glyphPageCombo.getSelectedIndex();
        List pages = unicodeFont.getGlyphPages();
        if (index >= 0 && index < pages.size()) {
          Texture texture = ((GlyphPage)pages.get(glyphPageCombo.getSelectedIndex())).getTexture();

          glDisable(GL_TEXTURE_2D);
          glColor4f(renderingBackgroundColor.r, renderingBackgroundColor.g, renderingBackgroundColor.b,
            renderingBackgroundColor.a);
          glBegin(GL_QUADS);
          glVertex3f(0, 0, 0);
          glVertex3f(0, texture.getHeight(), 0);
          glVertex3f(texture.getWidth(), texture.getHeight(), 0);
          glVertex3f(texture.getWidth(), 0, 0);
          glEnd();
          glEnable(GL_TEXTURE_2D);

          texture.bind();
          glColor4f(1, 1, 1, 1);
          glBegin(GL_QUADS);
          glTexCoord2f(0, 0);
          glVertex3f(0, 0, 0);

          glTexCoord2f(0, 1);
          glVertex3f(0, texture.getHeight(), 0);

          glTexCoord2f(1, 1);
          glVertex3f(texture.getWidth(), texture.getHeight(), 0);

          glTexCoord2f(1, 0);
          glVertex3f(texture.getWidth(), 0, 0);
          glEnd();
        }
      }
    }
View Full Code Here

        if(file != null){
          TextureParameter params = new TextureParameter();
          params.genMipMaps = genMipMaps.isSelected();
          params.minFilter = (TextureFilter)minFilterBox.getSelectedItem();
          params.magFilter = (TextureFilter)magFilterBox.getSelectedItem();
          Texture texture = editor.load(file.getAbsolutePath(), Texture.class, null, params);
          if(texture != null){
            editor.setTexture(texture);
          }
        }
      }
View Full Code Here

        // renderingBackgroundColor.a);
        // fillRect(0, 0, unicodeFont.getGlyphPageWidth() + 2, unicodeFont.getGlyphPageHeight() + 2);
        int index = glyphPageCombo.getSelectedIndex();
        List pages = unicodeFont.getGlyphPages();
        if (index >= 0 && index < pages.size()) {
          Texture texture = ((GlyphPage)pages.get(glyphPageCombo.getSelectedIndex())).getTexture();

          glDisable(GL_TEXTURE_2D);
          glColor4f(renderingBackgroundColor.r, renderingBackgroundColor.g, renderingBackgroundColor.b,
            renderingBackgroundColor.a);
          glBegin(GL_QUADS);
          glVertex3f(0, 0, 0);
          glVertex3f(0, texture.getHeight(), 0);
          glVertex3f(texture.getWidth(), texture.getHeight(), 0);
          glVertex3f(texture.getWidth(), 0, 0);
          glEnd();
          glEnable(GL_TEXTURE_2D);

          texture.bind();
          glColor4f(1, 1, 1, 1);
          glBegin(GL_QUADS);
          glTexCoord2f(0, 0);
          glVertex3f(0, 0, 0);

          glTexCoord2f(0, 1);
          glVertex3f(0, texture.getHeight(), 0);

          glTexCoord2f(1, 1);
          glVertex3f(texture.getWidth(), texture.getHeight(), 0);

          glTexCoord2f(1, 0);
          glVertex3f(texture.getWidth(), 0, 0);
          glEnd();
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.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.