glTexImage2D gives our beloved 'KERN-EXEC 3'

Login to reply to this topic.
Wed, 2007-10-24 12:31
Joined: 2007-10-24
Forum posts: 6

I'm loading and converting a GIF image using CImageDecoder

I then create a copy of the resulting CFbsBitmap, because I read somewhere that handles between threads could cause problems.

But it is ultimately the glTexImage2D(...) function which crashes my emulator:

  CFbsBitmap* iBitmapCopy = new (ELeave) CFbsBitmap();

  iBitmapCopy->Create(iBitmap->SizeInPixels(),iBitmap->DisplayMode());

  CFbsBitmapDevice* fbsdev = CFbsBitmapDevice::NewL(iBitmapCopy);
  CleanupStack::PushL(fbsdev);
  CFbsBitGc* fbsgc = CFbsBitGc::NewL();
  CleanupStack::PushL(fbsgc);
  fbsgc->Activate(fbsdev);
  fbsgc->BitBlt(TPoint(0,0),iBitmap);
  CleanupStack::PopAndDestroy(2); //pop from cleanupstack and destroy fbsgc, fbsdev

  iBitmapCopy->LockHeap();
  TUint8 *tex1 = (TUint8*)iBitmapCopy->DataAddress();
  glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, tex1);
  iBitmapCopy->UnlockHeap();

Any ideas?


Wed, 2007-10-24 13:53
Joined: 2004-11-29
Forum posts: 1134
Re: glTexImage2D gives our beloved 'KERN-EXEC 3'

You mention your app is multi threaded.
Is the call to glTexImage2D in the same thread as the main UI thread, where you created the gl context?
If not, that is your problem...

gl calls must be in the same thread as where you create the gl context.
And in S60, you also have to create the gl context in the main UI thread (or provide a (new) instance of CCoeEnv/CEikonEnv in the new thread)

Thu, 2007-10-25 09:15
Joined: 2007-10-24
Forum posts: 6
Re: glTexImage2D gives our beloved 'KERN-EXEC 3'

Thanks for your help, alh, but I never found out what gave that KERN-EXEC 3, because I tried many different things.

I also tried to synchronously decode my GIF, but that never worked.

I later got some errors because the created CFbsBitmap had some strange properties:

iBitsPerPixel=12           <-- 4096 colors?!
iBitmapSize=32808
iWidth=128
iHeight=128

Even though my GIF is only 16 colors, these are chosen from a 24-bit palette, so you loose accuracy with only 12 bpp, right? I now forced my bitmap to 24 bpp.

Anyways after a lot of fiddling about i found that SetActive conflicted with my drawing loop:

  CFbsBitmap* iBitmap = new (ELeave) CFbsBitmap();
  iBitmap->Create(iFrameInfo.iOverallSizeInPixels, EColor16M);
  // start reading the bitmap: RunL called when complete
  iLoadUtil->Convert(&iStatus, *iBitmap);
//  SetActive();        <-- culprit!
  User::WaitForRequest(iStatus);

The conversion was done, but the drawing loop never started:

start:
        int iFramesPerSecond = 50;
        int iOneSecondInMicroSeconds = 1000000;
        iPeriodic = CPeriodic::NewL(CActive::EPriorityStandard);
        iPeriodic->Start(100000,iOneSecondInMicroSeconds/iFramesPerSecond,TCallBack(CAppView::DrawCallback,this));

I hope this'll help other frustrated newbie Symbian developers.

Mon, 2007-11-12 16:21
Joined: 2007-10-24
Forum posts: 6
Re: glTexImage2D gives our beloved 'KERN-EXEC 3'

Okay, the persons responsible for porting OpenGL ES to Symbian should be stabbed - repeatedly.

I spent hours trying to figure out if my CImageDecoder somehow didn't load the GIF/PNG/JPG correctly, but it seems a 24-bit CFbsBitmap has its colors in BGR format. So after your convertion is finished, you have to swap the Blue & Red component:

        GLubyte* bytes = new GLubyte[width*height*3];
        iBitmap->LockHeap();
        TUint8 *tex1 = (TUint8*)iBitmap->DataAddress();
        for(int i = 0; i < width*height*3; i += 3) {
                bytes[i] = tex1[i+2];
                bytes[i+1] = tex1[i+1];
                bytes[i+2] = tex1[i];
        }
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, bytes); 
        iBitmap->UnlockHeap();

"#ยค&"#/"%& Assholes!

  • Login to reply to this topic.