Results 1 to 5 of 5

Thread: Clanlib 9 CL_DisplayMessageQueue

  1. #1

    Default Clanlib 9 CL_DisplayMessageQueue

    I updated my project from cl 8.1 to cl 9 to gain some basic shader support. Anyway, things are acting funny with input. I updated my input handlers to run in cl 9, they seem to work correctly, giving me the same results I had in cl 8.

    The issue it seems is that anytime any system input is given, the CL_DisplayMessageQueue gets confused and the game loop stops iterating. My game loop is set up exactly how it was setup in cl 8 and the new things described in the cl 9 hello world project were added... so my loop looks something like this:

    Code:
    //simplified game loop
    while (foo)
    {
    		update(dt);
    		draw();
    
    		// Read messages from the windowing system message queue,
    		// if any are available:
    		if (CL_DisplayMessageQueue::has_messages())
    			CL_DisplayMessageQueue::process();
    
    		CL_System::sleep(10);
    }
    For an example, i have my fps being shown each loop. I display them in the console and render them to the window. They both give 58-60 frames. If I move the mouse, the frames being displayed on the screen and on the console stop being output. The screen display freezes. Break points indicate that the CL_DisplayMessageQueue:rocess(); is continuously being hit and the loop never progresses passed that. If I click in my game window, the program goes back to normal (outputting fps on screen and console). If i move the mouse it again freezes. This happens with all mouse/keyboard input.

    If i remove the CL_DisplayMessageQueue, i obviously don't get input to my window. I tried putting the CL_DisplayMessageQueue in its own thread and that also seems to not get the input. Is there a correct way to do this?

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    The code you display here should work, so that's not the explanation for why its not working. Are you using the latest SVN version? The reason I'm asking is because Rombust recently made an important fix on the message queue pump and before that it was acting quite dodgy.

    If that still doesn't fix it, can you reproduce the bug in one of our test projects? That would allow us to try see if it is happening here as well and attempt to debug it.

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Yes, the code should work

    In your code:

    Code:
    if (CL_DisplayMessageQueue::has_messages())
    			CL_DisplayMessageQueue::process();
    The "if (has_messages())" is not required.

    As:
    Code:
    void CL_DisplayMessageQueue::process()
    {
    	while(has_messages())
    	{
    		CL_DisplayWindowMessage message = get_message();
    		dispatch_message(message);
    	}
    }
    If your code does not work with the latest SVN, there is a fault somewhere.

    Does the Basic2D example work?

  4. #4

    Default

    I was using code from svn, which was up to date when last I tried... around sept ~28...

    this code creates the same issue and is the basic 2d hello world app on the clan lib 9 overview page, i added console output so you could see when the app gets lost in the input processor. I've decided that I'm not going to upgrade to cl9, its not as stable or complete as some of the threads on here suggest. I do appreciate the hard work put into it though.

    Code:
    #include <ClanLib/core.h>
    #include <ClanLib/display.h>
    #include <ClanLib/gl.h>
    #include <ClanLib/application.h>
    
    class DisplayApplication : public CL_ClanApplication
    {
    public:
       int main(int argc, CL_String::char_type** argv);
    };
    
    // Create global application object:
    // You MUST include this line or the application start-up will fail to
    // locate your application object.
    DisplayApplication app;
    
    int DisplayApplication::main(int argc, CL_String::char_type** argv)
    {
       // Create a console window for text-output if not available
       // Use printf or cout to display some text in your program
       CL_ConsoleWindow console("Console", 80, 10000);
    
       // Setup clanlib modules:
       CL_SetupCore setup_core;
       CL_SetupDisplay setup_display;
       CL_SetupGL setup_gl;
    
       // Create a window:
       CL_DisplayWindow window(cl_text("Hello World"), 640, 480);
    
       // Retrieve some commonly used objects:
       CL_GraphicContext gc = window.get_gc();
       CL_InputDevice keyboard = window.get_ic().get_keyboard();
       CL_Font font(gc, cl_text("Tahoma"), 20);
    
       // Loop until user hits escape:
       while (!keyboard.get_keycode(CL_KEY_ESCAPE))
       {
          // Display the error message
          CL_Console::write_line("text ");
    
          // Draw some text and lines:
          gc.clear(CL_Colorf::cadetblue);
          gc.set_font(font);
          CL_Draw::line(gc, 0, 0, 640, 480, CL_Colorf::yellow);
          gc.draw_text(10, 10, cl_text("Hello World!"), CL_Colorf::lightseagreen);
    CL_Console::write_line("Hello World! ");
    
          // Make the stuff visible:
          window.flip();
    
          // Read messages from the windowing system message queue,
          // if any are available:
          if (CL_DisplayMessageQueue::has_messages())
             CL_DisplayMessageQueue::process();
    
          // Avoid using 100% CPU in the loop:
          CL_System::sleep(10);
       }
    
       return 0;
    }

  5. #5
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    It should work in the latest SVN.

    0.9 Is still in development, in general it is relatively stable, but occasionally, big changes are still required.

Similar Threads

  1. Replies: 7
    Last Post: 08-26-2008, 09:57 PM
  2. Installing ClanLib 0.8 and ClanLib 0.9 on linux
    By rombust in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-15-2008, 09:51 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •