GLX platform doesn't work without InputReader::capture()

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Azatoth
Gnome
Posts: 327
Joined: Sat Jul 10, 2004 6:46 pm
Location: Sweden
x 4
Contact:

GLX platform doesn't work without InputReader::capture()

Post by Azatoth »

If compiled with "--with-gl-support=GLX --with-platform=GLX", nothing will be rendered (i.e. it will not enter the rendering loop) unless InputReader::capture is called. I'd guess it has something to do with XNextEvent(mDisplay,&event); being called in GLXInput::capture().

I noticed this when I tried to use the debian packages, since they use the GLX platform. Now, I use SDL for input, using my own classes and never touching the Ogre event system. When Ogre is compiled for the SDL platform, there's no problem, since SDL_Init(...) already is called. But there are a number of problems when using ogre compiled for GLX. In order to get the SDL input to work I would need a way to tell SDL to attach to an already created window, but I can't seem to find a way to do that. A call to SDL_SetVideoMode(...) creates a new separate window.
Also, I need to do things differently depending on the platform used, for example not call SDL_Init if SDL is used, but call it if GLX is used. But I could find no method in PlatformManager which tells me what underlying system is used. I could always use getInputReader and dynamically cast the return value until I've found out what kind of class it is, but there must be a better way.
makob
Kobold
Posts: 32
Joined: Wed Jan 28, 2004 10:09 pm
Location: Aalborg, Denmark

Post by makob »

I think I've bumped into the same problem - I also use the Debian packages and use SDL as the input driver. When I start my Ogre program, the screen simply goes 'black' :? I havn't dived into the issues as deeply as you, but I did find out that the renderloop never starts (eventhough i call Root::startRender()).

I don't know if this is related only to fog's Debian packages, or it's an "upstream bug" -- wumpus, you're in charge of the GLX driver, right? Can you confirm this?

Anyhow, with the 1.0.0 release on it's way (yiiiihaaaar! 8)) I guess a fix for Hastur is out of the question :P

Cheers, and keep up the good work,
-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: »

If you don't use the Ogre event system, you do your own X event handling right? In which case you or your windowing system should call XNextEvent/XPeekEvent.

An X application without X event loop will not display anything. I don't see how this is a bug in Ogre.
User avatar
Azatoth
Gnome
Posts: 327
Joined: Sat Jul 10, 2004 6:46 pm
Location: Sweden
x 4
Contact:

Post by Azatoth »

Well, that kinda breaks the platform agnostic nature of Ogre then, if the behaviour is different depending on whether SDL or GLX is used as the platform for the libs.
I don't use any X event handling code, I use SDL event handling. Now, in SDL mode the behaviour is that everything renders independant of whether an InputReader is present or not. If the library used is compiled against GLX this is not true; the behaviour has changed. If you really don't think this is a bug, at least make it so that the other platforms breaks if InputReader::capture() isn't called first.

One of the main benefits of using SDL is not having to care about how event and input is managed on all the different platforms SDL is implemented on. I really don't want to write three different sets of input handling code (SDL, GLX and DIrectX) since this is already taken care of by SDL. And that's why I need to know if there's some way to attach SDL to an already created window (i.e. the one created by GLX). As far as I know, there is no way to do this, but I was hoping that someone with more experience in SDL could help me.

If there is no way to do this, I will have to write three different input managers and at runtime decide which to use. To do that I could either do some dynamic casts and check the pointer, or use some kind of mechanism to query the PlatformManager about the currently running subsystem. I would prefer the latter.
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: »

It sounds like a good idea to use the SDL glsupport and not GLX if you use SDL.

Anyway, it just might be a bug if you do use some input system as you can be sure that SDL internally uses XEvent* on a X platform. I'll have a look at it later.
User avatar
Azatoth
Gnome
Posts: 327
Joined: Sat Jul 10, 2004 6:46 pm
Location: Sweden
x 4
Contact:

Post by Azatoth »

As I understand it after looking through the code, one cannot set the instance of GLSupport used by OgreGLRenderSystem; that is decided at compilation by what version of OgreGLUtil.h is used.

SDL uses XEvent* internally, but only for windows created by SDL. So a window created by GLX will never recieve any XEvent* calls from SDL (unless there's a way to attach SDL to an already created window).
User avatar
Azatoth
Gnome
Posts: 327
Joined: Sat Jul 10, 2004 6:46 pm
Location: Sweden
x 4
Contact:

Post by Azatoth »

I was wrong: it's not possible to dynamically cast the InputReader since the headers for the different platforms aren't available.
I've been searching through the code, but I can't see how I can get any information about the underlying platform. Is there no such functionality?

There's a hack in SDL which involves setting the environment variable SDL_WINDOWID to an already existing window. But it is a hack, it doesn't work on many platforms, it should not be used, and most important: it doesn't help with the event handling. So it can't be used.

A better solution to this problem (i.e. not having to write three different event managers) would be if the architecture would allow the platform to be set at run time. As it is now, once you compile for GLX you can't use SDL. Would it be possible to make it so that the instance of GLSupport that is used could be changed at runtime? So that an application which uses SDL could tell Ogre to use an instance of SDLGLSupport instead of the default GLXGLSupport?
Post Reply