Merged from 1.6 branch, revisions 2936:3075. Several bugfixes for GUI, containers, file system.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3076 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2009-12-28 10:56:30 +00:00
parent 1b523f689b
commit a8229b3f10
23 changed files with 121 additions and 53 deletions

View File

@ -147,6 +147,16 @@ Changes in 1.7
----------------
Changes in 1.6.1
- Fix problem that the window did sometimes not get the keyboard focus in X11 in fullscreen. Add more debug output in case focus grabbing goes wrong.
- Fix screensize in videodriver when we didn't get the requested window size. This also prevents that gui-clicks are no longer synchronized with gui-drawing and elements can't be hit anymore.
- Bugfix: Prevent a crash when getTypeName was called for the guienvironment. EGUIET_ELEMENT got changed for this.
- Bugfix: Horizontal centered font with linebreaks draw now all lines. For example multiline TextSceneNodes work again.
- Bugfix: spinbox can no longer get in an endless loop due to floating point rounding error (found by slavik262)
- !!API change!! Disabled AntiAliasing of Lines in material default
Please enable this manually per material when sure that it won't lead to SW rendering.
@ -830,7 +840,7 @@ Changes in 1.6 (23.09.2009)
- Add a hitPosition out parameter to ISceneCollisionManager::getCollisionResultPosition() - this is a (small) API breaking change.
-------------------------------------
Changes in version 1.5.2 (??.??.2009)
Changes in version 1.5.2 (16.12.2009)
- Properly check boundaries in getFont and setFont.

View File

@ -85,12 +85,12 @@ enum EGUI_ELEMENT_TYPE
//! A window
EGUIET_WINDOW,
//! Not an element, amount of elements in there
EGUIET_COUNT,
//! Unknown type.
EGUIET_ELEMENT,
//! Not an element, amount of elements in there
EGUIET_COUNT,
//! This enum is never used, it only forces the compiler to compile this enumeration to 32 bit.
EGUIET_FORCE_32_BIT = 0x7fffffff
@ -122,6 +122,7 @@ const c8* const GUIElementTypeNames[] =
"toolBar",
"treeview",
"window",
"element",
0
};

View File

@ -216,8 +216,8 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
}
}
delete verts;
delete faces;
delete [] verts;
delete [] faces;
}
// delete all buffers without geometry in it.

View File

@ -460,7 +460,6 @@ io::path CFileSystem::getAbsolutePath(const io::path& filename) const
return tmp;
#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))
c8* p=0;
c8 fpath[4096];
fpath[0]=0;
p = realpath(filename.c_str(), fpath);

View File

@ -357,7 +357,7 @@ void CGUIFileOpenDialog::fillListBox()
int len = mbstowcs(ws,cs,strlen(cs));
ws[len] = 0;
s = ws;
delete ws;
delete [] ws;
#else
s = FileSystem->getWorkingDirectory();
#endif

View File

@ -470,7 +470,7 @@ void CGUIFont::draw(const core::stringw& text, const core::rect<s32>& position,
if (!Driver)
return;
core::dimension2d<s32> textDimension;
core::dimension2d<s32> textDimension; // NOTE: don't make this u32 or the >> later on can fail when the dimension widht is < position width
core::position2d<s32> offset = position.UpperLeftCorner;
if (hcenter || vcenter || clip)
@ -516,8 +516,7 @@ void CGUIFont::draw(const core::stringw& text, const core::rect<s32>& position,
if ( hcenter )
{
core::dimension2d<u32> lineDim = getDimension(text.c_str());
offset.X += (position.getWidth() - lineDim.Width) >> 1;
offset.X += (position.getWidth() - textDimension.Width) >> 1;
}
continue;
}

View File

@ -236,9 +236,9 @@ bool CGUISpinBox::OnEvent(const SEvent& event)
void CGUISpinBox::verifyValueRange()
{
f32 val = getValue();
if ( val < RangeMin )
if ( val+core::ROUNDING_ERROR_f32 < RangeMin )
val = RangeMin;
else if ( val > RangeMax )
else if ( val-core::ROUNDING_ERROR_f32 > RangeMax )
val = RangeMax;
else
return;

View File

@ -300,6 +300,37 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
}
#if defined(_IRR_COMPILE_WITH_X11_)
void IrrPrintXGrabError(int grabResult, const c8 * grabCommand )
{
if ( grabResult == GrabSuccess )
{
// os::Printer::log(grabCommand, ": GrabSuccess", ELL_INFORMATION);
return;
}
switch ( grabResult )
{
case AlreadyGrabbed:
os::Printer::log(grabCommand, ": AlreadyGrabbed", ELL_WARNING);
break;
case GrabNotViewable:
os::Printer::log(grabCommand, ": GrabNotViewable", ELL_WARNING);
break;
case GrabFrozen:
os::Printer::log(grabCommand, ": GrabFrozen", ELL_WARNING);
break;
case GrabInvalidTime:
os::Printer::log(grabCommand, ": GrabInvalidTime", ELL_WARNING);
break;
default:
os::Printer::log(grabCommand, ": grab failed with unknown problem", ELL_WARNING);
break;
}
}
#endif
bool CIrrDeviceLinux::createWindow()
{
#ifdef _IRR_COMPILE_WITH_X11_
@ -601,10 +632,13 @@ bool CIrrDeviceLinux::createWindow()
XSetWMProtocols(display, window, &wmDelete, 1);
if (CreationParams.Fullscreen)
{
XGrabKeyboard(display, window, True, GrabModeAsync,
XSetInputFocus(display, window, RevertToParent, CurrentTime);
int grabKb = XGrabKeyboard(display, window, True, GrabModeAsync,
GrabModeAsync, CurrentTime);
XGrabPointer(display, window, True, ButtonPressMask,
IrrPrintXGrabError(grabKb, "XGrabKeyboard");
int grabPointer = XGrabPointer(display, window, True, ButtonPressMask,
GrabModeAsync, GrabModeAsync, window, None, CurrentTime);
IrrPrintXGrabError(grabPointer, "XGrabPointer");
XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0);
}
}
@ -690,6 +724,9 @@ bool CIrrDeviceLinux::createWindow()
XGetGeometry(display, window, &tmp, &x, &y, &Width, &Height, &borderWidth, &bits);
CreationParams.Bits = bits;
CreationParams.WindowSize.Width = Width;
CreationParams.WindowSize.Height = Height;
StdHints = XAllocSizeHints();
long num;
XGetWMNormalHints(display, window, StdHints, &num);

View File

@ -288,6 +288,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
dev->postEventFromUser(event);
return 0;
case WM_SETCURSOR:
// because Windows forgot about that in the meantime
dev = getDeviceFromHWnd(hWnd);
if (dev)
dev->getCursorControl()->setVisible( dev->getCursorControl()->isVisible() );
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}

View File

@ -135,31 +135,23 @@ namespace irr
{
CURSORINFO info;
info.cbSize = sizeof(CURSORINFO);
if ( visible )
BOOL gotCursorInfo = GetCursorInfo(&info);
while ( gotCursorInfo )
{
while ( GetCursorInfo(&info) )
if ( (visible && info.flags == CURSOR_SHOWING) // visible
|| (!visible && info.flags == 0 ) ) // hidden
{
if ( info.flags == CURSOR_SHOWING )
{
IsVisible = visible;
break;
}
ShowCursor(true); // this only increases an internal display counter in windows, so it might have to be called some more
}
}
else
int showResult = ShowCursor(visible); // this only increases an internal display counter in windows, so it might have to be called some more
if ( showResult < 0 )
{
while ( GetCursorInfo(&info) )
{
if ( info.flags == 0 ) // cursor hidden
{
IsVisible = visible;
break;
}
ShowCursor(false); // this only decreases an internal display counter in windows, so it might have to be called some more
}
info.cbSize = sizeof(CURSORINFO); // yes, it really must be set each time
gotCursorInfo = GetCursorInfo(&info);
}
IsVisible = visible;
}
//! Returns if the cursor is currently visible.

View File

@ -395,7 +395,15 @@ ITexture* CNullDriver::getTexture(const io::path& filename)
if (file)
{
texture = loadTextureFromFile(file, filename);
// Re-check name for actual archive names
texture = findTexture(file->getFileName());
if (texture)
{
file->drop();
return texture;
}
texture = loadTextureFromFile(file);
file->drop();
if (texture)

View File

@ -2455,8 +2455,6 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
if (resetAllRenderStates ||
lastmaterial.ColorMaterial != material.ColorMaterial)
{
if (material.ColorMaterial != ECM_NONE)
glEnable(GL_COLOR_MATERIAL);
switch (material.ColorMaterial)
{
case ECM_NONE:
@ -2478,6 +2476,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
break;
}
if (material.ColorMaterial != ECM_NONE)
glEnable(GL_COLOR_MATERIAL);
}
if (resetAllRenderStates ||

View File

@ -115,7 +115,8 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
ray.end = ray.start + (rayVector * sqrtf(toIntersectionSq));
}
}
else if (objectBox.intersectsWithLine(objectRay))
else
if (objectBox.intersectsWithLine(objectRay))
{
// Now transform into world space, since we need to use world space
// scales and distances.

View File

@ -497,6 +497,7 @@ namespace scene
{
TerrainData.Scale = scale;
applyTransformation();
calculateNormals(RenderBuffer);
ForceRecalculation = true;
}

View File

@ -60,7 +60,8 @@ bool disambiguateTextures(void)
readFile->drop();
// All 3 of the above textures should be identical.
assert(tex1 == tex2 && tex1 == tex3);
assert(tex1 == tex2);
assert(tex1 == tex3);
stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());

View File

@ -95,3 +95,4 @@ bool filesystem(void)
result |= testFlattenFilename(fs);
return result;
}

View File

@ -62,14 +62,11 @@ bool loadFromFileFolder(void)
// adding a folder archive
device->getFileSystem()->addFolderFileArchive( "../media/" );
// NOTE: Allow that this creates a new texture even if it is the same file.
// The reason is that we _want_ to allow accessing the same texture with different names in other contexts,
// so we can't use the absolute filename for identification.
ITexture * tex3 = driver->getTexture("tools.png");
assert(tex3);
if(!tex3)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+2)
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
@ -79,14 +76,14 @@ bool loadFromFileFolder(void)
assert(tex4);
if(!tex4)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+2)
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
device->drop();
return (tex1 == tex2 && tex3 == tex4);
return ((tex1 == tex2) && (tex1 == tex3) && (tex1 == tex4));
}
bool loadTextures()

View File

@ -203,6 +203,8 @@ int main(int argumentCount, char * arguments[])
FILE * testsLastPassedAtFile = fopen("tests-last-passed-at.txt", "w");
if(testsLastPassedAtFile)
{
(void)fprintf(testsLastPassedAtFile, "Tests finished. %d test%s of %d passed.\n",
passed, 1 == passed ? "" : "s", numberOfTests);
(void)fprintf(testsLastPassedAtFile, "Test suite pass at GMT %s\n", asctime(timeinfo));
(void)fclose(testsLastPassedAtFile);
}

View File

@ -349,6 +349,8 @@ bool sceneCollisionManager(void)
bool result = testGetCollisionResultPosition(device, smgr, collMgr);
smgr->clear();
result &= testGetSceneNodeFromScreenCoordinatesBB(device, smgr, collMgr);
result &= getScaledPickedNodeBB(device, smgr, collMgr);

View File

@ -133,7 +133,7 @@ static bool doTests()
tmp.getAngle(), ref.getAngle());
return false;
}
val = atan2f((float)tmp.Y, (float)tmp.X)*core::RADTODEG;
val = atan2f((f32)tmp.Y, (f32)tmp.X)*core::RADTODEG;
if (val<=0)
val=-val;
else

View File

@ -1,2 +1,3 @@
Test suite pass at GMT Mon Dec 21 20:14:01 2009
Tests finished. 44 tests of 44 passed.
Test suite pass at GMT Mon Dec 28 10:51:50 2009

View File

@ -226,10 +226,22 @@
RelativePath=".\guiDisabledMenu.cpp"
>
</File>
<File
RelativePath=".\irrArray.cpp"
>
</File>
<File
RelativePath=".\irrCoreEquals.cpp"
>
</File>
<File
RelativePath=".\irrList.cpp"
>
</File>
<File
RelativePath=".\irrMap.cpp"
>
</File>
<File
RelativePath=".\irrString.cpp"
>
@ -298,10 +310,6 @@
RelativePath=".\terrainSceneNode.cpp"
>
</File>
<File
RelativePath=".\testArray.cpp"
>
</File>
<File
RelativePath=".\testDimension2d.cpp"
>

View File

@ -189,7 +189,7 @@ inline u32 getTextureSizeFromSurfaceSize(u32 size)
u32 lastTextureHeight = getTextureSizeFromSurfaceSize(currenty);
// delete the glyph set
delete buf;
delete [] buf;
currentImages.set_used(currentImage+1);
currentTextures.set_used(currentImage+1);