Fullscreen issues

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Fullscreen issues

Post by abrams.b.a »

Hey everybody!

I've been wanting to create a low resolution game to be a bit more like the NES games, however I'm running up against some issues.

When I try to use fullscreen it doesn't seem to be actually going fullscreen. The only thing that's happening is a window is being drawn in the top corner of my screen without any border. I've tried to maximize the window via the device and instead I get something like that:

Image
My Irrlicht device is drawn in the corner and everything else is black.

I've also tried making it not fullscreen and allowing the window to be resized, hoping the device would stretch to match the resolution of the window, which doesn't happen either.
Image

I've tried to peek around the API and in the methods of the interfaces to see but I'm not really sure where else to search, or what to search for. Does anybody have some tips on where to start searching?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Fullscreen issues

Post by hybrid »

What about some code? Though you tell us some details, it's far from knowing what you really do. And even if the code is completely correct, we might still give some hints how to do things better regarding the Irrlicht part.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Fullscreen issues

Post by CuteAlien »

And for stuff like fullscreen behaviour please also mention the OS you are using. For a quick test if it is working at all use the Irrlicht Demo - that has a fullscreen option. If that's not working there is likely some problem with Irrlicht on your system - if that is working then it's more likely something in your code.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: Fullscreen issues

Post by abrams.b.a »

hybrid wrote:What about some code? Though you tell us some details, it's far from knowing what you really do. And even if the code is completely correct, we might still give some hints how to do things better regarding the Irrlicht part.
Sure, I'm using Windows 7 and the OpenGL driver, as for code there really isn't too much to be shown.

Code: Select all

 
IrrlichtService * IrrlichtService::instance = NULL;
IrrlichtService * IrrlichtService::Instance()
{
    if ( instance == NULL )
        instance = new IrrlichtService();
    return instance;
}
 
IrrlichtService::IrrlichtService()
{
    irrlichtDevice = createDevice( EDT_OPENGL, // type of renderer
                                   dimension2d<u32>(256,240), // dimension of window
                                   32, // bits
                                   true, // fullscreen
                                   false, // stencil buffer
                                   true, // vsync
                                   NULL );
    irrlichtDevice->setResizable(true);
    videoDriver = irrlichtDevice->getVideoDriver();
    guiEnvironment = irrlichtDevice->getGUIEnvironment();
}
 
and my main loop mostly just contains this

Code: Select all

 
    ITexture * link = video->getTexture("link.png");
    while ( service->IsRunning() )
    {
        video->beginScene(true,true,SColor(255,45,10,10));
        video->draw2DImage( link, vector2d<s32>(0,0), rect<s32>(0,0,16,32), 0, SColor(255,255,255,255), true );
        video->endScene();
    }
 
CuteAlien wrote:And for stuff like fullscreen behaviour please also mention the OS you are using. For a quick test if it is working at all use the Irrlicht Demo - that has a fullscreen option. If that's not working there is likely some problem with Irrlicht on your system - if that is working then it's more likely something in your code.
The demo is working OK, so I'll check out the source code for that that report back if that was any help, thanks for the tip!
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Fullscreen issues

Post by hendu »

That's the thing - the draw2D methods are pixel-accurate.

You can either use your own relative drawing, or render to a RTT of that size, and then render that to the screen to blow it up (without bilinear to make it look blocky).
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: Fullscreen issues

Post by abrams.b.a »

hendu wrote:That's the thing - the draw2D methods are pixel-accurate.

You can either use your own relative drawing, or render to a RTT of that size, and then render that to the screen to blow it up (without bilinear to make it look blocky).
Is it pixel accurate based on the resolution of the desktop or the resolution that you passed to the createDevice function? I'm not disputing the positioning of things.

If I use render to target as well I'd have to either assign that to a sort of ISceneNode* and then work inside a 3D space, or use the draw function again which would be a redudant step (or am I thinking about it incorrectly?)

EDIT: Also on the issue of the fullscreen thing, I can't seem to find anything different that the Demo uses that I don't. The only thing I saw was in the Demo it uses createDeviceEx(), so I switched to that but that also isn't working.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Fullscreen issues

Post by hendu »

Is it pixel accurate based on the resolution of the desktop or the resolution that you passed to the createDevice function? I'm not disputing the positioning of things.
The current resolution of the irrlicht window.

If you tell it to draw a 16x16 picture to position 0x0, it will draw it as 16x16 no matter what your window has been resized to. Anything else would be just weird for normal use.
If I use render to target as well I'd have to either assign that to a sort of ISceneNode* and then work inside a 3D space, or use the draw function again which would be a redudant step (or am I thinking about it incorrectly?)
Sorry, I don't understand you.
Mikhail9
Posts: 54
Joined: Mon Jun 29, 2009 8:41 am

Re: Fullscreen issues

Post by Mikhail9 »

Is it possible your video card doesn't support your requested resolution? Mine only goes down to 640 x 480 using DirectX. I doubt GL would go lower.
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: Fullscreen issues

Post by abrams.b.a »

Mikhail9 wrote:Is it possible your video card doesn't support your requested resolution? Mine only goes down to 640 x 480 using DirectX. I doubt GL would go lower.
I have an Nvidia GeForce GTX 460, and I get the same result no matter what resolution I use.
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: Fullscreen issues

Post by abrams.b.a »

Update on the fullscreen issue:

I was having problems even with 640x480 originally (as in not drawing the entire screen, I'm not sure why). I reinstalled my video drivers and now it's working with 640x480. I tried again with 256x240 and got the same issue of not using the entire screen. So Mikhail9 was correct, thanks for the help.

Hendu, I'm assuming you mean something like this?
Image

I have 2 cubes active in my scene right now (I don't have a 3D modeling tool so I'm using addCubeSceneNode and scaling them to the size I want.) But I'm a bit confused about the specific details.

My first cube is the background image:

Code: Select all

 
    ISceneNode * mapN = scene->addCubeSceneNode( 1.0F );
    mapN->setScale( vector3df( 640.0F, 480.0F, 1.0F ) );
    mapN->setPosition( vector3d<f32>(0,0,1) );
 
I've created a cube, scaled it to a window resolution (640x480) and pushed it 1 unit back to compenstate for the Z sticking out 1 unit so that the node face is aligned at Z = 0.

Next I have a cube created for the 'hero' running around the map scaled at 32x32

Code: Select all

 
    ISceneNode * heroN = scene->addCubeSceneNode( 1.0F );
    heroN->setScale( vector3d<f32>( 32.0f, 32.0f, 1.0f ) );
    heroN->setPosition( vector3d<f32>(0,0,1) );
 
The binlinear filtering is disabled on both meshes to keep the sharp pixels.

As it is now 1 image pixel = 1 irrlicht pixel ( the images I used were 16x16 that I scaled up myself to 32x32 ). However I'm not entirely sure how to align the camera to always match this. At first I positioned the camera at -640 units on the Z axis, and I get something like this:

Code: Select all

 
    camera->setPosition( vector3d<f32>(0,0,-640.0F) );
    camera->setTarget( vector3d<f32>(0,0,0) );
 
Image

So I figured if I divided it in half I'd get the correct pixel ratio, but it's still not fine:

Code: Select all

 
    camera->setPosition( vector3d<f32>(0,0,-320.0F) );
    camera->setTarget( vector3d<f32>(0,0,0) );
 
Image

Confused I just randomly pushed the camera back 10 units and this gives me a result in the first screenshots.

I'm guessing this may have something to do with the perspective of the camera? Or I'm not sure about the mathematics behind the positioning.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Fullscreen issues

Post by sudi »

use an orthogonal projection matrix.
matrix for has functions for that. buildProjectionMatrixOrthoLH and buildProjectionMatrixOrthoRH
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: Fullscreen issues

Post by abrams.b.a »

Sudi wrote:use an orthogonal projection matrix.
matrix for has functions for that. buildProjectionMatrixOrthoLH and buildProjectionMatrixOrthoRH
Thanks! Though I don't fully understand it.
Image

My vertical pixels are at a 1:1, but my horizontal are pretty off. I'll do a bit of research on this.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Fullscreen issues

Post by sudi »

make the cube scale 1,1 the otho matrix streches it automaticly
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
abrams.b.a
Posts: 13
Joined: Tue Jul 19, 2011 10:17 am
Location: Eindhoven, NL

Re: Fullscreen issues

Post by abrams.b.a »

Sudi wrote:make the cube scale 1,1 the otho matrix streches it automaticly
Well I've seen matricies but I've never really understood it all (reading up on it now). Also with the function I filled in the height for the width and the width for the height by accident.
http://www.songho.ca/opengl/gl_projectionmatrix.html

Though now I've got values that seem to at least make sense that I can reproduce consistently across multiple resolutions and my image pixel to screen pixel ration is staying 1:1 with nice sharp pixels (and also in fullscreen):
Image

(I rotated the hero scenenode to make sure the pixels were 1:1)

Thanks for the help everybody!
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Fullscreen issues

Post by hendu »

You're going about it way too difficult :)

I meant:

1. Draw to a 240x120 (or whatever your target is) texture/RTT, using the standard draw2D calls
2. Blit it to the screen using a screen quad, those are available in the snippets forum

Much simpler.


Of course if you want 3d effects, then this wouldn't be enough.
Post Reply