playn.core.Graphics.createTexture()方法的使用及代码示例

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

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

Graphics.createTexture介绍

[英]Creates an empty texture into which one can render. The supplied width and height are in display units and will be converted to pixels based on the current scale factor.
[中]创建可以渲染到其中的空纹理。提供的宽度和高度以显示单位表示,并将根据当前比例因子转换为像素。

代码示例

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

  1. /** Creates a texture surface which is {@code width x height} in display units.
  2. * A managed backing texture will be automatically created. */
  3. public TextureSurface (Graphics gfx, QuadBatch defaultBatch, float width, float height) {
  4. this(gfx, defaultBatch, gfx.createTexture(width, height, Texture.Config.DEFAULT));
  5. }

代码示例来源:origin: io.playn/playn-core

  1. /** Creates a texture surface which is {@code width x height} in display units.
  2. * A managed backing texture will be automatically created. */
  3. public TextureSurface (Graphics gfx, QuadBatch defaultBatch, float width, float height) {
  4. this(gfx, defaultBatch, gfx.createTexture(width, height, Texture.Config.DEFAULT));
  5. }

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

  1. /** See {@link #createTexture(float,float,Texture.Config)}. */
  2. public Texture createTexture (IDimension size, Texture.Config config) {
  3. return createTexture(size.width(), size.height(), config);
  4. }

代码示例来源:origin: io.playn/playn-core

  1. /** See {@link #createTexture(float,float,Texture.Config)}. */
  2. public Texture createTexture (IDimension size, Texture.Config config) {
  3. return createTexture(size.width(), size.height(), config);
  4. }

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

  1. /**
  2. * Creates an empty texture into which one can render. The supplied width and height are in
  3. * display units and will be converted to pixels based on the current scale factor.
  4. */
  5. public Texture createTexture (float width, float height, Texture.Config config) {
  6. int texWidth = config.toTexWidth(scale.scaledCeil(width));
  7. int texHeight = config.toTexHeight(scale.scaledCeil(height));
  8. if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
  9. "Invalid texture size: " + texWidth + "x" + texHeight);
  10. int id = createTexture(config);
  11. gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight,
  12. 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
  13. return new Texture(this, id, config, texWidth, texHeight, scale, width, height);
  14. }

代码示例来源:origin: io.playn/playn-core

  1. /**
  2. * Creates an empty texture into which one can render. The supplied width and height are in
  3. * display units and will be converted to pixels based on the current scale factor.
  4. */
  5. public Texture createTexture (float width, float height, Texture.Config config) {
  6. int texWidth = config.toTexWidth(scale.scaledCeil(width));
  7. int texHeight = config.toTexHeight(scale.scaledCeil(height));
  8. if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
  9. "Invalid texture size: " + texWidth + "x" + texHeight);
  10. int id = createTexture(config);
  11. gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight,
  12. 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
  13. return new Texture(this, id, config, texWidth, texHeight, scale, width, height);
  14. }

代码示例来源:origin: threerings/tripleplay

  1. @Override public Root setSize (float width, float height) {
  2. super.setSize(width, height);
  3. // update the image to the new size, if it's changed
  4. Texture old = _texture.get();
  5. if (old == null || old.displayWidth != width || old.displayHeight != height) {
  6. _texture.update(iface.plat.graphics().createTexture(width, height, textureConfig()));
  7. }
  8. return this;
  9. }

代码示例来源:origin: io.playn/playn-core

  1. /**
  2. * Creates a texture with this image's bitmap data using {@code config}. NOTE: this creates a new
  3. * texture with every call. This is generally only needed if you plan to create multiple textures
  4. * from the same bitmap, with different configurations. Otherwise just use {@link #texture} to
  5. * create the image's "default" texture which will be shared by all callers.
  6. */
  7. public Texture createTexture (Texture.Config config) {
  8. if (!isLoaded()) throw new IllegalStateException(
  9. "Cannot create texture from unready image: " + this);
  10. int texWidth = config.toTexWidth(pixelWidth());
  11. int texHeight = config.toTexHeight(pixelHeight());
  12. if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
  13. "Invalid texture size: " + texWidth + "x" + texHeight + " from: " + this);
  14. Texture tex = new Texture(gfx, gfx.createTexture(config), config, texWidth, texHeight,
  15. scale(), width(), height());
  16. tex.update(this); // this will handle non-POT source image conversion
  17. return tex;
  18. }

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

  1. /**
  2. * Creates a texture with this image's bitmap data using {@code config}. NOTE: this creates a new
  3. * texture with every call. This is generally only needed if you plan to create multiple textures
  4. * from the same bitmap, with different configurations. Otherwise just use {@link #texture} to
  5. * create the image's "default" texture which will be shared by all callers.
  6. */
  7. public Texture createTexture (Texture.Config config) {
  8. if (!isLoaded()) throw new IllegalStateException(
  9. "Cannot create texture from unready image: " + this);
  10. int texWidth = config.toTexWidth(pixelWidth());
  11. int texHeight = config.toTexHeight(pixelHeight());
  12. if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
  13. "Invalid texture size: " + texWidth + "x" + texHeight + " from: " + this);
  14. Texture tex = new Texture(gfx, gfx.createTexture(config), config, texWidth, texHeight,
  15. scale(), width(), height());
  16. tex.update(this); // this will handle non-POT source image conversion
  17. return tex;
  18. }

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

  1. Texture subtex = game.graphics.createTexture(
  2. otile.width(), otile.height(), Texture.Config.DEFAULT.repeat(true, true));
  3. new TextureSurface(game.graphics, game.defaultBatch, subtex).begin().

相关文章