Package com.badlogic.gdx.utils

Examples of com.badlogic.gdx.utils.GdxRuntimeException


          int length = input.readData(buffer);
          if (length == -1) break;
          output.write(buffer, 0, length);
        }
      } catch (IOException ex) {
        throw new GdxRuntimeException("Error reading WAV file: " + file, ex);
      }
      setup(output.toByteArray(), input.channels, input.sampleRate);
    }
View Full Code Here


    public boolean getSliderY (int sliderIndex) {
      return joystick.getSliderY(sliderIndex);
    }

    public Vector3 getAccelerometer (int accelerometerIndex) {
      throw new GdxRuntimeException("Invalid accelerometer index: " + accelerometerIndex);
    }
View Full Code Here

        Mouse.setNativeCursor (null);
        return;
      }

      if (pixmap.getFormat() != Pixmap.Format.RGBA8888) {
        throw new GdxRuntimeException ("Cursor image pixmap is not in RGBA8888 format.");
      }

      if ((pixmap.getWidth() & (pixmap.getWidth() - 1)) != 0 ) {
        throw new GdxRuntimeException ("Cursor image pixmap width of " + pixmap.getWidth() + " is not a power-of-two greater than zero.");
      }

      if ((pixmap.getHeight() & (pixmap.getHeight() - 1)) != 0 ) {
        throw new GdxRuntimeException ("Cursor image pixmap height of " + pixmap.getHeight() + " is not a power-of-two greater than zero.");
      }

      if (xHotspot < 0 || xHotspot >= pixmap.getWidth()) {
        throw new GdxRuntimeException ("xHotspot coordinate of " + xHotspot  + " is not within image width bounds: [0, " + pixmap.getWidth() + ").");
      }

      if (yHotspot < 0 || yHotspot >= pixmap.getHeight()) {
        throw new GdxRuntimeException ("yHotspot coordinate of " + yHotspot  + " is not within image height bounds: [0, " + pixmap.getHeight() + ").");
      }

      // Convert from RGBA8888 to ARGB8888 and flip vertically
      IntBuffer pixelBuffer = pixmap.getPixels().asIntBuffer();
      int[] pixelsRGBA = new int[pixelBuffer.capacity()];
      pixelBuffer.get(pixelsRGBA);
      int[] pixelsARGBflipped = new int[pixelBuffer.capacity()];
      int pixel;
      if (pixelBuffer.order() == ByteOrder.BIG_ENDIAN) {
        for (int y = 0; y < pixmap.getHeight(); ++y) {
          for (int x = 0; x < pixmap.getWidth(); ++x) {
            pixel = pixelsRGBA[x + (y * pixmap.getWidth())];
            pixelsARGBflipped[x + ((pixmap.getHeight() - 1 - y) * pixmap.getWidth())] = ((pixel >> 8) & 0x00FFFFFF) | ((pixel << 24) & 0xFF000000);
          }
        }
      } else {
        for (int y = 0; y < pixmap.getHeight(); ++y) {
          for (int x = 0; x < pixmap.getWidth(); ++x) {
            pixel = pixelsRGBA[x + (y * pixmap.getWidth())];
            pixelsARGBflipped[x + ((pixmap.getHeight() - 1 - y) * pixmap.getWidth())] = ((pixel & 0xFF) << 16) | ((pixel & 0xFF0000) >> 16) | (pixel & 0xFF00FF00);
          }
        }
      }

      Mouse.setNativeCursor(new Cursor(pixmap.getWidth(), pixmap.getHeight(), xHotspot, pixmap.getHeight() - yHotspot - 4, 1, IntBuffer.wrap(pixelsARGBflipped), null));
    } catch (LWJGLException e) {
      throw new GdxRuntimeException("Could not set cursor image.", e);
    }
  }
View Full Code Here

    if (file.getPath().length() == 0) return new LwjglFileHandle(new File(name), type);
    return new LwjglFileHandle(new File(file, name), type);
  }

  public FileHandle sibling (String name) {
    if (file.getPath().length() == 0) throw new GdxRuntimeException("Cannot get the sibling of the root.");
    return new LwjglFileHandle(new File(file.getParent(), name), type);
  }
View Full Code Here

    GL14.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
  }

  public void glBufferData (int target, int size, Buffer data, int usage) {
    if(data == null)
      throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
    else if (data instanceof ByteBuffer)
      GL15.glBufferData(target, (ByteBuffer)data, usage);
    else if (data instanceof IntBuffer)
      GL15.glBufferData(target, (IntBuffer)data, usage);
    else if (data instanceof FloatBuffer)
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);
      setPan(pan, volume);
      int filled = 0; // check if there's anything to play actually, see #1770
      for (int i = 0; i < bufferCount; i++) {
View Full Code Here

      GL15.glBufferData(target, (ShortBuffer)data, usage);
  }

  public void glBufferSubData (int target, int offset, int size, Buffer data) {
    if(data == null)
      throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
    else if (data instanceof ByteBuffer)
      GL15.glBufferSubData(target, offset, (ByteBuffer)data);
    else if (data instanceof IntBuffer)
      GL15.glBufferSubData(target, offset, (IntBuffer)data);
    else if (data instanceof FloatBuffer)
View Full Code Here

  public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border,
    int imageSize, Buffer data) {
    if (data instanceof ByteBuffer) {
         GL13.glCompressedTexImage2D(target, level, internalformat, width, height, border, (ByteBuffer)data);
      } else {
          throw new GdxRuntimeException("Can't use " + data.getClass().getName()
             + " with this method. Use ByteBuffer instead.");
      }
  }
View Full Code Here

      }
  }

  public void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format,
    int imageSize, Buffer data) {
    throw new GdxRuntimeException("not implemented");
  }
View Full Code Here

    else if (indices instanceof ByteBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_SHORT)
      GL11.glDrawElements(mode, ((ByteBuffer)indices).asShortBuffer()); // FIXME yay...
    else if (indices instanceof ByteBuffer && type == com.badlogic.gdx.graphics.GL20.GL_UNSIGNED_BYTE)
      GL11.glDrawElements(mode, (ByteBuffer)indices);
    else
      throw new GdxRuntimeException("Can't use " + indices.getClass().getName()
        + " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL");
  }
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.