[not a bug] bug in COpenGLDriver::draw2DImage( ... )

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
radubolovan
Posts: 60
Joined: Tue Nov 13, 2007 7:03 pm
Location: Bucharest - Romania
Contact:

[not a bug] bug in COpenGLDriver::draw2DImage( ... )

Post by radubolovan »

I saw the code in function:

Code: Select all

void COpenGLDriver::draw2DImage(const video::ITexture* texture,
				const core::position2d<s32>& pos,
				const core::rect<s32>& sourceRect,
				const core::rect<s32>* clipRect, SColor color,
				bool useAlphaChannelOfTexture)
And there are some lines of code:

Code: Select all

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));
Shouldn't be:

Code: Select all

glTexCoord2f(0, 0);
glVertex2f(GLfloat(poss.UpperLeftCorner.X), GLfloat(poss.UpperLeftCorner.Y));

glTexCoord2f(1, 0);
glVertex2f(GLfloat(poss.LowerRightCorner.X), GLfloat(poss.UpperLeftCorner.Y));

glTexCoord2f(1, 1);
glVertex2f(GLfloat(poss.LowerRightCorner.X), GLfloat(poss.LowerRightCorner.Y));

glTexCoord2f(0, 1);
glVertex2f(GLfloat(poss.UpperLeftCorner.X), GLfloat(poss.LowerRightCorner.Y));
???

With code <1>, if the tcoords is bigger then the rect of the texture, the texture doesn't grow/stretch, but multiplies itself into that rect :lol:
With code <2> it works just fine.

But I don't know if this is a bug or if that was the design of that function ...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, that is intended because you can specify a position and a source rectangle together with a clipping rectangle. All this may lead to a smaller part of the image being drawn, hence we need texture coords which are between 0 and 1.
radubolovan
Posts: 60
Joined: Tue Nov 13, 2007 7:03 pm
Location: Bucharest - Romania
Contact:

Post by radubolovan »

I see!
And what should I do if I want to draw an image in a rectangle for example:
1) tex is 50x50 pixels
2) rectangle is 100x100 pixels
3) I want the texture to be drawn having 100x100 pixels.
I've tried that with that function and I saw nothing but my texture drawn having 50x50 pixels and the rest 'till 100x100 is transparent
(Sorry for my english language :( )
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

use the other draw2dimage method, the one that takes a destination rect rather than a position-

Code: Select all

IVideoDriver:: draw2DImage (video::ITexture *texture, 
    const core::rect< s32 > &destRect, 
    const core::rect< s32 > &sourceRect, 
    const core::rect< s32 > *clipRect=0, 
    video::SColor *colors=0, 
    bool useAlphaChannelOfTexture=false)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply