本文整理匯總了Java中org.newdawn.slick.opengl.Texture.bind方法的典型用法代碼示例。如果您正苦於以下問題:Java Texture.bind方法的具體用法?Java Texture.bind怎麽用?Java Texture.bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.newdawn.slick.opengl.Texture
的用法示例。
在下文中一共展示了Texture.bind方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: draw
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
/**
* Draw the outline of the given shape. Only the vertices are set.
* The colour has to be set independently of this method.
*
* @param shape The shape to draw.
*/
public static final void draw(Shape shape) {
Texture t = TextureImpl.getLastBind();
TextureImpl.bindNone();
float points[] = shape.getPoints();
LSR.start();
for(int i=0;i<points.length;i+=2) {
LSR.vertex(points[i], points[i + 1]);
}
if (shape.closed()) {
LSR.vertex(points[0], points[1]);
}
LSR.end();
if (t == null) {
TextureImpl.bindNone();
} else {
t.bind();
}
}
示例2: setup
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
/**
* Setup.
*
* @param u the u
* @return the shader args
*/
public static ShaderArgs setup(FightUnit u) {
Unit unit = u.getUnit();
ShaderArgs args = new ShaderArgs();
if(unit.getTheClass().name.equals("Lord")) return args;
String c = unit.functionalClassName();
Texture t = palettes.get(c);
if(t == null) return args;
if(lookup.get(c) == null) return args;
int offset = lookup.get(c).indexOf(unit.name);
if(offset < 0) return args;
args.programName = "paletteSwap";
args.args = new float[] {t.getTextureWidth(), t.getTextureHeight(), offset, t.getImageWidth()};
GL13.glActiveTexture(GL13.GL_TEXTURE8);
t.bind();
GL13.glActiveTexture(GL13.GL_TEXTURE0);
return args;
}
示例3: draw
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
/**
* Draw the outline of the given shape. Only the vertices are set.
* The colour has to be set independently of this method.
*
* @param shape The shape to draw.
*/
public static final void draw(@Nonnull Shape shape) {
Texture t = TextureImpl.getLastBind();
TextureImpl.bindNone();
float points[] = shape.getPoints();
LSR.start();
for(int i=0;i<points.length;i+=2) {
LSR.vertex(points[i], points[i + 1]);
}
if (shape.closed()) {
LSR.vertex(points[0], points[1]);
}
LSR.end();
if (t == null) {
TextureImpl.bindNone();
} else {
t.bind();
}
}
示例4: fill
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
/**
* Draw the the given shape filled in. Only the vertices are set.
* The colour has to be set independently of this method.
*
* @param shape The shape to fill.
*/
public static final void fill(@Nonnull Shape shape) {
if (!validFill(shape)) {
return;
}
Texture t = TextureImpl.getLastBind();
TextureImpl.bindNone();
fill(shape, (shape1, x, y) -> null);
if (t == null) {
TextureImpl.bindNone();
} else {
t.bind();
}
}
示例5: texture
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
/**
* Draw the the given shape filled in with a texture. Only the vertices are set.
* The colour has to be set independently of this method.
*
* @param shape The shape to texture.
* @param image The image to tile across the shape
* @param gen The texture coordinate generator to create coordiantes for the shape
*/
public static final void texture(@Nonnull final Shape shape, @Nonnull Image image, @Nonnull final TexCoordGenerator gen) {
Texture t = TextureImpl.getLastBind();
image.getTexture().bind();
shape.getCenter();
fill(shape, (shape1, x, y) -> {
Vector2f tex = gen.getCoordFor(x, y);
GL.glTexCoord2f(tex.x, tex.y);
return new float[] {x,y};
});
if (t == null) {
TextureImpl.bindNone();
} else {
t.bind();
}
}
示例6: drawBackGround
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
public static void drawBackGround(){
initGL(Display.getWidth(),Display.getHeight());
try {
Texture background = TextureLoader.getTexture("JPG", ResourceLoader.getResourceAsStream("imgs/Map_test_1.jpg"));
background.bind();
glBegin(GL_QUADS);
GL11.glTexCoord2f(0,0);
GL11.glVertex2f(0,0);
GL11.glTexCoord2f(1,0);
GL11.glVertex2f(background.getTextureWidth(),0);
GL11.glTexCoord2f(1,1);
GL11.glVertex2f(background.getTextureWidth(),background.getTextureHeight());
GL11.glTexCoord2f(0,1);
GL11.glVertex2f(0,background.getTextureHeight());
GL11.glBindTexture(GL_TEXTURE_2D,0);
glEnd();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例7: drawSprites
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
public static void drawSprites(String spriteLoc) {
initGL(Display.getWidth(),Display.getHeight());
try {
Texture sprite = TextureLoader.getTexture("JPG", ResourceLoader.getResourceAsStream("imgs/"+spriteLoc));
sprite.bind();
glBegin(GL_QUADS);
GL11.glTexCoord2f(0,0);
GL11.glVertex2f(0,0);
GL11.glTexCoord2f(1,0);
GL11.glVertex2f(sprite.getTextureWidth(),0);
GL11.glTexCoord2f(1,1);
GL11.glVertex2f(sprite.getTextureWidth(),sprite.getTextureHeight());
GL11.glTexCoord2f(0,1);
GL11.glVertex2f(0,sprite.getTextureHeight());
GL11.glBindTexture(GL_TEXTURE_2D,0);
glEnd();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例8: DrawQuadTex
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
public static void DrawQuadTex(float x, float y, float width, float height, Texture tex) {
tex.bind();
glTranslatef(x, y, 0);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(1, 0);
glVertex2f(width, 0);
glTexCoord2f(1, 1);
glVertex2f(width, height);
glTexCoord2f(0, 1);
glVertex2f(0, height);
glEnd();
glLoadIdentity();
}
示例9: textureFit
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
/**
* Draw the the given shape filled in with a texture. Only the vertices are set.
* The colour has to be set independently of this method. This method is required to
* fit the texture scaleX times across the shape and scaleY times down the shape.
*
* @param shape The shape to texture.
* @param image The image to tile across the shape
* @param scaleX The scale to apply on the x axis for texturing
* @param scaleY The scale to apply on the y axis for texturing
*/
public static final void textureFit(@Nonnull Shape shape, @Nonnull final Image image, final float scaleX, final float scaleY) {
if (!validFill(shape)) {
return;
}
shape.getPoints();
Texture t = TextureImpl.getLastBind();
image.getTexture().bind();
shape.getX();
shape.getY();
shape.getMaxX();
shape.getMaxY();
fill(shape, (shape1, x, y) -> {
x -= shape1.getMinX();
y -= shape1.getMinY();
x /= (shape1.getMaxX() - shape1.getMinX());
y /= (shape1.getMaxY() - shape1.getMinY());
float tx = x * scaleX;
float ty = y * scaleY;
tx = image.getTextureOffsetX() + (image.getTextureWidth() * tx);
ty = image.getTextureOffsetY() + (image.getTextureHeight() * ty);
GL.glTexCoord2f(tx, ty);
return null;
});
if (t == null) {
TextureImpl.bindNone();
} else {
t.bind();
}
}
示例10: apply
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
/**
* Uploads the pixel data to the given texture at the specified position.
* This only needs to be called once, after the pixel data has changed.
*
* @param texture the texture to modify
* @param x the x position to place the pixel data on the texture
* @param y the y position to place the pixel data on the texture
*/
public void apply(Texture texture, int x, int y) {
if (x+width > texture.getTextureWidth() || y+height > texture.getTextureHeight())
throw new IndexOutOfBoundsException("pixel data won't fit in given texture");
position(length());
pixels.flip();
int glFmt = format.getOGLType();
final SGL GL = Renderer.get();
texture.bind();
GL.glTexSubImage2D(SGL.GL_TEXTURE_2D, 0, x, y, width, height,
glFmt, SGL.GL_UNSIGNED_BYTE, pixels);
}
示例11: render
import org.newdawn.slick.opengl.Texture; //導入方法依賴的package包/類
public void render(World world, Camera camera, float x, float y, int type)
{
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL13.GL_COMBINE);
Texture texture = getMask(type).getFinalProduct().getTexture();
texture.bind();
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glBegin(GL11.GL_QUADS);
float width2 = (float)((float)getSprite().getTexture().getImageWidth() / (float)16);
float height2 = (float)((float)getSprite().getTexture().getImageHeight() / (float)16);
int x2 = (int)x;
int y2 = (int)y;
float fx = x * getSprite().getTexture().getImageWidth() - (camera.getX() * width2);
float fy = y * getSprite().getTexture().getImageWidth() - (camera.getY() * height2);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(fx, fy);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(fx + texture.getTextureWidth(), fy);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(fx + texture.getTextureWidth(), fy + texture.getTextureHeight());
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(fx, fy + texture.getTextureHeight());
GL11.glEnd();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glPopMatrix();
GL11.glColor3f(1, 1, 1);
}