Jump to content
  • Advertisement
Sign in to follow this  
pal3mp

OpenGL Opengl-es texture having a stretched area not wanted

This topic is 2243 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

Hi,

EDIT: i fixed it, i had to move a line down, and it works... But the image is actually in the wrong direction, upside down, if anyone has any idea about that
Would anyone know why i get this stretched slice in the texture?

The stretched area : (it starts in the middle, then goes left, and comes back again in the right side)

[attachment=10331:imgs.png]


Here is the image without the texture, the triangles seem correctly drawn (even when i zoom in: the triangles seem to work fine) :

[attachment=10332:triangles.png]

And the code : here is the offset, called every second, to make the path and texture move :


- (void) setOffsetY:(float)newOffsetY {
y_line = -_offsetY - winSize.height/self.scale; //readjust the bottom line where to connect the triangles to
self.position = CGPointMake(-_offsetY, _offsetY); //move to the top left
[self generatePolygons];//the triangles
}


Here is how i create the triangles (division = 512, the size of my texture image) :


_polyVertices[_nPolyVertices] = CGPointMake(p0.x, y_line);
_polyTexCoords[_nPolyVertices++] = CGPointMake(p0.x/division, y_line/division);
//V1: to the first "point"
_polyVertices[_nPolyVertices] = CGPointMake(p0.x, p0.y);
_polyTexCoords[_nPolyVertices++] = CGPointMake(p0.x/division, p0.y/division);
//V2, same y as point n°2:
_polyVertices[_nPolyVertices] = CGPointMake(p1.x, y_line);
_polyTexCoords[_nPolyVertices++] = CGPointMake(p1.x/division, y_line/division);
//V3 = same x,y as point at index 1
_polyVertices[_nPolyVertices] = CGPointMake(p1.x, p1.y);
_polyTexCoords[_nPolyVertices++] = CGPointMake(p1.x/division, p1.y/division);


and how i draw the texture :


- (void) draw {
//blue triangles
glColor4f(0, 0, 1, 1);
for(int i = 1; i < 50; i++) {
ccDrawLine(_polyVertices[i-1], _polyVertices);
}
//texture
glDisableClientState(GL_COLOR_ARRAY);
//glDisableClientState(GL_TEXTURE_COORD_ARRAY);
//glBindTexture(GL_TEXTURE_2D, _textureImage.texture.name);
glBindTexture(GL_TEXTURE_2D, texture.textureID);
glColor4f(1, 1, 1, 1);
glVertexPointer(2, GL_FLOAT, 0, _polyVertices);
glTexCoordPointer(2, GL_FLOAT, 0, _polyTexCoords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nPolyVertices);
}


Thanks Edited by PWall

Share this post


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