Hi,

I had problems with setting up the pixmap surface but then i managed to have it working. on the emulator i am having a bitmap in the background and a cube rotating on top of it. however, when i run it on the device i just get the background and no cube on top!!! it seems as if the cube has been hidden by the bitmap.
I am using Nokia Series602.1 on Nokia 6630.

any one know why my poor cube is dismissed???

I noticed something else as well. on the emulator, when i use glClear(GL_COLOR_BUFFER_BIT); the bitmap in the background is cleared to the color specified in glClearColor(); does any one know why this has an effect on the emulator and not on the device, ie the background bitmap stays unchanged (but no cube still!!!).

below is my code
cheers

// this function is called periodically
void CTestContainer:rawScreens(CFbsBitmap &aFrame)
{
if(iVisited && iFile->iLoaded)
{
// Getting the cube data from a file
iSimpleCube->UseParserData(iFile);
// copying the bitmap to be drawn to another with less color depth (for performance only).
iBitmap1->Create(aFrame.SizeInPixels(),EColor64K);
CFbsBitmapDevice* fbsdevb = CFbsBitmapDevice::NewL(iBitmap1);
CleanupStack::PushL(fbsdevb);
CFbsBitGc* fbsgcb = CFbsBitGc::NewL();
CleanupStack::PushL(fbsgcb);
fbsgcb->Activate(fbsdevb);
fbsgcb->BitBlt(TPoint(0,0),&aFrame);
CleanupStack::PopAndDestroy(2); //pop from cleanupstack and destroy fbsgc, fbsdev
}
else if(!iVisited)
{
EGLint numConfigs = 0;
iFrame = 0;
// Initialize EGL
static const EGLint attribList[] =
{
EGL_SURFACE_TYPE, EGL_PIXMAP_BIT,
EGL_RED_SIZE, 4,
EGL_GREEN_SIZE, 4,
EGL_BLUE_SIZE, 4,
EGL_BUFFER_SIZE, 16,
// EGL_DEPTH_SIZE, 16,
// EGL_NATIVE_RENDERABLE, EGL_TRUE,
EGL_NONE
};

// creating the display interface to the device default display
iEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if(iEglDisplay == EGL_NO_DISPLAY || eglGetError() != EGL_SUCCESS)
{
_LIT(KInitializeFailed, "eglGetDisplay failed");
User::Panic( KInitializeFailed, 0 );
}

// Initialising the display
if( eglInitialize(iEglDisplay, NULL, NULL) == EGL_FALSE)
{
_LIT(KInitializeFailed, "eglInitialize failed");
User::Panic( KInitializeFailed, 0 );
}

// Here we get the configs
if(eglChooseConfig(iEglDisplay, attribList, &iEglSurface, 1, &numConfigs) == EGL_FALSE || eglGetError() != EGL_SUCCESS)
{
_LIT(KInitializeFailed, "eglChooseConfig failed");
User::Panic( KInitializeFailed, 0 );
}

// this function here is only for checking it is not actually used in the initialization
int val = 0;
eglGetConfigAttrib(iEglDisplay, iEglSurface, EGL_SURFACE_TYPE, &val);
if(!(val & EGL_PIXMAP_BIT))
{
_LIT(KInitializeFailed, "eglGetConfigAttrib failed");
User::Panic( KInitializeFailed, 0 );
}

iEglContext = eglCreateContext(iEglDisplay, iEglSurface, NULL, NULL);
if(iEglContext == EGL_NO_CONTEXT)
{
_LIT(KInitializeFailed, "eglCreateContext failed");
User::Panic( KInitializeFailed, 0 );
}

// Creating the window graphics context to draw on.
iWindowGc = new CWindowGc(iEikonEnv->ScreenDevice());
iWindow = Window();

if (!iWindowGc || (iWindowGc->Construct() != KErrNone))
{
_LIT(KInitializeFailed, "CWindowGc failed");
User::Panic( KInitializeFailed, 0 );
}

//the pixmap buffer
iBitmap1 = new (ELeave) CFbsBitmap();
iBitmap1->Create(aFrame.SizeInPixels(),EColor16M);
CFbsBitmapDevice* fbsdevb = CFbsBitmapDevice::NewL(iBitmap1);
CleanupStack::PushL(fbsdevb);
CFbsBitGc* fbsgcb = CFbsBitGc::NewL();
CleanupStack::PushL(fbsgcb);
fbsgcb->Activate(fbsdevb);
fbsgcb->BitBlt(TPoint(0,0),&aFrame);
CleanupStack::PopAndDestroy(2); //pop from cleanupstack and destroy fbsgc, fbsdev

iEglSurface = eglCreatePixmapSurface(iEglDisplay, iEglSurface, iBitmap1, NULL);
eglMakeCurrent(iEglDisplay, iEglSurface, iEglSurface, iEglContext);

iSimpleCube = CSimpleCube::NewL( size.iWidth, size.iHeight, &Window(), iWindowGc, iBitmap1 ); // Create an instance of SimpleCube
iSimpleCube->AppInit(); // Initialize OpenGL ES

iVisited = ETrue;
}

iFrame++;
// Call the main OpenGL ES Symbian rendering 'loop'
iSimpleCube->AppCycle( iFrame );

// Call eglSwapBuffers, which blit the graphics to the window
eglSwapBuffers( iEglDisplay, iEglSurface );

// To keep the background light on
if ( !(iFrame%100) )
{
User::ResetInactivityTime();
}

if ( !(iFrame%50) )
{
User::After(0);
}
}



void CSimpleCube::AppInit( void )
{
static const GLfloat light_position[] = { -50.f, 50.f, 200.f, 0.f };
static const GLfloat light_ambient[] = { 0.25f, 0.25f, 0.25f, 1.f };
static const GLfloat light_diffuse[] = { 1.f, 1.f, 1.f, 1.f };
static const GLfloat material_spec[] = { 0.f, 0.f, 0.f, 0.f };

glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_spec);

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);

// Enable back face culling.
glDisable(GL_DEPTH_TEST); // this is required for pixmap
/ glDepthMask(GL_FALSE); // no need in pixmap
glDisable(GL_DITHER); // no need in pixmap

glClearColor( 0.f, 0.f, 0.f, 0.f );

// Initialize viewport and projection.
glViewport( 0, 0, iScreenWidth, iScreenHeight );
glMatrixMode( GL_PROJECTION );
glFrustumf( -1.f, 1.f, -1.f, 1.f, 3.f, 1000.f );
glMatrixMode( GL_MODELVIEW );

glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );

// Set the initial shading mode
glShadeModel( GL_SMOOTH );
// Do not use perspective correction
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );

glLoadIdentity();
glTranslatef(0.f, 0.f, -40.f);
}


void CSimpleCube::AppCycle( TInt iFrame )
{
if(iFile)
{
const GLint cameraDistance = 100;

// ********** YOU SHOULD NOT CLEAR ANYTHING HERE ***********
// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glClear( GL_COLOR_BUFFER_BIT );
/* Animate and draw box */
glPushMatrix();
glTranslatex( 0 , 0 , -cameraDistance << 16 );
glRotatex( iFrame << 16, 1 << 16, 0 , 0 );
glRotatex( iFrame << 15, 0 , 1 << 16, 0 );
glRotatex( iFrame << 14, 0 , 0 , 1 << 16 );
DrawBox( 15.f, 15.f, 15.f );
glPopMatrix();
}
eglWaitGL();
iWindow->Invalidate();
iWindowGc->Activate(*iWindow);
iWindow->BeginRedraw();
iWindowGc->BitBlt(TPoint(0,0), iBitmap1);
iWindowGc->SetPenStyle(CGraphicsContext::ENullPen);
iWindowGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
iWindow->EndRedraw();
iWindowGc->Deactivate();
}