i am trying to load a bmp texture to a plane (simple example). the plane is shown on screen. the problem i am facing is creating the loader for the bmp. i used Series60 built-in function CFbsBitmap:: Load(...) to load the bitmap file. then i applied it on a CFbSBitmap object to hold the bitmap data like the following:
iBitMap = new (ELeave) CFbsBitmap();
iBitMap->Create( TSize(256,256), EColor16M );
then i created a pointer to point to the first memeory address of the bitmap data array like this:
TUint8 *tex1 = (TUint8*)iBitMap->DataAddress();
now, it is supposed to have all the data in hold and ready for mapping. but, when i apply the glTexImage2D to load the texture, the system crashes. Note that my BMP is 256X256.
/* Enable vertex, normals and texture arrays. */
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
glVertexPointer( 3, GL_BYTE, 0, v); // v array holding plane verts
glTexCoordPointer( 2, GL_BYTE, 0, x); // x holding texture coord
glNormalPointer( GL_BYTE, 0, n); // n hold norms
/* binding the texture */
glGenTextures( 1, iNokTexObjects );
glBindTexture( GL_TEXTURE_2D, iNokTexObjects );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 256, 256,
0, GL_RGB, GL_UNSIGNED_BYTE, tex1);
// t holds triangles data
glDrawElements( GL_TRIANGLES, 2 * 3, GL_UNSIGNED_BYTE, t);
does this way of loading bmp in Series60 works? i dont know, i just tried to work around the Texture application provided witht he SDK since it uses conversion, coding and decoding for JPeg images. and i dont need JPeg here.
one more thing...
all code for texture mapping requirements is included in AppInit().
if i pass to glTexImage2D the iBitMap instead of tex1 pointer, i get coloured dots on the square, which proves that texturing is enabled but the problem is when i use tex1!!!