本文整理汇总了Java中com.jogamp.opengl.util.texture.Texture.enable方法的典型用法代码示例。如果您正苦于以下问题:Java Texture.enable方法的具体用法?Java Texture.enable怎么用?Java Texture.enable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.util.texture.Texture
的用法示例。
在下文中一共展示了Texture.enable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindTexture
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
private void bindTexture(GL gl, Texture texture, float xmin, float xmax, float ymin, float ymax) {
texture.enable(gl);
texture.bind(gl);
TextureCoords coords = texture.getImageTexCoords();
gl.getGL2().glBegin(GL2.GL_QUADS);
gl.getGL2().glTexCoord2f(coords.left(), coords.top());
gl.getGL2().glVertex2f(xmin, 1 - ymin);
gl.getGL2().glTexCoord2f(coords.right(), coords.top());
gl.getGL2().glVertex2f(xmax, 1 - ymin);
gl.getGL2().glTexCoord2f(coords.right(), coords.bottom());
gl.getGL2().glVertex2f(xmax, 1 - ymax);
gl.getGL2().glTexCoord2f(coords.left(), coords.bottom());
gl.getGL2().glVertex2f(xmin, 1 - ymax);
gl.getGL2().glEnd();
texture.disable(gl);
}
示例2: bindTexture
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
/**
*
* @param gl
* @param texture
* @param xmin
* @param xmax
* @param ymin
* @param ymax
*/
private void bindTexture(GL gl, Texture texture, float xmin, float xmax, float ymin, float ymax) {
texture.enable(gl);
texture.bind(gl);
TextureCoords coords = texture.getImageTexCoords();
gl.getGL2().glBegin(GL2.GL_QUADS);
gl.getGL2().glTexCoord2f(coords.left(), coords.top());
gl.getGL2().glVertex2f(xmin, 1 - ymin);
gl.getGL2().glTexCoord2f(coords.right(), coords.top());
gl.getGL2().glVertex2f(xmax, 1 - ymin);
gl.getGL2().glTexCoord2f(coords.right(), coords.bottom());
gl.getGL2().glVertex2f(xmax, 1 - ymax);
gl.getGL2().glTexCoord2f(coords.left(), coords.bottom());
gl.getGL2().glVertex2f(xmin, 1 - ymax);
gl.getGL2().glEnd();
texture.disable(gl);
}
示例3: innerDraw
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
@Override
public void innerDraw(GL2 gl) {
Texture texture = textureProvider.getTexture(gl, "◆");
texture.enable(gl);
texture.bind(gl);
gl.glColor4d(0.4, 0.4, 1, 0.5);
gl.glRotated((System.currentTimeMillis() / 5) % 360, 0, 1, 0);
gl.glBegin(GL2.GL_POLYGON);
gl.glTexCoord2f(0, 1);
gl.glVertex2d(-0.5, -0.5);
gl.glTexCoord2f(0, 0);
gl.glVertex2d(-0.5, 0.5);
gl.glTexCoord2f(1, 0);
gl.glVertex2d(0.5, 0.5);
gl.glTexCoord2f(1, 1);
gl.glVertex2d(0.5, -0.5);
gl.glEnd();
}
示例4: innerDraw
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
@Override
public void innerDraw(GL2 gl) {
Texture texture = textureProvider.getTexture(gl, String.valueOf(bufferChar.getChar()));
texture.enable(gl);
texture.bind(gl);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_ALPHA_TYPE, GL2.GL_LINEAR);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
gl.glBegin(GL2.GL_POLYGON);
gl.glTexCoord2f(0, 1);
gl.glVertex2d(-0.5, -0.5);
gl.glTexCoord2f(0, 0);
gl.glVertex2d(-0.5, 0.5);
gl.glTexCoord2f(1, 0);
gl.glVertex2d(0.5, 0.5);
gl.glTexCoord2f(1, 1);
gl.glVertex2d(0.5, -0.5);
gl.glEnd();
}
示例5: drawTexture
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
public static void drawTexture(GL2 gl, Texture texture, int x, int y, int width, int height)
{
texture.enable(gl);
texture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2d(0.0, 0.0);
gl.glVertex2d(x, y);
gl.glTexCoord2d(1.0, 0.0);
gl.glVertex2d(x + width, y);
gl.glTexCoord2d(1.0, 1.0);
gl.glVertex2d(x + width, y + height);
gl.glTexCoord2d(0.0, 1.0);
gl.glVertex2d(x, y + height);
gl.glEnd();
texture.disable(gl);
}
示例6: drawTile
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
private void drawTile(GL2 gl, double x, double y, double tileSize, Texture texture) {
texture.enable(gl);
texture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
//(0,0)
gl.glTexCoord2d(0, 0);
gl.glVertex3d(x * tileSize, 0, y * tileSize);
//(1,0)
gl.glTexCoord2d(1, 0);
gl.glVertex3d(x * tileSize + tileSize, 0, y * tileSize);
//(1,1)
gl.glTexCoord2d(1, 1);
gl.glVertex3d(x * tileSize + tileSize, 0, y * tileSize + tileSize);
//(0,1)
gl.glTexCoord2d(0, 1);
gl.glVertex3d(x * tileSize, 0, y * tileSize + tileSize);
gl.glEnd();
texture.disable(gl);
}
示例7: drawTile
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
private void drawTile(GL2 gl, double x, double y, double tileSize, Texture texture) {
texture.enable(gl);
texture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
//(0,0)
gl.glTexCoord2d(0, 0);
gl.glVertex3d(x*tileSize, 0, y*tileSize);
//(1,0)
gl.glTexCoord2d(1, 0);
gl.glVertex3d(x*tileSize+tileSize, 0, y*tileSize);
//(1,1)
gl.glTexCoord2d(1, 1);
gl.glVertex3d(x*tileSize+tileSize, 0, y*tileSize+tileSize);
//(0,1)
gl.glTexCoord2d(0, 1);
gl.glVertex3d(x*tileSize, 0, y*tileSize+tileSize);
gl.glEnd();
texture.disable(gl);
}
示例8: drawTile
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
private void drawTile(GL2 gl, double x, double y, double tileSize, Texture texture) {
texture.enable(gl);
texture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
//(0,0)
gl.glTexCoord2d(0, 0);
gl.glVertex3d(x*tileSize-tileSize/2, 0, y*tileSize-tileSize/2);
//(1,0)
gl.glTexCoord2d(1, 0);
gl.glVertex3d(x*tileSize-tileSize/2+tileSize, 0, y*tileSize-tileSize/2);
//(1,1)
gl.glTexCoord2d(1, 1);
gl.glVertex3d(x*tileSize+tileSize-tileSize/2, 0, y*tileSize+tileSize-tileSize/2);
//(0,1)
gl.glTexCoord2d(0, 1);
gl.glVertex3d(x*tileSize-tileSize/2, 0, y*tileSize+tileSize-tileSize/2);
gl.glEnd();
texture.disable(gl);
}
示例9: switchOnTex
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
private void switchOnTex(Texture tex, GL2 gl) // switch the lights off, and texturing on
{
gl.glEnable(GL2.GL_LIGHTING);
useWhiteMtl(gl);
tex.enable(gl);
tex.bind(gl);
}
示例10: renderTexture
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
/**
* Render a texture to the given position.
*
* @param texture Texture to draw
* @param centerX X coordinate for the center of the texture
* @param centerY Y coordinate for the center of the texture
*/
private void renderTexture(Texture texture, double centerX, double centerY) {
TextureCoords tc = texture.getImageTexCoords();
float tx1 = tc.left();
float ty1 = tc.top();
float tx2 = tc.right();
float ty2 = tc.bottom();
float halfWidth = quarterValue(texture.getWidth());
float halfHeight = quarterValue(texture.getHeight());
GL2 gl = scene.gl;
texture.bind(gl);
texture.enable(gl);
Color foreground = scene.getForegroundColor();
gl.glColor4f(foreground.getRed() / 255f,
foreground.getGreen() / 255f,
foreground.getBlue() / 255f,
foreground.getAlpha() / 255f);
gl.glPushMatrix();
float[] translate = GLScene.P((float) centerX, (float) centerY);
gl.glTranslatef(translate[0], translate[1], translate[2]);
gl.glBegin(GL2.GL_QUADS);
// divided by 2 to get nicer textures
// divided by 4 when we center it : 1/2 on each side of x axis for instance.
gl.glTexCoord2f(tx1, ty1);
GLScene.V(gl, -halfWidth, halfHeight);
gl.glTexCoord2f(tx2, ty1);
GLScene.V(gl, halfWidth, halfHeight);
gl.glTexCoord2f(tx2, ty2);
GLScene.V(gl, halfWidth, -halfHeight);
gl.glTexCoord2f(tx1, ty2);
GLScene.V(gl, -halfWidth, -halfHeight);
gl.glEnd();
gl.glPopMatrix();
texture.disable(gl);
}
示例11: setTexture
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
/**
* Set the texture uniform.
* @param gl the OpenGL interface
* @param texture the texture to set
*/
public final void setTexture(@Nonnull GL2 gl, @Nonnull Texture texture) {
gl.glActiveTexture(GL.GL_TEXTURE0);
texture.enable(gl);
texture.bind(gl);
gl.glUniform1i(textureLocation, 0);
}
示例12: setTexture
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
/**
* Set the texture uniform.
* @param gl the OpenGL interface
* @param texture the texture to set
*/
public final void setTexture(@Nonnull GL2 gl, @Nonnull Texture texture) {
gl.glActiveTexture(GL.GL_TEXTURE0);
texture.enable(gl);
texture.bind(gl);
gl.glUniform1i(texureLocation, 0);
}
示例13: Villain
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
Villain(double x, double y, double z, int degrees, double bounding_cir_rad,
int display_list, the_game playing_field, GLAutoDrawable drawable, Texture texture) {
super(x, y, z, degrees, bounding_cir_rad, display_list, playing_field,
drawable);
GL2 gl = drawable.getGL().getGL2();
GLU glu = my_playing_field.glu;
GLUquadric cyl = glu.gluNewQuadric();
GLUquadric top = glu.gluNewQuadric();
gl.glNewList(my_display_list, GL2.GL_COMPILE);
texture.enable(gl);
texture.bind(gl);
// Set material properties.
float[] rgba = {1f, 1f, 1f};
gl.glMaterialfv(GL.GL_FRONT, GL2.GL_AMBIENT, rgba, 0);
gl.glMaterialfv(GL.GL_FRONT, GL2.GL_SPECULAR, rgba, 0);
gl.glMaterialf(GL.GL_FRONT, GL2.GL_SHININESS, 0.5f);
glu.gluQuadricTexture(cyl, true);
gl.glPushMatrix();
gl.glRotated(-90.0, 1.0,0.0,0.0);
glu.gluCylinder(cyl, bounding_cir_rad, bounding_cir_rad, 25.0, 15, 5);
gl.glPopMatrix();
gl.glPushMatrix();
gl.glTranslated(0, 25.0, 0 );
gl.glRotated(-90.0, 1.0,0.0,0.0);
glu.gluDisk(top, 0.0, bounding_cir_rad, 15, 5);
texture.disable(gl);
gl.glPopMatrix();
gl.glEndList();
}
示例14: getTexture
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
public Texture getTexture(GL2 gl, String resourceName) throws IOException {
URL url = TextureLoader.class.getClassLoader().getResource(resourceName);
if (url == null) {
throw new IOException("Cannot find: "+resourceName);
}
BufferedImage bufferedImage = ImageIO.read(new BufferedInputStream(getClass().getClassLoader().getResourceAsStream(resourceName)));
// ImageUtil.flipImageVertically(bufferedImage);
Texture result = AWTTextureIO.newTexture(GLProfile.getDefault(), bufferedImage, true);
result.enable(gl);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
return result;
}
示例15: drawEarth
import com.jogamp.opengl.util.texture.Texture; //导入方法依赖的package包/类
private void drawEarth(GL2 gl) {
// set material properties
float[] rgba = { 1f, 1f, 1f }; // neutral white surface
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, rgba, 0);
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, rgba, 0);
gl.glMaterialf(GL2.GL_FRONT, GL2.GL_SHININESS, 0.5f);
if (!texturesCreated) {
earth.scheduleAvailableTextures(gl.getGLProfile());
earth.createScheduledTextures(gl);
List<String> textureNames = earth.getAvailableTextureNames();
if (!textureNames.isEmpty()) {
earth.setCurrentTexture(earth.getDefaultTexture());
}
texturesCreated = true;
}
if(skydomeTexture == null) {
loadSkydomeTexture();
} else {
skydomeTexture.enable(gl);
skydomeTexture.bind(gl);
// create the earth ball
GLUquadric skydome = glu.gluNewQuadric();
glu.gluQuadricTexture(skydome, true); // apply texture to the sphere
glu.gluQuadricDrawStyle(skydome, GLU.GLU_FILL);
glu.gluQuadricNormals(skydome, GLU.GLU_FLAT);
glu.gluQuadricOrientation(skydome, GLU.GLU_INSIDE);
glu.gluSphere(skydome, this.currentRadius()*5, SKYDOME_RESOLUTION, SKYDOME_RESOLUTION);
glu.gluDeleteQuadric(skydome);
}
if(credits != null && !wasLastFrame2D()) {
credits.render(gl);
} else {
// apply the texture
Texture texture = earth.getCurrentTexture();
if (texture != null) {
texture.enable(gl);
texture.bind(gl);
}
// create the earth ball
GLUquadric earthQuad = glu.gluNewQuadric();
glu.gluQuadricTexture(earthQuad, true); // apply texture to the sphere
glu.gluQuadricDrawStyle(earthQuad, GLU.GLU_FILL);
glu.gluQuadricNormals(earthQuad, GLU.GLU_FLAT);
glu.gluQuadricOrientation(earthQuad, GLU.GLU_OUTSIDE);
// size of sphere depends on zoom
glu.gluSphere(earthQuad, this.currentRadius(), EARTH_RESOLUTION, EARTH_RESOLUTION);
glu.gluDeleteQuadric(earthQuad);
}
}