Text showing up as blocks [FIXED]

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

knight666
Just popping in
Just popping in
Posts: 7
Joined: Sat Jul 18, 2009 21:36

Text showing up as blocks [FIXED]

Postby knight666 » Sun May 30, 2010 19:06

I'm trying to integrate CEGUI into my template, which uses SDL to render to a texture, which is then displayed as a quad.

These are the results I'm getting:

Image

And this is (hopefully) the relevant bit of code:

Code: Select all

   void Renderer::Swap()
   {

#ifdef SWAP_OLD

      glClear(GL_COLOR_BUFFER_BIT);

      CEGUI::System::getSingleton().renderGUI();

      SDL_GL_SwapBuffers();

#else

      if (vbo)
      {      
         // set up render mode

         glViewport(0, 0, SCRWIDTH, SCRHEIGHT);
         glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(0, 1, 0, 1, -1, 1);
         glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();

         // frame buffer swapping for VBO mode

         static int index = 0;
         int nextindex;

         glActiveTextureARB(GL_TEXTURE0_ARB);
         glEnable(GL_TEXTURE_2D);
         glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
         glBindTexture(GL_TEXTURE_2D, framebufferTexID[index]);
         glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, fbPBO[index]);
         glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, SCRWIDTH, SCRHEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, 0);

         nextindex = (index + 1) % 2;
         index = (index + 1) % 2;

         glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, fbPBO[nextindex]);   
         framedata = (unsigned char*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);

         // draw game quad

         glColor3f(1.0f, 1.0f, 1.0f);
         glBegin(GL_QUADS);
            glNormal3f(0, 0, 1);
            glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 1.0f);
            glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 1.0f);
            glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 0.0f);
            glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 0.0f);
         glEnd();

         // interface drawing

         glViewport(0, 0, SCRWIDTH, SCRHEIGHT);
         glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(0, SCRWIDTH, SCRHEIGHT, 1, -100, 100);
         glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();

         glActiveTextureARB(GL_TEXTURE1_ARB);
         glEnable(GL_TEXTURE_2D);
         glBindTexture(GL_TEXTURE_2D, g_GUITexture);

         glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, SCRWIDTH, SCRHEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, 0);
         
         CEGUI::System::getSingleton().renderGUI();

         // draw a quad

         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);

         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);

         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

         glBegin(GL_QUADS);
         {
            glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);
            glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);
            glVertex2f(0.0f, 1.0f);

            glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f);
            glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f);
            glVertex2f(1.0f, 1.0f);

            glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f);
            glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f);
            glVertex2f(1.0f, 0.0f);

            glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f);
            glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f);
            glVertex2f(0.0f, 0.0f);
         }
         glEnd();

         SDL_GL_SwapBuffers();

         // reset

         glActiveTextureARB(GL_TEXTURE0_ARB);
         glDisable(GL_TEXTURE_2D);
         glActiveTextureARB(GL_TEXTURE1_ARB);
         glDisable(GL_TEXTURE_2D);
      }
      else   
      {
         // frame buffer swapping for fall-back path

         SDL_Surface* s = SDL_GetVideoSurface();
         SDL_UpdateRect(s, 0, 0, 0, 0);
         framedata = (unsigned char*)s->pixels;
         frontbuffer->SetPitch(s->pitch / 4);
      }

      frontbuffer->SetBuffer((Pixel*)framedata);

#endif

   }


And here's how I instantiate CEGUI:

Code: Select all

      CEGUI::Size screen_size(SCRWIDTH, SCRHEIGHT);
      //g_GUIRenderer = &CEGUI::OpenGLRenderer::create(screen_size, CEGUI::OpenGLRenderer::TTT_NONE);
      g_GUIRenderer = &CEGUI::OpenGLRenderer::create(screen_size);
      g_GUIRenderer->enableExtraStateSettings(true);

      g_GUISystem = &CEGUI::System::create(*g_GUIRenderer);

      CEGUI::DefaultResourceProvider* provider = (CEGUI::DefaultResourceProvider*)CEGUI::System::getSingleton().getResourceProvider();
      provider->setResourceGroupDirectory("fonts", "fonts\\");
      provider->setResourceGroupDirectory("schemes", "F:\\Downloads\\CEGUI-0.7.1\\CEGUI-0.7.1\\datafiles\\schemes\\");
      provider->setResourceGroupDirectory("imagesets", "F:\\Downloads\\CEGUI-0.7.1\\CEGUI-0.7.1\\datafiles\\imagesets\\");
      provider->setResourceGroupDirectory("looknfeel", "F:\\Downloads\\CEGUI-0.7.1\\CEGUI-0.7.1\\datafiles\\looknfeel\\");

      CEGUI::Imageset::setDefaultResourceGroup("imagesets");
      CEGUI::Font::setDefaultResourceGroup("fonts");
      CEGUI::Scheme::setDefaultResourceGroup("schemes");
      CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeel");
      CEGUI::WindowManager::setDefaultResourceGroup("layouts");

      CEGUI::String look_namespace("WindowsLook");
      CEGUI::String look_file("WindowsLook.scheme");

      CEGUI::SchemeManager::getSingleton().create(look_file);

      CEGUI::FontManager::getSingleton().createFreeTypeFont("Consolas", 12.f, true, "DejaVuSans.ttf", "fonts");
      CEGUI::System::getSingleton().setDefaultFont("Consolas");

      glGenTextures(1, &g_GUITexture);

      CEGUI::DefaultWindow* root = (CEGUI::DefaultWindow*)CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "root");
      CEGUI::System::getSingleton().setGUISheet(root);

      //CEGUI::FrameWindow* fw = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().createWindow(look_namespace + "/FrameWindow");
      CEGUI::FrameWindow* fw = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().createWindow(look_namespace + "/StaticImage");
      fw->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25f, 0.f), CEGUI::UDim(0.25f, 0.f)));
      fw->setSize(CEGUI::UVector2(CEGUI::UDim(0.5f, 0.f), CEGUI::UDim(0.5f, 0.f)));
      fw->setText("Hello World!");
      root->addChildWindow(fw);
      

      CEGUI::PushButton* btn = (CEGUI::PushButton*)CEGUI::WindowManager::getSingleton().createWindow(look_namespace + "/Button");
      btn->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25f, 0.f), CEGUI::UDim(0.5f, 0.f)));
      btn->setSize(CEGUI::UVector2(CEGUI::UDim(0.5f, 0.f), CEGUI::UDim(0.25f, 0.f)));
      btn->setText("I'm a button!");
      fw->addChildWindow(btn);


Even when I strip out everything and just use SDL I get blocks for text.

What's going on?
Last edited by knight666 on Tue Jun 01, 2010 13:29, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Text showing up as blocks

Postby CrazyEddie » Mon May 31, 2010 07:45

I think it's an old bug, can't know for sure since you did not post your CEGUI.log :P

Try upgrading to the latest snapshot viewtopic.php?f=6&t=4704 and see if this fixes it for you :)

CE.

knight666
Just popping in
Just popping in
Posts: 7
Joined: Sat Jul 18, 2009 21:36

Re: Text showing up as blocks

Postby knight666 » Mon May 31, 2010 17:50

Sorry. ;) I'm using CEGUI 0.7.1, which is the latest stable build on the main site.

Code: Select all

31/05/2010 08:18:49 (Std)    ---- Version 0.7.1 (Build: May 29 2010 Microsoft Windows MSVC++ 9.0 32 bit) ----
31/05/2010 08:18:49 (Std)    ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module.  TextureTarget support enabled via FBO extension. ----
31/05/2010 08:18:49 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
31/05/2010 08:18:49 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
31/05/2010 08:18:49 (Std)    ---- Scripting module is: None ----


In the mean time I've tried rendering to an FBO, but my texture always comes up empty. I'm sure it's not CEGUI though, even a simple OpenGL scene doesn't show up in the texture.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Text showing up as blocks

Postby CrazyEddie » Tue Jun 01, 2010 08:50

Yeah, as I say, 0.7.1 has related bugs (not certain about the FBO related issue though), so I can't look into the issue any further due to the version you're using and the fact I likely already fixed these issues. Your best bet is to either move to the stable branch subversion code (cegui_mk2/branches/v0-7) or grab one of the aforementioned snapshot releases; I wouldn't wait for an official 0.7.2 release, because you could be waiting a long time ;)

CE

knight666
Just popping in
Just popping in
Posts: 7
Joined: Sat Jul 18, 2009 21:36

Re: Text showing up as blocks

Postby knight666 » Tue Jun 01, 2010 13:27

I upgraded to the latest version, it didn't fix my problem.

But I did find out what the problem was.

The template I'm using uses OpenGL to manipulate pixels of a texture directly. It starts a VBO and never exits. It then binds GL_PIXEL_UNPACK_BUFFER_ARB like this:

Code: Select all

const int sizeMemory = 4 * SCRWIDTH * SCRHEIGHT;
glGenBuffers(2, fbPBO);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, fbPBO[0]);   
glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, sizeMemory, NULL, GL_STREAM_DRAW_ARB);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, fbPBO[1]);   
glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, sizeMemory, NULL, GL_STREAM_DRAW_ARB);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
glBindTexture(GL_TEXTURE_2D, framebufferTexID[0]);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, fbPBO[0]);
framedata = (unsigned char*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);


I fixed it by turning off the VBO and rendering CEGUI:

Code: Select all

// turn off VBO to make sure CEGUI works
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);

CEGUI::System::getSingleton().renderGUI();

// turn it on again
nextindex = (index + 1) % 2;
index = (index + 1) % 2;
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, fbPBO[nextindex]);   
framedata = (unsigned char*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);


But thanks for the help. :D

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Text showing up as blocks [FIXED]

Postby CrazyEddie » Wed Jun 02, 2010 08:58

Aha! Thanks for posting the eventual solution. I wonder if we could / should add these states to the 'extra states' that get reset - it's a bit of a balancing act, we clearly can't reset all states, though obviously we want to hit the common ones.

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 9 guests