Java Code Examples for com.jogamp.opengl.GL2#glTexParameteri()
The following examples show how to use
com.jogamp.opengl.GL2#glTexParameteri() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenGLVideoRenderer.java From sagetv with Apache License 2.0 | 4 votes |
private void createVideo() { //System.out.println("createvideo"); if(owner.isInFrame() || (owner.getPbuffer().getContext().makeCurrent()==GLContext.CONTEXT_NOT_CURRENT)) { if(!owner.isInFrame()) { System.out.println("Couldn't make pbuffer current?"); return; } else { System.out.println("Create video while already in frame"); } } GL2 gl = owner.getPbuffer().getGL().getGL2(); System.out.println("createvideo width: "+videowidth+" height: "+videoheight); if(videot!=null) gl.glDeleteTextures(3, videot, 0); // try { // closeVideo0(); // } catch(Throwable t) {} if(pureNativeMode) { videot = null; videoMode = 0; // release resources and force reallocation when we leave native mode try { createVideo0(videowidth, videoheight); } catch(Throwable t) {} } else { byte img[] = new byte[videowidth*videoheight*2]; videot = new int[3]; gl.glGenTextures(3, videot, 0); gl.glEnable(gl.GL_TEXTURE_RECTANGLE); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, videot[0]); if(MiniClient.MAC_OS_X) { gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, 0x85BC/*GL_TEXTURE_STORAGE_HINT_APPLE*/, 0x85Be/*GL_STORAGE_CACHED_APPLE*/); gl.glPixelStorei(0x85B2/*GL_UNPACK_CLIENT_STORAGE_APPLE*/, gl.GL_TRUE); } gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); gl.glTexImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 1, videowidth, videoheight, 0, gl.GL_LUMINANCE, gl.GL_UNSIGNED_BYTE, java.nio.ByteBuffer.wrap(img)); gl.glDisable(gl.GL_TEXTURE_RECTANGLE); gl.glEnable(gl.GL_TEXTURE_RECTANGLE); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, videot[1]); if(MiniClient.MAC_OS_X) { gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, 0x85BC/*GL_TEXTURE_STORAGE_HINT_APPLE*/, 0x85Be/*GL_STORAGE_CACHED_APPLE*/); gl.glPixelStorei(0x85B2/*GL_UNPACK_CLIENT_STORAGE_APPLE*/, gl.GL_TRUE); } gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); gl.glTexImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 1, videowidth/2, videoheight/2, 0, gl.GL_LUMINANCE, gl.GL_UNSIGNED_BYTE, java.nio.ByteBuffer.wrap(img)); gl.glDisable(gl.GL_TEXTURE_RECTANGLE); gl.glEnable(gl.GL_TEXTURE_RECTANGLE); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, videot[2]); if(MiniClient.MAC_OS_X) { gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, 0x85BC/*GL_TEXTURE_STORAGE_HINT_APPLE*/, 0x85Be/*GL_STORAGE_CACHED_APPLE*/); gl.glPixelStorei(0x85B2/*GL_UNPACK_CLIENT_STORAGE_APPLE*/, gl.GL_TRUE); } gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); gl.glTexImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 1, videowidth/2, videoheight/2, 0, gl.GL_LUMINANCE, gl.GL_UNSIGNED_BYTE, java.nio.ByteBuffer.wrap(img)); gl.glDisable(gl.GL_TEXTURE_RECTANGLE); } if(!owner.isInFrame()) owner.getPbuffer().getContext().release(); }
Example 2
Source File: OpenGLGFXCMD.java From sagetv with Apache License 2.0 | 4 votes |
private void initpbuffer() { GL2 gl; System.out.println("initpbuffer"); osdwidth=newosdwidth; osdheight=newosdheight; GLCapabilities caps = new GLCapabilities(null); caps.setHardwareAccelerated(true); caps.setDoubleBuffered(false); caps.setAlphaBits(8); caps.setRedBits(8); caps.setGreenBits(8); caps.setBlueBits(8); caps.setDepthBits(0); caps.setFBO(false); System.out.println("initpbuffer2"); if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer(null, caps.getGLProfile())) { throw new GLException("pbuffers unsupported"); } if(pbuffer!=null) pbuffer.destroy(); System.out.println("initpbuffer3"); pbuffer = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable(null, caps, null, osdwidth, osdheight ); pbuffer.setContext(pbuffer.createContext(c.getContext()), true); //pbuffer.setContext(c.getContext(), false); System.out.println("initpbuffer4: pbuffers is null? " + (pbuffer==null)); if(pbuffer.getContext().makeCurrent()==GLContext.CONTEXT_NOT_CURRENT) { System.out.println("Couldn't make pbuffer current?"); return; } System.out.println("initpbuffer5"); gl = pbuffer.getGL().getGL2(); gl.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f); gl.glClear( gl.GL_COLOR_BUFFER_BIT); gl.glViewport(0, 0, osdwidth, osdheight); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0,osdwidth,0,osdheight,-1.0,1.0); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glLoadIdentity(); // TODO: look into reusing same texture like OSX version... if(osdt!=null) gl.glDeleteTextures(1, osdt, 0); osdt = new int[1]; byte img[] = new byte[osdwidth*osdheight*4]; gl.glGenTextures(1, osdt, 0); gl.glEnable(gl.GL_TEXTURE_RECTANGLE); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE,osdt[0]); gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); gl.glTexParameteri(gl.GL_TEXTURE_RECTANGLE, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); gl.glTexImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 4, osdwidth, osdheight, 0, gl.GL_BGRA, bigendian ? gl.GL_UNSIGNED_INT_8_8_8_8_REV : gl.GL_UNSIGNED_BYTE, java.nio.ByteBuffer.wrap(img)); gl.glEnable(gl.GL_TEXTURE_RECTANGLE); gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE, osdt[0]); gl.glCopyTexSubImage2D(gl.GL_TEXTURE_RECTANGLE, 0, 0, 0, 0, 0, osdwidth, osdheight); gl.glDisable(gl.GL_TEXTURE_RECTANGLE); System.out.println("initpbuffer6"); pbuffer.getContext().release(); System.out.println("initpbuffer7"); }