com.badlogic.gdx.Graphics.getBackBufferWidth()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中com.badlogic.gdx.Graphics.getBackBufferWidth()方法的一些代码示例,展示了Graphics.getBackBufferWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics.getBackBufferWidth()方法的具体详情如下:
包路径:com.badlogic.gdx.Graphics
类名称:Graphics
方法名:getBackBufferWidth

Graphics.getBackBufferWidth介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

/**
 * Converts an x-coordinate given in logical screen coordinates to
 * backbuffer coordinates.
 */
public static int toBackBufferX(int logicalX) {
  return (int)(logicalX * Gdx.graphics.getBackBufferWidth() / (float)Gdx.graphics.getWidth());
}

代码示例来源:origin: libgdx/libgdx

/**
 * Converts an x-coordinate given in logical screen coordinates to
 * backbuffer coordinates.
 */
public static int toBackBufferX(int logicalX) {
  return (int)(logicalX * Gdx.graphics.getBackBufferWidth() / (float)Gdx.graphics.getWidth());
}

代码示例来源:origin: libgdx/libgdx

/**
 * Converts an x-coordinate given in backbuffer coordinates to
 * logical screen coordinates.
 */
public static int toLogicalX(int backBufferX) {
  return (int)(backBufferX * Gdx.graphics.getWidth() / (float)Gdx.graphics.getBackBufferWidth());
}

代码示例来源:origin: libgdx/libgdx

/**
 * Converts an x-coordinate given in backbuffer coordinates to
 * logical screen coordinates.
 */
public static int toLogicalX(int backBufferX) {
  return (int)(backBufferX * Gdx.graphics.getWidth() / (float)Gdx.graphics.getBackBufferWidth());
}

代码示例来源:origin: libgdx/libgdx

/** Returns the default framebuffer contents as a byte[] array with a length equal to screen width * height * 4. The byte[] will
 * always contain RGBA8888 data. Because of differences in screen and image origins the framebuffer contents should be flipped
 * along the Y axis if you intend save them to disk as a bitmap. Flipping is not a cheap operation, so use this functionality
 * wisely.
 * 
 * @param flipY whether to flip pixels along Y axis */
public static byte[] getFrameBufferPixels (boolean flipY) {
  final int w = Gdx.graphics.getBackBufferWidth();
  final int h = Gdx.graphics.getBackBufferHeight();
  return getFrameBufferPixels(0, 0, w, h, flipY);
}

代码示例来源:origin: libgdx/libgdx

/** Returns the default framebuffer contents as a {@link TextureRegion} with a width and height equal to the current screen
 * size. The base {@link Texture} always has {@link MathUtils#nextPowerOfTwo} dimensions and RGBA8888 {@link Format}. It can be
 * accessed via {@link TextureRegion#getTexture}. The texture is not managed and has to be reloaded manually on a context loss.
 * The returned TextureRegion is flipped along the Y axis by default. */
public static TextureRegion getFrameBufferTexture () {
  final int w = Gdx.graphics.getBackBufferWidth();
  final int h = Gdx.graphics.getBackBufferHeight();
  return getFrameBufferTexture(0, 0, w, h);
}

代码示例来源:origin: libgdx/libgdx

/** Returns the default framebuffer contents as a {@link TextureRegion} with a width and height equal to the current screen
 * size. The base {@link Texture} always has {@link MathUtils#nextPowerOfTwo} dimensions and RGBA8888 {@link Format}. It can be
 * accessed via {@link TextureRegion#getTexture}. The texture is not managed and has to be reloaded manually on a context loss.
 * The returned TextureRegion is flipped along the Y axis by default. */
public static TextureRegion getFrameBufferTexture () {
  final int w = Gdx.graphics.getBackBufferWidth();
  final int h = Gdx.graphics.getBackBufferHeight();
  return getFrameBufferTexture(0, 0, w, h);
}

代码示例来源:origin: libgdx/libgdx

@Override
  public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
    // Value must be float type to work !
    shader.set(inputID, (float)Gdx.graphics.getBackBufferWidth(), (float)Gdx.graphics.getBackBufferHeight());
  }
};

代码示例来源:origin: libgdx/libgdx

/** Returns the default framebuffer contents as a byte[] array with a length equal to screen width * height * 4. The byte[] will
 * always contain RGBA8888 data. Because of differences in screen and image origins the framebuffer contents should be flipped
 * along the Y axis if you intend save them to disk as a bitmap. Flipping is not a cheap operation, so use this functionality
 * wisely.
 * 
 * @param flipY whether to flip pixels along Y axis */
public static byte[] getFrameBufferPixels (boolean flipY) {
  final int w = Gdx.graphics.getBackBufferWidth();
  final int h = Gdx.graphics.getBackBufferHeight();
  return getFrameBufferPixels(0, 0, w, h, flipY);
}

代码示例来源:origin: libgdx/libgdx

protected void beginRender (boolean lighting) {
  Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl.glClearColor(0, 0, 0, 0);
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  camera.update();
}

代码示例来源:origin: libgdx/libgdx

@Override
public void render () {
  counter = (counter + Gdx.graphics.getDeltaTime()) % 2.f;
  testAttribute1.value = Math.abs(1f - counter);
  testAttribute2.value = 1f - testAttribute1.value;
  camController.update();
  Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  modelBatch.begin(cam);
  modelBatch.render(instances);
  modelBatch.end();
}

代码示例来源:origin: libgdx/libgdx

@Override
  public void render () {
    Gdx.gl20.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
    Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
    shader.begin();
    mesh.render(shader, GL20.GL_TRIANGLES);
    shader.end();
  }
}

代码示例来源:origin: libgdx/libgdx

@Override
public void render () {
  counter = (counter + Gdx.graphics.getDeltaTime()) % 1.f;
  blendingAttribute.opacity = 0.25f + Math.abs(0.5f - counter);
  Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  modelInstance.transform.rotate(Vector3.Y, 30 * Gdx.graphics.getDeltaTime());
  modelBatch.begin(camera);
  modelBatch.render(background);
  modelBatch.render(modelInstance);
  modelBatch.end();
}

代码示例来源:origin: libgdx/libgdx

@Override
public void render () {
  inputController.update();
  Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  modelBatch.begin(cam);
  modelBatch.render(instance, environment);
  modelBatch.end();
}

代码示例来源:origin: libgdx/libgdx

@Override
public void render () {
  counter = (counter + Gdx.graphics.getDeltaTime()) % 1.f;
  blendingAttribute.opacity = 0.25f + Math.abs(0.5f - counter);
  Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  modelInstance.transform.rotate(Vector3.Y, 30 * Gdx.graphics.getDeltaTime());
  modelBatch.begin(camera);
  modelBatch.render(background);
  modelBatch.render(modelInstance, environment);
  modelBatch.end();
}

代码示例来源:origin: libgdx/libgdx

/** Calls {@link GL20#glViewport(int, int, int, int)}, expecting the coordinates and sizes given in logical coordinates and
 * automatically converts them to backbuffer coordinates, which may be bigger on HDPI screens. */
public static void glViewport (int x, int y, int width, int height) {
  if (mode == HdpiMode.Logical && (Gdx.graphics.getWidth() != Gdx.graphics.getBackBufferWidth()
    || Gdx.graphics.getHeight() != Gdx.graphics.getBackBufferHeight())) {
    Gdx.gl.glViewport(toBackBufferX(x), toBackBufferY(y), toBackBufferX(width), toBackBufferY(height));
  } else {
    Gdx.gl.glViewport(x, y, width, height);
  }
}

代码示例来源:origin: libgdx/libgdx

/** Calls {@link GL20#glScissor(int, int, int, int)}, expecting the coordinates and sizes given in logical coordinates and
 * automatically converts them to backbuffer coordinates, which may be bigger on HDPI screens. */
public static void glScissor (int x, int y, int width, int height) {
  if (mode == HdpiMode.Logical && (Gdx.graphics.getWidth() != Gdx.graphics.getBackBufferWidth()
    || Gdx.graphics.getHeight() != Gdx.graphics.getBackBufferHeight())) {
    Gdx.gl.glScissor(toBackBufferX(x), toBackBufferY(y), toBackBufferX(width), toBackBufferY(height));
  } else {
    Gdx.gl.glScissor(x, y, width, height);
  }
}

代码示例来源:origin: libgdx/libgdx

/** Calls {@link GL20#glViewport(int, int, int, int)}, expecting the coordinates and sizes given in logical coordinates and
 * automatically converts them to backbuffer coordinates, which may be bigger on HDPI screens. */
public static void glViewport (int x, int y, int width, int height) {
  if (mode == HdpiMode.Logical && (Gdx.graphics.getWidth() != Gdx.graphics.getBackBufferWidth()
    || Gdx.graphics.getHeight() != Gdx.graphics.getBackBufferHeight())) {
    Gdx.gl.glViewport(toBackBufferX(x), toBackBufferY(y), toBackBufferX(width), toBackBufferY(height));
  } else {
    Gdx.gl.glViewport(x, y, width, height);
  }
}

代码示例来源:origin: libgdx/libgdx

@Override
public void render () {
  animate();
  inputController.update();
  Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  Gdx.gl.glClearColor(0.13f, 0.13f, 0.13f, 1);
  modelBatch.begin(cam);
  modelBatch.render(instance, environment);
  modelBatch.end();
}

代码示例来源:origin: libgdx/libgdx

@Override
public void render () {
  if (loading && assets.update()) doneLoading();
  camController.update();
  Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  modelBatch.begin(cam);
  for (ModelInstance instance : instances)
    modelBatch.render(instance, lights);
  if (space != null) modelBatch.render(space);
  modelBatch.end();
}

相关文章