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 Textures in Realtime
Page Index Toggle Pages: 1
Rendering Textures in Realtime? (Read 1195 times)
Rendering Textures in Realtime?
Sep 13th, 2005, 11:15pm
 
I'm a total newbie to OpenGL programming, but I'm diving in because I'd like to learn to utilize it for the project I'm working on. My question is thus:

Does Processing provide anything like the ability to render a 2d scene to a buffer, then copy it immediately to a texture I can then display on a 3d-rendered polygon.  Eg, interactive billboard textures.  

Edited:
Thinking about it, if I could instantiate another PApplet window, but get it to not draw the contents of the canvas to the screen, but instead to an img I could call as a texture for the 3d object in the "real" canvas, that would be awesome, but I'm not sure how to go about doing this..


I know the FAQ says support will not be available for more complex opengl topics, but I'm wondering if anyone here has tinkered with this, or if I should just search for another option.

Cheers,
Ryan Spicer
Re: Rendering Textures in Realtime?
Reply #1 - Sep 14th, 2005, 2:45am
 
I don't know if PGraphics is fixed yet. In the Beta version of Processing that was how you drew to a virtual applet and then you could paste it about like a PImage. I'll leave that one for someone else to answer. As for textures we have some useful objects in Processing called Quads. You make them with the beginShape() command and they don't even require opengl as such, it just goes like the proverbial off the shovel if you do use opengl.
Code:

PImage picture;
void setup(){
size(400,400,P3D);
picture = loadImage("pic.gif");//a 100x100 .gif
}
void draw(){
background(150);
translate(200,200);
rotateX((PI/400)*mouseY);
rotateY((PI/400)*mouseX);
beginShape(QUADS);
texture(picture);
vertex(-100,-100,0, 0,0); //top left
vertex(100,-100,0, 100,0); //top right
vertex(100,100,0, 100,100); //bottom right
vertex(-100,100,0, 0,100); //bottom left
endShape();
}
Re: Rendering Textures in Realtime?
Reply #2 - Sep 14th, 2005, 4:27am
 
Thanks for the tip re: pgraphics, St33d. I'll look into it. Smiley

Edited:
this works great, man.. thanks again. Smiley  Next question: is it possible to get alpha transparency in a PGraphics' background?
Re: Rendering Textures in Realtime?
Reply #3 - Sep 16th, 2005, 3:43pm
 
You can use a function called tint().

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1126108058;start=1#1

I imagine it would work but I haven't tried using PGraphics yet. I think they're called PGraphics2 and PGraphics3 now (in respect to the drawing modes). You create them as new objects (virtual = new PGraphics(width,height,null);) and then draw to them as methods of that object (virtual.background(0);).

Found some references to virtual applet space

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1126623602;start=0#0

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1124291770;start=7#7

I suggest you experiment with loadPixels() and updatePixels() in your code too as they seem to fix some shennanigans with images in memory.

I would be a little meek about your aims though and do a search on any bugs you find.
Page Index Toggle Pages: 1