Page 1 of 1

Fonts on MacOSX

Posted: Fri Mar 18, 2005 12:29
by scruffya
I just upgraded CEGUI and OGRE to the newest versions,
I am running the GUI example in the OGRE Samples Directory,
my text is not displaying correctly in the CEGUI Widgets.
It has a yellow backgroud.

Re: Fonts on MacOSX

Posted: Fri Mar 18, 2005 13:09
by Guest
Are you sure your app is linked with the right library? After compiling CEGUI, you have to check that your ogre project accesses the new files before compiling it again.

It could also be a font problem (if you use a static font with no alpha in your image file for example). Did you modified something related with that?

--
Chris

Re: Fonts on MacOSX

Posted: Fri Mar 18, 2005 22:10
by CrazyEddie
This is an endian issue. I'm not sure where this got broken since nothing in CEGUI was changed. Obviously I want to fix this, but it's rather difficult since I don't have access to a Mac, and as such I can't reproduce the issue to debug it :?

CE.

Re: Fonts on MacOSX

Posted: Wed May 11, 2005 17:20
by fats
* Bump *

This yellow background is bugging me too. It makes the fonts almost unreadable. If somebody can point me in the right direction, I will attempt to fix the problem.

Re: Fonts on MacOSX

Posted: Thu May 12, 2005 02:00
by _mental_
Unforunately I am in the same situation as CE was with regards to OSX. I'll see if I can get temas to take a look if he has time, otherwise if anyone with OSX wants to take a stab at fixing this I'd greatly appreciate it.

Re: Fonts on MacOSX

Posted: Thu May 12, 2005 09:34
by zakalawe
On the quite likely assumption that I'm going to hit this issue in the near future (trying to get our 'ember' client which is Ogre + CEGUI running), could someone provide a few hints on where this problem lies, so I don't have to learn the entire codebase.

Eg, is it specific to the OGRE renderer? Does it happen on Linux-PPC? Any other hints as to where to start debugging?

Re: Fonts on MacOSX

Posted: Wed Jun 01, 2005 08:27
by asu
In case someone is interested, this is quite an easy fix. As Crazy Eddie suggested, it's an endian issue. All i did was to implement byte swapping in the OgreCEGUITexture.cpp file inside the loadFromMemory member function.

It looks like this now:

//--asu start
//byte swapping utils

void _ByteSwap(unsigned char * b, int n)
{
register int i = 0;
register int j = n-1;
while (i<j)
{
std::swap(b[i], b[j]);
i++, j--;
}
}

#define ByteSwap(x) _ByteSwap((unsigned char *) &x,sizeof(x))
//--asu end

void OgreCEGUITexture::loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight)
{
using namespace Ogre;

// get rid of old texture
freeOgreTexture();

// wrap input buffer with an Ogre DataChunk
uint32 bytesize = ((buffWidth * sizeof(uint32)) * buffHeight);

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
//do byte swapping -- asu start
uint32 *swappedBuffer = new uint32[bytesize/4];
memcpy(swappedBuffer, buffPtr, bytesize);

for (int i=0;i<bytesize/4;i++)
ByteSwap(swappedBuffer[i]);

DataStreamPtr odc(new MemoryDataStream((void*)(swappedBuffer), bytesize, false));
// -- asu end
#else
DataStreamPtr odc(new MemoryDataStream(const_cast<void*>(buffPtr), bytesize, false));
#endif

// try to create a Ogre::Texture from the input data
d_ogre_texture = TextureManager::getSingleton().loadRawData(getUniqueName(), "General", odc, buffWidth, buffHeight, PF_A8R8G8B8, TEX_TYPE_2D, 0, 1.0f);

// if we got a pointer cache some details
if (!d_ogre_texture.isNull())
{
d_width = d_ogre_texture->getWidth();
d_height = d_ogre_texture->getHeight();
}
// no texture from memory so throw.
else
{
throw RendererException((utf8*)"Failed to create Texture object from memory: Ogre returned a NULL Ogre::Texture pointer.");
}

}

Sorry for the formating. I'm not really used to this...

Re: Fonts on MacOSX

Posted: Wed Jun 01, 2005 08:46
by CrazyEddie
Cool :)

Somebody should get this change into CVS.

Do you know if the issue affects the plain OpenGL renderer as well as the Ogre one?

Thanks for that.

CE.

Re: Fonts on MacOSX

Posted: Thu Jun 02, 2005 02:39
by _mental_
I've committed this to the OGRE renderer with a small modification. Thanks!