Hey,
I'm writing an EdgeLib based application for a Nokia N97 device.
I have a couple of questions regarding OpenGL and Edge.
1. I've read in one of the posts that due to Texture size limitation, the Fontmap size is limited. What is the that limit in width ? ( using RGBA fontmap )
2. In one point in the application I need to take a snapshot of the display, and use this snapshot as a background for future blt operations.
My problem is that I don't get the same behavior in the PC emulator ( where everything works just fine ) and in the device.
Here is how I perform the snapshot:
I read the pixel data from the display into a buffer, and blt it back to the screen using a surface.
Here is the code I'm using in order to read the pixel data:
After reading the pixel data I create a new surface, the size of the display, and manually put the pixel data I've got in the buffer into the surface buffer.
Here is the code I use for this task (still not optimized)
Well... this works just fine under the PC emulator, but on the device I get a black screen with some dirty pixels at the bottom.
What am I doing wrong ?
Is there a different, more efficient way to do draw back the pixel data?
I'm writing an EdgeLib based application for a Nokia N97 device.
I have a couple of questions regarding OpenGL and Edge.
1. I've read in one of the posts that due to Texture size limitation, the Fontmap size is limited. What is the that limit in width ? ( using RGBA fontmap )
2. In one point in the application I need to take a snapshot of the display, and use this snapshot as a background for future blt operations.
My problem is that I don't get the same behavior in the PC emulator ( where everything works just fine ) and in the device.
Here is how I perform the snapshot:
I read the pixel data from the display into a buffer, and blt it back to the screen using a surface.
Here is the code I'm using in order to read the pixel data:
- Code:
//get the height and width of the display
int nHeight = m_pESSharedData->m_pDisplay->GetHeight();
int nWidth = m_pESSharedData->m_pDisplay->GetWidth();
unsigned char * pPixelData = (unsigned char*)ClassEMemory::Alloc(nHeight*nWidth*3);
if (!pPixelData)
return IERR_NO_MEMORY;
//read the pixel data of the entire display
glPixelStorei(GL_PACK_ALIGNMENT,4);
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
glReadPixels((GLint)0, (GLint)0,
(GLint)nWidth-1, (GLint)nHeight-1,
GL_RGB, GL_UNSIGNED_BYTE, pPixelData);
After reading the pixel data I create a new surface, the size of the display, and manually put the pixel data I've got in the buffer into the surface buffer.
Here is the code I use for this task (still not optimized)
- Code:
//init the new snap shot surface
unsigned char * pTmpPixelData = pPixelData;
m_pSnapShotSurface = new E2DSurface();
m_pDisplay->CreateSurface(m_pSnapShotSurface, nWidth, nHeight);
E2DSURFACEINFO lockinfo;
unsigned char* pBufferInfo = NULL;
pBufferInfo = m_pSnapShotSurface->Lock(&lockinfo);
if(pBufferInfo)
{
/*
the pixel data is from the bottom up so we point the pixel target in the surface
to the first pixel of the last row
*/
pBufferInfo+=lockinfo.bufferoffset;
pBufferInfo+= lockinfo.ypitch * (nHeight-1);
int x, y;
//iterate over the pixels and copy each pixel to its target pixel to create the surface
for(y = 0 ; y < nHeight ; y++)
{
for(x = 0 ; x < nWidth ; x++)
{
*((unsigned char *)(pBufferInfo)) = *((unsigned char*)(pTmpPixelData));
*((unsigned char *)(pBufferInfo+1)) = *((unsigned char*)(pTmpPixelData+1));
*((unsigned char *)(pBufferInfo+2)) = *((unsigned char*)(pTmpPixelData+2));
pTmpPixelData += 3;
pBufferInfo += lockinfo.xpitch;
}
//move the target pointer to the previous row and to the first pixel of that row
pBufferInfo -= lockinfo.ypitch + x * lockinfo.xpitch;
}
if(pPixelData)
{
ClassEMemory::DeAlloc(pPixelData);
}
m_pSnapShotSurface->Unlock();
m_pDisplay->SetShading(E3D_TEXTURE);
m_pDisplay->UploadTexture(m_pSnapShotSurface);
}
Well... this works just fine under the PC emulator, but on the device I get a black screen with some dirty pixels at the bottom.
What am I doing wrong ?
Is there a different, more efficient way to do draw back the pixel data?