Help drawing non-rectangle sprites

Hi,

I’m having an issue trying to draw some non-rectangle sprites. For some reason the image is not mapped correctly across the triangle strip. Can anyone advise on what I might be doing wrong?

Here’s the result I’m getting:

Here’s the image I’m using:

Here’s the code I’m using:

class TestNode : public CCNode
{
public:

	CREATE_FUNC( TestNode );

	virtual bool init()
	{
		CCNode::init();

		m_texture = CCTextureCache::sharedTextureCache()->addImage( "Test/test.png" );
		m_texture->retain();

		setShaderProgram( CCShaderCache::sharedShaderCache()->programForKey( kCCShader_PositionTextureColor ) );

		return true;
	}

	virtual void draw()
	{
		CC_NODE_DRAW_SETUP();

		ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );
		ccGLBlendFunc( CC_BLEND_SRC, CC_BLEND_DST );
		ccGLBindTexture2D( m_texture->getName() );

		static ccVertex2F	verts[4] = { {0.0f, 0.0f}, {256.0f, 0.0f}, {64.0f, 256.0f}, {192, 256.0f} };
		static ccTex2F		uvs[4] = { {0.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}, {1.0f, 0.0f} };
		static ccColor4B	colors[4] = { {255, 255, 255, 255}, {255, 255, 255, 255}, {255, 255, 255, 255}, {255, 255, 255, 255} };

		glVertexAttribPointer( kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, verts );
		glVertexAttribPointer( kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, uvs );
		glVertexAttribPointer( kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, colors );

		glDrawArrays( GL_TRIANGLE_STRIP, 0, (GLsizei)4 );
	}

protected:

	CCTexture2D*	m_texture;
};


bug.jpg (25.7 KB)


test.jpg (13.2 KB)