Hi all I am a newbie and want to create a skin for my application . Please help , it is urgent . My problem is that the skin do not show .
START BITMAP Mobile.mbm
HEADER
TARGETPATH \system\apps\Mobile
SOURCEPATH ..\gfx
SOURCE c24 screen.bmp //pic size 128,340
SOURCE c24 screen1.bmp //pic size 128,128
END
_LIT(KTextureBitmap,"z:\\system\\apps\\Mobile\\Mobile.mbm");
/*Macro for changing the input texture coordinate values from
GLubyte [0,255] to GLbyte [-128,127]. See more info below. */
#define tex(u,v) (GLbyte)( (u) - 128 ) , (GLbyte)( (v) - 128 )
static const GLbyte skinvertices[4 *2] =
{
/* top */
-1, -1,
1, -1 ,
1, 1,
-1, 1
};
/* Define indices for drawing the triangles. The color of the square
* is determined by the color of the last vertex of the square.*/
static const GLubyte triangles[2* 3] =
{
/* up */
0,1,2,
/*down*/
1,2,3
};
static const GLbyte nokTexCoords[4 * 2] =
{
/**** */
tex(0,0),
tex(255,0),
tex(255,255),
tex(0,255)
};
GLuint CMobileContainer::BindTextures(const TRect& aRect,TBool aWrap,CFbsBitmap& aTextureBitmap) const
{
GLuint texture;
TInt TextureSize=aTextureBitmap.SizeInPixels().iHeight*aTextureBitmap.SizeInPixels().iWidth;
// allocate a texture name
glGenTextures( 2, &texture );
/* The data in the texture are in RGB order but is read in BGR order.
So we have to swap the 1st and 3rd bytes. */
TUint8 * TextureData = (TUint8 *) aTextureBitmap.DataAddress();
for ( TInt i = 0; i < TextureSize; i++ )
{
TUint8 t = TextureData[i*3];
TextureData[i*3] = TextureData[i*3+2];
TextureData[i*3+2] = t;
}
/* Enable back face culling, texturing, and normalization. */
glEnable( GL_TEXTURE_2D );
/***an appropriate texture matrix has to be initialized*/
glMatrixMode( GL_TEXTURE );
glLoadIdentity();
glScalef( 1.f / 128.f, 1.f / 128.f, 1.f );
glTranslatef( 128.f, 128.f, 0.f );
glMatrixMode( GL_MODELVIEW );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
// select our current texture[/COLOR]
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, aRect.Width(), aRect.Height(),
0, GL_RGB, GL_UNSIGNED_BYTE, aTextureBitmap.DataAddress() );
/**************Texture environment parameters are set using glTexEnvf().*/
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,/*GL_REPLACE */GL_DECAL);
// if wrap is true, the texture wraps over at the edges (repeat)
// ... false, the texture ends at the edges (clamp)
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,aWrap ? GL_REPEAT : GL_CLAMP_TO_EDGE );
return texture;
}
void CMobileContainer::GenSkin(const TRect& aRect) const
{
CFbsBitmap* TextureBitmap= new (ELeave)CFbsBitmap;
TBool wrap=ETrue;
TextureBitmap->Load(KTextureBitmap,EMbmMobileScreen1,ETrue);
glBindTexture( GL_TEXTURE_2D, BindTextures(aRect,wrap,*TextureBitmap) );
/* Enable vertex array */
glVertexPointer( 2,/*GL_SHORT*/GL_BYTE, 0, skinvertices );//no of cocordinates per vertex,type,byte offset between consecutive vertexes,first vertex in array
glTexCoordPointer( 2, GL_BYTE, 0, nokTexCoords );
glShadeModel( GL_FLAT );
glClear( GL_COLOR_BUFFER_BIT );
glLoadIdentity();
glDrawElements( GL_TRIANGLES, 2* 3, GL_UNSIGNED_BYTE, triangles );
}
void CMobileContainer::Draw(const TRect& aRect) const
{
/**************************Set the correct step of OpenGl renderer*/
/* Set the screen background color to black */
glClearColor( 0.f, 0.f, 0.f, 1.f );
/* Initialize viewport */
glViewport( 0, 0, aRect.Width(), aRect.Height());
//**************draw the object to made it translucent
/* Set the projection matrix */
glMatrixMode( GL_PROJECTION );
glFrustumf( -1.f, 1.f, -1.f, 1.f, 3.f, 1000.f );
GenSkin(aRect);
GenSelector(aRect);
/* Call eglSwapBuffers, which blit the graphics to the window */
eglSwapBuffers( iEglDisplay, iEglSurface );
}