Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Current Situation

I have a spritesheet loaded in for a texture when drawing the specific portions of the sheet that I'd like to have on my quads I do some simple math to get their location on the sheet and normalize it.

My texture is setup like this:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

The Problem

Where I'm facing the problem is that because I'm using a "chunk" of the total texture I can't take advantage of using 1.0 for the mapping of values to glTexCoordPointer to cause the texture to stretch over the entire face.

Looked Into

I've looked for a glTexParameterf option for scaling options but I failed to find anything.

Question

Is it possible with my current methods to stretch the texture over the face of the quad without having to load a separate image for every "sprite" of the texture? Or am I just doing everything completely wrong?

Picture that hopefully sort of clarifies: enter image description here

Thanks for any help.

edit The problem was another issue all together: Turns out it was another issue all together, I thought this didn't make sense cause it was mapping it to the vertices so it should stretch regardless and infact it does work right I was assigning the wrong the width and height values to the drawing routines calculations. And now I feel really stupid, thanks for the help Byte56. Sorry for taking up your time. The GL_CLAMP solution would be the correct answer if I hadn't made a huge fail.

share|improve this question
3  
How are you assigning the texture coordinates to the quad? –  Byte56 Apr 24 '12 at 23:42
    
(x, y) of position in texture divided accordingly (x/width) (y/height) become x0 and y0. Then the same for with the width and height of that chunk added on become x1 and y1. Then GLfloat texture_coords[] = {x0, y0, x1, y0, x1, y1, x0, y1}; using glTexCoordPointer obviously. –  dennmat Apr 24 '12 at 23:49
1  
Try: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); –  Byte56 Apr 24 '12 at 23:55
    
Turns out it was another issue all together, I thought this didn't make sense cause it was mapping it to the vertices so it should stretch regardless and infact it does work right I was assigning the wrong the width and height values to the drawing routines calculations. And now I feel really stupid, thanks for the help Byte56. Sorry for taking up your time. The GL_CLAMP solution would be the correct answer if I hadn't made a huge fail. –  dennmat Apr 24 '12 at 23:57
    
Ah, well I was just making my comment into an answer. I guess it's moot then. Glad you solved it! –  Byte56 Apr 25 '12 at 0:01
add comment

1 Answer

up vote 2 down vote accepted

It looks like your assigning the textures to the vertices correctly. I don't see how you're getting the results you're getting with what you've shown us. But you may want to try this:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.