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 GL_QUADS: texture does not fit.
Page Index Toggle Pages: 1
Texture GL_QUADS: texture does not fit. (Read 1000 times)
Texture GL_QUADS: texture does not fit.
Apr 13th, 2008, 11:37am
 
I am currently simply trying to translate some of my processing programs to native openGL and have a simple problem which I still could not fix: When I try to draw a simple quad with a texture, the texture always does not texture the whole quad. Its propably a simple thing I just don't see right now. Here is the code. I first draw a filled quad and afterwards a textured one to see if they match. Apparently they dont:

import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import com.sun.opengl.util.*;
import processing.opengl.*;
import java.nio.*;

PGraphicsOpenGL pgl;  // g may change
GL gl;  // always use the GL object returned by beginGL
GLU glu;

PImage test;
void setup() {
 size(640, 480, OPENGL);
 hint(ENABLE_OPENGL_4X_SMOOTH);
 colorMode(RGB, 1.0, 1.0, 1.0);
 pgl = (PGraphicsOpenGL) g;
 gl = pgl.beginGL();
 glu = ( (PGraphicsOpenGL) g ).glu;
 test = loadImage("test.jpg");
}

void draw(){
 background(0);
 pgl.beginGL();
 gl.glDisable(GL.GL_DEPTH_TEST);
 gl.glDepthMask(false);
 gl.glTranslatef(width/2, height/2, 0);
 gl.glBegin(GL.GL_QUADS);
 gl.glColor4f(1.0, 0.5, 1.0, 1.0);
 gl.glVertex2f (0.0, 0.0);
 gl.glVertex2f (frameCount, 0.0);
 gl.glVertex2f (frameCount, frameCount);
 gl.glVertex2f (0.0, frameCount);
 gl.glEnd();
 gl.glEnable(GL.GL_TEXTURE_2D);
 pgl.bindTexture(test);
 gl.glBegin(GL.GL_QUADS);
 gl.glTexCoord2f(0.0,0.0);
 gl.glVertex2f (0.0, 0.0);
 gl.glTexCoord2f(1.0,0.0);
 gl.glVertex2f (frameCount, 0.0);
 gl.glTexCoord2f(1.0,1.0);
 gl.glVertex2f (frameCount, frameCount);
 gl.glTexCoord2f(0.0,1.0);
 gl.glVertex2f (0.0, frameCount);
 gl.glEnd();
 gl.glDisable(GL.GL_TEXTURE_2D);
 gl.glEnable(GL.GL_DEPTH_TEST);
 pgl.endGL();
}
Re: Texture GL_QUADS: texture does not fit.
Reply #1 - Apr 13th, 2008, 4:16pm
 
okay, i think its the way I bind the texture. If i load the texture using the way described here:
http://www.processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1199399046
everything works fine.
Page Index Toggle Pages: 1