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 › Please help my WaterCube....
Page Index Toggle Pages: 1
Please help my WaterCube.... (Read 855 times)
Please help my WaterCube....
May 3rd, 2008, 3:28am
 
I'm trying to do something way over my head.

I'm working on getting a water like texture on an opengl cube.

I pasted a few sketches together and got really lost.

I don't know how to get the water ripples into the opengl code.

I tried:

img.pixels[i+j*width]=img.pixels[int((i+Xoffset)+(j+Yoffset)*img.width)] ;

Obviously this is not the correct way to go about passing the array into opengl.

Here is the full code I'm working on:

http://www.tristanhansen.com/WaterCube.pde

texture if you need one: http://www.tristanhansen.com/foo.png

I always get an array index outofbounds error.

Please please help. I have a draft of this project due Monday. Final project with music due Thursday.

Re: Please help my WaterCube....
Reply #1 - May 5th, 2008, 5:33am
 
I figured out what the array error was. My image was too small and the buffer was too small.

At least it will compile now.


I had a dream about this cube so if anyone has a moment it really would be a dream come true. I just have no idea how to pass the vector information into the texture.

http://www.tristanhansen.com/WaterCube.pde

texture at the right size: http://www.tristanhansen.com/foo.png

Re: Please help my WaterCube....
Reply #2 - May 7th, 2008, 8:12am
 
My sever was down for a while. It's now back, up if anyone has a minute. At the moment I've almost lost hope of achieving this.

I don't understand why I can't just change the image before it goes into the buffer.

I think the pixels can be altered with glReadPixels() but I really have no idea how to write the buffer that I need.

glTexSubImage2d (write pixels to a texture)
glGetTexImage (get pixels from a texture)
glGetTexLevelParameterfv (used to get pixel dimensions for figuring out what size of an array needed for use with glGetTexImage)  

These calls might also help. I'm not sure. I feel so alone. Sad

Please help!
Re: Please help my WaterCube....
Reply #3 - May 8th, 2008, 7:47am
 
use this instead it will make your life easier:

import com.sun.opengl.util.texture.*;

Texture foo;

void setup(){

try{
   foo=TextureIO.newTexture(new                       File(dataPath("foo.png")),true);
   }
catch(Exception e) {
   println(e);
   }
}

void draw {
foo.bind();
foo.enable();
 // draw stuff that uses texture
}

here's a link to official documentation:
http://jsourcery.com/api/java.net/jogl/1.1.0/com/sun/opengl/util/texture/package-summary.html

and another one that discusses texturing in opengl in processing:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1199399046


Re: Please help my WaterCube....
Reply #4 - May 8th, 2008, 8:23am
 
That gets me so close. Thanks! Now how do I read the pixel array into the new way the texture is stored?

I'm going to try to figure this out myself but I'm running out of time.
Re: Please help my WaterCube....
Reply #5 - May 8th, 2008, 9:17am
 
I think what I need is:


updateImage(TextureData data)

Not sure how to use it though.
Page Index Toggle Pages: 1