PDA

View Full Version : help plea: unwanted texture artifacts



baggins
02-24-2003, 01:25 AM
hi, i've been having some irritating problems recently with my own implementation of a font using a single texture with a display list for each character which draws a quad (or a two-triangle strip) from a GL_T2F_V3F vertex array with the appropriate texture coordinates.

Two examples of the unwanted pixels can be found here:

http://pix.hobbiton.cjb.net/bill/screenshots/quads.png
http://pix.hobbiton.cjb.net/bill/screenshots/triangles.png

a snippet of the code i use to generate a display lists for a character:



fontelement[0][0]=float(cursor.x)/float(fontSurf->w);
fontelement[0][1]=float(cursor.y)/float(fontSurf->h);

fontelement[1][0]=float(cursor.x+cursor.w)/float(fontSurf->w);
fontelement[1][1]=float(cursor.y)/float(fontSurf->h);

fontelement[2][0]=float(cursor.x+cursor.w)/float(fontSurf->w);
fontelement[2][1]=float(cursor.y+cursor.h)/float(fontSurf->h);

fontelement[3][0]=float(cursor.x)/float(fontSurf->w);
fontelement[3][1]=float(cursor.y+cursor.h)/float(fontSurf->h);

fontelement[0][2]=0.0f;
fontelement[0][3]=cursor.h;

fontelement[1][2]=cursor.w;
fontelement[1][3]=cursor.h;

fontelement[2][2]=cursor.w;
fontelement[2][3]=0.0f;

fontelement[3][2]=0.0f;
fontelement[3][3]=0.0f;


glNewList(base+ch-g1,GL_COMPILE);
glInterleavedArrays(GL_T2F_V3F,0,fontelement);
glDrawArrays(GL_QUADS,0,sizeof(fontelement)/sizeof(GLfloat));
glTranslatef(glyphSurfs[ch-g1]->w,0.0f,0.0f);
glEndList();



and i render it with primarily these calls:


glBindTexture(GL_TEXTURE_2D,getTexture());

glListBase(base-32);
glPushMatrix();
glCallLists(s.size(),GL_UNSIGNED_BYTE,s.c_str());
glPopMatrix();

if you think you can help and need more information, or have had any similar problems in the past then please let me know. thanks
-bill

Ysaneya
02-24-2003, 03:02 AM
glDrawArrays(GL_QUADS,0,sizeof(fontelement)/sizeof(GLfloat));


Assuming you've defined fontelement as GLfloat fontelement[4][4], sizeof(fontelement) will return 64, hence you'll be drawing 16 indices, which means 4 quads, and not one. I'm guessing that's not what you want to do, do you?

Y.

baggins
02-24-2003, 04:02 AM
OMG! thank you sooo much... i have searched high and low for the solution to that problem... so simple. thanks a lot. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-bill