Help with event listener

Problems building or running the engine, queries about how to use features etc.
Post Reply
MkAlister
Gnoblar
Posts: 1
Joined: Sat Jan 29, 2022 8:26 am

Help with event listener

Post by MkAlister »

Hello, i try write example with input from keyboard or mouse, but event not invoke, not showing any updates and in log
only <Start setup> string from OgreApp::seput .
My OS ubuntu 20.04, ogre version 1.12

PluginFolder=/usr/lib/x86_64-linux-gnu/OGRE-1.12
Plugin=RenderSystem_GL
Plugin=Plugin_DotScene.so

Code: Select all

class Eventer: public OgreBites::InputListener{
	OgreApp* _oga;
	Ogre::Degree deg_cam;
	public:
	Eventer(OgreApp* oga):OgreBites::InputListener(){
		_oga = oga;
		deg_cam=0;
	}
	
	
	
	bool keyPressed(const OgreBites::KeyboardEvent& evt)
{
	_oga->log->logMessage("key event");
    if (evt.keysym.sym == 'w')
    {
		
        //getRoot()->queueEndRendering();
        Ogre::Vector3 vec = _oga->camNode->getPosition();
		Ogre::Quaternion qn;
		deg_cam+=Ogre::Degree(30.0);
		Ogre::Radian rad(deg_cam);
		qn.FromAngleAxis(rad,Ogre::Vector3(0,1,0));
		_oga->camNode->setOrientation(qn);
    }
    
    return InputListener::keyPressed(evt);
}

Code: Select all

class OgreApp : public OgreBites::ApplicationContext
void OgreApp::setup(void)
{
	//Ogre::FreeImageCodec::startup();
    // do not forget to call the base first
    OgreBites::ApplicationContext::setup();
    Eventer* ev = new Eventer(this);
    addInputListener(ev);
     Ogre::Root* mRoot = getRoot();
    log = new Ogre::Log("Custom");
    log->logMessage("Start setup");

Code: Select all

int main(int argc, char *argv[])
{
    OgreBites app;
    app.initApp();
    app.getRoot()->startRendering();
    
    app.closeApp();
    return 0;
}
I run SampleBrowser from examples, but main window program not respond by mouse and keyboard
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Help with event listener

Post by paroj »

you likely compiled Ogre without SDL2, which is required for input event handling. Check the CMake output to verify.
MkAlister
Gnoblar
Posts: 1
Joined: Sat Jan 29, 2022 8:26 am

Re: Help with event listener

Post by MkAlister »

This message by cmake run
-- The following external packages were located on your system.
-- This installation will have the extra features provided by these packages.
+ freeimage
+ freetype
+ X11
+ OpenGL
+ OpenGL ES 2.x
+ Python
+ pugixml
+ zlib
+ Assimp
+ SDL2
+ Doxygen
+ Xaw

I test with custom add SDL support

Code: Select all

SDL_Window *win =  SDL_CreateWindow("sdl",
                              0, 0, width,
                              height, SDL_WINDOW_OPENGL);
	
    Ogre::Root * mRoot = new Ogre::Root();
	mRoot->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL.so");
	Ogre::RenderSystem *rs = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
	
	mRoot->setRenderSystem(rs);
	rs->setConfigOption("Full Screen", "no");
	rs->setConfigOption("Video Mode", "800 x 600 16-bit colour");
	mRoot->initialise(false);
	
	
	
	
	
	SDL_SysWMinfo info;
    SDL_VERSION(&info.version);
    Ogre::NameValuePairList misc;
    misc["currentGLContext"] = Ogre::String("True");
    misc["externalGLControl"] = Ogre::String("True");
    Ogre::RenderWindow *renderWindow = mRoot->createRenderWindow("MainRenw", 1024, 768, false, &misc);
	renderWindow->setVisible(true);
but error
what(): RenderingAPIException: currentGLContext was specified with no current GL context in EGLWindow::create
Last edited by MkAlister on Sat Jan 29, 2022 5:50 pm, edited 1 time in total.
Post Reply