Texture filter only works half the time
Here is my texture loading code first
OR this code does the same thing
For some reason when I render with my vertex array for the actual road object it works fine, BUT when I use the same texture pointer for my terrain it always uses nearest instead of linear! If I used the mipmap code then it will still be mipmapped, but very very pixelated compared to the working road right next to it.
What should I do? Here is the code that works
And this is my temporary immediate mode code for rendering (until I can fix the vertex array terrain)
EDIT : Even with using vertex arrays with the immediate mode its still loses the linear filter on the terrain.
PHP Code:
glBindTexture( GL_TEXTURE_2D, texture[ textureOn ] );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST );
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, size[textureOn], size[textureOn], GL_RGB,GL_UNSIGNED_BYTE, [imageRep[textureOn] bitmapData]);
OR this code does the same thing
PHP Code:
glBindTexture( GL_TEXTURE_2D, texture[ textureOn ] );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, size[textureOn],size[textureOn], 0, GL_RGB,GL_UNSIGNED_BYTE, [imageRep[textureOn] bitmapData]);
For some reason when I render with my vertex array for the actual road object it works fine, BUT when I use the same texture pointer for my terrain it always uses nearest instead of linear! If I used the mipmap code then it will still be mipmapped, but very very pixelated compared to the working road right next to it.
What should I do? Here is the code that works
PHP Code:
glPushMatrix();
glTranslatef( mx, my, mz );
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(zrot,0.0f,0.0f,1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(XYZ), vert1);
glTexCoordPointer(2, GL_FLOAT, sizeof(UV), vert2);
glLockArraysEXT(0, numVertex);
glDrawElements(GL_TRIANGLES, 3 * numTriangles, GL_UNSIGNED_SHORT, stria);
glUnlockArraysEXT();
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glPopMatrix();
And this is my temporary immediate mode code for rendering (until I can fix the vertex array terrain)
PHP Code:
glBindTexture(GL_TEXTURE_2D, gv->texture[i]);
glBegin( GL_QUADS );
for (j = 0; j < theQuadCount[i]; j++)
{
glNormal3f(smoothNormal[(int)(theVertex[theQuad[ i ][ j ].w])][(int)(theVertex[2+theQuad[ i ][ j ].w])].x,
smoothNormal[(int)(theVertex[theQuad[ i ][ j ].w])][(int)(theVertex[2+theQuad[ i ][ j ].w])].y,
smoothNormal[(int)(theVertex[theQuad[ i ][ j ].w])][(int)(theVertex[2+theQuad[ i ][ j ].w])].z);
glTexCoord2f(theUV[theQuad[ i ][ j ].a]/div,theUV[1+theQuad[ i ][ j ].a]/div);
glVertex3f(theVertex[theQuad[ i ][ j ].w],theVertex[1+theQuad[ i ][ j ].w],theVertex[2+theQuad[ i ][ j ].w]);
glNormal3f(smoothNormal[(int)(theVertex[theQuad[ i ][ j ].x])][(int)(theVertex[2+theQuad[ i ][ j ].x])].x,
smoothNormal[(int)(theVertex[theQuad[ i ][ j ].x])][(int)(theVertex[2+theQuad[ i ][ j ].x])].y,
smoothNormal[(int)(theVertex[theQuad[ i ][ j ].x])][(int)(theVertex[2+theQuad[ i ][ j ].x])].z);
glTexCoord2f(theUV[theQuad[ i ][ j ].b]/div,theUV[1+theQuad[ i ][ j ].b]/div);
glVertex3f(theVertex[theQuad[ i ][ j ].x],theVertex[1+theQuad[ i ][ j ].x],theVertex[2+theQuad[ i ][ j ].x]);
glNormal3f(smoothNormal[(int)(theVertex[theQuad[ i ][ j ].y])][(int)(theVertex[2+theQuad[ i ][ j ].y])].x,
smoothNormal[(int)(theVertex[theQuad[ i ][ j ].y])][(int)(theVertex[2+theQuad[ i ][ j ].y])].y,
smoothNormal[(int)(theVertex[theQuad[ i ][ j ].y])][(int)(theVertex[2+theQuad[ i ][ j ].y])].z);
glTexCoord2f(theUV[theQuad[ i ][ j ].c]/div,theUV[1+theQuad[ i ][ j ].c]/div);
glVertex3f(theVertex[theQuad[ i ][ j ].y],theVertex[1+theQuad[ i ][ j ].y],theVertex[2+theQuad[ i ][ j ].y]);
glNormal3f(smoothNormal[(int)(theVertex[theQuad[ i ][ j ].z])][(int)(theVertex[2+theQuad[ i ][ j ].z])].x,
smoothNormal[(int)(theVertex[theQuad[ i ][ j ].z])][(int)(theVertex[2+theQuad[ i ][ j ].z])].y,
smoothNormal[(int)(theVertex[theQuad[ i ][ j ].z])][(int)(theVertex[2+theQuad[ i ][ j ].z])].z);
glTexCoord2f(theUV[theQuad[ i ][ j ].d]/div,theUV[1+theQuad[ i ][ j ].d]/div);
glVertex3f(theVertex[theQuad[ i ][ j ].z],theVertex[1+theQuad[ i ][ j ].z],theVertex[2+theQuad[ i ][ j ].z]);
}
glEnd();
EDIT : Even with using vertex arrays with the immediate mode its still loses the linear filter on the terrain.
Any ideas at all? I honestly have no clue what to do because it just isn't working and isn't giving any errors or anything.
Texture filtering is completely independent of your vertex submission method. Just look at all of your texture IDs-- do you have a glTexParameteri for each one you create?
Yes I have a glTexParameteri for each texture, the thing is that the texture only uses the linear filter sometimes and the nearest filter other times, and when I say texture I am talking about the pointer to memory of the texture I loaded, so it is EXACTLY the same.
When you say "texture" that means the texture ID that is currently bound and all of the associated texture state for the ID. That includes all the state spelled out in sec 3.8.11 of the spec (the texel array, texture dimensions, wrap modes, filter modes, border color, mipmap range, etc) as well as any extension state like the AGP storage hint.
Try sticking glGetTexParameter()s everywhere you bind and use a texture. Chances are you've just got the wrong filtering state set somewhere.
Try sticking glGetTexParameter()s everywhere you bind and use a texture. Chances are you've just got the wrong filtering state set somewhere.
Using glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,&a); I get the same values both places, 9985 for the mipmapped terrain.
Then you ought to be getting bilinear mipmapping.
Try trilinear? GL_LINEAR_MIPMAP_LINEAR?
Try trilinear? GL_LINEAR_MIPMAP_LINEAR?
I will try trilinear but I have to get my code working here http://www.idevgames.com/forum/showthrea...#post67661 first to test it
arekkusu Wrote:Then you ought to be getting bilinear mipmapping.
Try trilinear? GL_LINEAR_MIPMAP_LINEAR?
Just got the multitexturing working, but the trilinear doesn't help fix the problem.
Erm. Post screenshots or mail me your executable?
I will post one when I have the chance, but its just pixelated up close to the camera, because it is stretching a texture onto a big surface and not filtering it, just using the nearest pixel.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| audio error ( 2 identical project one works and the other not) why ? | imaumac | 4 | 2,261 |
Nov 12, 2008 01:26 PM Last Post: imaumac |
|
| [For David] Half Dynamic Range | OneSadCookie | 1 | 2,542 |
Aug 9, 2003 06:07 PM Last Post: inio |
|
| QuartzExtreme works even on non-32MB cards?! | morgant | 4 | 2,895 |
Jun 10, 2003 08:21 PM Last Post: morgant |
|

