<commit_before>#include "MeshLodTests.h"
#include "OgreDefaultHardwareBufferManager.h"
#include "OgreVertexIndexData.h"
#include "OgreEdgeListBuilder.h"
#include "OgreMesh.h"
#include "OgreMeshManager.h"
#include "OgreSubMesh.h"
#include "OgreMeshSerializer.h"
#include "OgreRoot.h"
#include "OgreException.h"
#include "OgreArchive.h"
#include "OgreArchiveManager.h"
#include "OgreFileSystem.h"
#include "OgreConfigFile.h"
#include "OgreMeshLodGenerator.h"
#include "OgrePixelCountLodStrategy.h"
#include "OgreLodCollapseCostQuadric.h"
#include "OgreRenderWindow.h"
#include "OgreLodConfigSerializer.h"

CPPUNIT_TEST_SUITE_REGISTRATION(MeshLodTests);

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
#include "macUtils.h"
#endif

void MeshLodTests::setUp()
{
	OGRE_DELETE LogManager::getSingletonPtr();
	mLogManager = OGRE_NEW LogManager();
	mLogManager->createLog("MeshWithoutIndexDataTests.log", false);
	mLogManager->setLogDetail(LL_LOW);

#if OGRE_STATIC
        mStaticPluginLoader = OGRE_NEW StaticPluginLoader();
#endif

#ifdef OGRE_STATIC_LIB
	Root* root = OGRE_NEW Root(StringUtil::BLANK);
        
	mStaticPluginLoader.load();
#else
	Root* root = OGRE_NEW Root();
	
#endif
	CPPUNIT_ASSERT(!root->getAvailableRenderers().empty());
	root->setRenderSystem(root->getAvailableRenderers().back());
	root->initialise(false); // Needed for setting up HardwareBufferManager
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
	Ogre::NameValuePairList misc;
	// Tell OGRE that we're using cocoa, so it doesn't need to make a window for us
	misc["macAPI"] = "cocoa";
	root->createRenderWindow("", 320, 240, false, &misc)->setHidden(true);
#else
	root->createRenderWindow("", 320, 240, false, NULL)->setHidden(true);
#endif
	new MeshLodGenerator;

	// Load resource paths from config file
	ConfigFile cf;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
	cf.load(macBundlePath() + "/Contents/Resources/resources.cfg");
#elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#if OGRE_DEBUG_MODE
	cf.load("resources_d.cfg");
#else<commit_msg>Fix up new MeshLodTests, make sure a render system is loaded before initializing root.<commit_after>#include "MeshLodTests.h"
#include "OgreDefaultHardwareBufferManager.h"
#include "OgreVertexIndexData.h"
#include "OgreEdgeListBuilder.h"
#include "OgreMesh.h"
#include "OgreMeshManager.h"
#include "OgreSubMesh.h"
#include "OgreMeshSerializer.h"
#include "OgreRoot.h"
#include "OgreException.h"
#include "OgreArchive.h"
#include "OgreArchiveManager.h"
#include "OgreFileSystem.h"
#include "OgreConfigFile.h"
#include "OgreMeshLodGenerator.h"
#include "OgrePixelCountLodStrategy.h"
#include "OgreLodCollapseCostQuadric.h"
#include "OgreRenderWindow.h"
#include "OgreLodConfigSerializer.h"

CPPUNIT_TEST_SUITE_REGISTRATION(MeshLodTests);

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
#include "macUtils.h"
#endif

void MeshLodTests::setUp()
{
	OGRE_DELETE LogManager::getSingletonPtr();
	mLogManager = OGRE_NEW LogManager();
	mLogManager->createLog("MeshLodTests.log", false);
	mLogManager->setLogDetail(LL_LOW);

#if OGRE_STATIC
    mStaticPluginLoader = OGRE_NEW StaticPluginLoader();
#endif

#ifdef OGRE_STATIC_LIB
	Root* root = OGRE_NEW Root(StringUtil::BLANK);
        
	mStaticPluginLoader.load();
#else
	Root* root = OGRE_NEW Root();

    // Try to load a Rendersystem
    try
	{
        root->loadPlugin("RenderSystem_GL");
	}
	catch(std::exception&)
    {
        root->loadPlugin("RenderSystem_Direct3D9");
    }

#endif
	CPPUNIT_ASSERT(!root->getAvailableRenderers().empty());
	root->setRenderSystem(root->getAvailableRenderers().back());
	root->initialise(false); // Needed for setting up HardwareBufferManager
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
	Ogre::NameValuePairList misc;
	// Tell OGRE that we're using cocoa, so it doesn't need to make a window for us
	misc["macAPI"] = "cocoa";
	root->createRenderWindow("", 320, 240, false, &misc)->setHidden(true);
#else
	root->createRenderWindow("", 320, 240, false, NULL)->setHidden(true);
#endif
	new MeshLodGenerator;

	// Load resource paths from config file
	ConfigFile cf;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
	cf.load(macBundlePath() + "/Contents/Resources/resources.cfg");
#elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#if OGRE_DEBUG_MODE
	cf.load("resources_d.cfg");
#else
{'fraction_non_alphanumeric': 0.12768468255841398, 'fraction_numerical': 0.007080481472740146, 'mean_word_length': 6.677536231884058, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4149196', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1511, 'n_words': 299}