Hi,
I'm trying to do some pretty simple textured quads in OpenGL using the GLTexture class from GLGraphics, but I'm noticing that when the quad is scaled bigger than the texture, it appears to be using NEAREST for the mag filter and my texture looks all yucky!
I tried using an alternate constructor, first creating a GLTextureParameters object and manually setting the magfilter to LINEAR and passing that to a new GLTexture constructor and then loading the texture after the GLTexture had been created, but I got the same results.
When I print out getTextureMagFilter(), it returns 9728 while GLConstants.LINEAR is 1. Hmmm...
Anyway, as far as I know, the mag filter used when rendering texture mapped polys is based on how the texture was created and not on a GL render state... maybe I'm mistaken on that. Regardless, I'd like to get some nice texture filtering happening with my GLTextures. Any advice? here is a simplified example:
Code:
import processing.opengl.*;
import javax.media.opengl.*;
import codeanticode.glgraphics.*;
GLTexture halo;
PGraphicsOpenGL pgl;
GL gl;
int quadDisplayList;
void setup()
{
size(800,600,OPENGL);
hint(ENABLE_OPENGL_4X_SMOOTH);
smooth();
pgl = (PGraphicsOpenGL)g;
gl = pgl.gl;
halo = new GLTexture(this, "halo.png");
initGL();
}
void draw()
{
float quadScale = (sin(millis() * .001f) + 1) * .5f;
quadScale *= height;
background(0);
pgl.beginGL();
gl.glPushMatrix();
gl.glTranslatef(width/2f, height/2f, 0);
gl.glScalef(quadScale, quadScale, quadScale);
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glCallList(quadDisplayList);
gl.glPopMatrix();
pgl.endGL();
}
private void initGL()
{
pgl.beginGL();
quadDisplayList = gl.glGenLists(1);
gl.glNewList(quadDisplayList, GL.GL_COMPILE);
gl.glBegin(GL.GL_POLYGON);
gl.glTexCoord2f(0, 0);
gl.glVertex2f(-.5f, -.5f);
gl.glTexCoord2f(1, 0);
gl.glVertex2f( .5f, -.5f);
gl.glTexCoord2f(1, 1);
gl.glVertex2f( .5f, .5f);
gl.glTexCoord2f(0, 1);
gl.glVertex2f(-.5f, .5f);
gl.glEnd();
gl.glEndList();
gl.glActiveTexture(GL.GL_TEXTURE0);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D, halo.getTextureID());
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
pgl.endGL();
}
Alternately, here is a zipped project including the little texture file: http://bit.ly/3guVMN
This is with Processing 0148 and GLGraphics 0.8.2
Thanks.
-Aaron