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 & HelpSyntax Questions › image works in P3D but not OpenGL
Page Index Toggle Pages: 1
image works in P3D but not OpenGL (Read 510 times)
image works in P3D but not OpenGL
Mar 10th, 2008, 8:17pm
 
Hi,

probably this is a know issue, so can please somebody confirm it.

I draw an image via:

pImage = loadImage(image.getPath());
noStroke();
image(pImage, min, min, max, max);

Usually I use P3D and everything is fine. When using OPENGL the image is not drawn. Does the image overlay not work with OpenGL or is it my fault?

Cheers,
sb
Re: image works in P3D but not OpenGL
Reply #1 - Mar 12th, 2008, 8:08am
 
images work fine in opengl. you're probably drawing at bad coordinates, which is OpenGL is more sensitive to than P3D (OpenGL has proper clipping). see help -> getting started for a description of the coordinate system.
Re: image works in P3D but not OpenGL
Reply #2 - Mar 12th, 2008, 5:49pm
 
Hmm...I tried to fix the problem and after a couple of hours of trial and error I can at least fix it, although I don't understand the details.

Here is what I do:

textMode(SCREEN);

background(...);

image(...);

popMatrix
a lot of transformations
some heavy load drawing (many cubes, lines etc.)
pushmatrix


Solution:
It seems the textMode(SCREEN) invokation does prevent the picture from being drawn.

I believe the problem is either:

A) the background() command deletes the drawn image in this case, although it is issued before the image() invocation. Now if I use textMode(SCREEN) and comment out background the image seems to be drawn.

B) the textMode(SCREEN) method affects somehow the coordinate system, so the image will be drawn but won't be visible since it is drawn in some non-visible place in the coordinate system.

The solution is to not use textMode(SCREEN). This is very anoying since I only switched it on once where I worked with text, which I don't do anymore. This is the most problematic part of the else great processing, that seemingly unconnectable parts effect each other. This is very hard to debug Smiley
Re: image works in P3D but not OpenGL
Reply #3 - Mar 12th, 2008, 8:03pm
 
please post a bug report (to dev.processing.org/bugs) with the problem (and attach an archived sketch that i can use to test) and i'll be happy to get it fixed.
Re: image works in P3D but not OpenGL
Reply #4 - Mar 12th, 2008, 8:32pm
 
should you use pushMatrix() and then popMatrix() and not the other way around ? unless you made a mistake when posting. otherwise it works just fine

example using image() before any push/pop. works fine


-----------------------------------------
import processing.opengl.*;

PImage img;

float min = 0;
float max = 500;

void setup()
{
 size( 500, 500, OPENGL );
 
 img = loadImage( "test.png" );
 
 noStroke();
}

void draw()
{
 float time = millis() * 0.001;
 
 image( img, min, min, max, max );
 
 for( int i=0; i<300; i++ )
 {
   fill( i, i, 0, 128 );
   pushMatrix();
   translate( i*2, i*2, 0 );
   rotateZ( 20*sin(i*3 + time * 0.5) );
   rect( 0, 0, 20, 20 );
   popMatrix();
 }  
}
Re: image works in P3D but not OpenGL
Reply #5 - Mar 12th, 2008, 11:56pm
 
No, it was just a mistake in the post. I didn't paste program code but typed it in.

I will try to make a small showcase which hopefully will reproduce the problem. So far it is inside a bigger application which may be also the reason for problems although I doubt it.

If I can reproduce it I send the bugreport.

Thanks,
sb
Re: image works in P3D but not OpenGL
Reply #6 - Mar 13th, 2008, 1:17am
 
my guess is you messed with the viewmatrix and image is drawing somewhere else. follow your code and see what you're doing.
Page Index Toggle Pages: 1