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 › texture() not called
Page Index Toggle Pages: 1
texture() not called (Read 877 times)
texture() not called
Mar 28th, 2010, 4:07am
 
I've been working on a little program and I've run into a problem. Whenever I try to map a texture to a quad it gives me this illogical error:
damm, can't insert images, well
Code:
void TexturedQuad() {
 textureMode(NORMALIZED);
 beginShape();
 texture(img);
 vertex(X2[0],Y2[0],Z2[0],0,0);
 vertex(X2[2],Y2[2],Z2[2],1,0);
 vertex(X2[3],Y2[3],Z2[3],1,1);
 vertex(X2[1],Y2[1],Z2[1],0,1);
 endShape();


Which gives me this error:

'You must first call texture() before using u and v coordinates with vertex()'


I'm not sure what I'm doing wrong here. I called the texture(), right? This problem probably has a very simple solution that I've overlooked. But I'm stuck on this for more then an hour already and I just can't seem to work it out.

Any help would greatly be appreciated.

Paperclip/Tim
Re: texture() not called
Reply #1 - Mar 28th, 2010, 4:12am
 
there is nothing wrong with this code.
could you show more of it? a working/not working version...

Re: texture() not called
Reply #2 - Mar 28th, 2010, 4:19am
 
Code:


import processing.opengl.*;

import controlP5.*;

ControlP5 controlP5;

PImage img;

void setup(){
 size(w, h, P3D);
 frameRate(25);
 noStroke();
 PImage img = loadImage("kid.jpg");


 //fs = new FullScreen(this);

 //fs.enter();

 controlP5 = new ControlP5(this);
 controlP5.addNumberbox("Y3",0,40,60,40,20);
 controlP5.addNumberbox("Y4",0,100,60,40,20);
 controlP5.addNumberbox("Y",0,40,100,40,20);
 controlP5.addNumberbox("Y2",0,100,100,40,20);
 controlP5.addSlider("bgknop",0, 200, achtergrond, 20, h-40, 100, 20);
 controlP5.addNumberbox("X",0,40,130,40,20);
 controlP5.addToggle("toggle",true,30,h-160,20,20);
 controlP5.addNumberbox("X2",0,100,130,40,20);
 controlP5.addNumberbox("Z",0,40,160,40,20);
 controlP5.addNumberbox("Z2",0,100,160,40,20);

}

void draw(){
 background(achtergrond);
 controlP5.draw();
 if(toggle==true){
   fill(255);
   stroke(30);
   noSmooth();
   rect(w/2+30, 30, w/2-60, h/2-60);
   rect(w/2+30, h/2+30, w/2-60, h/2-60);
   drawGrid();
   drawCubeGrid();
 }
 else if(toggle==false){
   redraw();
   for(int i = 0; i < 4 ; i++){
     X2[i] = X[i]+(w/2);
     Y2[i] = Z[i]+(h/2);
     Z2[i] = Y[i]+(w/2);
   }
   TexturedQuad();
 }
}



void TexturedQuad() {
 textureMode(NORMALIZED);
 beginShape();
 texture(img);
 vertex(X2[0],Y2[0],Z2[0],0,0);
 vertex(X2[2],Y2[2],Z2[2],1,0);
 vertex(X2[3],Y2[3],Z2[3],1,1);
 vertex(X2[1],Y2[1],Z2[1],0,1);
 endShape();
}


It works fine when I leave out the u,v coordinates. If I need to post the full code you let me know. Maybe the controlP5 library is conflicting. I really appreciate the fast response. btw maybe you already noticed from the code but I'm not really 'a programmer'.
Re: texture() not called
Reply #3 - Mar 28th, 2010, 4:45am
 
you miss all the variables, hard to run your code.

ah, but i ve got an idea.
remove the PImage from

PImage img = loadImage("wb.jpg"); in setup
just write
img = loadImage("wb.jpg");
Re: texture() not called
Reply #4 - Mar 28th, 2010, 4:57am
 
Thanks, that did it.

* Paperclip does little happy dance

You have been really helpfull, thanks.
Page Index Toggle Pages: 1