当前位置: 首页>>代码示例>>Java>>正文


Java GL11.glBindTexture方法代码示例

本文整理汇总了Java中org.lwjgl.opengl.GL11.glBindTexture方法的典型用法代码示例。如果您正苦于以下问题:Java GL11.glBindTexture方法的具体用法?Java GL11.glBindTexture怎么用?Java GL11.glBindTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.opengl.GL11的用法示例。


在下文中一共展示了GL11.glBindTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
/**
 * Initialise the PBuffer that will be used to render to
 * 
 * @throws SlickException
 */
private void init() throws SlickException {
	try {
		Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());

		pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), null, null);
		// Initialise state of the pbuffer context.
		pbuffer.makeCurrent();

		initGL();
		image.draw(0,0);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
		GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, 
							  tex.getTextureWidth(), 
							  tex.getTextureHeight(), 0);
		image.setTexture(tex);
		
		Display.makeCurrent();
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:28,代码来源:PBufferUniqueGraphics.java

示例2: disable

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.Graphics#disable()
 */
protected void disable() {
	// Bind the texture after rendering.
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID());
	GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, 
						  image.getTexture().getTextureWidth(), 
						  image.getTexture().getTextureHeight(), 0);
	
	try {
		Display.makeCurrent();
	} catch (LWJGLException e) {
		Log.error(e);
	}
	
	SlickCallable.leaveSafeBlock();
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:19,代码来源:PBufferUniqueGraphics.java

示例3: prepareTexturedModel

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
private void prepareTexturedModel(TexturedModel model) {
	RawModel rawModel = model.getRawModel();
	GL30.glBindVertexArray(rawModel.getVaoID());
	GL20.glEnableVertexAttribArray(0);
	GL20.glEnableVertexAttribArray(1);
	GL20.glEnableVertexAttribArray(2);
	
	ModelTexture texture = model.getTexture();
	
	if(texture.isHasTransparency()) {
		MasterRenderer.disableCulling();
	}
	
	shader.loadFakeLightingVariable(texture.isUseFakeLighting());
	shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());
	
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID());
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:20,代码来源:EntityRenderer.java

示例4: drawBackground

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public void drawBackground(int i)
{
    GL11.glDisable(2896 /*GL_LIGHTING*/);
    GL11.glDisable(2912 /*GL_FOG*/);
    Tessellator tessellator = Tessellator.instance;
    GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, mc.renderEngine.getTexture("/gui/background.png"));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    float f = 32F;
    tessellator.startDrawingQuads();
    tessellator.setColorOpaque_I(0x404040);
    tessellator.addVertexWithUV(0.0D, height, 0.0D, 0.0D, (float)height / f + (float)i);
    tessellator.addVertexWithUV(width, height, 0.0D, (float)width / f, (float)height / f + (float)i);
    tessellator.addVertexWithUV(width, 0.0D, 0.0D, (float)width / f, 0 + i);
    tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0 + i);
    tessellator.draw();
}
 
开发者ID:jd-lang,项目名称:betaexpansion,代码行数:17,代码来源:GuiScreen.java

示例5: 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);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:27,代码来源:Texture.java

示例6: setSampler2d

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public void setSampler2d(String label, int value, int activeTexture){
    int loc = getUniform(label);
    GL20.glUniform1i(loc, 0);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + activeTexture);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, value);
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:8,代码来源:Shader.java

示例7: bindTexture

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public void bindTexture(int i)
{
    if(i < 0)
    {
        return;
    } else
    {
        GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, i);
        return;
    }
}
 
开发者ID:jd-lang,项目名称:betaexpansion,代码行数:12,代码来源:RenderEngine.java

示例8: bindTexture

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public static void bindTexture(int texture)
{
    if (texture != textureState[activeTextureUnit].textureName)
    {
        textureState[activeTextureUnit].textureName = texture;
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:9,代码来源:GlStateManager.java

示例9: bindTextures

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
private void bindTextures() {
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getReflectionTexture());
	GL13.glActiveTexture(GL13.GL_TEXTURE1);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionTexture());
	dudvTexture.bindToUnit(2);
	normalMap.bindToUnit(3);
	GL13.glActiveTexture(GL13.GL_TEXTURE4);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionDepthTexture());
}
 
开发者ID:TheThinMatrix,项目名称:OcclusionQueries,代码行数:11,代码来源:WaterRenderer.java

示例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;
		}
	}
 
开发者ID:ComunityEngine,项目名称:CommunityEngine-Java,代码行数:41,代码来源:TextureLoader.java

示例11: 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;
}
 
开发者ID:TheThinMatrix,项目名称:OcclusionQueries,代码行数:12,代码来源:WaterFrameBuffers.java

示例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;
}
 
开发者ID:TheThinMatrix,项目名称:OpenGL-Animation,代码行数:34,代码来源:TextureUtils.java

示例13: 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;
}
 
开发者ID:TheThinMatrix,项目名称:OcclusionQueries,代码行数:16,代码来源:TextureUtils.java

示例14: print

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
public void print(float x, float y, String text){
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
	
	FloatBuffer xbuf = BufferUtils.createFloatBuffer(1);
	FloatBuffer ybuf = BufferUtils.createFloatBuffer(1);
	
	xbuf.put(x);
	ybuf.put(Window.instance.getHeight() - y);
	
	xbuf.flip();
	ybuf.flip();
	
	STBTTAlignedQuad q = STBTTAlignedQuad.malloc();
	
	GL11.glBegin(GL11.GL_QUADS);
	
	for(char c : text.toCharArray()){
		if(c == '\n'){
			ybuf.put(0, ybuf.get(0) + fontHeight);
			xbuf.put(0, x);
			continue;
		}else if(c < 32 || c > 128){
			continue;
		}
		
		STBTruetype.stbtt_GetBakedQuad(cdata, 512, 512, (int)(c - 32), xbuf, ybuf, q, true);
		
		GL11.glTexCoord2f(q.s0(), q.t0());
		GL11.glVertex2f(q.x0(), q.y0());

		GL11.glTexCoord2f(q.s1(), q.t0());
		GL11.glVertex2f(q.x1(), q.y0());

		GL11.glTexCoord2f(q.s1(), q.t1());
		GL11.glVertex2f(q.x1(), q.y1());

		GL11.glTexCoord2f(q.s0(), q.t1());
		GL11.glVertex2f(q.x0(), q.y1());
	}
	
	GL11.glEnd();
}
 
开发者ID:tek256,项目名称:LD38,代码行数:44,代码来源:UIFont.java

示例15: drawForIcon

import org.lwjgl.opengl.GL11; //导入方法依赖的package包/类
private int drawForIcon(TextureAtlasSprite p_drawForIcon_1_, int p_drawForIcon_2_)
{
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, p_drawForIcon_1_.glSpriteTextureId);
    int i = -1;
    int j = -1;
    int k = this.vertexCount / 4;

    for (int l = p_drawForIcon_2_; l < k; ++l)
    {
        TextureAtlasSprite textureatlassprite = this.quadSprites[l];

        if (textureatlassprite == p_drawForIcon_1_)
        {
            if (j < 0)
            {
                j = l;
            }
        }
        else if (j >= 0)
        {
            this.draw(j, l);

            if (this.blockLayer == EnumWorldBlockLayer.TRANSLUCENT)
            {
                return l;
            }

            j = -1;

            if (i < 0)
            {
                i = l;
            }
        }
    }

    if (j >= 0)
    {
        this.draw(j, k);
    }

    if (i < 0)
    {
        i = k;
    }

    return i;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:49,代码来源:WorldRenderer.java


注:本文中的org.lwjgl.opengl.GL11.glBindTexture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。