in game switch to fullscreen , how to ?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
gabdab
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Re: in game switch to fullscreen , how to ?

Post by gabdab »

ok thanks. this kind of work .
I am having a problem with Linux not going back to previous screen resolution once I switch back from fullscreen .
device->closedevice() looks like giving troubles in this contest though, so I avoid using it.

Code: Select all

#include <irrlicht.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <iostream>
 
using namespace irr;
 
 
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
 
//#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
//#endif
 
int irr1(), irr3();
 
class MyEventReceiver : public IEventReceiver
{
public:
        // This is the one method that we have to implement
        virtual bool OnEvent(const SEvent& event)
        {
                // Remember whether each key is down or up
                if (event.EventType == irr::EET_KEY_INPUT_EVENT)
                        KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
 
                return false;
        }
 
        // This is used to check whether a key is being held down
        virtual bool IsKeyDown(EKEY_CODE keyCode) const
        {
                return KeyIsDown[keyCode];
        }
        
        MyEventReceiver()
        {
                for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
                        KeyIsDown[i] = false;
        }
 
private:
        // We use this array to store the current state of each key
        bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
 
int irr1()
{
        MyEventReceiver receiver;
        IrrlichtDevice *device =
                createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
                        false, false, false, &receiver);
 
        if (!device)
                return 1;
 
 
        device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
 
 
        IVideoDriver* driver = device->getVideoDriver();
        ISceneManager* smgr = device->getSceneManager();
        IGUIEnvironment* guienv = device->getGUIEnvironment();
 
 
        guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
                rect<s32>(10,10,260,22), true);
 
 
        smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
 
        while(device->run())
        {
                        if(receiver.IsKeyDown(irr::KEY_KEY_W)){
                                                driver->endScene();
                                                device->drop();
 
 
                                                irr3();
                        }
                driver->beginScene(true, true, SColor(255,100,101,140));
 
                smgr->drawAll();
                guienv->drawAll();
 
                driver->endScene();
        }
 
 
        device->drop();
 
        return 0;
}
 
int irr3()
{
        MyEventReceiver receiver;
        IrrlichtDevice *device =
                createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
                        true, false, false, &receiver);
 
        if (!device)
                return 1;
 
 
        device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
 
 
        IVideoDriver* driver = device->getVideoDriver();
        ISceneManager* smgr = device->getSceneManager();
        IGUIEnvironment* guienv = device->getGUIEnvironment();
 
 
        guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
                rect<s32>(10,10,260,22), true);
 
 
        smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
 
        while(device->run())
        {
                        if(receiver.IsKeyDown(irr::KEY_KEY_W)){
                                                driver->endScene();
                                                device->drop();
 
                                                irr1();
                        }
                driver->beginScene(true, true, SColor(255,100,101,140));
 
                smgr->drawAll();
                guienv->drawAll();
 
                driver->endScene();
        }
 
 
        device->drop();
 
        return 0;
}
 
int main(){
irr1();
 
return 0;
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: in game switch to fullscreen , how to ?

Post by hybrid »

I guess this wild mix of render loop fragments and in-loop device destruction will give far more problems than any resolution change. Don't escape the render loop while endScene was not called.
gabdab
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Re: in game switch to fullscreen , how to ?

Post by gabdab »

ok , thanks hybrid I'll test some more.
I would be curious to discuss more the 'qt directx/opengl widget window id' thing if someone is in the mood.
Post Reply