Clipping Viewport to ScreenSize leads to distortion

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
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Clipping Viewport to ScreenSize leads to distortion

Post by gerdb »

Hi guys,

im currently making a gui plot for drawing functions and stuff,

when i move the window around, the view of my plot get distorted due to clipping to rendertargetsize.

This is not what i expect, pls help! Also when the clipping leads to zero pixels within, the whole viewport call fails -> renders to normal screen not within the gui element.

here example project with exe ( dll has only opengl driver, dont know whats happening in D3D )

pls tell me this is not wanted behaviour. Atleast make an if, that does no clipping when rendertarget is the normal screen.

thx

http://benjaminhampe.be.ohost.de/homepa ... GUIPlot.7z

Reign of Error

Code: Select all

 
// this code was sent in by Oliver Klems, thank you! (I modified the glViewport
// method just a bit.
void COpenGLDriver::setViewPort(const core::rect<s32>& area)
{
    if (area == ViewPort)
        return;
    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;
    }
}
 
normal ( nothing clipped )
Image
distorted
Image
complete fail ( window border visible at bottom )
Image
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Clipping Viewport to ScreenSize leads to distortion

Post by gerdb »

hi,

i corrected the setViewport function and now my shapes get not distorted anymore, but ITextSceneNode still does.

Code: Select all

// this code was sent in by Oliver Klems, thank you! (I modified the glViewport
// method just a bit.
void COpenGLDriver::setViewPort(const core::rect<s32>& area)
{
    if (area == ViewPort)
        return;
 
//  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;
//  }
    ViewPort = core::recti(
        core::position2di(
            area.UpperLeftCorner.X,
            getCurrentRenderTargetSize().Height - area.getHeight() - area.UpperLeftCorner.Y ),
        core::dimension2du( (u32)area.getWidth(), (u32)area.getHeight()) );
 
    glViewport(
        ViewPort.UpperLeftCorner.X,
        ViewPort.UpperLeftCorner.Y,
        ViewPort.getWidth(),
        ViewPort.getHeight() );
}
 
[new issue] When i project a vector3df to my plot's rect, the vector is still projected on screen and not my new ( smaller ) viewport.

1. i setViewport
2. hide all scenenodes except my emptyscenenode that is the parent of all shapes and my ortho-camera
3. activate the camera
4. then SceneManager->drawAll ( TextScenenode is distorted )
5. then i project vector to get 2d coords for my text
6. set old viewport
7. set all scenenodes visible again ( except the emptyscenenode that is root of all plot-shapes )
8. activate old camera
9. draw the text at calculated pos, but pos is wrong

Thats a real issue for me. The project is updated and here an image of my new problems

Image

thx
Last edited by gerdb on Sun Nov 24, 2013 8:36 pm, edited 2 times in total.
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: Clipping Viewport to ScreenSize leads to distortion

Post by gerdb »

hi, i got the projection working, forgot to save the new ViewPort var in changed irrlicht code.

The TextSceneNodes are still distorted, but i can use font->draw() as overlay to render text.

This should suffice now but i had to alter irrlicht.

Also Burning's VideoDriver still does not render EPT_LINE_STRIPs.

good night
chronologicaldot
Competition winner
Posts: 685
Joined: Mon Sep 10, 2012 8:51 am

Re: Clipping Viewport to ScreenSize leads to distortion

Post by chronologicaldot »

... I designed a GUI graph in case you're interested. I don't think it has any problems with the window resizing, but I haven't checked. You can find it in the IrrExt.
http://sourceforge.net/p/irrext/code/HE ... mpleGraph/

Oh yeah, and about Burning's... Sorry, I meant to get around to adding the missing primitives, but it'll take some time.
Post Reply