We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Texture in 'pure' openGL
Pages: 1 2 
Texture in 'pure' openGL (Read 7307 times)
Re: Texture in 'pure' openGL
Reply #15 - May 3rd, 2008, 2:17am
 
Strangely enough I was able to alter the code to make it transparent.

It's not perfect because I think only the outside is transparent but it's still a cool effect. If anyone knows how to fix it that would be great.

http://www.tristanhansen.com/texture_test3.pde
Re: Texture in 'pure' openGL
Reply #16 - May 3rd, 2008, 11:12am
 
if the ByteBuffer includes an alpha channel you must specify this the glTexImage2D call.

just change GL.GL_RGB to GL.GL_RGBA

gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, img.width, img.height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getTextureByteBuffer( true ) );
Re: Texture in 'pure' openGL
Reply #17 - May 3rd, 2008, 10:47pm
 
julapy wrote on May 3rd, 2008, 11:12am:
if the ByteBuffer includes an alpha channel you must specify this the glTexImage2D call.

just change GL.GL_RGB to GL.GL_RGBA

gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, img.width, img.height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getTextureByteBuffer( true ) );


Oh I get it. That lets me use the transparency of the png.

Thanks,

I'm guessing there is no way to control the amount of transparency.
Re: Texture in 'pure' openGL
Reply #18 - May 4th, 2008, 12:30pm
 
Any ideas on how I can pass an array to the pixels on the texture?
Re: Texture in 'pure' openGL
Reply #19 - Nov 23rd, 2008, 6:06pm
 
Just a note for other OpenGL newbies like myself. I was using Julapy's excellent code (http://www.julapy.com/processing/TextureTest.pde) but getting a weird effect where my my texture was being applied with a diagonal break.

I discovered that OpenGL textures need to be sized in powers of two (2,4,8,16...) so I resized the texture JPG to 256x256 and it works great. That came from a useful tutorial on OpenGL textures at http://www.gamedev.net/reference/articles/article947.asp
Pages: 1 2