當前位置: 首頁>>代碼示例>>Java>>正文


Java GLU.gluBuild2DMipmaps方法代碼示例

本文整理匯總了Java中org.lwjgl.util.glu.GLU.gluBuild2DMipmaps方法的典型用法代碼示例。如果您正苦於以下問題:Java GLU.gluBuild2DMipmaps方法的具體用法?Java GLU.gluBuild2DMipmaps怎麽用?Java GLU.gluBuild2DMipmaps使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.util.glu.GLU的用法示例。


在下文中一共展示了GLU.gluBuild2DMipmaps方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: begin

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static void begin() {
    glEnable( GL_TEXTURE_2D );

    // one-time only we bind the texture, create mip-maps so it can be nicely viewed at any distance, etc.
    if ( !textureInitialized ) {
        textureInitialized = true;
        textureId = glGenTextures();
        glBindTexture( GL_TEXTURE_2D, textureId );

        glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                         GL_LINEAR_MIPMAP_NEAREST );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

        // repeat
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );

        GLU.gluBuild2DMipmaps( GL_TEXTURE_2D, 4, WIDTH, HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, buffer );
    }

    // from then on, we always use the bound texture ID to efficiently show the stored texture
    glBindTexture( GL_TEXTURE_2D, textureId );
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:25,代碼來源:EarthTexture.java

示例2: create2dTexture

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public int create2dTexture(int color) {
	int id = genTexID();
	
	IntBuffer ibuf = bbuf.asIntBuffer();
	for (int i = 0; i < ibuf.capacity(); i++) ibuf.put(i, color);

	GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);
	int targetFormat = GL11.GL_RGBA;
	GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
	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);
	GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, targetFormat, TEXTURE_RESX, TEXTURE_RESY, 0, GL11.GL_RGBA,
			GL11.GL_UNSIGNED_BYTE, bbuf.asIntBuffer());
	GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, targetFormat, TEXTURE_RESX, TEXTURE_RESY, GL11.GL_RGBA,
			GL11.GL_UNSIGNED_BYTE, bbuf);

	return id;
}
 
開發者ID:Erkaman,項目名稱:NeoTextureEdit2,代碼行數:20,代碼來源:OpenGLTextureRenderCanvas.java

示例3: update2dTexture_ConstanctColor

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public synchronized void update2dTexture_ConstanctColor(int color, int id) {
	IntBuffer ibuf = bbuf.asIntBuffer();
	for (int i = 0; i < ibuf.capacity(); i++) ibuf.put(i, color);

	GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);
	int targetFormat = GL11.GL_RGBA;
	GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, targetFormat, TEXTURE_RESX, TEXTURE_RESY, 0, GL11.GL_RGBA,
			GL11.GL_UNSIGNED_BYTE, bbuf.asIntBuffer());
	GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, targetFormat, TEXTURE_RESX, TEXTURE_RESY, GL11.GL_RGBA,
			GL11.GL_UNSIGNED_BYTE, bbuf);
}
 
開發者ID:Erkaman,項目名稱:NeoTextureEdit2,代碼行數:12,代碼來源:OpenGLTextureRenderCanvas.java

示例4: update2dTexture

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public synchronized void update2dTexture(BufferedImage img, int id) {
	if (img.getWidth() != TEXTURE_RESX || img.getHeight() != TEXTURE_RESY) {
		Logger.logError(this, "TextureResolution does not match image resolution for update.");
		return;
	}
	convertImageData(bbuf.asIntBuffer(), img);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);
	//int targetFormat = (img.getColorModel().hasAlpha()) ? GL11.GL_RGBA : GL11.GL_RGB;
	int targetFormat = GL11.GL_RGBA;
	GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, targetFormat, TEXTURE_RESX, TEXTURE_RESY, 0, GL11.GL_RGBA,
			GL11.GL_UNSIGNED_BYTE, bbuf.asIntBuffer());
	GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, targetFormat, TEXTURE_RESX, TEXTURE_RESY, GL11.GL_RGBA,
			GL11.GL_UNSIGNED_BYTE, bbuf);
}
 
開發者ID:Erkaman,項目名稱:NeoTextureEdit2,代碼行數:15,代碼來源:OpenGLTextureRenderCanvas.java

示例5: setPixelData

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
@Override
public void setPixelData(ByteBuffer pixels, InternalFormat format, int width, int height, boolean generateMipmaps) {
	ensureCreated("Texture must be created to set pixel data.");
	// Check if mipmaps should be generated for this texture
	if (generateMipmaps) {
		GLU.gluBuild2DMipmaps(GL_TEXTURE_2D, format.getFormat().getNumComponents(), width, height, format.getFormat().getGLConstant(), format.getDataType().getGLConstant(), pixels);
	} else {
		GL11.glTexImage2D(GL_TEXTURE_2D, 0, format.getGLConstant(), width, height, 0, format.getFormat().getGLConstant(), format.getDataType().getGLConstant(), pixels);
	}
}
 
開發者ID:thehutch,項目名稱:Fusion,代碼行數:11,代碼來源:OpenGL20Texture.java

示例6: Texture

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public Texture(String resourceName){
    try{
        if (idMap.containsKey(resourceName)) return;

        this.path = resourceName;

        IntBuffer ib = BufferUtils.createIntBuffer(1);
        ib.clear();
        glGenTextures(ib);
        int id = ib.get(0);
        idMap.put(resourceName, Integer.valueOf(id));

        glBindTexture(3553, id);

        glTexParameteri(3553, 10241, GL_NEAREST);
        glTexParameteri(3553, 10240, GL_NEAREST);

        BufferedImage img = ImageIO.read(Texture.class.getResourceAsStream(resourceName));

        int w = img.getWidth();
        int h = img.getHeight();

        ByteBuffer pixels = BufferUtils.createByteBuffer(w * h * 4);
        int[] rawPixels = new int[w * h];

        img.getRGB(0, 0, w, h, rawPixels, 0, w);

        for (int i = 0; i < rawPixels.length; i++){
            int a = rawPixels[i] >> 24 & 0xFF;
            int r = rawPixels[i] >> 16 & 0xFF;
            int g = rawPixels[i] >> 8 & 0xFF;
            int b = rawPixels[i] & 0xFF;

            rawPixels[i] = (a << 24 | b << 16 | g << 8 | r);
        }

        pixels.asIntBuffer().put(rawPixels);
        GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, pixels);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
    }catch (IOException e){
        throw new RuntimeException("!!");
    }
}
 
開發者ID:Vinetos,項目名稱:FreeWorld,代碼行數:44,代碼來源:Texture.java

示例7: loadImage

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static int loadImage(BufferedImage bufferedImage) {
    try {
        short width = (short) bufferedImage.getWidth();
        short height = (short) bufferedImage.getHeight();
        //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
        int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
        ByteBuffer byteBuffer;
        DataBuffer db = bufferedImage.getData().getDataBuffer();
        if (db instanceof DataBufferInt) {
            int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
            byte newI[] = new byte[intI.length * 4];
            for (int i = 0; i < intI.length; i++) {
                byte b[] = intToByteArray(intI[i]);
                int newIndex = i * 4;

                newI[newIndex] = b[1];
                newI[newIndex + 1] = b[2];
                newI[newIndex + 2] = b[3];
                newI[newIndex + 3] = b[0];
            }

            byteBuffer = ByteBuffer.allocateDirect(
                    width * height * (bpp / 8))
                    .order(ByteOrder.nativeOrder())
                    .put(newI);
        } else {
            byteBuffer = ByteBuffer.allocateDirect(
                    width * height * (bpp / 8))
                    .order(ByteOrder.nativeOrder())
                    .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
        }
        byteBuffer.flip();


        int internalFormat = GL11.GL_RGBA8,
                format = GL11.GL_RGBA;
        IntBuffer textureId = BufferUtils.createIntBuffer(1);

        GL11.glGenTextures(textureId);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);


        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);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);

        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST);

        GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

        GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer);
        return textureId.get(0);

    } catch (Exception e) {
        e.printStackTrace();
    }

    return -1;
}
 
開發者ID:McJty,項目名稱:Lector,代碼行數:66,代碼來源:TrueTypeFont.java

示例8: loadDirect

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
@Override
public @Nonnull DynamicImageTexture loadDirect() {
	final BufferedImage bufferedImage = this.image;
	if (bufferedImage!=null) {
		try {
			final int width = bufferedImage.getWidth();
			final int height = bufferedImage.getHeight();
			//textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
			final int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
			ByteBuffer byteBuffer;
			final DataBuffer db = bufferedImage.getData().getDataBuffer();
			if (db instanceof DataBufferInt) {
				final int intI[] = ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData();
				final byte newI[] = new byte[intI.length*4];
				for (int i = 0; i<intI.length; i++) {
					final byte b[] = intToByteArray(intI[i]);
					final int newIndex = i*4;

					newI[newIndex] = b[1];
					newI[newIndex+1] = b[2];
					newI[newIndex+2] = b[3];
					newI[newIndex+3] = b[0];
				}

				byteBuffer = ByteBuffer.allocateDirect(
						width*height*(bpp/8))
						.order(ByteOrder.nativeOrder())
						.put(newI);
			} else
				byteBuffer = ByteBuffer.allocateDirect(
						width*height*(bpp/8))
						.order(ByteOrder.nativeOrder())
						.put(((DataBufferByte) bufferedImage.getData().getDataBuffer()).getData());
			byteBuffer.flip();

			final int internalFormat = GL_RGBA8, format = GL_RGBA;
			final int textureId = getId();
			OpenGL.glBindTexture(GL_TEXTURE_2D, textureId);

			OpenGL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
			OpenGL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

			OpenGL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			OpenGL.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

			GL11.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

			GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D,
					internalFormat,
					width,
					height,
					format,
					GL11.GL_UNSIGNED_BYTE,
					byteBuffer);

		} catch (final Exception e) {
		}
		this.image = null;
	}

	return this;
}
 
開發者ID:Team-Fruit,項目名稱:SignPicture,代碼行數:63,代碼來源:DynamicImageTexture.java

示例9: loadImage

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static int loadImage(BufferedImage bufferedImage)
    {
        try
        {
            short width = (short) bufferedImage.getWidth();
            short height = (short) bufferedImage.getHeight();
            // textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
            int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
            ByteBuffer byteBuffer;
            DataBuffer db = bufferedImage.getData().getDataBuffer();
            if (db instanceof DataBufferInt)
            {
                int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
                byte newI[] = new byte[intI.length * 4];
                for (int i = 0; i < intI.length; i++)
                {
                    byte b[] = Useful.intToByteArray(intI[i]);
                    int newIndex = i * 4;

                    newI[newIndex] = b[1];
                    newI[newIndex + 1] = b[2];
                    newI[newIndex + 2] = b[3];
                    newI[newIndex + 3] = b[0];
                }

                byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()).put(newI);
            }
            else
            {
                byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                        .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
            }
            byteBuffer.flip();

            IntBuffer textureId = BufferUtils.createIntBuffer(1);

            GL11.glGenTextures(textureId);
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

            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_NEAREST);

//            GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

            GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, GL11.GL_RGBA8, width, height, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, byteBuffer);
            return textureId.get(0);

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        return -1;
    }
 
開發者ID:grondag,項目名稱:Hard-Science,代碼行數:59,代碼來源:TrueTypeFont.java

示例10: loadImage

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static int loadImage(BufferedImage bufferedImage) {
    short width = (short) bufferedImage.getWidth();
    short height = (short) bufferedImage.getHeight();
    // textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ?
    // (byte)32 : (byte)24;
    int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
    ByteBuffer byteBuffer;
    DataBuffer db = bufferedImage.getData().getDataBuffer();
    if (db instanceof DataBufferInt) {
        int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
        byte newI[] = new byte[intI.length * 4];
        for (int i = 0; i < intI.length; i++) {
            byte b[] = intToByteArray(intI[i]);
            int newIndex = i * 4;

            newI[newIndex] = b[1];
            newI[newIndex + 1] = b[2];
            newI[newIndex + 2] = b[3];
            newI[newIndex + 3] = b[0];
        }

        byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()).put(newI);
    } else {
        byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()).put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
    }
    byteBuffer.flip();

    int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA;
    IntBuffer textureId = BufferUtils.createIntBuffer(1);
    GL11.glGenTextures(textureId);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

    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);

    GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

    GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer);
    return textureId.get(0);
}
 
開發者ID:devnewton,項目名稱:jnuit,代碼行數:44,代碼來源:LwjglNuitFont.java

示例11: loadImage

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static int loadImage(BufferedImage bufferedImage)
{
    try
    {
        short width = (short) bufferedImage.getWidth();
        short height = (short) bufferedImage.getHeight();
        int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
        ByteBuffer byteBuffer;
        DataBuffer db = bufferedImage.getData().getDataBuffer();
        if(db instanceof DataBufferInt)
        {
            int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
            byte newI[] = new byte[intI.length * 4];
            for(int i = 0; i < intI.length; i++)
            {
                byte b[] = intToByteArray(intI[i]);
                int newIndex = i * 4;
                
                newI[newIndex] = b[1];
                newI[newIndex + 1] = b[2];
                newI[newIndex + 2] = b[3];
                newI[newIndex + 3] = b[0];
            }
            
            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(newI);
        }
        else
            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
        byteBuffer.flip();
        
        int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA;
        IntBuffer textureId = BufferUtils.createIntBuffer(1);
        ;
        GL11.glGenTextures(textureId);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));
        
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
        
        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);
        
        GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
        
        // NOTE: GLU isn't in LWJGL 3!!! This is from lwjgl_util.jar that comes with LWJGL 2
        GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer);
        return textureId.get(0);
        
    }
    catch(Exception e)
    {
        e.printStackTrace();
        System.exit(-1);
    }
    
    return -1;
}
 
開發者ID:LoDoMa,項目名稱:Lime,代碼行數:60,代碼來源:TrueTypeFont.java

示例12: loadImage

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static int loadImage(BufferedImage bufferedImage) {
    try {
	    short width       = (short)bufferedImage.getWidth();
	    short height      = (short)bufferedImage.getHeight();
	    //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
	    int bpp = (byte)bufferedImage.getColorModel().getPixelSize();
	    ByteBuffer byteBuffer;
	    DataBuffer db = bufferedImage.getData().getDataBuffer();
	    if (db instanceof DataBufferInt) {
	    	int intI[] = ((DataBufferInt)(bufferedImage.getData().getDataBuffer())).getData();
	    	byte newI[] = new byte[intI.length * 4];
	    	for (int i = 0; i < intI.length; i++) {
	    		byte b[] = intToByteArray(intI[i]);
	    		int newIndex = i*4;

	    		newI[newIndex]   = b[1];
	    		newI[newIndex+1] = b[2];
	    		newI[newIndex+2] = b[3];
	    		newI[newIndex+3] = b[0];
	    	}

	    	byteBuffer  = ByteBuffer.allocateDirect(
	    			width*height*(bpp/8))
		                           .order(ByteOrder.nativeOrder())
		                            .put(newI);
	    } else {
	    	byteBuffer  = ByteBuffer.allocateDirect(
	    			width*height*(bpp/8))
		                           .order(ByteOrder.nativeOrder())
		                            .put(((DataBufferByte)(bufferedImage.getData().getDataBuffer())).getData());
	    }
	    byteBuffer.flip();


	    int internalFormat = GL11.GL_RGBA8,
		format = GL11.GL_RGBA;
		IntBuffer   textureId =  BufferUtils.createIntBuffer(1);;
		GL11.glGenTextures(textureId);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);


		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);
		//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
		//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);

		//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
		//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
		//GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST);

		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

		GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer);
		return textureId.get(0);

	} catch (Exception e) {
    	e.printStackTrace();
    	System.exit(-1);
    }

	return -1;
}
 
開發者ID:SpitefulFox,項目名稱:ForbiddenMagic,代碼行數:66,代碼來源:TrueTypeFont.java

示例13: loadImage

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static int loadImage(BufferedImage bufferedImage) {
	try {
		short width = (short) bufferedImage.getWidth();
		short height = (short) bufferedImage.getHeight();
		// textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ?
		// (byte)32 : (byte)24;
		int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
		ByteBuffer byteBuffer;
		DataBuffer db = bufferedImage.getData().getDataBuffer();
		if (db instanceof DataBufferInt) {
			int intI[] = ((DataBufferInt) (bufferedImage.getData()
					.getDataBuffer())).getData();
			byte newI[] = new byte[intI.length * 4];
			for (int i = 0; i < intI.length; i++) {
				byte b[] = intToByteArray(intI[i]);
				int newIndex = i * 4;

				newI[newIndex] = b[1];
				newI[newIndex + 1] = b[2];
				newI[newIndex + 2] = b[3];
				newI[newIndex + 3] = b[0];
			}

			byteBuffer = ByteBuffer
					.allocateDirect(width * height * (bpp / 8))
					.order(ByteOrder.nativeOrder()).put(newI);
		} else {
			byteBuffer = ByteBuffer
					.allocateDirect(width * height * (bpp / 8))
					.order(ByteOrder.nativeOrder())
					.put(((DataBufferByte) (bufferedImage.getData()
							.getDataBuffer())).getData());
		}
		byteBuffer.flip();

		int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA;
		IntBuffer textureId = BufferUtils.createIntBuffer(1);
		;
		GL11.glGenTextures(textureId);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
				GL11.GL_CLAMP);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
				GL11.GL_CLAMP);

		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);

		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE,
				GL11.GL_MODULATE);

		GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width,
				height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer);
		return textureId.get(0);

	} catch (Exception e) {
		e.printStackTrace();
                       /*
                        * ARE YOU SERIOUS WHY IS THIS HERE
                        */
		System.exit(-1);
	}

	return -1;
}
 
開發者ID:GabrielRStella,項目名稱:Utility,代碼行數:69,代碼來源:TrueTypeFont.java

示例14: getTexture

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
/**
 * Load a texture into OpenGL from a image reference on disk.
 * 
 * @param resourceName
 *        The location of the resource to load
 * @param target
 *        The GL target to load the texture against
 * @param dstPixelFormat
 *        The pixel format of the screen
 * @param minFilter
 *        The minimising filter
 * @param magFilter
 *        The magnification filter
 * @return The loaded texture
 * @throws IOException
 *         Indicates a failure to access the resource
 */
public Texture getTexture(final String resourceName, final boolean injar, final int target,
        final int dstPixelFormat, final int minFilter, final int magFilter) throws IOException {

    int srcPixelFormat = 0;

    // create the texture ID for this texture
    final int textureID = createTextureID();
    final Texture texture = new Texture(target, textureID);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    final BufferedImage bufferedImage = loadImage(resourceName, injar);
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
        srcPixelFormat = GL11.GL_RGBA;
    } else {
        srcPixelFormat = GL11.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    final ByteBuffer textureBuffer = convertImageData(bufferedImage, texture);

    if (target == GL11.GL_TEXTURE_2D) {
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
    }

    // produce a texture from the byte buffer
    /*
     * GL11.glTexImage2D(target, 0, dstPixelFormat,
     * get2Fold(bufferedImage.getWidth()),
     * get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat,
     * GL11.GL_UNSIGNED_BYTE,
     * textureBuffer );
     */

    GLU.gluBuild2DMipmaps(target, dstPixelFormat, get2Fold(bufferedImage.getWidth()),
            get2Fold(bufferedImage.getHeight()), srcPixelFormat, GL11.GL_UNSIGNED_BYTE,
            textureBuffer);

    return texture;
}
 
開發者ID:JMaNGOS,項目名稱:JMaNGOS,代碼行數:65,代碼來源:TextureLoader.java

示例15: loadImage

import org.lwjgl.util.glu.GLU; //導入方法依賴的package包/類
public static int loadImage(BufferedImage bufferedImage) {
    try {
	    short width       = (short)bufferedImage.getWidth();
	    short height      = (short)bufferedImage.getHeight();
	    //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
	    int bpp = (byte)bufferedImage.getColorModel().getPixelSize();
	    ByteBuffer byteBuffer;
	    DataBuffer db = bufferedImage.getData().getDataBuffer();
	    if (db instanceof DataBufferInt) {
	    	int intI[] = ((DataBufferInt)(bufferedImage.getData().getDataBuffer())).getData();
	    	byte newI[] = new byte[intI.length * 4];
	    	for (int i = 0; i < intI.length; i++) {
	    		byte b[] = intToByteArray(intI[i]);
	    		int newIndex = i*4;
	    		
	    		newI[newIndex]   = b[1];
	    		newI[newIndex+1] = b[2];
	    		newI[newIndex+2] = b[3];
	    		newI[newIndex+3] = b[0];
	    	}
	    	
	    	byteBuffer  = ByteBuffer.allocateDirect(
	    			width*height*(bpp/8))
		                           .order(ByteOrder.nativeOrder())
		                            .put(newI);
	    } else {
	    	byteBuffer  = ByteBuffer.allocateDirect(
	    			width*height*(bpp/8))
		                           .order(ByteOrder.nativeOrder())
		                            .put(((DataBufferByte)(bufferedImage.getData().getDataBuffer())).getData());
	    }
	    byteBuffer.flip();
	    
	    
	    int internalFormat = GL11.GL_RGBA8,
		format = GL11.GL_RGBA;
		IntBuffer   textureId =  BufferUtils.createIntBuffer(1);;
		GL11.glGenTextures(textureId);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));
		

		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
		
		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);
		
		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
		
		
		
		GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D,
		      internalFormat,
		      width,
		      height,
		      format,
		      GL11.GL_UNSIGNED_BYTE,
		      byteBuffer);
		return textureId.get(0);
	    
	} catch (Exception e) {
    	e.printStackTrace();
    	System.exit(-1);
    }
	
	return -1;
}
 
開發者ID:IvyBits,項目名稱:Amber-IDE,代碼行數:68,代碼來源:TrueTypeFont.java


注:本文中的org.lwjgl.util.glu.GLU.gluBuild2DMipmaps方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。