本文整理汇总了Java中org.lwjgl.opengl.EXTTextureFilterAnisotropic类的典型用法代码示例。如果您正苦于以下问题:Java EXTTextureFilterAnisotropic类的具体用法?Java EXTTextureFilterAnisotropic怎么用?Java EXTTextureFilterAnisotropic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EXTTextureFilterAnisotropic类属于org.lwjgl.opengl包,在下文中一共展示了EXTTextureFilterAnisotropic类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadTexture
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
public int loadTexture(String fileName) {
Texture texture = null;
try {
texture = TextureLoader.getTexture("PNG",
new FileInputStream(MainGameLoop.fileManager.getTextureFile(fileName)));
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
float amount = Math.min(4f,
GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
amount);
} else {
System.out.println("Filter Anisotropic Not Supported");
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("Tried to load texture " + fileName + ".png , didn't work");
System.exit(-1);
}
textures.add(texture.getTextureID());
return texture.getTextureID();
}
开发者ID:Radseq,项目名称:Mystic-Bastion,代码行数:25,代码来源:Loader.java
示例2: loadTextureToOpenGL
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
protected static int loadTextureToOpenGL(TextureData data, TextureBuilder builder) {
int texID = GL11.glGenTextures();
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL12.GL_BGRA,
GL11.GL_UNSIGNED_BYTE, data.getBuffer());
if (builder.isMipmap()) {
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
if (builder.isAnisotropic() && GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
4.0f);
}
} else if (builder.isNearest()) {
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);
} else {
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
}
if (builder.isClampEdges()) {
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
} else {
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
}
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
return texID;
}
开发者ID:TheThinMatrix,项目名称:OpenGL-Animation,代码行数:34,代码来源:TextureUtils.java
示例3: loadTexture
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
/**
* Loads buffered image to graphics card
*
* @param bImage Buffered image describing the image
* @return Integer describing the image's location on the GPU
*/
protected int loadTexture(BufferedImage bImage) {
LuminosImage image = LuminosImage.loadImage(bImage, Format.RGBA);
int textureID = glGenTextures();
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -0.6f);
if(getCapabilities().GL_EXT_texture_filter_anisotropic) {
float amount = Math.min(4f, glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
glTexParameterf(GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount);
}
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.getBuffer());
Loader.textures.add(textureID);
return textureID;
}
开发者ID:nickclark2016,项目名称:JavaGraphicsEngine,代码行数:35,代码来源:ImageLoader.java
示例4: loadTexture
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
public int loadTexture(boolean root, String directory, String file, float bias) {
Texture texture = null;
if (!file.toLowerCase().endsWith(".png")) file += ".png";
try {
String path = directory + "/" + file;
if (!root) path = "assets/" + path;
texture = TextureLoader.getTexture("PNG", net.gogo98901.util.Loader.getResourceAsStream(path));
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, bias);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
if (directory != "fonts") {
if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
if (Config.anisotropic.get()) {
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0F);
float amount = Math.min(4F, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount);
} else {
Log.info("GL: Anisotropic filtering disabled by config");
}
} else {
Log.warn("GL: Anisotropic filtering not supported");
}
}
} catch (IOException e) {
Log.warn("Could not read texture '" + file + "'");
Log.stackTrace(e);
}
textures.add(texture.getTextureID());
return texture.getTextureID();
}
开发者ID:roryclaasen,项目名称:sandbox,代码行数:35,代码来源:Loader.java
示例5: loadTexture
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
private static int loadTexture(String texName) {
try(InputStream in = Resources.getInputStream("textures/" + texName)) {
PNGDecoder decoder = new PNGDecoder(in);
int width = decoder.getWidth();
int height = decoder.getHeight();
ByteBuffer data = BufferUtils.createByteBuffer(width * height * 4);
decoder.decode(data, width * 4, Format.RGBA);
data.flip();
int tex = glGenTextures();
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, glGetInteger(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
return tex;
}
catch(Exception exc) {
throw new RuntimeException("Failed to load " + texName, exc);
}
}
开发者ID:ra4king,项目名称:OpenGL-Worlds,代码行数:29,代码来源:WorldRenderer.java
示例6: enableAnisotropy
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
public void enableAnisotropy(int level) {
if (isAnisotropySupported())
glTexParameteri(type, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, level);
else throw new RuntimeException("Anisotropic filtering is not supported.");
}
开发者ID:WarpOrganization,项目名称:warp,代码行数:6,代码来源:Texture.java
示例7: disableAnisotropy
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
public void disableAnisotropy() {
if (isAnisotropySupported())
glTexParameteri(type, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, 0);
else throw new RuntimeException("Anisotropic filtering is not supported.");
}
开发者ID:WarpOrganization,项目名称:warp,代码行数:6,代码来源:Texture.java
示例8: setupTextureParams
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
@SuppressWarnings("fallthrough")
private void setupTextureParams(Texture tex) {
Image image = tex.getImage();
int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1);
// filter things
int minFilter = convertMinFilter(tex.getMinFilter());
int magFilter = convertMagFilter(tex.getMagFilter());
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter);
if (tex.getAnisotropicFilter() > 1) {
if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
glTexParameterf(target,
EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
tex.getAnisotropicFilter());
}
}
if (context.pointSprite) {
return; // Attempt to fix glTexParameter crash for some ATI GPUs
}
// repeat modes
switch (tex.getType()) {
case ThreeDimensional:
case CubeMap: // cubemaps use 3D coords
glTexParameteri(target, GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R)));
case TwoDimensional:
case TwoDimensionalArray:
glTexParameteri(target, GL_TEXTURE_WRAP_T, convertWrapMode(tex.getWrap(WrapAxis.T)));
// fall down here is intentional..
// case OneDimensional:
glTexParameteri(target, GL_TEXTURE_WRAP_S, convertWrapMode(tex.getWrap(WrapAxis.S)));
break;
default:
throw new UnsupportedOperationException("Unknown texture type: " + tex.getType());
}
// R to Texture compare mode
if (tex.getShadowCompareMode() != Texture.ShadowCompareMode.Off) {
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(target, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
if (tex.getShadowCompareMode() == Texture.ShadowCompareMode.GreaterOrEqual) {
glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_GEQUAL);
} else {
glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
}
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:LwjglRenderer.java
示例9: loadTexture
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
private int loadTexture(String name){
int[] pixels = new int[width*height];
img.getRGB(0, 0, width, height, pixels, 0, width);
ByteBuffer buffer = BufferUtils.createByteBuffer(width*height*4);
boolean hasAlpha = img.getColorModel().hasAlpha();
//loop through all the pixels and extract the red, green, blue and alpha components
//and put them in the buffer which will then be sent to the gpu
for(int y = 0; y < height; y++)
for(int x = 0; x < width; x++){
int pixelData = pixels[x + (y*width)];
buffer.put((byte) ((pixelData >> 16) & 0xFF)); //RED Component
buffer.put((byte) ((pixelData >> 8) & 0xFF)); //GREEN Component
buffer.put((byte) (pixelData & 0xFF)); //BLUE Component
if(hasAlpha)
buffer.put((byte) ((pixelData >> 24) & 0xFF)); //ALPHA Component
else buffer.put((byte) 0xFF);
}
buffer.flip();
int id = glGenTextures();
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
//send the texture data to the gpu
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
buffer = null;
glBindTexture(GL_TEXTURE_2D, 0);
return id;
}
开发者ID:DigohD,项目名称:CR,代码行数:46,代码来源:Texture.java
示例10: getTexture
import org.lwjgl.opengl.EXTTextureFilterAnisotropic; //导入依赖的package包/类
/**
* Ladet eine Textur zum angegebenen BufferedImage.
* @param bufferedImage Image mit den Bildinformationen.
* @return die geladene Textur.
*/
private Texture getTexture(BufferedImage bufferedImage, int flags)
{
int textureID = glGenTextures();
int srcWidth = bufferedImage.getWidth();
int srcHeight = bufferedImage.getHeight();
boolean alpha = bufferedImage.getColorModel().hasAlpha();
ColorSpace colorSpace = bufferedImage.getColorModel().getColorSpace();
switch(colorSpace.getType())
{
case ColorSpace.TYPE_RGB: break;
default: throw new IllegalArgumentException("unsupported color-format: " + getColorFormat(colorSpace));
}
int colorFormat = alpha ? GL_RGBA : GL_RGB;
Texture texture = new Texture(GL_TEXTURE_2D, textureID, srcWidth, srcHeight);
byte[] data = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
convertColorFormat(data, alpha);
ByteBuffer buffer = ByteBuffer.allocateDirect(data.length);
buffer.order(ByteOrder.nativeOrder());
buffer.put(data, 0, data.length);
buffer.flip();
GLCache.bindTexture(texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if ((flags & ANIOTROPIC) != 0)
{
// Due to LWJGL buffer check, you can't use smaller sized buffers (min_size = 16 for glGetFloat()).
FloatBuffer max_a = BufferUtils.createFloatBuffer(16);
// Grab the maximum anisotropic filter.
GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, max_a);
System.out.println(max_a.get(0));
// Set up the anisotropic filter.
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
max_a.get(0));
}
if (texture.getWidth() != srcWidth || texture.getHeight() != srcHeight)
{
GL11.glTexImage2D(GL_TEXTURE_2D, 0, colorFormat,
texture.getWidth(), texture.getHeight(), 0, colorFormat,
GL_UNSIGNED_BYTE, (ByteBuffer) null);
GL11.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
srcWidth, srcHeight, colorFormat, GL_UNSIGNED_BYTE, buffer);
}
else
{
GL11.glTexImage2D(GL_TEXTURE_2D, 0, colorFormat,
texture.getWidth(), texture.getHeight(), 0, colorFormat,
GL_UNSIGNED_BYTE, buffer);
}
Util.checkGLError();
return texture;
}
开发者ID:TheWhiteShadow3,项目名称:cuina,代码行数:64,代码来源:TextureLoader.java
注:本文中的org.lwjgl.opengl.EXTTextureFilterAnisotropic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论