OpenGL texturing
The problem I'm having is when I zoom into my model the texture doesnt scale with it, it sort of tiles...
Zoomed just a little:
Zoomed None:
What I want is the texture to stay the same only scaled when I zoom in. What I mean by that is no tileing, only resizeing.
Well this is some really aweful code....
But here it is, this is pretty well just the draw function
fXoff, fYoff, and uZoom, are used to move and zoom....
The resizer things were put in there so I could mess with the texture coords a little easier
There the code, in source tags... for OpenGLAaron
[Edited by - Arenth on November 26, 2004 5:39:54 PM]
But here it is, this is pretty well just the draw function
fXoff, fYoff, and uZoom, are used to move and zoom....
The resizer things were put in there so I could mess with the texture coords a little easier
static void draw_screen( void ){unsigned long int i;unsigned long int j;float resizerX;float resizerY; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, gTexture); glMatrixMode( GL_TEXTURE ); glLoadIdentity(); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); glTranslatef( fXOff, fYOff, uZoom ); glRotatef(180,1,0,0); glBegin( GL_TRIANGLES ); for (i = 0; i<Map.MPolygon_Start.PolyCount; i++) { resizerX = Map.Polygon.Poly.Vertices[2].X; resizerY = Map.Polygon.Poly.Vertices[2].Y; glTexCoord2f(resizerX, resizerY); glColor4ub(Map.Polygon.Poly.Vertices[2].DColorB, Map.Polygon.Poly.Vertices[2].DColorG, Map.Polygon.Poly.Vertices[2].DColorR, Map.Polygon.Poly.Vertices[2].DColorA); glVertex3f(Map.Polygon.Poly.Vertices[2].X, Map.Polygon.Poly.Vertices[2].Y, Map.Polygon.Poly.Vertices[2].Z ); resizerX = Map.Polygon.Poly.Vertices[1].X; resizerY = Map.Polygon.Poly.Vertices[1].Y; glTexCoord2f(resizerX, resizerY); glColor4ub(Map.Polygon.Poly.Vertices[1].DColorB, Map.Polygon.Poly.Vertices[1].DColorG, Map.Polygon.Poly.Vertices[1].DColorR, Map.Polygon.Poly.Vertices[1].DColorA); glVertex3f(Map.Polygon.Poly.Vertices[1].X, Map.Polygon.Poly.Vertices[1].Y, Map.Polygon.Poly.Vertices[1].Z ); resizerX = Map.Polygon.Poly.Vertices[0].X; resizerY = Map.Polygon.Poly.Vertices[0].Y; glTexCoord2f(resizerX, resizerY); glColor4ub(Map.Polygon.Poly.Vertices[0].DColorB, Map.Polygon.Poly.Vertices[0].DColorG, Map.Polygon.Poly.Vertices[0].DColorR, Map.Polygon.Poly.Vertices[0].DColorA); glVertex3f(Map.Polygon.Poly.Vertices[0].X, Map.Polygon.Poly.Vertices[0].Y, Map.Polygon.Poly.Vertices[0].Z); } glEnd( );glDisable(GL_TEXTURE_2D);SDL_GL_SwapBuffers( ); }
There the code, in source tags... for OpenGLAaron
[Edited by - Arenth on November 26, 2004 5:39:54 PM]
after a quick gander, your code looks ok
try doing this before you render
try doing this before you render
glMatrixMode( GL_TEXTURE ); glLoadIdentity();glMatrixMode( GL_MODELVIEW );
Well I tried that, I pasted it right in before where I swapped buffers, and it still does the same thing.
Try using the glext.h header file. GL_CLAMP_TO_EDGE is an OpenGL 1.2 constant, I believe, and windows only includes OpenGL 1.1. Also, could you include your code in [ source ] tags? Please? For me? :)
Well I tried GL_CLAMP_TO_EDGE and it looks just like GL_CLAMP.
This is what clamped, and clamped to edge both look like:
A whole lot of blah.....
Well this is something I thought i should add... the vertex coords are not in the range of -1.0 to 1.0, some go all the way up to like 200.
Also the glRotatef(180,1,0,0); is there because the vertex coords were for D3D. And they drew upside down, so I flipped the model.
[Edited by - Arenth on November 26, 2004 5:23:20 PM]
This is what clamped, and clamped to edge both look like:
A whole lot of blah.....
Well this is something I thought i should add... the vertex coords are not in the range of -1.0 to 1.0, some go all the way up to like 200.
Also the glRotatef(180,1,0,0); is there because the vertex coords were for D3D. And they drew upside down, so I flipped the model.
[Edited by - Arenth on November 26, 2004 5:23:20 PM]
sorry i meant CLAMP_TO_BORDER which should show a lot of the texture has become black.
anyways the reason it does this is cause the texture coordinates are larger than 1.0 if they are this then the texture tiles , normally u dont use the same numbers for texture coords as u use for vertices (like youre doing)
anyways the reason it does this is cause the texture coordinates are larger than 1.0 if they are this then the texture tiles , normally u dont use the same numbers for texture coords as u use for vertices (like youre doing)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement