[with fix] Increase the viewport region

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
TheMrCerebro
Competition winner
Posts: 80
Joined: Tue Jun 29, 2010 10:06 pm
Location: Valencia, Spain

[with fix] Increase the viewport region

Post by TheMrCerebro »

Hi!.

I am developing a 2d game with Irrlicht and is a resolution of 160x144.

It is assumed that with the setViewport, could change the size of the view but I can not increase in a window 320x288 in order to see the larger region. I want to increase a region of the window to fill the window.

Someone can help me? :roll:
Last edited by TheMrCerebro on Wed Aug 17, 2011 5:32 pm, edited 1 time in total.
Follow me on twitter: @themrcerebro
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Increase the viewport region

Post by hybrid »

No, setViewport can set a new render area inside the original window. This creates a partial render area, which uses the original resolution again in the smaller area. It is, e.g., used for multi-view games as shown in example 18.
TheMrCerebro
Competition winner
Posts: 80
Joined: Tue Jun 29, 2010 10:06 pm
Location: Valencia, Spain

Re: [SOLVED] Increase the viewport region

Post by TheMrCerebro »

Already is solved :wink: (but I had to modify the function setViewPort.

only for 2D with OpenGL.

Code: Select all

 
void COpenGLDriver::setViewPort(const core::rect<s32>& area)
{
        core::rect<s32> vp = area;
        core::rect<s32> rendert(0,0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height);
        //vp.clipAgainst(rendert); <----------------------------------------
 
        if (vp.getHeight()>0 && vp.getWidth()>0)
                glViewport(vp.UpperLeftCorner.X,
                                getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(),
                                vp.getWidth(), vp.getHeight());
 
        ViewPort = vp;
}
 
Follow me on twitter: @themrcerebro
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [SOLVED] Increase the viewport region

Post by hybrid »

Ok, now I understand what you intend. You'd like to get a larger region to be shown in your window. Say, having a window of 800x600 you'd like to have 1600x1200 to be rendered into the screen. This should indeed be possible, and the current implementation of setViewport does prohibit it. But I need to check d3d as well, and see what happens there.
Moving to bug reports while investigating.
TheMrCerebro
Competition winner
Posts: 80
Joined: Tue Jun 29, 2010 10:06 pm
Location: Valencia, Spain

Re: [with fix] Increase the viewport region

Post by TheMrCerebro »

Huuuoooooo!! Thanks Hybrid :D

I found another engine (that specializes only in "2D") that it does, but I refuse to use another engine, even for 2D. I have all the best of Irrlicht and its source code and I'm comfortable with it.

I appreciate your attention.
Follow me on twitter: @themrcerebro
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [with fix] Increase the viewport region

Post by hybrid »

Ok, as I feared. There's a restriction for D3D. It won't support negative x/y values. Which would be very handy for large screens. Otherwise they are not centered anymore. It sounds as if a matrix shift would help here. If someone has an idea or a link, please chime in. So maybe we start with a first try with only positive area values?!
TheMrCerebro
Competition winner
Posts: 80
Joined: Tue Jun 29, 2010 10:06 pm
Location: Valencia, Spain

Re: [with fix] Increase the viewport region

Post by TheMrCerebro »

I just found a modification to do what he wanted, without modifying the source code of Irrlicht (Only works for 2D).

Code: Select all

 
core::matrix4 m;
glMatrixMode(GL_MODELVIEW);
m.setTranslation(core::vector3df(400-240,300-216, 0));
m.setScale(3);
glLoadMatrixf(m.pointer());
 
Now I can center and resize the scene. :D (i'm happy)
Follow me on twitter: @themrcerebro
Post Reply