Package com.badlogic.gdx.utils

Examples of com.badlogic.gdx.utils.GdxRuntimeException


    } else {
      gl20 = new LwjglGL20();
    }

    if (major <= 1)
      throw new GdxRuntimeException("OpenGL 2.0 or higher with the FBO extension is required. OpenGL version: " + version);
    if (major == 2 || version.contains("2.1")) {
      if (!supportsExtension("GL_EXT_framebuffer_object") && !supportsExtension("GL_ARB_framebuffer_object")) {
        throw new GdxRuntimeException("OpenGL 2.0 or higher with the FBO extension is required. OpenGL version: " + version
          + ", FBO extension: false");
      }
    }

    Gdx.gl = gl20;
View Full Code Here


        }
      }

      return modes;
    } catch (LWJGLException e) {
      throw new GdxRuntimeException("Couldn't fetch available display modes", e);
    }
  }
View Full Code Here

      sourceID = audio.obtainSource(true);
      if (sourceID == -1) return;
      if (buffers == null) {
        buffers = BufferUtils.createIntBuffer(bufferCount);
        alGenBuffers(buffers);
        if (alGetError() != AL_NO_ERROR) throw new GdxRuntimeException("Unabe to allocate audio buffers.");
      }
      alSourcei(sourceID, AL_LOOPING, AL_FALSE);
      alSourcef(sourceID, AL_GAIN, volume);
      // Fill initial buffers.
      int queuedBuffers = 0;
View Full Code Here

        }
        // Already on the open list
        else {
          PathNode pn = getNode(openList, currentNode.x+xOffset, currentNode.y+yOffset);
          if(pn == null)
            throw new GdxRuntimeException("PathNode at ("+(currentNode.x+xOffset)+","+(currentNode.y+yOffset)+") claimed to be on the open list but returned null.");

          // Calculate total g cost to move to potential square THROUGH the current square
          int gThroughCurrent = 0;
          if(diagnal)
            gThroughCurrent = currentNode.g + diagnalMovementCost;
View Full Code Here

   * succeed.
   * @param font the {@link FileHandle} to the TrueType font file */
  public FreeTypeFontGenerator (FileHandle font) {
    filePath = font.pathWithoutExtension();
    library = FreeType.initFreeType();
    if (library == null) throw new GdxRuntimeException("Couldn't initialize FreeType");
    face = FreeType.newFace(library, font, 0);
    if (face == null) throw new GdxRuntimeException("Couldn't create face for font '" + font + "'");
    if(checkForBitmapFont())
    {
      return;
    }
    if (!FreeType.setPixelSizes(face, 0, 15)) throw new GdxRuntimeException("Couldn't set size for font '" + font + "'");
  }
View Full Code Here

  /** Uses ascender and descender of font to calculate real height that makes
   *  all glyphs to fit in given pixel size. Source:
   *  http://nothings.org/stb/stb_truetype.h / stbtt_ScaleForPixelHeight
   */
  public int scaleForPixelHeight(int size) {
    if (!bitmapped && !FreeType.setPixelSizes(face, 0, size)) throw new GdxRuntimeException("Couldn't set size for font");
    SizeMetrics fontMetrics = face.getSize().getMetrics();
    int ascent = FreeType.toInt(fontMetrics.getAscender());
    int descent = FreeType.toInt(fontMetrics.getDescender());
    return size * size / (ascent - descent);
  }
View Full Code Here

 
  /** Returns null if glyph was not found. If there is nothing to render,
   * for example with various space characters, then bitmap is null.
   * */
  public GlyphAndBitmap generateGlyphAndBitmap(int c, int size, boolean flip) {
    if (!bitmapped && !FreeType.setPixelSizes(face, 0, size)) throw new GdxRuntimeException("Couldn't set size for font");

    SizeMetrics fontMetrics = face.getSize().getMetrics();
    int baseline = FreeType.toInt(fontMetrics.getAscender());

    // Check if character exists in this font.
    // 0 means 'undefined character code'
    if (FreeType.getCharIndex(face, c) == 0) {
      return null;
    }

    // Try to load character
    if (!FreeType.loadChar(face, c, FreeType.FT_LOAD_DEFAULT)) {
      throw new GdxRuntimeException("Unable to load character!");
    }

    GlyphSlot slot = face.getGlyph();
   
    // Try to render to bitmap
View Full Code Here

   * @param characters the characters the font should contain
   * @param flip whether to flip the font horizontally, see {@link BitmapFont#BitmapFont(FileHandle, TextureRegion, boolean)}
   * @param packer the optional PixmapPacker to use */
  public FreeTypeBitmapFontData generateData (int size, String characters, boolean flip, PixmapPacker packer) {
    FreeTypeBitmapFontData data = new FreeTypeBitmapFontData();
    if (!bitmapped && !FreeType.setPixelSizes(face, 0, size)) throw new GdxRuntimeException("Couldn't set size for font");

    // set general font data
    SizeMetrics fontMetrics = face.getSize().getMetrics();
    data.flipped = flip;
    data.ascent = FreeType.toInt(fontMetrics.getAscender());
    data.descent = FreeType.toInt(fontMetrics.getDescender());
    data.lineHeight = FreeType.toInt(fontMetrics.getHeight());
    float baseLine = data.ascent;

    // if bitmapped
    if(bitmapped && (data.lineHeight==0))
    {
      for(int c=32 ; c< (32+face.getNumGlyphs()); c++)
      {
        if(FreeType.loadChar(face, c, FreeType.FT_LOAD_DEFAULT))
        {
          int lh = FreeType.toInt(face.getGlyph().getMetrics().getHeight());
          data.lineHeight = (lh > data.lineHeight) ? lh : data.lineHeight ;
        }
      }
    }

    // determine space width and set glyph
    if (FreeType.loadChar(face, ' ', FreeType.FT_LOAD_DEFAULT)) {
      data.spaceWidth = FreeType.toInt(face.getGlyph().getMetrics().getHoriAdvance());
    } else {
      data.spaceWidth = face.getMaxAdvanceWidth(); // FIXME possibly very wrong :)
    }
    Glyph spaceGlyph = new Glyph();
    spaceGlyph.xadvance = (int)data.spaceWidth;
    spaceGlyph.id = (int)' ';
    data.setGlyph(' ', spaceGlyph);

    // determine x-height
    for (char xChar : BitmapFont.xChars) {
      if (!FreeType.loadChar(face, xChar, FreeType.FT_LOAD_DEFAULT)) continue;
      data.xHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight());
      break;
    }
    if (data.xHeight == 0) throw new GdxRuntimeException("No x-height character found in font");
    for (char capChar : BitmapFont.capChars) {
      if (!FreeType.loadChar(face, capChar, FreeType.FT_LOAD_DEFAULT)) continue;
      data.capHeight = FreeType.toInt(face.getGlyph().getMetrics().getHeight());
      break;
    }

    // determine cap height
    if (!bitmapped && data.capHeight == 1) throw new GdxRuntimeException("No cap character found in font");
    data.ascent = data.ascent - data.capHeight;
    data.down = -data.lineHeight;
    if (flip) {
      data.ascent = -data.ascent;
      data.down = -data.down;
View Full Code Here

  /** Increases the capacity of the array.
   *
   * @param minCapacity the desired minimum capacity */
  private void growToSize (int minCapacity) {
    if (minCapacity < 0) // overflow
      throw new GdxRuntimeException("Capacity upper limit exceeded.");
    int oldCapacity = queue.length;
    // Double size if small; else grow by 50%
    int newCapacity = (int)((oldCapacity < 64) ? ((oldCapacity + 1) * CAPACITY_RATIO_HI) : (oldCapacity * CAPACITY_RATIO_LOW));
    if (newCapacity < 0) // overflow
      newCapacity = Integer.MAX_VALUE;
View Full Code Here

  };

  static String readValue (BufferedReader reader) throws IOException {
    String line = reader.readLine();
    int colon = line.indexOf(':');
    if (colon == -1) throw new GdxRuntimeException("Invalid line: " + line);
    return line.substring(colon + 1).trim();
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.utils.GdxRuntimeException

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.