# OpenGL Opengl-es texture having a stretched area not wanted

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

## 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

1. 1
2. 2
3. 3
4. 4
Rutin
16
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631415
• Total Posts
2999965
×