draw2DImage - without clipping

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.
Post Reply
AlfAlien
Posts: 20
Joined: Tue Jan 28, 2014 2:08 pm

draw2DImage - without clipping

Post by AlfAlien »

draw2DImage() in COpenGLDriver class will render image relative to screen coordinates (so even if camera moves the image will kind of move with it). I want the image to be rendered only at it's specific position (call it absolute position) - so when camera moves the image will scroll out and then disappear. I tried to modify draw2DImage() method. It compiles but it renders nothing.

Code: Select all

 
void COpenGLDriver::draw2DImageAbsoluteCoordinates(const video::ITexture* texture, const core::position2d<s32>& pos)
{
        //1st -> must specify coordinates for vertices and UVs
    const core::dimension2d<u32>& textureSize = texture->getOriginalSize();
    const core::rect<f32> tcoords(0, 1, 1, 0); // rect has only upper left and lower right corners that we must specify
    const core::rect<s32> poss(pos.X, pos.Y, pos.X + textureSize.Width, pos.Y + textureSize.Height); // texture position
        
        // all the code below wasn't modified
    disableTextures(1);
    if (!setActiveTexture(0, texture))
        return;
 
    glBegin (GL_QUADS);
 
    glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
    glVertex2f(GLfloat(poss.UpperLeftCorner.X), GLfloat(poss.UpperLeftCorner.Y));
 
    glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
    glVertex2f(GLfloat(poss.LowerRightCorner.X), GLfloat(poss.UpperLeftCorner.Y));
 
    glTexCoord2f(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
    glVertex2f(GLfloat(poss.LowerRightCorner.X), GLfloat(poss.LowerRightCorner.Y));
 
    glTexCoord2f(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
    glVertex2f(GLfloat(poss.UpperLeftCorner.X), GLfloat(poss.LowerRightCorner.Y));
 
    glEnd();
}
 
Please, help!
horvatha4
Posts: 12
Joined: Sun Feb 23, 2014 6:03 am
Location: Rheiland-Pfalz, Germany
Contact:

Re: draw2DImage - without clipping

Post by horvatha4 »

Maybe this is a better solution/class for you: irr::scene::IBillboardSceneNode
AlfAlien
Posts: 20
Joined: Tue Jan 28, 2014 2:08 pm

Re: draw2DImage - without clipping

Post by AlfAlien »

Yes, I already use it, but this seems to be the most straightforward approach.
Post Reply