Jump to content
  • Advertisement
Sign in to follow this  
Arenth

OpenGL OpenGL texturing

This topic is 5041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
odd, post code.

Share this post


Link to post
Share on other sites
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

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]

Share this post


Link to post
Share on other sites
after a quick gander, your code looks ok

try doing this before you render
glMatrixMode( GL_TEXTURE );
glLoadIdentity();
glMatrixMode( GL_MODELVIEW );

Share this post


Link to post
Share on other sites
Well I tried that, I pasted it right in before where I swapped buffers, and it still does the same thing.

Share this post


Link to post
Share on other sites
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? :)

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!