Adjust sprite bounds of the visible part of texture

Posted by Crazy D0G on Game Development See other posts from Game Development or by Crazy D0G
Published on 2012-06-26T11:21:38Z Indexed on 2012/06/26 15:25 UTC
Read the original article Hit count: 293

Filed under:
|
|
|

Is there any way to adjust the boundaries of the visible part of the sprite? To make it easier to understand: I have a texture, such as shown at figure 1. Then I break it into pieces and fill the resulting fragments using PRKit (wood texture on figure 2 and 3). But the resulting fragments have the transparent (green color on figure 2 and 3) and when creating a sprite from the fragments they have the size of the initial texture. Is there a way to get rid of this transparency and to adjust the size of the visible part (wood texture), openGL or cocos2d-x means?

example

Maybe it help - draw() method from PRKit:

void PRFilledPolygon::draw() {

//CCNode::draw();

glDisableClientState(GL_COLOR_ARRAY);

// we have a pointer to vertex points so enable client state
glBindTexture(GL_TEXTURE_2D, texture->getName());

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ONE_MINUS_SRC_ALPHA);
glVertexPointer(2, GL_FLOAT, 0, areaTrianglePoints);
glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates);

glDrawArrays(GL_TRIANGLES, 0, areaTrianglePointCount);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

//Restore texture matrix and switch back to modelview matrix
glEnableClientState(GL_COLOR_ARRAY);}

© Game Development or respective owner

Related posts about opengl

Related posts about opengl-es