本文整理汇总了Java中org.lwjgl.opengl.GL11.glTexImage2D方法的典型用法代码示例。如果您正苦于以下问题:Java GL11.glTexImage2D方法的具体用法?Java GL11.glTexImage2D怎么用?Java GL11.glTexImage2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.opengl.GL11
的用法示例。
在下文中一共展示了GL11.glTexImage2D方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allocateTexture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
/**
* Allocate a new OpenGL texture for caching pre-rendered glyph images. The new texture is initialized to fully transparent
* white so the individual glyphs images within can have a transparent border between them. The new texture remains bound
* after returning from the function.
*/
private void allocateTexture() {
/* Initialize the background to all white but fully transparent. */
glyphGraphics.clearRect(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);
/* Allocate new OpenGL texure */
texture = GL11.glGenTextures();
/* Load imageBuffer with pixel data ready for transfer to OpenGL texture */
updateBuffer(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);
/*
* Initialize texture with the now cleared BufferedImage. Using a texture with GL_ALPHA8 internal format may result in
* faster rendering since the GPU has to only fetch 1 byte per texel instead of 4 with a regular RGBA texture.
*/
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL11.GL_RGBA,
GL11.GL_UNSIGNED_BYTE, imageBuffer);
/* Explicitly disable mipmap support because updateTexture() will only update the base level 0 */
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
}
示例2: getGLMaximumTextureSize
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
/**
* Used in the usage snooper.
*/
public static int getGLMaximumTextureSize()
{
for (int i = 16384; i > 0; i >>= 1)
{
GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)((ByteBuffer)null));
int j = GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
if (j != 0)
{
return i;
}
}
return -1;
}
示例3: createTexture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
/**
* Creates an OpenGL texture based on a given Image
* @param id OpenGL reference id to create texture in
* @param image
*/
private void createTexture(int id, Image image) {
// Set as texture 0
GL13.glActiveTexture(GL13.GL_TEXTURE0);
bind();
// Set pixel storage mode
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
// Setup texture
GL11.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GL11.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GL11.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width, image.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image.buffer);
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
unbind();
}
示例4: Texture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public Texture(int width, int height, int minMagFilter, int wrapMode, Bitmap.Format pixelFormat)
{
this.bitmap = null;
this.width = width;
this.height = height;
this.handle = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.handle);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, minMagFilter);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, minMagFilter);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapMode);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapMode);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D,
0,
getInternalTextureFormat(pixelFormat),
this.width,
this.height,
0,
getTextureFormat(pixelFormat),
getTextureBufferType(pixelFormat),
(ByteBuffer) null);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
TEXTURES.add(this);
}
示例5: loadTexture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public static Texture loadTexture(String textureFile) {
try {
// InputStream in = TextureLoader.class.getResourceAsStream("/" + textureFile);
InputStream in = Util.loadInternal(textureFile);
BufferedImage image = ImageIO.read(in);
int[] pixels = new int[image.getWidth() * image.getHeight()];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
ByteBuffer buffer = ByteBuffer.allocateDirect(image.getWidth() * image.getHeight() * 4);
for(int h = 0; h < image.getHeight(); h++) {
for(int w = 0; w < image.getWidth(); w++) {
int pixel = pixels[h * image.getWidth() + w];
buffer.put((byte) ((pixel >> 16) & 0xFF));
buffer.put((byte) ((pixel >> 8) & 0xFF));
buffer.put((byte) (pixel & 0xFF));
buffer.put((byte) ((pixel >> 24) & 0xFF));
}
}
buffer.flip();
in.close();
int textureID = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_MAX_TEXTURE_LOD_BIAS, -1);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
return new Texture(textureID, image.getWidth(), image.getHeight());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例6: indicateStorageType
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
private void indicateStorageType(int width, int height) {
if (isDepthAttachment()) {
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, format, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
} else {
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, format, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
}
}
示例7: allocateMipmapTextures
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public static void allocateMipmapTextures(int p_allocateMipmapTextures_0_, int p_allocateMipmapTextures_1_, String p_allocateMipmapTextures_2_)
{
Dimension[] adimension = makeMipmapDimensions(p_allocateMipmapTextures_0_, p_allocateMipmapTextures_1_, p_allocateMipmapTextures_2_);
for (int i = 0; i < adimension.length; ++i)
{
Dimension dimension = adimension[i];
int j = dimension.width;
int k = dimension.height;
int l = i + 1;
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, l, GL11.GL_RGBA, j, k, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)((IntBuffer)null));
}
}
示例8: indicateStorageType
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
private void indicateStorageType(int width, int height){
if(isDepthAttachment()){
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, format, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
}else{
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, format, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
}
}
示例9: createDepthTextureAttachment
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
private int createDepthTextureAttachment(int width, int height){
int texture = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT32, width, height,
0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
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);
GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT,
texture, 0);
return texture;
}
示例10: UIFont
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public UIFont(String path, float fontHeight){
ByteBuffer data = ResourceLoader.getBytes(path);
cdata = STBTTBakedChar.malloc(96);
ByteBuffer bitmap = BufferUtils.createByteBuffer(512 * 512);
STBTruetype.stbtt_BakeFontBitmap(data, 32, bitmap, 512, 512, 32, cdata);
texId = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA, 512, 512, 0, GL11.GL_ALPHA, GL11.GL_UNSIGNED_BYTE, bitmap);
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);
}
示例11: allocateTextureImpl
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public static void allocateTextureImpl(int p_180600_0_, int p_180600_1_, int p_180600_2_, int p_180600_3_)
{
Object object = TextureUtil.class;
if (Reflector.SplashScreen.exists())
{
object = Reflector.SplashScreen.getTargetClass();
}
synchronized (object)
{
deleteTexture(p_180600_0_);
bindTexture(p_180600_0_);
}
if (p_180600_1_ >= 0)
{
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, p_180600_1_);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)p_180600_1_);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F);
}
for (int i = 0; i <= p_180600_1_; ++i)
{
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, p_180600_2_ >> i, p_180600_3_ >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)((IntBuffer)null));
}
}
示例12: loadTextureToOpenGL
import org.lwjgl.opengl.GL11; //导入方法依赖的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;
}
示例13: HFNoiseTexture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public HFNoiseTexture(int width, int height)
{
byte[] abyte = this.genHFNoiseImage(width, height);
ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length);
bytebuffer.put(abyte);
bytebuffer.flip();
GlStateManager.bindTexture(this.texID);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, width, height, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)bytebuffer);
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.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);
GlStateManager.bindTexture(0);
}
示例14: createFramebuffer
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public void createFramebuffer(int width, int height)
{
this.framebufferWidth = width;
this.framebufferHeight = height;
this.framebufferTextureWidth = width;
this.framebufferTextureHeight = height;
if (!OpenGlHelper.isFramebufferEnabled())
{
this.framebufferClear();
}
else
{
this.framebufferObject = OpenGlHelper.glGenFramebuffers();
this.framebufferTexture = TextureUtil.glGenTextures();
if (this.useDepth)
{
this.depthBuffer = OpenGlHelper.glGenRenderbuffers();
}
this.setFramebufferFilter(9728);
GlStateManager.bindTexture(this.framebufferTexture);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, this.framebufferTextureWidth, this.framebufferTextureHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)((ByteBuffer)null));
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, this.framebufferObject);
OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, 3553, this.framebufferTexture, 0);
if (this.useDepth)
{
OpenGlHelper.glBindRenderbuffer(OpenGlHelper.GL_RENDERBUFFER, this.depthBuffer);
OpenGlHelper.glRenderbufferStorage(OpenGlHelper.GL_RENDERBUFFER, 33190, this.framebufferTextureWidth, this.framebufferTextureHeight);
OpenGlHelper.glFramebufferRenderbuffer(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_DEPTH_ATTACHMENT, OpenGlHelper.GL_RENDERBUFFER, this.depthBuffer);
}
this.framebufferClear();
this.unbindFramebufferTexture();
}
}
示例15: loadTexture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public static int loadTexture(String imagename, BufferedImage image) {
int BYTES_PER_PIXEL = 4;
int[] pixels = new int[image.getWidth() * image.getHeight()];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * BYTES_PER_PIXEL);
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
int pixel = pixels[y * image.getWidth() + x];
buffer.put((byte) ((pixel >> 16) & 0xFF)); // Red component
buffer.put((byte) ((pixel >> 8) & 0xFF)); // Green component
buffer.put((byte) (pixel & 0xFF)); // Blue component
buffer.put((byte) ((pixel >> 24) & 0xFF)); // Alpha component.
// Only for RGBA
}
}
buffer.flip(); // FOR THE LOVE OF GOD DO NOT FORGET THIS
// You now have a ByteBuffer filled with the color data of each pixel.
// Now just create a texture ID and bind it. Then you can load it using
// whatever OpenGL method you want, for example:
int textureID = GL11.glGenTextures(); // Generate texture ID
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); // Bind texture ID
// Setup wrap mode
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);
// Setup texture scaling filtering
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
// Send texel data to OpenGL
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA,
GL11.GL_UNSIGNED_BYTE, buffer);
// Return the texture ID so we can bind it later again
loadedPicture.put(imagename, textureID);
return textureID;
}