本文整理汇总了Java中org.lwjgl.opengl.GL11.glGenTextures方法的典型用法代码示例。如果您正苦于以下问题:Java GL11.glGenTextures方法的具体用法?Java GL11.glGenTextures怎么用?Java GL11.glGenTextures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.opengl.GL11
的用法示例。
在下文中一共展示了GL11.glGenTextures方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCubeMap
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public static int loadCubeMap(MyFile[] textureFiles) {
int texID = GL11.glGenTextures();
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texID);
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
for (int i = 0; i < textureFiles.length; i++) {
TextureData data = decodeTextureFile(textureFiles[i]);
GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL11.GL_RGBA, data.getWidth(),
data.getHeight(), 0, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, data.getBuffer());
}
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, 0);
return texID;
}
示例2: getMultiTexID
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public static MultiTexID getMultiTexID(AbstractTexture tex)
{
MultiTexID multitexid = tex.multiTex;
if (multitexid == null)
{
int i = tex.getGlTextureId();
multitexid = (MultiTexID)multiTexMap.get(Integer.valueOf(i));
if (multitexid == null)
{
multitexid = new MultiTexID(i, GL11.glGenTextures(), GL11.glGenTextures());
multiTexMap.put(Integer.valueOf(i), multitexid);
}
tex.multiTex = multitexid;
}
return multitexid;
}
示例3: createEmptyCubeMap
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public static int createEmptyCubeMap(int size) {
int texID = GL11.glGenTextures();
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texID);
for (int i = 0; i < 6; i++) {
GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA,
GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);
}
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL12.GL_TEXTURE_WRAP_R, GL12.GL_CLAMP_TO_EDGE);
GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, 0);
return texID;
}
示例4: attachTexture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public void attachTexture(int internalFormat, int format, int type, int filtering, int attachment, int width, int height) {
bind();
int tid = GL11.glGenTextures();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, tid);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, (ByteBuffer) null);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, attachment, GL11.GL_TEXTURE_2D, tid, 0);
textureids.add(tid);
unbind();
}
示例5: init
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
@Override
public void init(int attachment, int width, int height, int samples) {
int texture = GL11.glGenTextures();
super.setBufferId(texture);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
indicateStorageType(width, height);
setTextureParams();
GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, attachment, GL11.GL_TEXTURE_2D, texture, 0);
}
示例6: Texture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
/**
* @param filename image to use for texture
*/
public Texture(String filename){
image = new Image(filename);
// Generate ID
id = GL11.glGenTextures();
createTexture(id, image);
}
示例7: 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);
}
示例8: 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;
}
示例9: Texture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public Texture(Bitmap bitmap, int minMagFilter, int wrapMode)
{
this.bitmap = bitmap;
this.width = this.bitmap.getWidth();
this.height = this.bitmap.getHeight();
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);
Bitmap.Format format = this.bitmap.getFormat();
GL11.glTexImage2D(GL11.GL_TEXTURE_2D,
0,
getInternalTextureFormat(format),
this.bitmap.getWidth(),
this.bitmap.getHeight(),
0,
getTextureFormat(format),
getTextureBufferType(format),
this.bitmap.getPixelBuffer());
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
TEXTURES.add(this);
}
示例10: 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;
}
}
示例11: generateTexture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public static int generateTexture()
{
return GL11.glGenTextures();
}
示例12: glGenTextures
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public void glGenTextures(IntBuffer ids) {
GL11.glGenTextures(ids);
}
示例13: createTextureID
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
private static int createTextureID()
{
IntBuffer tmp = createIntBuffer(1);
GL11.glGenTextures(tmp);
return tmp.get(0);
}
示例14: loadTexture
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
/**
* Loads a texture with the specified filename
* @param name The name of the texture (extension inclusive)
* @return The loaded TextureData
*/
public static TextureData loadTexture(String name) {
// The BufferedImage of the loaded texture
BufferedImage image = null;
// Try to load the buffered image into memory
try {
image = ImageIO.read(new FileInputStream(new File(path + name)));
} catch (IOException e) {
System.err.println("Error in Texture.loadTexture(): unable to load texture[" + name + "]");
e.printStackTrace();
System.exit(1);
}
// Get image dimensions
int width = image.getWidth();
int height = image.getHeight();
// Get a new texture id
int id = GL11.glGenTextures();
// Store the image data into a pixel array
int[] pixels = new int[width * height * 4];
image.getRGB(0, 0, width, height, pixels, 0, width);
// Create a ByteBuffer to hold the image data to upload to OpenGL
ByteBuffer buffer = BufferUtils.createByteBuffer(pixels.length);
// Store the pixel data into the buffer
for(int y = height - 1; y >= 0; y--) {
for(int x = 0; x < width; x++) {
// Get the current pixel;
int pixel = pixels[y * width + x];
// Store the red value
buffer.put((byte) ((pixel >> 16) & 0xFF));
// Store the green value
buffer.put((byte) ((pixel >> 8) & 0xFF));
// Store the blue value
buffer.put((byte) ((pixel) & 0xFF));
// Store the alpha value
buffer.put((byte) ((pixel >> 24) & 0xFF));
}
}
// Prepare the buffer for get() operations
buffer.flip();
return new TextureData(id, width, height, buffer);
}
示例15: setupShadowFrameBuffer
import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
private static void setupShadowFrameBuffer()
{
if (usedShadowDepthBuffers != 0)
{
if (sfb != 0)
{
EXTFramebufferObject.glDeleteFramebuffersEXT(sfb);
GlStateManager.deleteTextures(sfbDepthTextures);
GlStateManager.deleteTextures(sfbColorTextures);
}
sfb = EXTFramebufferObject.glGenFramebuffersEXT();
EXTFramebufferObject.glBindFramebufferEXT(36160, sfb);
GL11.glDrawBuffer(0);
GL11.glReadBuffer(0);
GL11.glGenTextures((IntBuffer)sfbDepthTextures.clear().limit(usedShadowDepthBuffers));
GL11.glGenTextures((IntBuffer)sfbColorTextures.clear().limit(usedShadowColorBuffers));
sfbDepthTextures.position(0);
sfbColorTextures.position(0);
for (int i = 0; i < usedShadowDepthBuffers; ++i)
{
GlStateManager.bindTexture(sfbDepthTextures.get(i));
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10496.0F);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10496.0F);
int j = shadowFilterNearest[i] ? 9728 : 9729;
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, j);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, j);
if (shadowHardwareFilteringEnabled[i])
{
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_COMPARE_MODE, GL14.GL_COMPARE_R_TO_TEXTURE);
}
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, shadowMapWidth, shadowMapHeight, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (FloatBuffer)((FloatBuffer)null));
}
EXTFramebufferObject.glFramebufferTexture2DEXT(36160, 36096, 3553, sfbDepthTextures.get(0), 0);
checkGLError("FT sd");
for (int k = 0; k < usedShadowColorBuffers; ++k)
{
GlStateManager.bindTexture(sfbColorTextures.get(k));
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10496.0F);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10496.0F);
int i1 = shadowColorFilterNearest[k] ? 9728 : 9729;
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i1);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, i1);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, shadowMapWidth, shadowMapHeight, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (ByteBuffer)((ByteBuffer)null));
EXTFramebufferObject.glFramebufferTexture2DEXT(36160, 36064 + k, 3553, sfbColorTextures.get(k), 0);
checkGLError("FT sc");
}
GlStateManager.bindTexture(0);
if (usedShadowColorBuffers > 0)
{
GL20.glDrawBuffers(sfbDrawBuffers);
}
int l = EXTFramebufferObject.glCheckFramebufferStatusEXT(36160);
if (l != 36053)
{
printChatAndLogError("[Shaders] Error: Failed creating shadow framebuffer! (Status " + l + ")");
}
else
{
SMCLog.info("Shadow framebuffer created.");
}
}
}