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 › Texture map in OPENGL
Page Index Toggle Pages: 1
Texture map in OPENGL (Read 847 times)
Texture map in OPENGL
Mar 19th, 2006, 12:17pm
 
It works in P3D but doesnt in OPENGL, why and what to do?

import processing.opengl.*;
PImage im;
int L=100;

void setup(){
size(500,500,P3D);
im=loadImage("fish.jpg");
stroke(255);
}

void draw(){
background(0);
translate(356,256,0);
beginShape();
texture(im);
vertex(0,0,1);
vertex(-L,0,1);
vertex(-L,L,1);
vertex(0,L,1);
endShape();
}
Re: Texture map in OPENGL
Reply #1 - Apr 14th, 2006, 4:28pm
 
Yea. I noticed this issue when I tried to run .obj loader on recent versions of Processing. I am not sure why yet.
Please let me know if anybody knows why.



Xeon_SX wrote on Mar 19th, 2006, 12:17pm:
It works in P3D but doesnt in OPENGL, why and what to do

import processing.opengl.*;
PImage im;
int L=100;

void setup(){
size(500,500,P3D);
im=loadImage("fish.jpg");
stroke(255);
}

void draw(){
background(0);
translate(356,256,0);
beginShape();
texture(im);
vertex(0,0,1);
vertex(-L,0,1);
vertex(-L,L,1);
vertex(0,L,1);
endShape();
}

Re: Texture map in OPENGL
Reply #2 - Apr 14th, 2006, 4:40pm
 
You need to tell OpenGL what part of the texture maps to each vertex, and that you want it to use QUADS.

So you want:
Code:
 beginShape(QUADS);
texture(im);
vertex(0,0,1,0,0);
vertex(-L,0,1,im.width,0);
vertex(-L,L,1,im.width,im.height);
vertex(0,L,1,0,im.height);
endShape();


You may need to change the last 2 numbers around a bit as the image may be inverted or flipped.
Page Index Toggle Pages: 1