I tried creating my own texture using the following codes . Problem is
the emulator is exiting abruptly without any panic code . I am new in OpenGles . Please Help .
Code:static const GLbyte vertices[4 * 3] = //row major { -1, 0, 0, 1, 0, 0, -1, 2, 0, 1, 2, 0 }; 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) }; /* Define normals for the cube */ static const GLbyte normals[4 * 3] = { /* top */ 0,0,1, /* right */ 0,1,0, /* left */ 0,-1,0, /* back */ -1,0,0, }; #define LIGHT_MAX (1 << 16) #define LIGHTCOLOR(r, g, b, a) \ (GLfixed)(r * LIGHT_MAX), \ (GLfixed)(g * LIGHT_MAX), \ (GLfixed)(b * LIGHT_MAX), \ (GLfixed)(a * LIGHT_MAX) /* Define global ambient light. */ static const GLfixed globalAmbient[4] = { LIGHTCOLOR(0.0, 0.0, 0.0, 1.0) }; /* Define lamp parameters. */ static const GLfixed lightDiffuseLamp[4] = { LIGHTCOLOR(1.0, 1.0, 1.0, 1.0) }; static const GLfixed lightAmbientLamp[4] = { LIGHTCOLOR(0.3, 0.3, 0.3, 1.0) }; static const GLfixed lightSpecularLamp[4] = { LIGHTCOLOR(0.5, 0.5, 0.5, 1.0) }; static const GLfixed lightPositionLamp[4] = { 0, 0, 10, 0 };Code:GLuint CMobileEMailContainer::BindTextures(const TRect& aRect,TBool aWrap) const { GLuint texture; TRAPD(err, // allocate a texture name glGenTextures( 2, &texture ); // glBindTexture( GL_TEXTURE_2D,texture );//in here to test texture /* Enable back face culling, texturing, and normalization. */ glEnable( GL_TEXTURE_2D ); glEnable( GL_NORMALIZE ); /***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 ); glEnableClientState( GL_NORMAL_ARRAY); // select our current texture glBindTexture( GL_TEXTURE_2D, texture ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, aRect.Width(), aRect.Height(), 0, GL_RGB, GL_UNSIGNED_BYTE, iImageEngine->TextureData()); /**************Texture environment parameters are set using glTexEnvf().*/ glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); // 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 ); ) Panic(err); return texture; } void CMobileEMailContainer::SetLight() const { /* Set up global ambient light. */ glLightModelxv( GL_LIGHT_MODEL_AMBIENT, globalAmbient ); /* Set up lamp. */ glEnable( GL_LIGHT0 ); glLightxv( GL_LIGHT0, GL_DIFFUSE, lightDiffuseLamp ); glLightxv( GL_LIGHT0, GL_AMBIENT, lightAmbientLamp ); glLightxv( GL_LIGHT0, GL_SPECULAR, lightSpecularLamp ); glLightxv( GL_LIGHT0, GL_POSITION, lightPositionLamp ); /* Set shading mode*/ glShadeModel( GL_FLAT ); } // --------------------------------------------------------- // CMobileEMailContainer::Draw(const TRect& aRect) const // --------------------------------------------------------- // void CMobileEMailContainer::GenSkin(const TRect& aRect) const { TRAPD(err, // CFbsBitmap* TextureBitmap= new (ELeave)CFbsBitmap; TBool wrap=ETrue; glBindTexture( GL_TEXTURE_2D, BindTextures(aRect,wrap) ); // BindTextures(aRect,wrap,*TextureBitmap);//while bind texture is in Bindtextures // /* Enable vertex array */ // glMatrixMode( GL_MODELVIEW ); glEnableClientState( GL_VERTEX_ARRAY ); glLoadIdentity(); SetLight(); glClear( GL_COLOR_BUFFER_BIT ); ) Panic(err); glTexCoordPointer( 2, GL_BYTE, 0, nokTexCoords ); glNormalPointer( GL_BYTE, 0, normals ); glVertexPointer( 2, /*GL_SHORT*/GL_BYTE, 0, skinvertices ); glDrawElements( GL_TRIANGLES, 2* 3, GL_UNSIGNED_BYTE, triangles ); // glDeleteTextures(2, &texture); }




