Commit a8229b3f authored by hybrid's avatar hybrid

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
parent 1b523f68
...@@ -147,6 +147,16 @@ Changes in 1.7 ...@@ -147,6 +147,16 @@ Changes in 1.7
---------------- ----------------
Changes in 1.6.1 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 - !!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. 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) ...@@ -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. - 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. - Properly check boundaries in getFont and setFont.
......
...@@ -85,12 +85,12 @@ enum EGUI_ELEMENT_TYPE ...@@ -85,12 +85,12 @@ enum EGUI_ELEMENT_TYPE
//! A window //! A window
EGUIET_WINDOW, EGUIET_WINDOW,
//! Not an element, amount of elements in there
EGUIET_COUNT,
//! Unknown type. //! Unknown type.
EGUIET_ELEMENT, 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. //! This enum is never used, it only forces the compiler to compile this enumeration to 32 bit.
EGUIET_FORCE_32_BIT = 0x7fffffff EGUIET_FORCE_32_BIT = 0x7fffffff
...@@ -122,6 +122,7 @@ const c8* const GUIElementTypeNames[] = ...@@ -122,6 +122,7 @@ const c8* const GUIElementTypeNames[] =
"toolBar", "toolBar",
"treeview", "treeview",
"window", "window",
"element",
0 0
}; };
......
...@@ -216,8 +216,8 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file) ...@@ -216,8 +216,8 @@ IAnimatedMesh* CDMFLoader::createMesh(io::IReadFile* file)
} }
} }
delete verts; delete [] verts;
delete faces; delete [] faces;
} }
// delete all buffers without geometry in it. // delete all buffers without geometry in it.
......
...@@ -460,7 +460,6 @@ io::path CFileSystem::getAbsolutePath(const io::path& filename) const ...@@ -460,7 +460,6 @@ io::path CFileSystem::getAbsolutePath(const io::path& filename) const
return tmp; return tmp;
#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) #elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))
c8* p=0; c8* p=0;
c8 fpath[4096]; c8 fpath[4096];
fpath[0]=0; fpath[0]=0;
p = realpath(filename.c_str(), fpath); p = realpath(filename.c_str(), fpath);
......
...@@ -357,7 +357,7 @@ void CGUIFileOpenDialog::fillListBox() ...@@ -357,7 +357,7 @@ void CGUIFileOpenDialog::fillListBox()
int len = mbstowcs(ws,cs,strlen(cs)); int len = mbstowcs(ws,cs,strlen(cs));
ws[len] = 0; ws[len] = 0;
s = ws; s = ws;
delete ws; delete [] ws;
#else #else
s = FileSystem->getWorkingDirectory(); s = FileSystem->getWorkingDirectory();
#endif #endif
......
...@@ -470,7 +470,7 @@ void CGUIFont::draw(const core::stringw& text, const core::rect<s32>& position, ...@@ -470,7 +470,7 @@ void CGUIFont::draw(const core::stringw& text, const core::rect<s32>& position,
if (!Driver) if (!Driver)
return; 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; core::position2d<s32> offset = position.UpperLeftCorner;
if (hcenter || vcenter || clip) if (hcenter || vcenter || clip)
...@@ -516,8 +516,7 @@ void CGUIFont::draw(const core::stringw& text, const core::rect<s32>& position, ...@@ -516,8 +516,7 @@ void CGUIFont::draw(const core::stringw& text, const core::rect<s32>& position,
if ( hcenter ) if ( hcenter )
{ {
core::dimension2d<u32> lineDim = getDimension(text.c_str()); offset.X += (position.getWidth() - textDimension.Width) >> 1;
offset.X += (position.getWidth() - lineDim.Width) >> 1;
} }
continue; continue;
} }
......
...@@ -236,9 +236,9 @@ bool CGUISpinBox::OnEvent(const SEvent& event) ...@@ -236,9 +236,9 @@ bool CGUISpinBox::OnEvent(const SEvent& event)
void CGUISpinBox::verifyValueRange() void CGUISpinBox::verifyValueRange()
{ {
f32 val = getValue(); f32 val = getValue();
if ( val < RangeMin ) if ( val+core::ROUNDING_ERROR_f32 < RangeMin )
val = RangeMin; val = RangeMin;
else if ( val > RangeMax ) else if ( val-core::ROUNDING_ERROR_f32 > RangeMax )
val = RangeMax; val = RangeMax;
else else
return; return;
......
...@@ -300,6 +300,37 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset) ...@@ -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() bool CIrrDeviceLinux::createWindow()
{ {
#ifdef _IRR_COMPILE_WITH_X11_ #ifdef _IRR_COMPILE_WITH_X11_
...@@ -601,10 +632,13 @@ bool CIrrDeviceLinux::createWindow() ...@@ -601,10 +632,13 @@ bool CIrrDeviceLinux::createWindow()
XSetWMProtocols(display, window, &wmDelete, 1); XSetWMProtocols(display, window, &wmDelete, 1);
if (CreationParams.Fullscreen) if (CreationParams.Fullscreen)
{ {
XGrabKeyboard(display, window, True, GrabModeAsync, XSetInputFocus(display, window, RevertToParent, CurrentTime);
int grabKb = XGrabKeyboard(display, window, True, GrabModeAsync,
GrabModeAsync, CurrentTime); GrabModeAsync, CurrentTime);
XGrabPointer(display, window, True, ButtonPressMask, IrrPrintXGrabError(grabKb, "XGrabKeyboard");
int grabPointer = XGrabPointer(display, window, True, ButtonPressMask,
GrabModeAsync, GrabModeAsync, window, None, CurrentTime); GrabModeAsync, GrabModeAsync, window, None, CurrentTime);
IrrPrintXGrabError(grabPointer, "XGrabPointer");
XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0); XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0);
} }
} }
...@@ -690,6 +724,9 @@ bool CIrrDeviceLinux::createWindow() ...@@ -690,6 +724,9 @@ bool CIrrDeviceLinux::createWindow()
XGetGeometry(display, window, &tmp, &x, &y, &Width, &Height, &borderWidth, &bits); XGetGeometry(display, window, &tmp, &x, &y, &Width, &Height, &borderWidth, &bits);
CreationParams.Bits = bits; CreationParams.Bits = bits;
CreationParams.WindowSize.Width = Width;
CreationParams.WindowSize.Height = Height;
StdHints = XAllocSizeHints(); StdHints = XAllocSizeHints();
long num; long num;
XGetWMNormalHints(display, window, StdHints, &num); XGetWMNormalHints(display, window, StdHints, &num);
......
...@@ -288,6 +288,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -288,6 +288,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
dev->postEventFromUser(event); dev->postEventFromUser(event);
return 0; 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); return DefWindowProc(hWnd, message, wParam, lParam);
} }
......
...@@ -135,31 +135,23 @@ namespace irr ...@@ -135,31 +135,23 @@ namespace irr
{ {
CURSORINFO info; CURSORINFO info;
info.cbSize = sizeof(CURSORINFO); info.cbSize = sizeof(CURSORINFO);
BOOL gotCursorInfo = GetCursorInfo(&info);
if ( visible ) while ( gotCursorInfo )
{ {
while ( GetCursorInfo(&info) ) if ( (visible && info.flags == CURSOR_SHOWING) // visible
|| (!visible && info.flags == 0 ) ) // hidden
{ {
if ( info.flags == CURSOR_SHOWING ) break;
{
IsVisible = visible;
break;
}
ShowCursor(true); // this only increases an internal display counter in windows, so it might have to be called some more
} }
} int showResult = ShowCursor(visible); // this only increases an internal display counter in windows, so it might have to be called some more
else if ( showResult < 0 )
{
while ( GetCursorInfo(&info) )
{ {
if ( info.flags == 0 ) // cursor hidden break;
{
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. //! Returns if the cursor is currently visible.
......
...@@ -395,7 +395,15 @@ ITexture* CNullDriver::getTexture(const io::path& filename) ...@@ -395,7 +395,15 @@ ITexture* CNullDriver::getTexture(const io::path& filename)
if (file) 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(); file->drop();
if (texture) if (texture)
......
...@@ -2455,8 +2455,6 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -2455,8 +2455,6 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
if (resetAllRenderStates || if (resetAllRenderStates ||
lastmaterial.ColorMaterial != material.ColorMaterial) lastmaterial.ColorMaterial != material.ColorMaterial)
{ {
if (material.ColorMaterial != ECM_NONE)
glEnable(GL_COLOR_MATERIAL);
switch (material.ColorMaterial) switch (material.ColorMaterial)
{ {
case ECM_NONE: case ECM_NONE:
...@@ -2478,6 +2476,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -2478,6 +2476,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
break; break;
} }
if (material.ColorMaterial != ECM_NONE)
glEnable(GL_COLOR_MATERIAL);
} }
if (resetAllRenderStates || if (resetAllRenderStates ||
......
...@@ -115,7 +115,8 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root, ...@@ -115,7 +115,8 @@ void CSceneCollisionManager::getPickedNodeBB(ISceneNode* root,
ray.end = ray.start + (rayVector * sqrtf(toIntersectionSq)); 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 // Now transform into world space, since we need to use world space
// scales and distances. // scales and distances.
......
...@@ -497,6 +497,7 @@ namespace scene ...@@ -497,6 +497,7 @@ namespace scene
{ {
TerrainData.Scale = scale; TerrainData.Scale = scale;
applyTransformation(); applyTransformation();
calculateNormals(RenderBuffer);
ForceRecalculation = true; ForceRecalculation = true;
} }
......
...@@ -60,7 +60,8 @@ bool disambiguateTextures(void) ...@@ -60,7 +60,8 @@ bool disambiguateTextures(void)
readFile->drop(); readFile->drop();
// All 3 of the above textures should be identical. // 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"; stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str()); bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
......
...@@ -95,3 +95,4 @@ bool filesystem(void) ...@@ -95,3 +95,4 @@ bool filesystem(void)
result |= testFlattenFilename(fs); result |= testFlattenFilename(fs);
return result; return result;
} }
...@@ -62,14 +62,11 @@ bool loadFromFileFolder(void) ...@@ -62,14 +62,11 @@ bool loadFromFileFolder(void)
// adding a folder archive // adding a folder archive
device->getFileSystem()->addFolderFileArchive( "../media/" ); 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"); ITexture * tex3 = driver->getTexture("tools.png");
assert(tex3); assert(tex3);
if(!tex3) if(!tex3)
logTestString("Unable to open tools.png\n"); 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__); logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false; return false;
...@@ -79,14 +76,14 @@ bool loadFromFileFolder(void) ...@@ -79,14 +76,14 @@ bool loadFromFileFolder(void)
assert(tex4); assert(tex4);
if(!tex4) if(!tex4)
logTestString("Unable to open tools.png\n"); 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__); logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false; return false;
} }
device->drop(); device->drop();
return (tex1 == tex2 && tex3 == tex4); return ((tex1 == tex2) && (tex1 == tex3) && (tex1 == tex4));
} }
bool loadTextures() bool loadTextures()
......
...@@ -203,6 +203,8 @@ int main(int argumentCount, char * arguments[]) ...@@ -203,6 +203,8 @@ int main(int argumentCount, char * arguments[])
FILE * testsLastPassedAtFile = fopen("tests-last-passed-at.txt", "w"); FILE * testsLastPassedAtFile = fopen("tests-last-passed-at.txt", "w");
if(testsLastPassedAtFile) 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)fprintf(testsLastPassedAtFile, "Test suite pass at GMT %s\n", asctime(timeinfo));
(void)fclose(testsLastPassedAtFile); (void)fclose(testsLastPassedAtFile);
} }
......
...@@ -349,6 +349,8 @@ bool sceneCollisionManager(void) ...@@ -349,6 +349,8 @@ bool sceneCollisionManager(void)
bool result = testGetCollisionResultPosition(device, smgr, collMgr); bool result = testGetCollisionResultPosition(device, smgr, collMgr);
smgr->clear();
result &= testGetSceneNodeFromScreenCoordinatesBB(device, smgr, collMgr); result &= testGetSceneNodeFromScreenCoordinatesBB(device, smgr, collMgr);
result &= getScaledPickedNodeBB(device, smgr, collMgr); result &= getScaledPickedNodeBB(device, smgr, collMgr);
......
...@@ -133,7 +133,7 @@ static bool doTests() ...@@ -133,7 +133,7 @@ static bool doTests()
tmp.getAngle(), ref.getAngle()); tmp.getAngle(), ref.getAngle());
return false; 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) if (val<=0)
val=-val; val=-val;
else else
......
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
...@@ -226,10 +226,22 @@ ...@@ -226,10 +226,22 @@
RelativePath=".\guiDisabledMenu.cpp" RelativePath=".\guiDisabledMenu.cpp"
> >
</File> </File>
<File
RelativePath=".\irrArray.cpp"
>
</File>
<File <File
RelativePath=".\irrCoreEquals.cpp" RelativePath=".\irrCoreEquals.cpp"
> >
</File> </File>
<File
RelativePath=".\irrList.cpp"
>
</File>
<File
RelativePath=".\irrMap.cpp"
>
</File>
<File <File
RelativePath=".\irrString.cpp" RelativePath=".\irrString.cpp"
> >
...@@ -298,10 +310,6 @@ ...@@ -298,10 +310,6 @@
RelativePath=".\terrainSceneNode.cpp" RelativePath=".\terrainSceneNode.cpp"
> >
</File> </File>
<File
RelativePath=".\testArray.cpp"
>
</File>
<File <File
RelativePath=".\testDimension2d.cpp" RelativePath=".\testDimension2d.cpp"
> >
......
...@@ -189,7 +189,7 @@ inline u32 getTextureSizeFromSurfaceSize(u32 size) ...@@ -189,7 +189,7 @@ inline u32 getTextureSizeFromSurfaceSize(u32 size)
u32 lastTextureHeight = getTextureSizeFromSurfaceSize(currenty); u32 lastTextureHeight = getTextureSizeFromSurfaceSize(currenty);
// delete the glyph set // delete the glyph set
delete buf; delete [] buf;
currentImages.set_used(currentImage+1); currentImages.set_used(currentImage+1);
currentTextures.set_used(currentImage+1); currentTextures.set_used(currentImage+1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment