Changed OpenGL default Renderstate to ALPHA_TEST being disabled. Some indentation changes in other files.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@786 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-07-13 23:33:17 +00:00
parent 63b756e8db
commit 838ea26474
5 changed files with 62 additions and 70 deletions

View File

@ -1,5 +1,10 @@
Changes in version 1.4 (... 2007)
- Fixed some OpenGL renderstate stuff. setBasicRenderstate returns with
active texture layer 0. The material renderer must return from OnUnset
with the same active texture layer. The alpha test is disabled and the
texture mode should be GL_MODULATE.
- Fixed CSoftwareTexture2::getOriginalSize, reported by CaptainPants. Added a
new method CSoftwareTexture2::getMaxSize to return the size of the largest
mipmap, which is used by texelarea instead of getOriginalSize.

View File

@ -17,9 +17,9 @@ namespace gui
{
//! constructor
CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool clip,
bool drawBack, bool moveOverSelect)
CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool clip,
bool drawBack, bool moveOverSelect)
: IGUIListBox(environment, parent, id, rectangle), Selected(-1), ItemHeight(0),
TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0),
ScrollBar(0), Selecting(false), DrawBack(drawBack),
@ -37,7 +37,7 @@ CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
!clip);
ScrollBar->setSubElement(true);
ScrollBar->setTabStop(false);
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
ScrollBar->drop();
ScrollBar->setPos(0);
@ -48,7 +48,7 @@ CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
// this element can be tabbed to
setTabStop(true);
setTabOrder(-1);
updateAbsolutePosition();
}
@ -199,9 +199,9 @@ bool CGUIListBox::OnEvent(SEvent event)
switch(event.EventType)
{
case EET_KEY_INPUT_EVENT:
if (event.KeyInput.PressedDown &&
(event.KeyInput.Key == KEY_DOWN ||
event.KeyInput.Key == KEY_UP ||
if (event.KeyInput.PressedDown &&
(event.KeyInput.Key == KEY_DOWN ||
event.KeyInput.Key == KEY_UP ||
event.KeyInput.Key == KEY_HOME ||
event.KeyInput.Key == KEY_END ||
event.KeyInput.Key == KEY_NEXT ||
@ -210,10 +210,10 @@ bool CGUIListBox::OnEvent(SEvent event)
s32 oldSelected = Selected;
switch (event.KeyInput.Key)
{
case KEY_DOWN:
Selected += 1;
case KEY_DOWN:
Selected += 1;
break;
case KEY_UP:
case KEY_UP:
Selected -= 1;
break;
case KEY_HOME:
@ -227,10 +227,13 @@ bool CGUIListBox::OnEvent(SEvent event)
break;
case KEY_PRIOR:
Selected -= AbsoluteRect.getHeight() / ItemHeight;
break;
default:
break;
}
if (Selected >= (s32)Items.size())
Selected = Items.size() - 1;
else
else
if (Selected<0)
Selected = 0;
@ -247,10 +250,10 @@ bool CGUIListBox::OnEvent(SEvent event)
e.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
Parent->OnEvent(e);
}
return true;
}
else
else
if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE ) )
{
if (Parent)
@ -278,6 +281,8 @@ bool CGUIListBox::OnEvent(SEvent event)
if (event.GUIEvent.Caller == this)
Selecting = false;
}
default:
break;
}
break;
case EET_MOUSE_INPUT_EVENT:
@ -295,20 +300,20 @@ bool CGUIListBox::OnEvent(SEvent event)
IGUIElement *el = Environment->getRootGUIElement()->getElementFromPoint(
core::position2di(event.MouseInput.X, event.MouseInput.Y));
if (Environment->hasFocus(this) &&
if (Environment->hasFocus(this) &&
ScrollBar == el &&
ScrollBar->OnEvent(event))
{
return true;
}
Selecting = true;
Environment->setFocus(this);
return true;
}
case EMIE_LMOUSE_LEFT_UP:
if (Environment->hasFocus(this) &&
if (Environment->hasFocus(this) &&
ScrollBar->isPointInside(p) &&
ScrollBar->OnEvent(event))
return true;
@ -320,7 +325,7 @@ bool CGUIListBox::OnEvent(SEvent event)
break;
}
Selecting = false;
Selecting = false;
selectNew(event.MouseInput.Y);
return true;
@ -333,6 +338,8 @@ bool CGUIListBox::OnEvent(SEvent event)
return true;
}
}
default:
break;
}
}
break;
@ -353,7 +360,7 @@ void CGUIListBox::selectNew(s32 ypos, bool onlyHover)
if (Selected >= (s32)Items.size())
Selected = Items.size() - 1;
else
else
if (Selected<0)
Selected = 0;
@ -392,7 +399,7 @@ void CGUIListBox::draw()
// draw background
core::rect<s32> frameRect(AbsoluteRect);
// draw items
core::rect<s32> clientClip(AbsoluteRect);
@ -433,8 +440,8 @@ void CGUIListBox::draw()
{
core::position2di iconPos = textRect.UpperLeftCorner;
iconPos.Y += textRect.getHeight() / 2;
iconPos.X += ItemsIconWidth/2;
IconBank->draw2DSprite( (u32)Items[i].icon, iconPos, &clientClip,
iconPos.X += ItemsIconWidth/2;
IconBank->draw2DSprite( (u32)Items[i].icon, iconPos, &clientClip,
skin->getColor((i==Selected) ? EGDC_ICON_HIGH_LIGHT : EGDC_ICON),
(i==Selected) ? selectTime : 0 , (i==Selected) ? os::Timer::getTime() : 0, false, true);
}
@ -466,20 +473,20 @@ s32 CGUIListBox::addItem(const wchar_t* text, s32 icon)
Items.push_back(i);
recalculateItemHeight();
if (IconBank && icon > -1 &&
if (IconBank && icon > -1 &&
IconBank->getSprites().size() > (u32)icon &&
IconBank->getSprites()[(u32)icon].Frames.size())
{
u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber;
if (IconBank->getPositions().size() > rno)
{
s32 w = IconBank->getPositions()[rno].getWidth();
const s32 w = IconBank->getPositions()[rno].getWidth();
if (w > ItemsIconWidth)
ItemsIconWidth = w;
}
}
return Items.size() - 1;
return Items.size() - 1;
}
@ -500,7 +507,7 @@ void CGUIListBox::recalculateScrollPos()
{
ScrollBar->setPos(ScrollBar->getPos() + selPos);
}
else
else
if (selPos > AbsoluteRect.getHeight() - ItemHeight)
{
ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight);
@ -553,7 +560,6 @@ void CGUIListBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadW
u32 i;
for (i=0; i<Items.size(); ++i)
addItem(tmpText[i].c_str(), tmpIcons[i].c_str());
this->setSelected(in->getAttributeAsInt("Selected"));
*/

View File

@ -4,7 +4,7 @@
#include "IVideoDriver.h"
#include "ITexture.h"
namespace irr
namespace irr
{
namespace gui
{
@ -18,7 +18,6 @@ CGUISpriteBank::CGUISpriteBank(IGUIEnvironment* env) :
if (Driver)
Driver->grab();
}
}
CGUISpriteBank::~CGUISpriteBank()
@ -31,7 +30,6 @@ CGUISpriteBank::~CGUISpriteBank()
// drop video driver
if (Driver)
Driver->drop();
}
core::array< core::rect<s32> >& CGUISpriteBank::getPositions()
@ -81,8 +79,9 @@ void CGUISpriteBank::setTexture(u32 index, video::ITexture* texture)
//! draws a sprite in 2d with scale and color
void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos, const core::rect<s32>* clip,
const video::SColor& color, u32 starttime, u32 currenttime, bool loop, bool center)
void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos,
const core::rect<s32>* clip, const video::SColor& color,
u32 starttime, u32 currenttime, bool loop, bool center)
{
if (index >= Sprites.size() || Sprites[index].Frames.empty())
return;
@ -106,7 +105,7 @@ void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos, const
return;
core::rect<s32> &r = Rectangles[rn];
if (center)
{
core::position2di p = pos;
@ -118,7 +117,7 @@ void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di& pos, const
Driver->draw2DImage(tex, pos, r, clip, color, true);
}
}
} // namespace gui

View File

@ -1051,7 +1051,6 @@ bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture)
if (stage >= MaxTextureUnits)
return false;
// Not working, texture confusion in menu of Meshviewer.
if (CurrentTexture[stage]==texture)
return true;
@ -1187,6 +1186,7 @@ void COpenGLDriver::setRenderStates3DMode()
{
// Reset Texture Stages
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE );
glDisable(GL_ALPHA_TEST);
glDisable( GL_BLEND );
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_COLOR );

View File

@ -53,8 +53,6 @@ public:
// thanks to Murphy, the following line removed some
// bugs with several OpenGL implementations.
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_ALPHA_TEST);
}
}
};
@ -91,6 +89,7 @@ public:
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, (f32) modulate );
glBlendFunc( getGLBlend(srcFact), getGLBlend(dstFact) );
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
if ( getTexelAlpha ( srcFact ) + getTexelAlpha ( dstFact ) )
@ -109,6 +108,7 @@ public:
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
}
private:
@ -171,13 +171,12 @@ public:
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_ALPHA_TEST);
}
}
};
@ -200,8 +199,6 @@ public:
if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates)
{
glDisable(GL_ALPHA_TEST);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
@ -238,8 +235,6 @@ public:
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
glDisable(GL_ALPHA_TEST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
@ -348,9 +343,7 @@ public:
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
}
@ -386,8 +379,6 @@ public:
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
glDisable(GL_ALPHA_TEST);
// diffuse map
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
@ -457,6 +448,7 @@ public:
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f );
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
}
}
};
@ -481,8 +473,6 @@ public:
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
glDisable(GL_ALPHA_TEST);
// diffuse map
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
@ -502,6 +492,7 @@ public:
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR);
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
}
}
}
@ -525,18 +516,8 @@ public:
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_ALPHA_TEST);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
@ -547,8 +528,6 @@ public:
virtual void OnUnsetMaterial()
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
}
@ -573,8 +552,6 @@ public:
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
glDisable(GL_ALPHA_TEST);
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
@ -611,16 +588,19 @@ public:
virtual void OnUnsetMaterial()
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // default value
Driver->extGlActiveTexture(GL_TEXTURE1_ARB);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
}
};
@ -645,8 +625,6 @@ public:
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
@ -666,7 +644,6 @@ public:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
@ -684,6 +661,11 @@ public:
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->extGlActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // default value
}
}
//! Returns if the material is transparent.