Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Fixes for Windows #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/components/ogre/OgrePluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ OgrePluginLoader::OgrePluginLoader() {
//on windows we'll bundle the dll files in the same directory as the executable
mPluginDirs.push_back(".");
mPluginExtension = ".dll";
mPluginDirs.push_back("bin");// Prefix + "bin", or alternatives:
mPluginDirs.push_back("lib64");
mPluginDirs.push_back("lib");
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX

//If any prefix is set (for example for AppImage builds), check for the plugins in directories relative to the prefix first.
Expand Down Expand Up @@ -143,6 +146,12 @@ bool OgrePluginLoader::loadDynPlugin(const std::string& pluginName) {
//#else
pluginPath = dir + "/" + pluginName + mPluginExtension;
//#endif
if (!std::ifstream(pluginPath).good()) {
pluginPath = pluginName + mPluginExtension;// if absent, use plugin in current directory
}
if (!std::ifstream(pluginPath).good()) {
pluginPath = dir + "/" + pluginName + "_d" + mPluginExtension;
}
if (std::ifstream(pluginPath).good()) {
S_LOG_INFO("Trying to load the plugin '" << pluginPath << "'.");
try {
Expand All @@ -151,6 +160,9 @@ bool OgrePluginLoader::loadDynPlugin(const std::string& pluginName) {
} catch (...) {
}
}
else{
printf("\nUnable to load:%s", pluginPath.c_str());
}
}
S_LOG_FAILURE("Failed to load the plugin '" << pluginName << "'!");
#else
Expand Down
23 changes: 22 additions & 1 deletion src/components/ogre/OgreSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,37 @@ void OgreSetup::createOgreSystem() {
mPluginLoader.loadPlugin("Codec_FreeImage");
mPluginLoader.loadPlugin("Plugin_ParticleFX");
mPluginLoader.loadPlugin("RenderSystem_GL3Plus"); //We'll use OpenGL on Windows too, to make it easier to develop
mPluginLoader.loadPlugin("RenderSystem_Direct3D11");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you getting errors without these? Normally Ember should run without having to load the DirectX-plugins.

mPluginLoader.loadPlugin("RenderSystem_Direct3D10");
mPluginLoader.loadPlugin("RenderSystem_Direct3D9");
#endif

auto renderSystem = mRoot->getAvailableRenderers().front();
//auto renderSystem = mRoot->getAvailableRenderers().front();
const auto& renderers = mRoot->getAvailableRenderers();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to support both DirectX and OpenGL, but in the end it just became a huge hassle since it meant I had to provide shaders for both GLSL and HLSL. So in the end we decided on only supporting OpenGL.
In the long run we want to move to a PBS based rendering flow, in which we hopefully won't need to write any shaders. And in the even longer run we want to see Vulkan support in Ogre, making away with both DirectX and OpenGL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn’t come here for a long time. Yes, I wanted to make the game work on DirectX. But as I understand it, this is not worth doing. You can apply changes without this code.

if (renderers.size() == 0){
S_LOG_WARNING("\nFatal error: Empty renderer list!\n");
exit(1);
}
const char* envRenderName = getenv("OGRE_RENDER_SYSTEM");
if (envRenderName!= NULL)
{
auto renderSystem = mRoot->getRenderSystemByName(envRenderName);
if (renderSystem == NULL){
S_LOG_WARNING("\nmRoot->getRenderSystemByName() return NULL!Render name:\n");
S_LOG_WARNING(envRenderName);
renderSystem = renderers.front();
}
mRoot->setRenderSystem(renderSystem);
}else{
auto renderSystem = renderers.front();
try {
//Set the default resolution to 1280 x 720 unless overridden by the user.
renderSystem->setConfigOption("Video Mode", "1280 x 720"); //OGRE stores the value with two spaces after "x".
} catch (const std::exception& ex) {
S_LOG_WARNING("Could not set default resolution." << ex);
}
mRoot->setRenderSystem(renderSystem);
}

if (chdir(configSrv.getEmberDataDirectory().generic_string().c_str())) {
S_LOG_WARNING("Failed to change to the data directory '" << configSrv.getEmberDataDirectory().string() << "'.");
Expand Down