List of usage examples for org.lwjgl.opengl GL11 glBindTexture
public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture)
From source file:org.joge.core.draw.texture.Texture.java
License:Open Source License
public void bind() { GL11.glBindTexture(target, textureID); }
From source file:org.jtrfp.mtmx.internal.Texture.java
License:Open Source License
@Override public void bind() { GL11.glBindTexture(glTextureType, textureId); }
From source file:org.jtrfp.mtmx.internal.Texture.java
License:Open Source License
@Override public void unbind() { GL11.glBindTexture(glTextureType, 0); }
From source file:org.jtrfp.mtmx.internal.TextureLoader.java
License:Open Source License
@Override public ITexture load(RawImage rawImage) throws EngineException { BufferedImage bufferedImage = null; try {/*from ww w . ja va2 s . c o m*/ bufferedImage = rawImage.toImage(); } catch (FileStoreException e) { throw new EngineException("Could not convert texture image.", e); } final int type = GL11.GL_TEXTURE_2D; final int width = bufferedImage.getWidth(); final int height = bufferedImage.getHeight(); int textureId = createTextureId(); Texture texture = new Texture(type, textureId, width, height); GL11.glBindTexture(type, textureId); // really neccessary here? ByteBuffer buffer = makeByteBuffer(bufferedImage, width, height); GL11.glTexParameteri(type, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(type, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glTexImage2D(type, 0, GL11.GL_RGB, width, height, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buffer); System.out.println("Created texture " + textureId); return texture; }
From source file:org.llama.jmf.JMFVideoImage.java
License:Open Source License
/** * Update.//from www . j av a2 s . com * * @param texture * Texture to update * @param syncToFrameRate * Wait till the frame is updated before updating the texture. * @return true if the texture was updated */ public boolean update(Texture texture, boolean syncToFrameRate) { if (!active) { return false; } if (syncToFrameRate) { synchronized (this) { while (lastupdated >= framecounter) { try { this.wait(); } catch (InterruptedException e) { } } } } if (lastupdated >= framecounter) { return false; } if ((lastupdated + 1) < framecounter) { log.info("missed frames: " + ((framecounter - lastupdated) + 1)); } if (data == null) { return false; } if (inittexture && (this.scalemethod > 0)) { inittexture = false; // clear current textures. TextureState state = DisplaySystem.getDisplaySystem().getRenderer().createTextureState(); state.setEnabled(true); state.apply(); log.info("rescaling texture"); if (scalemethod == SCALE_FIT) { float scale; if (this.videowidth > this.videoheight) { scale = videowidth * (1f / this.width); } else { scale = videoheight * (1f / this.height); } texture.setScale(new Vector3f(scale, scale, scale)); } if (scalemethod == SCALE_MAXIMIZE) { // texture.setScale(new Vector3f(1f,videowidth* (1f / // this.width), videoheight * (1f / this.height))); texture.setScale( new Vector3f(videowidth * (1f / this.width), videoheight * (1f / this.height), 1f)); } } synchronized (this) { // long d = System.currentTimeMillis(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureId()); // TODO: use this.dataformat GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, videowidth, videoheight, pixelformat, dataformat, buffer); try { Util.checkGLError(); } catch (OpenGLException e) { log.info("Error rendering video to texture. No glTexSubImage2D/OpenGL 1.2 support?"); } lastupdated = framecounter; this.notifyAll(); } return false; }
From source file:org.oscim.gdx.LwjglGL20.java
License:Apache License
public void bindTexture(int target, int texture) { GL11.glBindTexture(target, texture); }
From source file:org.spout.engine.filesystem.resource.ClientRenderTexture.java
License:Open Source License
@Override public void writeGPU() { if (framebuffer != INVALID_BUFFER) { throw new IllegalStateException("Framebuffer already created!"); }/*from w w w . j a v a 2s . c o m*/ int buffers = 1; //Create the color buffer for this renderTexture textureID = GL11.glGenTextures(); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_INT, (ByteBuffer) null); // Create the texture data SpoutRenderer.checkGLError(); if (useNormalBuffer) { //Create the color buffer for this renderTexture normalTarget = GL11.glGenTextures(); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalTarget); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); // Create the texture data SpoutRenderer.checkGLError(); buffers++; } if (useDepthBuffer) { //Create the color buffer for this renderTexture depthTarget = GL11.glGenTextures(); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTarget); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null); // Create the texture data SpoutRenderer.checkGLError(); buffers++; } if (useEXT) { framebuffer = EXTFramebufferObject.glGenFramebuffersEXT(); SpoutRenderer.checkGLError(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); SpoutRenderer.checkGLError(); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, textureID, 0); SpoutRenderer.checkGLError(); if (useDepthBuffer) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTarget); SpoutRenderer.checkGLError(); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, depthTarget, 0); SpoutRenderer.checkGLError(); } if (useNormalBuffer) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalTarget); SpoutRenderer.checkGLError(); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT, GL11.GL_TEXTURE_2D, normalTarget, 0); SpoutRenderer.checkGLError(); } if (EXTFramebufferObject.glCheckFramebufferStatusEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT) != EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT) { System.out.println("ERROR: Framebuffer not complete"); throw new ComputerIsPotatoException("Framebuffer not complete"); } SpoutRenderer.checkGLError(); } else { framebuffer = GL30.glGenFramebuffers(); SpoutRenderer.checkGLError(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); SpoutRenderer.checkGLError(); IntBuffer drawBuffers = BufferUtils.createIntBuffer(buffers); drawBuffers.put(GL30.GL_COLOR_ATTACHMENT0); if (useNormalBuffer) { drawBuffers.put(GL30.GL_COLOR_ATTACHMENT1); } drawBuffers.flip(); GL20.glDrawBuffers(drawBuffers); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); SpoutRenderer.checkGLError(); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, textureID, 0); SpoutRenderer.checkGLError(); if (useDepthBuffer) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTarget); SpoutRenderer.checkGLError(); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, depthTarget, 0); SpoutRenderer.checkGLError(); } if (useNormalBuffer) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalTarget); SpoutRenderer.checkGLError(); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT1, GL11.GL_TEXTURE_2D, normalTarget, 0); SpoutRenderer.checkGLError(); } int status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); if (status != GL30.GL_FRAMEBUFFER_COMPLETE) { System.out.println("ERROR: Framebuffer not complete. Status: " + status); throw new ComputerIsPotatoException("Framebuffer not complete"); } SpoutRenderer.checkGLError(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, SCREEN_BUFFER); SpoutRenderer.checkGLError(); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); SpoutRenderer.checkGLError(); }
From source file:org.spout.engine.filesystem.resource.ClientTexture.java
License:Open Source License
@Override public void bind() { if (!isLoaded()) { throw new IllegalStateException("Cannot bind an unloaded texture!"); }/* w ww .jav a2 s .co m*/ GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); SpoutRenderer.checkGLError(); }
From source file:org.spout.engine.renderer.shader.variables.TextureSamplerShaderVariable.java
License:Open Source License
public void bind(int unit) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + unit); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); if (((Client) Spout.getEngine()).getRenderMode() != RenderMode.GL30) { GL20.glUniform1i(location, textureID); } else {// ww w . java 2 s . c o m GL30.glUniform1ui(location, textureID); } }
From source file:org.spout.engine.resources.ClientRenderTexture.java
License:Open Source License
@Override public void writeGPU() { if (framebuffer != INVALID_BUFFER) throw new IllegalStateException("Framebuffer already created!"); //Create the color buffer for this renderTexture textureID = GL11.glGenTextures();/*w w w. ja v a 2 s. c o m*/ GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); 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.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_INT, (java.nio.ByteBuffer) null); // Create the texture data if (useEXT) { framebuffer = EXTFramebufferObject.glGenFramebuffersEXT(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, textureID, 0); if (useDepthBuffer) { depthTarget = GL30.glGenRenderbuffers(); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthTarget); EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL11.GL_DEPTH_COMPONENT, this.getWidth(), this.getHeight()); EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, GL30.GL_DEPTH_ATTACHMENT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthTarget); } if (EXTFramebufferObject.glCheckFramebufferStatusEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT) != EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT) { System.out.println("ERROR: Framebuffer not complete"); throw new ComputerIsPotatoException("Framebuffer not complete"); } } else { framebuffer = GL30.glGenFramebuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, textureID, 0); if (useDepthBuffer) { depthTarget = GL30.glGenRenderbuffers(); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthTarget); GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, this.getWidth(), this.getHeight()); GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthTarget); } GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, SCREEN_BUFFER); if (GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE) { System.out.println("ERROR: Framebuffer not complete"); throw new ComputerIsPotatoException("Framebuffer not complete"); } } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); }