Texture filter only works half the time

Member
Posts: 509
Joined: 2002.05
Post: #1
Here is my texture loading code first

PHP Code:
glBindTextureGL_TEXTURE_2DtexturetextureOn ] );
            
glTexParameteriGL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR );
            
glTexParameteriGL_TEXTURE_2DGL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST );
            
gluBuild2DMipmapsGL_TEXTURE_2DGL_RGBsize[textureOn], size[textureOn], GL_RGB,GL_UNSIGNED_BYTE, [imageRep[textureOnbitmapData]); 


OR this code does the same thing

PHP Code:
glBindTextureGL_TEXTURE_2DtexturetextureOn ] );
            
glTexParameteriGL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR );
            
glTexParameteriGL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR );
            
glTexImage2DGL_TEXTURE_2D0GL_RGBsize[textureOn],size[textureOn], 0GL_RGB,GL_UNSIGNED_BYTE, [imageRep[textureOnbitmapData]); 



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();
        
glTranslatefmxmymz );
        
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(3GL_FLOATsizeof(XYZ), vert1);
        
glTexCoordPointer(2GL_FLOATsizeof(UV), vert2);
        
        
glLockArraysEXT(0numVertex);

        
glDrawElements(GL_TRIANGLESnumTrianglesGL_UNSIGNED_SHORTstria);
        
        
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_2Dgv->texture[i]);
            
glBeginGL_QUADS ); 
            for (
0theQuadCount[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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #2
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.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
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?
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #4
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.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #5
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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #6
Using glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,&a); I get the same values both places, 9985 for the mipmapped terrain.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #7
Then you ought to be getting bilinear mipmapping.

Try trilinear? GL_LINEAR_MIPMAP_LINEAR?
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #8
I will try trilinear but I have to get my code working here http://www.idevgames.com/forum/showthrea...#post67661 first to test it
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #9
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.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #10
Erm. Post screenshots or mail me your executable?
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #11
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  audio error ( 2 identical project one works and the other not) why ? imaumac 4 2,449 Nov 12, 2008 01:26 PM
Last Post: imaumac
  [For David] Half Dynamic Range OneSadCookie 1 2,682 Aug 9, 2003 06:07 PM
Last Post: inio
  QuartzExtreme works even on non-32MB cards?! morgant 4 3,019 Jun 10, 2003 08:21 PM
Last Post: morgant