nCEGUI bug fix

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

HyperIris
Just popping in
Just popping in
Posts: 11
Joined: Tue Aug 01, 2006 09:21
Location: China
Contact:

nCEGUI bug fix

Postby HyperIris » Wed Sep 20, 2006 08:38

Nebula2 is a nice OpenSource 3D engine and nCEGUI is a adapter to join CEGUI with Nebula2.

But nCEGUI has some bug in it, here are the fixes:

1 In nceguiserver_main.cc add:

Code: Select all

void nCEGUIServer::Render()
{
   nGfxServer2::Instance()->Clear(nGfxServer2::DepthBuffer, 0,0,0,0, 1, 0);

   matrix44 matrix_Model;
   matrix44 matrix_View;
   matrix44 matrix_Projection;
   matrix_Model=nGfxServer2::Instance()->GetTransform(nGfxServer2::Model);
   matrix_View=nGfxServer2::Instance()->GetTransform(nGfxServer2::View);
   matrix_Projection=nGfxServer2::Instance()->GetTransform(nGfxServer2::Projection);
   //
   CEGUI::System::getSingleton().renderGUI();
   //
   nGfxServer2::Instance()->SetTransform(nGfxServer2::Model, matrix_Model);
   nGfxServer2::Instance()->SetTransform(nGfxServer2::View, matrix_View);
   nGfxServer2::Instance()->SetTransform(nGfxServer2::Projection, matrix_Projection);
}


2 In nebularenderer.h add:

Code: Select all

private:
    typedef void (* CopyColor)(float*, const CEGUI::colour&);

3 In nebularenderer.cc add:

Code: Select all

NebulaRenderer::NebulaRenderer(nGfxServer2 *gfxServer) :
   m_gfxServer(gfxServer),
   m_needsTextureSort(false)
{
   nShader2* shader = m_gfxServer->NewShader(0);
   switch(gfxServer->GetFeatureSet())
   {
   case nGfxServer2::DX9:
   case nGfxServer2::DX9FLT:
      shader->SetFilename("home:export/cegui/shaders/cegui.fx");
      m_CopyColorFunc = copyColor;
      break;

   default:
      shader->SetFilename("home:export/cegui/shaders/cegui-fixed.fx");
      m_CopyColorFunc = copyColorFFP;
      break;
   }

    if (!shader->IsLoaded())
    {
        bool success = shader->Load();
        n_assert(success);
    }
   m_dynamicMesh.SetShader(shader);

   m_transform.scale(vector3(2.0f/getWidth(), -2.0f/getHeight(), 1));
   m_transform.set_translation(vector3(-1.0f/getWidth()-1.0f, -1.0f/getHeight()+1.0f, 0));
}


Code: Select all

void NebulaRenderer::addQuad(
   const CEGUI::Rect &dest_rect,
   float z,
   const CEGUI::Texture *tex,
   const CEGUI::Rect &texture_rect,
   const CEGUI::ColourRect &colours,
   CEGUI::QuadSplitMode quad_split_mode)
{
    //...
rectVertices[TOPLEFT].coord[0] = dest_rect.d_left;
      rectVertices[TOPLEFT].coord[1] = dest_rect.d_top;
      rectVertices[TOPLEFT].coord[2] = z;
      rectVertices[TOPLEFT].uv0[0] = texture_rect.d_left;
      rectVertices[TOPLEFT].uv0[1] = texture_rect.d_top;
      m_CopyColorFunc(rectVertices[TOPLEFT].color, colours.d_top_left);

      rectVertices[BOTTOMLEFT].coord[0] = dest_rect.d_left;
      rectVertices[BOTTOMLEFT].coord[1] = dest_rect.d_bottom;
      rectVertices[BOTTOMLEFT].coord[2] = z;
      rectVertices[BOTTOMLEFT].uv0[0] = texture_rect.d_left;
      rectVertices[BOTTOMLEFT].uv0[1] = texture_rect.d_bottom;
      m_CopyColorFunc(rectVertices[BOTTOMLEFT].color, colours.d_bottom_left);

      rectVertices[BOTTOMRIGHT].coord[0] = dest_rect.d_right;
      rectVertices[BOTTOMRIGHT].coord[1] = dest_rect.d_bottom;
      rectVertices[BOTTOMRIGHT].coord[2] = z;
      rectVertices[BOTTOMRIGHT].uv0[0] = texture_rect.d_right;
      rectVertices[BOTTOMRIGHT].uv0[1] = texture_rect.d_bottom;
      m_CopyColorFunc(rectVertices[BOTTOMRIGHT].color, colours.d_bottom_right);

      rectVertices[TOPRIGHT].coord[0] = dest_rect.d_right;
      rectVertices[TOPRIGHT].coord[1] = dest_rect.d_top;
      rectVertices[TOPRIGHT].coord[2] = z;
      rectVertices[TOPRIGHT].uv0[0] = texture_rect.d_right;
      rectVertices[TOPRIGHT].uv0[1] = texture_rect.d_top;
      m_CopyColorFunc(rectVertices[TOPRIGHT].color, colours.d_top_right);
    //...
}


Code: Select all

static void copyColorFFP(float* dest, const CEGUI::colour &src)
{
   unsigned long* p = (unsigned long*)&(dest[0]);
   *p = (unsigned long)(((int)(src.getAlpha()* 255.0) & 0x000000FF) << 24 |
      ((int)(src.getRed()  * 255.0) & 0x000000FF) << 16 |
      ((int)(src.getGreen()* 255.0) & 0x000000FF) << 8 |
      ((int)(src.getBlue() * 255.0) & 0x000000FF));
   dest[1] = 0;
   dest[2] = 0;
   dest[3] = 0;
}
I am a GAME UI Programmer, but...
almost all of my computer knowledge is system programming, such as IA32/X64 asm, rootkits, WDM...

Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 11 guests