Commit 7809c481 authored by hybrid's avatar hybrid

Merged revisions 1972:2004 from 1.5 branch, except for some revisions which...

Merged revisions 1972:2004 from 1.5 branch, except for some revisions which seemed to be merged already. MD2 loader updated, terrain node fixed, opengl texture handling fixed.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2005 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0ef1056e
...@@ -8,6 +8,11 @@ Changes in version 1.6 ...@@ -8,6 +8,11 @@ Changes in version 1.6
- 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.1 (??.?? 2009)
- MD2 mesh loader: Now uses much less memory, reduced number of allocations when loading meshes.
----------------------------------- -----------------------------------
Changes in version 1.5 (15.12.2008) Changes in version 1.5 (15.12.2008)
......
This diff is collapsed.
...@@ -28,9 +28,6 @@ namespace scene ...@@ -28,9 +28,6 @@ namespace scene
//! destructor //! destructor
virtual ~CAnimatedMeshMD2(); virtual ~CAnimatedMeshMD2();
//! loads an md2 file
virtual bool loadFile(io::IReadFile* file);
//! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh. //! returns the amount of frames in milliseconds. If the amount is 1, it is a static (=non animated) mesh.
virtual u32 getFrameCount() const; virtual u32 getFrameCount() const;
...@@ -82,19 +79,16 @@ namespace scene ...@@ -82,19 +79,16 @@ namespace scene
//! \param nr: Zero based index of animation. //! \param nr: Zero based index of animation.
virtual const c8* getAnimationName(s32 nr) const; virtual const c8* getAnimationName(s32 nr) const;
private:
//! updates the interpolation buffer //
void updateInterpolationBuffer(s32 frame, s32 startFrame, s32 endFrame); // exposed for loader
//
//! calculates the bounding box
virtual void calculateBoundingBox();
//! the buffer that contains the most recent animation
SMeshBuffer* InterpolationBuffer; SMeshBuffer* InterpolationBuffer;
core::array<video::S3DVertex> *FrameList;
core::array<core::aabbox3d<f32> > BoxList;
struct SFrameData //! named animations
struct SAnimationData
{ {
core::stringc name; core::stringc name;
s32 begin; s32 begin;
...@@ -102,10 +96,44 @@ namespace scene ...@@ -102,10 +96,44 @@ namespace scene
s32 fps; s32 fps;
}; };
core::array< SFrameData > FrameData; //! scale and translations for keyframes
struct SKeyFrameTransform
{
core::vector3df scale;
core::vector3df translate;
};
//! md2 vertex data
struct SMD2Vert
{
core::vector3d<u8> Pos;
u8 NormalIdx;
};
//! keyframe transformations
core::array<SKeyFrameTransform> FrameTransforms;
//! keyframe vertex data
core::array<SMD2Vert> *FrameList;
//! bounding boxes for each keyframe
core::array<core::aabbox3d<f32> > BoxList;
//! named animations
core::array< SAnimationData > AnimationData;
//! calculates the bounding box
virtual void calculateBoundingBox();
u32 FrameCount; u32 FrameCount;
s32 TriangleCount; s32 TriangleCount;
private:
//! updates the interpolation buffer
void updateInterpolationBuffer(s32 frame, s32 startFrame, s32 endFrame);
}; };
} // end namespace scene } // end namespace scene
......
This diff is collapsed.
...@@ -12,6 +12,8 @@ namespace irr ...@@ -12,6 +12,8 @@ namespace irr
namespace scene namespace scene
{ {
class CAnimatedMeshMD2;
//! Meshloader capable of loading MD2 files //! Meshloader capable of loading MD2 files
class CMD2MeshFileLoader : public IMeshLoader class CMD2MeshFileLoader : public IMeshLoader
{ {
...@@ -30,6 +32,10 @@ public: ...@@ -30,6 +32,10 @@ public:
//! See IReferenceCounted::drop() for more information. //! See IReferenceCounted::drop() for more information.
virtual IAnimatedMesh* createMesh(io::IReadFile* file); virtual IAnimatedMesh* createMesh(io::IReadFile* file);
private:
//! Loads the file data into the mesh
bool loadFile(io::IReadFile* file, CAnimatedMeshMD2* mesh);
}; };
} // end namespace scene } // end namespace scene
......
...@@ -178,7 +178,7 @@ void COpenGLTexture::copyTexture(bool newTexture) ...@@ -178,7 +178,7 @@ void COpenGLTexture::copyTexture(bool newTexture)
break; break;
} }
glBindTexture(GL_TEXTURE_2D, TextureName); Driver->setTexture(0, this);
if (Driver->testGLError()) if (Driver->testGLError())
os::Printer::log("Could not bind Texture", ELL_ERROR); os::Printer::log("Could not bind Texture", ELL_ERROR);
...@@ -416,7 +416,7 @@ void COpenGLTexture::bindRTT() ...@@ -416,7 +416,7 @@ void COpenGLTexture::bindRTT()
//! Unbind Render Target Texture //! Unbind Render Target Texture
void COpenGLTexture::unbindRTT() void COpenGLTexture::unbindRTT()
{ {
glBindTexture(GL_TEXTURE_2D, getOpenGLTextureName()); Driver->setTexture(0, this);
// Copy Our ViewPort To The Texture // Copy Our ViewPort To The Texture
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height);
...@@ -456,7 +456,7 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<s32>& size, ...@@ -456,7 +456,7 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<s32>& size,
// generate color texture // generate color texture
glGenTextures(1, &TextureName); glGenTextures(1, &TextureName);
glBindTexture(GL_TEXTURE_2D, TextureName); Driver->setTexture(0, this);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
......
This diff is collapsed.
// This is the entry point for the Irrlicht test suite. // This is the entry point for the Irrlicht test suite.
// This is an MSVC pragma to link against the Irrlicht library.
// Other builds must link against it in the project files.
#if defined(_MSC_VER)
#pragma comment(lib, "Irrlicht.lib")
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif // _MSC_VER
#include "testUtils.h" #include "testUtils.h"
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <assert.h> #include <assert.h>
#include <vector>
// This is an MSVC pragma to link against the Irrlicht library.
// Other builds must link against it in the project files.
#if defined(_MSC_VER)
#pragma comment(lib, "Irrlicht.lib")
#endif // _MSC_VER
typedef struct _STestDefinition /* Each test must have the same signature. Test should (but are not
{ * required to) live in a .cpp file of the same name. There is no
bool(*testSignature)(void); * need to #include anything since the test entry points can be
const char * testName; * declared as extern before calling them.
} STestDefinition; */
#define RUN_TEST(testEntryPoint)\
extern bool testEntryPoint(void);\
logTestString("\nStarting test '" #testEntryPoint "'\n");\
if(!testEntryPoint()) \
{\
(void)printf("\n\n\n******** Test failure ********\nTest '" #testEntryPoint "' failed\n"\
"******** Test failure ********\n\nPress return to continue\n");\
(void)getc(stdin);\
fails++;\
}
//! This is the main entry point for the Irrlicht test suite. //! This is the main entry point for the Irrlicht test suite.
/** \return The number of test that failed, i.e. 0 is success. */ /** \return The number of test that failed, i.e. 0 is success. */
...@@ -33,42 +41,45 @@ int main(int argumentCount, char * arguments[]) ...@@ -33,42 +41,45 @@ int main(int argumentCount, char * arguments[])
return 9999; return 9999;
} }
extern bool disambiguateTextures(void);
extern bool softwareDevice(void);
extern bool exports(void);
extern bool testVector3d(void);
extern bool testVector2d(void);
extern bool planeMatrix(void);
extern bool fast_atof(void);
extern bool line2dIntersectWith(void);
extern bool drawPixel(void);
extern bool md2Animation(void);
extern bool b3dAnimation(void);
extern bool guiDisabledMenu(void);
extern bool textureRenderStates(void);
typedef struct _STest
{
bool(*testSignature)(void);
const char * testName;
} STest;
#define TEST(x)\ #define TEST(x) { x, #x }
{\
extern bool x(void);\
STestDefinition newTest;\
newTest.testSignature = x;\
newTest.testName = #x;\
tests.push_back(newTest);\
}
std::vector<STestDefinition> tests; static const STest tests[] =
{
// Note that to interactively debug a test, you will generally want to move it TEST(disambiguateTextures), // Run this first, since it validates the WD.
// (temporarily) to the beginning of the list, since each test runs in its own TEST(exports),
// process. TEST(testVector3d),
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory. TEST(testVector2d),
TEST(vectorPositionDimension2d); TEST(planeMatrix),
TEST(irrCoreEquals); TEST(fast_atof),
TEST(sceneNodeAnimator); TEST(line2dIntersectWith),
TEST(sceneCollisionManager); TEST(drawPixel),
TEST(collisionResponseAnimator); TEST(md2Animation),
TEST(exports); TEST(guiDisabledMenu),
TEST(testVector3d); TEST(softwareDevice),
TEST(testVector2d); TEST(b3dAnimation),
TEST(planeMatrix); TEST(textureRenderStates)
TEST(fast_atof); };
TEST(line2dIntersectWith); static const unsigned int numberOfTests = sizeof tests / sizeof tests[0];
TEST(testDimension2d);
TEST(drawPixel);
TEST(md2Animation);
TEST(guiDisabledMenu);
TEST(softwareDevice);
TEST(b3dAnimation);
TEST(terrainSceneNode);
const unsigned int numberOfTests = tests.size();
unsigned int testToRun = 0; unsigned int testToRun = 0;
unsigned int fails = 0; unsigned int fails = 0;
...@@ -102,22 +113,10 @@ int main(int argumentCount, char * arguments[]) ...@@ -102,22 +113,10 @@ int main(int argumentCount, char * arguments[])
} }
testToRun++; testToRun++;
if(testToRun < numberOfTests)
{
closeTestLog();
char runNextTest[256];
(void)sprintf(runNextTest, "\"%s\" %d %d", arguments[0], testToRun, fails);
fails = system(runNextTest);
}
if(1 == testToRun) if(testToRun == numberOfTests)
{ {
(void)openTestLog(false); logTestString("\nTests finished. %d test%s failed.\n", fails, 1 == fails ? "" : "s");
const int passed = numberOfTests - fails;
logTestString("\nTests finished. %d test%s of %d passed.\n",
passed, 1 == passed ? "" : "s", numberOfTests);
if(0 == fails) if(0 == fails)
{ {
time_t rawtime; time_t rawtime;
...@@ -134,6 +133,13 @@ int main(int argumentCount, char * arguments[]) ...@@ -134,6 +133,13 @@ int main(int argumentCount, char * arguments[])
} }
closeTestLog(); closeTestLog();
} }
else
{
closeTestLog();
char runNextTest[256];
(void)sprintf(runNextTest, "\"%s\" %d %d", arguments[0], testToRun, fails);
fails = system(runNextTest);
}
return fails; return fails;
} }
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="..\lib\Win32-visualstudio\Irrlicht.lib"
OutputFile="..\bin\Win32-VisualStudio\$(ProjectName).exe" OutputFile="..\bin\Win32-VisualStudio\$(ProjectName).exe"
GenerateDebugInformation="true" GenerateDebugInformation="true"
TargetMachine="1" TargetMachine="1"
...@@ -129,6 +130,7 @@ ...@@ -129,6 +130,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="..\lib\Win32-visualstudio\Irrlicht.lib"
OutputFile="..\bin\Win32-VisualStudio\$(ProjectName).exe" OutputFile="..\bin\Win32-VisualStudio\$(ProjectName).exe"
GenerateDebugInformation="true" GenerateDebugInformation="true"
OptimizeReferences="2" OptimizeReferences="2"
...@@ -246,6 +248,10 @@ ...@@ -246,6 +248,10 @@
RelativePath=".\testVector3d.cpp" RelativePath=".\testVector3d.cpp"
> >
</File> </File>
<File
RelativePath=".\textureRenderStates.cpp"
>
</File>
<File <File
RelativePath=".\vectorPositionDimension2d.cpp" RelativePath=".\vectorPositionDimension2d.cpp"
> >
......
// Copyright (C) 2008 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "irrlicht.h"
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//! Tests interleaved loading and rendering of textures
/** The test loads a texture, renders it using draw2dimage, loads another
texture and renders the first one again. Due to the texture cache this
can lead to rendering of the second texture in second place. */
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<s32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
ITexture* tex1 = driver->getTexture("../media/wall.bmp");
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
driver->draw2DImage(tex1, position2di(0,0));
driver->endScene();
driver->getTexture("../media/tools.png");
driver->beginScene(true, true, SColor(255,100,101,140));
driver->draw2DImage(tex1, position2di(0,0));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-textureRenderStates.png", 100);
device->drop();
return result;
}
bool textureRenderStates(void)
{
bool passed = true;
passed &= runTestWithDriver(EDT_SOFTWARE);
passed &= runTestWithDriver(EDT_BURNINGSVIDEO);
passed &= runTestWithDriver(EDT_DIRECT3D9);
passed &= runTestWithDriver(EDT_DIRECT3D8);
passed &= runTestWithDriver(EDT_OPENGL);
return passed;
}
...@@ -860,13 +860,11 @@ void CGUIEditWorkspace::PasteXMLToSelectedElement() ...@@ -860,13 +860,11 @@ void CGUIEditWorkspace::PasteXMLToSelectedElement()
// rewind file // rewind file
memWrite->seek(0, false); memWrite->seek(0, false);
io::IXMLReader* xmlReader = (io::IXMLReader*) Environment->getFileSystem()->createXMLReader(memWrite);
// read xml // read xml
Environment->readGUIElement(xmlReader, SelectedElement); Environment->loadGUI(memWrite, SelectedElement);
// drop the xml reader // reset focus
xmlReader->drop(); Environment->setFocus(this);
// drop the read file // drop the read file
memWrite->drop(); memWrite->drop();
......
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