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 & HelpPrograms › is Processing bug
Page Index Toggle Pages: 1
is Processing bug (Read 302 times)
is Processing bug
Apr 29th, 2008, 4:30pm
 
I found the problem does  happen not only on OPENGL, but also on P3d. I have modified the code to the following. if I set the org_opengl to false, it seems fine; however, if I set the org_opengl to ture, the texture is distorted.

Is the processing bug??

Plz help

=======================================================
import processing.opengl.*;  
import javax.media.opengl.*;  
import com.sun.opengl.util.texture.*;  
boolean org_opengl=true;

Texture tex;  
PImage ti;
void setup()  
{  
 size(480,320, OPENGL);  
 if(org_opengl)
 {
   ti = loadImage("test.png");
   textureMode(NORMALIZED);
 } else  
 {
   try { tex=TextureIO.newTexture(new File(dataPath("test.png")),true); }  
   catch(Exception e) { println(e); }  
 }
}  

void draw()  
{  
 background(0);  

 // the texture size is 300x300
 if(org_opengl)
 {
   beginShape();
   texture(ti);
   vertex(290, 160, 1, 0.5);  
   vertex(265, 205, 236.0/300.0, 1);  
   vertex(215, 205, 64.0/300.0, 1);
   vertex(190, 160, 0, 0.5);  
   vertex(215, 115, 64.0/300.0, 0);  
   vertex(265, 115, 236.0/300.0, 0);  
   endShape();
 } else
 {
   PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;  
   GL gl = pgl.beginGL();  

   tex.bind();  
   tex.enable();  

   gl.glBegin(GL.GL_POLYGON);  
   gl.glNormal3f( 0.0f, 0.0f, 1.0f);  
   gl.glTexCoord2f(1, 0.5);    gl.glVertex2f(290, 160);  
   gl.glTexCoord2f(236.0/300.0, 1); gl.glVertex2f(265, 205);  
   gl.glTexCoord2f(64.0/300.0, 1);  gl.glVertex2f(215, 205);  
   gl.glTexCoord2f(0, 0.5);    gl.glVertex2f(190, 160);  
   gl.glTexCoord2f(64.0/300.0, 0);  gl.glVertex2f(215, 115);  
   gl.glTexCoord2f(236.0/300.0, 0); gl.glVertex2f(265, 115);  
   gl.glEnd();    

   tex.disable();  

   pgl.endGL();  
 }
}
Page Index Toggle Pages: 1