本文整理汇总了Java中com.jogamp.opengl.util.texture.Texture类的典型用法代码示例。如果您正苦于以下问题:Java Texture类的具体用法?Java Texture怎么用?Java Texture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Texture类属于com.jogamp.opengl.util.texture包,在下文中一共展示了Texture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
@Override
public void render(Object glC) {
OpenGLContext context=(OpenGLContext)glC;//SumoPlatform.getApplication().getGeoContext();
GL gl = context.getGL();
gl.getGL2().glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
BufferedImage temp=new BufferedImage(overview.getWidth(), overview.getHeight(), overview.getType());
this.overview.copyData(temp.getRaster());
BufferedImage buffer=rescale.filter(temp, temp);
Texture texture = AWTTextureIO.newTexture(((GLBase)gl).getGLProfile(), buffer, true);
//Texture texture = TextureIO.newTexture(rescale.filter(temp, temp), false);
float tempscale=this.scale*context.getHeight()/context.getWidth();
if(tempscale<1){
bindTexture(gl, texture, 0, tempscale, 0, 1);
}
else{
bindTexture(gl, texture, 0, 1, 0, tempscale);
}
texture.disable(gl);
context.setX(0);
context.setY(0);
context.setZoom(Math.max(thumbReader.getWidth() / context.getWidth(),thumbReader.getHeight() / context.getHeight()));
SumoPlatform.getApplication().getLayerManager().render(context);
}
示例2: 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);
}
示例3: 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);
}
示例4: loadAndBindSymbolTextures
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
private void loadAndBindSymbolTextures(GL2 gl) {
try {
Texture[] textures = new Texture[3];
InputStream is;
is = RoShamBoCNN.class.getResourceAsStream("rock.png");
textures[DECISION_ROCK] = TextureIO.newTexture(is, false, "png");
is = RoShamBoCNN.class.getResourceAsStream("scissors.png");
textures[DECISION_SCISSORS] = TextureIO.newTexture(is, false, "png");
is = RoShamBoCNN.class.getResourceAsStream("paper.png");
textures[DECISION_PAPER] = TextureIO.newTexture(is, false, "png");
symbolTextures = textures;
// for (Texture texture : textures) {
//
// texture.enable(gl);
// }
} catch (Exception e) {
log.warning("couldn't load symbol textures: " + e.toString());
}
}
示例5: drawGrid
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
private void drawGrid(GL2 gl, double x, double y) {
double spacing = 0.1;
Texture texture = marker;
int count = 0;
for (int i = 0; i < markerCount; i++) {
if (!activeMarkers.get(count)) {
texture = marker;
} else {
texture = active;
}
float size = tileSize;
if (count == area) {
size = tileSize * 1.05f;
}
drawTile(gl, -3 + i + (i * spacing), -.5, size, texture);
count++;
}
}
示例6: disposeInvalids
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
public void disposeInvalids(DrawContext dc) {
if (invalid.size() == 0) return;
rwl.writeLock().lock();
for (TileKey tile : invalid) {
Texture t = (Texture) dc.getTextureCache().get(tile);
if (t != null)
{
t.destroy(dc.getGL().getGL2());
dc.getTextureCache().remove(tile);
}
//
// TextureTile tt =
// (TextureTile)
// WorldWind.getMemoryCache(TextureTile.class.getName()).getObject(tile);
}
invalid.clear();
rwl.writeLock().unlock();
}
示例7: getTexture
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
private Texture getTexture(String matName, GL2 gl) // return the texture associated with the material name
{
for (int i = 0; i < materials.size(); i++) {
Material m = materials.get(i);
if (m.hasName(matName)) {
if (m.getTexture() == null) {
if (m.getTextureFile() != null) {
m.loadTexture(m.getTextureFile(), gl);
}
}
return m.getTexture();
}
}
return null;
}
示例8: initializeTexture
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
private Texture initializeTexture(GL2 gl) {
tileAtlas = null;
try {
tileAtlas = TextureIO.newTexture(new FileInputStream("Resources/DFfont.png"),false,".png");
tileAtlas.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_POINT);
tileAtlas.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_POINT);
tileAtlas.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_EDGE);
tileAtlas.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP_TO_EDGE);
} catch (IOException | GLException ex) {
//Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
}
return tileAtlas;
}
示例9: shiftNonRequired
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
/**
* Shifts all textures contained in the primary texture-cache into the
* secondary texture-cache (cf. <a href="#caching">Caching</a>).
* @param required The keys of all those textures still required
* and will therefore stay in the primary texture-cache if already contained.
*/
protected void shiftNonRequired(Collection<String> required) {
// All entities removed from primary cache must be remembered for later removal:
Collection<NamedImage<Texture>> shifted = new LinkedList<>();
// When shifting from primary to secondary cache, both are write-accessed.
// So lock them:
primaryTexturesLock.lock();
secondaryTexturesLock.lock();
// Iterate the primary texture-cache:
for (NamedImage<Texture> currentPrimary : primaryTextures) {
// If the entry is no longer required for drawing:
if(!required.contains(currentPrimary.getName())) {
// Move it to secondary cache:
secondaryTextures.add(currentPrimary);
shifted.add(currentPrimary); // Remember for removal
}
}
// Now remove all remembered textures from primary texture-cache:
primaryTextures.removeAll(shifted);
// Free the locks, so other threads can access the caches:
secondaryTexturesLock.unlock();
primaryTexturesLock.unlock();
}
示例10: getFontTexture
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
public Texture getFontTexture(String textureName) {
if (textureMap.containsKey(textureName)) {
return textureMap.get(textureName);
}
else {
String absolutePathToFontTextureFolder = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()
+ "res" + File.separator + "font" + File.separator;
String fontImage = absolutePathToFontTextureFolder + textureName + ".png";
Texture fontTexture = null;
try {
fontTexture = TextureIO.newTexture(new File(fontImage), false);
} catch (GLException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
textureMap.put(textureName, fontTexture);
return fontTexture;
}
}
示例11: 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();
}
示例12: 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();
}
示例13: FloorModel
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
FloorModel(Texture t, Point3d p, DynamicsWorld world) {
super(p,1);
mkStaticGroundPlane(world);
if(floorInt == 0){
this.gl = gl;
this.t = t;
TextureCoords textureCoords = t.getImageTexCoords();
textureTop = textureCoords.top();
textureBottom = textureCoords.bottom();
textureLeft = textureCoords.left();
textureRight = textureCoords.right();
floorInt = genCibeList(world);
}
}
示例14: 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);
}
示例15: load
import com.jogamp.opengl.util.texture.Texture; //导入依赖的package包/类
/**
* Pre-load or replace a specific texture.
*
* @param path Path of the texture to load.
* @return The loaded texture if successful. Throws runtime exception if texture could not be loaded.
*/
public Texture load(String path)
{
if (textures.containsKey(path)) {
// dispose the texture previously save under that id.
textures.get(path).destroy(gl);
}
try
{
Texture texture = loadImage(path);
textures.put(path, texture);
return texture;
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException("Unable to load texture " + path);
}
}