SDL input under Linux using the GLX renderer

Problems building or running the engine, queries about how to use features etc.
makob
Kobold
Posts: 32
Joined: Wed Jan 28, 2004 10:09 pm
Location: Aalborg, Denmark

SDL input under Linux using the GLX renderer

Post by makob »

Hi folks,

I've been trying for some time to make the so-called SDL_WINDOWID hack work under Linux using the Debian packages of Ogre which are GLX things.

The problem is that SDL_PollEvent(...) never returns an event.

Here's what I do in the application:
  • 1. Create the root
    2. Create the renderwindow
    3. Use renderwindow->getCustomAttribute("GLXWINDOW", win)
    4. Set the environment variable SDL_WINDOWID=<win>. For <win> I've tried both "0x%X", "0x%x" and "%d" formatting
    5. Initialize SDL using SDL_Init(SDL_INIT_VIDEO)
    6. Expose the glx window interface: renderwindow->getCustomAttribute("GLXWINDOWINTERFACE", iface) iface->exposed(true);
    7. Initialize some things to look at (color, a mesh, blah blah)
    8. Set up a framelistener
    9. root->startRendering()
I see the Ogre GLX window, the skybox, the mesh and everything seems to run beautifully...

Now, the framelistener from step 8 of course has a SDL_PollEvent(&e) check and should dump something to my console whenever I hit a key or move the mouse (which is grabbed). But it doesn't :(
If I interrupt the application (CTRL+C) in the console, I do receive the SDL_QUIT event.

Does anyone have a clue on what I might be doing incorrectly?

I've tried moving around with step 5 (SDL_Init), but this shouldn't matter as long as the SDL_WINDOWID variable is set before the init-call. My application is single-threaded.

If I get it working, I'll update the wiki so nobody has to bang his/her head so hard at the keyboard as much as I have... :twisted:

Thanks,
Jakob
6 times 7 equals 42.
User avatar
discipline
OGRE Community Helper
OGRE Community Helper
Posts: 766
Joined: Mon May 16, 2005 12:09 am

Post by discipline »

Any luck with this yet? I'm getting my ogre window to open but it is blank. Works mostly with libgii or ogre's input. SDL seems to be initializing, but I get zero events, neither mouse nor keyboard.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

Hm, maybe the Ogre input system is snatching the SDL events from you? You don't call capture on the input listener do you?
makob
Kobold
Posts: 32
Joined: Wed Jan 28, 2004 10:09 pm
Location: Aalborg, Denmark

Post by makob »

:wumpus: wrote:Hm, maybe the Ogre input system is snatching the SDL events from you? You don't call capture on the input listener do you?
No I don't. Should I do that?

Edit: Btw, I don't the Ogre input system at all - I want to control all input myself (ie. poll event once every frame).

Cheers,
Jakob
6 times 7 equals 42.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

No, you shouldn't do that. Maybe you got the syntax of the window handle wrong. I think it should include a display* as well as a window handle.
makob
Kobold
Posts: 32
Joined: Wed Jan 28, 2004 10:09 pm
Location: Aalborg, Denmark

Post by makob »

:wumpus: wrote:No, you shouldn't do that. Maybe you got the syntax of the window handle wrong. I think it should include a display* as well as a window handle.
Like in

Code: Select all

SDL_WINDOWID=display:window
I've already tried that, and it doesn't work, sorry. Same goes for various combinations of both screen, window and display (X handles), upper- and lowercase hex, integers, etc. etc.
Tough luck :(

If anyone gets SDL to work with a GLX-based Ogre, I'd be very interested in the solution, however, I've abandoned SDL for the moment. My plan is to write my own (LGPL'ed) input library which grabs event for the given X display/window pair "correctly" and without all the fuzz and weirdinesss of libgii.

The library will probably be written in C and mimic the API of SDL very closely...
6 times 7 equals 42.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

What about ripping the input component from SDL, and making it more friendly in attaching without environment hacks? I've thought about that various times, but never got around to it. But I think the SDL input component has by far the best portability and support, so it would be the preffered way IMO.
makob
Kobold
Posts: 32
Joined: Wed Jan 28, 2004 10:09 pm
Location: Aalborg, Denmark

Post by makob »

Yes, it's something like that I have in mind.

Once I finish my exams, (next week, hooray!) I'll start on the library and keep you posted on my progress! :-)
6 times 7 equals 42.
User avatar
discipline
OGRE Community Helper
OGRE Community Helper
Posts: 766
Joined: Mon May 16, 2005 12:09 am

Post by discipline »

:wumpus: wrote:Hm, maybe the Ogre input system is snatching the SDL events from you? You don't call capture on the input listener do you?
No. I'm working on stripping down my code to the bare minimum. What I've found so far is that if I use Ogre's Input these three lines determine whether ogre renders or not:

Code: Select all

mEventProcessor = new EventProcessor();
        mEventProcessor->initialise(win);
        mEventProcessor->startProcessingEvents();
If I exclude these I get a blank window.

My libgii module does not use these at all, but renders just fine. My libsdl module does not use them but gives me a blank window. Something in giiOpen and the above lines appears to be doing something that allows Ogre to render to the window. I'll strip down a file more and post it.
User avatar
discipline
OGRE Community Helper
OGRE Community Helper
Posts: 766
Joined: Mon May 16, 2005 12:09 am

Post by discipline »

Because this is more than SDL on GLX, I've created a new thread here: http://www.ogre3d.org/phpBB2/viewtopic. ... 9480#79480

This apparent EventProcessor requirement is preventing me from debugging SDL further. I can open a new window with SDL and I do get events, however can't do much with it until I can render.
User avatar
discipline
OGRE Community Helper
OGRE Community Helper
Posts: 766
Joined: Mon May 16, 2005 12:09 am

Post by discipline »

Well, SDL doesn't work for me either. I can get it to draw my screen but get zero input. Without this hack, I get neither input nor will ogre render and no one has run my code to test if it is a bug or a problem with my system (see thread above). On to other libraries...
User avatar
Azatoth
Gnome
Posts: 327
Joined: Sat Jul 10, 2004 6:46 pm
Location: Sweden
x 4

Post by Azatoth »

I've finally gotten SDL input to work with the GLX platform. I've updated the wiki with instructions: http://ogre3d.org/wiki/index.php/Using_SDL_Input
Ember, GPL virtual world client.
Development blog