本文整理了Java中playn.core.Graphics.createTexture()
方法的一些代码示例,展示了Graphics.createTexture()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics.createTexture()
方法的具体详情如下:
包路径:playn.core.Graphics
类名称: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
/** Creates a texture surface which is {@code width x height} in display units.
* A managed backing texture will be automatically created. */
public TextureSurface (Graphics gfx, QuadBatch defaultBatch, float width, float height) {
this(gfx, defaultBatch, gfx.createTexture(width, height, Texture.Config.DEFAULT));
}
代码示例来源:origin: io.playn/playn-core
/** Creates a texture surface which is {@code width x height} in display units.
* A managed backing texture will be automatically created. */
public TextureSurface (Graphics gfx, QuadBatch defaultBatch, float width, float height) {
this(gfx, defaultBatch, gfx.createTexture(width, height, Texture.Config.DEFAULT));
}
代码示例来源:origin: playn/playn
/** See {@link #createTexture(float,float,Texture.Config)}. */
public Texture createTexture (IDimension size, Texture.Config config) {
return createTexture(size.width(), size.height(), config);
}
代码示例来源:origin: io.playn/playn-core
/** See {@link #createTexture(float,float,Texture.Config)}. */
public Texture createTexture (IDimension size, Texture.Config config) {
return createTexture(size.width(), size.height(), config);
}
代码示例来源:origin: playn/playn
/**
* 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.
*/
public Texture createTexture (float width, float height, Texture.Config config) {
int texWidth = config.toTexWidth(scale.scaledCeil(width));
int texHeight = config.toTexHeight(scale.scaledCeil(height));
if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
"Invalid texture size: " + texWidth + "x" + texHeight);
int id = createTexture(config);
gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, null);
return new Texture(this, id, config, texWidth, texHeight, scale, width, height);
}
代码示例来源:origin: io.playn/playn-core
/**
* 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.
*/
public Texture createTexture (float width, float height, Texture.Config config) {
int texWidth = config.toTexWidth(scale.scaledCeil(width));
int texHeight = config.toTexHeight(scale.scaledCeil(height));
if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
"Invalid texture size: " + texWidth + "x" + texHeight);
int id = createTexture(config);
gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, null);
return new Texture(this, id, config, texWidth, texHeight, scale, width, height);
}
代码示例来源:origin: threerings/tripleplay
@Override public Root setSize (float width, float height) {
super.setSize(width, height);
// update the image to the new size, if it's changed
Texture old = _texture.get();
if (old == null || old.displayWidth != width || old.displayHeight != height) {
_texture.update(iface.plat.graphics().createTexture(width, height, textureConfig()));
}
return this;
}
代码示例来源:origin: io.playn/playn-core
/**
* Creates a texture with this image's bitmap data using {@code config}. NOTE: this creates a new
* texture with every call. This is generally only needed if you plan to create multiple textures
* from the same bitmap, with different configurations. Otherwise just use {@link #texture} to
* create the image's "default" texture which will be shared by all callers.
*/
public Texture createTexture (Texture.Config config) {
if (!isLoaded()) throw new IllegalStateException(
"Cannot create texture from unready image: " + this);
int texWidth = config.toTexWidth(pixelWidth());
int texHeight = config.toTexHeight(pixelHeight());
if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
"Invalid texture size: " + texWidth + "x" + texHeight + " from: " + this);
Texture tex = new Texture(gfx, gfx.createTexture(config), config, texWidth, texHeight,
scale(), width(), height());
tex.update(this); // this will handle non-POT source image conversion
return tex;
}
代码示例来源:origin: playn/playn
/**
* Creates a texture with this image's bitmap data using {@code config}. NOTE: this creates a new
* texture with every call. This is generally only needed if you plan to create multiple textures
* from the same bitmap, with different configurations. Otherwise just use {@link #texture} to
* create the image's "default" texture which will be shared by all callers.
*/
public Texture createTexture (Texture.Config config) {
if (!isLoaded()) throw new IllegalStateException(
"Cannot create texture from unready image: " + this);
int texWidth = config.toTexWidth(pixelWidth());
int texHeight = config.toTexHeight(pixelHeight());
if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
"Invalid texture size: " + texWidth + "x" + texHeight + " from: " + this);
Texture tex = new Texture(gfx, gfx.createTexture(config), config, texWidth, texHeight,
scale(), width(), height());
tex.update(this); // this will handle non-POT source image conversion
return tex;
}
代码示例来源:origin: playn/playn
Texture subtex = game.graphics.createTexture(
otile.width(), otile.height(), Texture.Config.DEFAULT.repeat(true, true));
new TextureSurface(game.graphics, game.defaultBatch, subtex).begin().
内容来源于网络,如有侵权,请联系作者删除!