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 › Rendering to a Texture + Flipped Image
Page Index Toggle Pages: 1
Rendering to a Texture + Flipped Image (Read 1475 times)
Rendering to a Texture + Flipped Image
Oct 6th, 2007, 4:42pm
 
Hey everyone
I was working on an implementation of Nehe's "Lesson 36 - Radial blur and rendering to a texture (using framebuffer objects if available)" ( http://pepijn.fab4.be/?page_id=34 ).  And I've got it working except for one aspect.


It's upside down.

I'm assuming this has something to do with the (0,0) registration point being in the bottom left (as opposed to the top right ?) or am I way off ?

Is there any way to fix this ? I've been at it for the last few hours and I've got no idea.  Thanks in advance, I'm going to get some sleep.
Re: Rendering to a Texture + Flipped Image
Reply #1 - Oct 7th, 2007, 7:37pm
 
why dont you just invert the uv texture coordinates ?
Re: Rendering to a Texture + Flipped Image
Reply #2 - Oct 17th, 2007, 6:27pm
 
FWIW, this is caused by an OpenGL bug that for whatever reason flips the y axis upside down when you try to read pixels back from the graphics card...I took a look through the source a while back and tried to track it down, but couldn't quite figure it out; it's definitely due to the inverted y direction in OpenGL (which is flipped back to normal by a transformation in order to match with the other renderers), but I'm not sure exactly what the fix is - something to do with the order of transformations or something like that, no doubt.  Unfortunately it's not as simple as adding in a special bit of code to fix it in this one case, because it also is messing with some other things like transformations in ortho mode.

Until this is all worked out, the thing to do is to just realize that you're getting the y or v-coordinate upside down, and flip it (a call like v = map(v,0,height,height,0) should do it) before you use it.  Unfortunately this will botch things up in P3D mode, and it might be fixed in the future, so I'd qualify every use of that with a check of a static final FLIP_V constant declared at the top that you can flip to false when this is finally fixed.
Re: Rendering to a Texture + Flipped Image
Reply #3 - Oct 17th, 2007, 11:25pm
 
opengl coordinates all start from the lower left corner, in processing they start from the upper left. so when you port opengl code to the processing api, you'll need to flip the coordinates accordingly (whether y coords or in particular, texture coords as you've found). this isn't a bug, it's just that you're using two different APIs that have different ideas about how coordinates work.
Re: Rendering to a Texture + Flipped Image
Reply #4 - Oct 18th, 2007, 2:07am
 
I fixed it the other night actually.  The displayed image, yeah, I flipped the coordinates so it was around the right way, the normal image, I'd for some reason called : gl.glLoadIdentity();

No idea why I did,
but as soon as I commented out the line, all was well again.
Re: Rendering to a Texture + Flipped Image
Reply #5 - Feb 18th, 2008, 3:53pm
 
Hi!

I've been working on converting this same example to work within Processing 0135, and have gotten to the point where it sometimes works fine, but usually crashes at startup for some reason that I am unable to find. My attempt to debug by catching any exceptions thrown hasn't gotten me very far...

If you have a working conversion of this example into a processing project, could you please share this so that I can see what I've been doing wrong?

Thank you!
Re: Rendering to a Texture + Flipped Image
Reply #6 - Jan 11th, 2009, 9:53pm
 
Hi everyone,

this is my first post.

I've been working on a game and I've decided to use image sequences in stead of movies (quicktime). I'm using P3D, as it is the ONLY render that will give me a descent framerate. OPENGL, is (for an unknown reason) slower.
Anyway, I've come across this problem also; images being flipped. Could anyone please explain what I should do?

My workaround is to "pre-flip" everything.
Page Index Toggle Pages: 1