forked from mirror/openmw-tes3mp
Started making ogre_manualresource_test.cpp
This commit is contained in:
parent
d6e4dc0b2a
commit
b739205ff6
4 changed files with 101 additions and 2 deletions
|
@ -70,7 +70,7 @@ class BSAFile
|
||||||
/// Used for error messages
|
/// Used for error messages
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
/// Non-case sensitive string comparison
|
/// Case insensitive string comparison
|
||||||
struct iltstr
|
struct iltstr
|
||||||
{
|
{
|
||||||
bool operator()(const char *s1, const char *s2) const
|
bool operator()(const char *s1, const char *s2) const
|
||||||
|
@ -79,7 +79,7 @@ class BSAFile
|
||||||
|
|
||||||
/** A map used for fast file name lookup. The value is the index into
|
/** A map used for fast file name lookup. The value is the index into
|
||||||
the files[] vector above. The iltstr ensures that file name
|
the files[] vector above. The iltstr ensures that file name
|
||||||
checks are non-case sensitive.
|
checks are case insensitive.
|
||||||
*/
|
*/
|
||||||
typedef std::map<const char*, int, iltstr> Lookup;
|
typedef std::map<const char*, int, iltstr> Lookup;
|
||||||
Lookup lookup;
|
Lookup lookup;
|
||||||
|
|
13
nifogre/tests/Makefile
Normal file
13
nifogre/tests/Makefile
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
GCC=g++
|
||||||
|
|
||||||
|
all: ogre_manualresource_test
|
||||||
|
|
||||||
|
I_OGRE=$(shell pkg-config --cflags OGRE)
|
||||||
|
L_OGRE=$(shell pkg-config --libs OGRE)
|
||||||
|
|
||||||
|
ogre_manualresource_test: ogre_manualresource_test.cpp
|
||||||
|
$(GCC) $^ -o $@ $(I_OGRE) $(L_OGRE)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm *_test
|
||||||
|
|
68
nifogre/tests/ogre_manualresource_test.cpp
Normal file
68
nifogre/tests/ogre_manualresource_test.cpp
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
#include <Ogre.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace Ogre;
|
||||||
|
|
||||||
|
struct MyMeshLoader : ManualResourceLoader
|
||||||
|
{
|
||||||
|
void loadResource(Resource *resource)
|
||||||
|
{
|
||||||
|
Mesh *mesh = dynamic_cast<Mesh*>(resource);
|
||||||
|
assert(mesh);
|
||||||
|
|
||||||
|
const String& name = mesh->getName();
|
||||||
|
cout << "Manually loading mesh " << name << endl;
|
||||||
|
|
||||||
|
// Create the mesh here
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
MyMeshLoader mml;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// When the test is done, consider disabling the rendering part
|
||||||
|
// unless a command line parameter is given (and write a note about
|
||||||
|
// this to console.) This allows you to run the test from scripts
|
||||||
|
// and still do some meaningful testing, even if you can't inpsect
|
||||||
|
// the result visually.
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Disable Ogre logging
|
||||||
|
new LogManager;
|
||||||
|
Log *log = LogManager::getSingleton().createLog("");
|
||||||
|
log->setDebugOutputEnabled(false);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Set up Root.
|
||||||
|
Root *root = new Root("plugin.cfg","ogre.cfg","");
|
||||||
|
|
||||||
|
if(!root->restoreConfig())
|
||||||
|
if(!root->showConfigDialog())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Create a window
|
||||||
|
RenderWindow *window = root->initialise(true, "Test");
|
||||||
|
|
||||||
|
// We might need input managment too
|
||||||
|
|
||||||
|
// More initialization
|
||||||
|
SceneManager *mgr = mRoot->createSceneManager(ST_GENERIC);
|
||||||
|
Camera *cam = mgr->createCamera("cam");
|
||||||
|
ViewPort *vp = window->addViewport(cam);
|
||||||
|
cam->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
|
||||||
|
cam->setFOVy(Degree(55));
|
||||||
|
|
||||||
|
// Background color
|
||||||
|
vp->setBackgroundColour(ColourValue(0,0,0));
|
||||||
|
|
||||||
|
// Declare a couple of manual meshes
|
||||||
|
ResourceGroupManager::getSingleton().declareResource("mesh1.mm", "Mesh", "General", &mml);
|
||||||
|
ResourceGroupManager::getSingleton().declareResource("mesh2.mm", "Mesh", "General", &mml);
|
||||||
|
|
||||||
|
// Display the meshes here
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
18
nifogre/tests/test.sh
Executable file
18
nifogre/tests/test.sh
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
make || exit
|
||||||
|
|
||||||
|
mkdir -p output
|
||||||
|
|
||||||
|
PROGS=*_test
|
||||||
|
|
||||||
|
for a in $PROGS; do
|
||||||
|
if [ -f "output/$a.out" ]; then
|
||||||
|
echo "Running $a:"
|
||||||
|
$a | diff output/$a.out -
|
||||||
|
else
|
||||||
|
echo "Creating $a.out"
|
||||||
|
$a > "output/$a.out"
|
||||||
|
git add "output/$a.out"
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in a new issue