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 › Processing OPENGL image background
Page Index Toggle Pages: 1
Processing OPENGL image background (Read 2355 times)
Processing OPENGL image background
Apr 22nd, 2009, 11:33am
 
Hello
Please help with this:

import processing.opengl.*;
PImage img;

void setup() {
 size(800, 800, OPENGL);
 smooth();
 frameRate(30);
 img = loadImage("bg.png");
}

void draw() {
 background(img);
 
 pushMatrix();
   translate(width/2, height/2, 0);
   rotateX(0);
   rotateY(10);
   strokeWeight(1);
   stroke(255,100);
   fill(255,10);
   box(200);
 popMatrix();

}

I set an image as background.
When i use OPENGL renderer, object (box) isn't displayed.
When i use change renderer to P3D, it's OK;

In OPENGL oject is shown only when i set background color -> background(50);

HOW TO DISPLAY OBJECTS in OPENGL when i'm using image background ?
Re: Processing OPENGL image background
Reply #1 - Apr 22nd, 2009, 11:38am
 
try removing background(img); from draw and substituting it with image(img, 0, 0, width, height);
Re: Processing OPENGL image background
Reply #2 - Apr 22nd, 2009, 12:04pm
 
It works BUT image(img,0,0,width,height); is now like a wall.
The half of an object disappeared.

Sad

I'm looki for option sets the image  as independent background which don't influent objects only refresh display when used  loop();
Re: Processing OPENGL image background
Reply #3 - Apr 22nd, 2009, 1:36pm
 
i don't think i understand exactly what you mean by 'is not like a wall'. what is the size of your image and what is happening that you don't want to happen? the half of the object which disappeared is from the background image? or was the box cut in half?

i suppose that if the image has no z axis it is drawn on z = 0 [and this way it would cut your box on half, while the z coordinate to which you translate to create it is 0]; so you could try translating the box width/2, height/2, 100 [or more on the z axis] to see if it works. if you want the box to appear to have the same size as before you can decrease its size.

this way you don't have an independent background, but you can still develop your code taking into account that no object should be drawn within a specific distance from the background.
Re: Processing OPENGL image background
Reply #4 - Apr 22nd, 2009, 1:48pm
 
I left image on the same position but change 'Z' coordinate in object translation:

translate(width/2, height/2, 400);

Now object 'doesn't touch' image wall Smiley

Ok it works but i'm wondering why background(img) works with P3D nor with OPENGL (objects not displayed)

Thank You for help.
Re: Processing OPENGL image background
Reply #5 - Apr 22nd, 2009, 1:57pm
 
you're welcome.

i actually couldn't figure it out, i mean, why background doesn't work with opengl... at some point i just decided to give up, move on and work with the options i had...
Page Index Toggle Pages: 1