mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Isolate irrlicht references and use a singleton (#6041)
* Add Device3D class which will contain IrrlichtDevice interface move getSupportedVideoDrivers to Device3D Add Device3D singleton & use it in various places Rename Device3D to Rendering engine & add helper functions to various device pointers More singleton work RenderingEngine owns draw_load_screen move draw functions to RenderingEngine Reduce IrrlichtDevice exposure and guienvironment RenderingEngine: Expose get_timer_time() to remove device from guiEngine Make irrlichtdevice & scene manager less exposed * Code style fixes * Move porting::getVideoDriverName, getVideoDriverFriendlyName, getDisplayDensity, getDisplaySize to RenderingEngine Fix XORG_USED macro -> RenderingEngine + create_engine_device from RenderingEngine constructor directly * enum paralax => enum parallax
This commit is contained in:
parent
a8650e785d
commit
b3a36f7378
50 changed files with 1568 additions and 1567 deletions
|
@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <IMaterialRenderer.h>
|
||||
#include <IMaterialRendererServices.h>
|
||||
#include <IShaderConstantSetCallBack.h>
|
||||
#include "client/renderingengine.h"
|
||||
#include "EShaderTypes.h"
|
||||
#include "log.h"
|
||||
#include "gamedef.h"
|
||||
|
@ -177,7 +178,7 @@ class ShaderCallback : public video::IShaderConstantSetCallBack
|
|||
std::vector<IShaderConstantSetter*> m_setters;
|
||||
|
||||
public:
|
||||
ShaderCallback(const std::vector<IShaderConstantSetterFactory*> &factories)
|
||||
ShaderCallback(const std::vector<IShaderConstantSetterFactory *> &factories)
|
||||
{
|
||||
for (u32 i = 0; i < factories.size(); ++i)
|
||||
m_setters.push_back(factories[i]->create());
|
||||
|
@ -260,7 +261,7 @@ public:
|
|||
class ShaderSource : public IWritableShaderSource
|
||||
{
|
||||
public:
|
||||
ShaderSource(IrrlichtDevice *device);
|
||||
ShaderSource();
|
||||
~ShaderSource();
|
||||
|
||||
/*
|
||||
|
@ -309,8 +310,6 @@ private:
|
|||
|
||||
// The id of the thread that is allowed to use irrlicht directly
|
||||
std::thread::id m_main_thread;
|
||||
// The irrlicht device
|
||||
IrrlichtDevice *m_device;
|
||||
|
||||
// Cache of source shaders
|
||||
// This should be only accessed from the main thread
|
||||
|
@ -332,18 +331,17 @@ private:
|
|||
std::vector<ShaderCallback *> m_callbacks;
|
||||
};
|
||||
|
||||
IWritableShaderSource* createShaderSource(IrrlichtDevice *device)
|
||||
IWritableShaderSource *createShaderSource()
|
||||
{
|
||||
return new ShaderSource(device);
|
||||
return new ShaderSource();
|
||||
}
|
||||
|
||||
/*
|
||||
Generate shader given the shader name.
|
||||
*/
|
||||
ShaderInfo generate_shader(const std::string &name,
|
||||
u8 material_type, u8 drawtype,
|
||||
IrrlichtDevice *device, std::vector<ShaderCallback *> &callbacks,
|
||||
const std::vector<IShaderConstantSetterFactory*> &setter_factories,
|
||||
u8 material_type, u8 drawtype, std::vector<ShaderCallback *> &callbacks,
|
||||
const std::vector<IShaderConstantSetterFactory *> &setter_factories,
|
||||
SourceShaderCache *sourcecache);
|
||||
|
||||
/*
|
||||
|
@ -354,11 +352,8 @@ void load_shaders(std::string name, SourceShaderCache *sourcecache,
|
|||
std::string &vertex_program, std::string &pixel_program,
|
||||
std::string &geometry_program, bool &is_highlevel);
|
||||
|
||||
ShaderSource::ShaderSource(IrrlichtDevice *device):
|
||||
m_device(device)
|
||||
ShaderSource::ShaderSource()
|
||||
{
|
||||
assert(m_device); // Pre-condition
|
||||
|
||||
m_main_thread = std::this_thread::get_id();
|
||||
|
||||
// Add a dummy ShaderInfo as the first index, named ""
|
||||
|
@ -453,7 +448,7 @@ u32 ShaderSource::getShaderIdDirect(const std::string &name,
|
|||
}
|
||||
|
||||
ShaderInfo info = generate_shader(name, material_type, drawtype,
|
||||
m_device, m_callbacks, m_setter_factories, &m_sourcecache);
|
||||
m_callbacks, m_setter_factories, &m_sourcecache);
|
||||
|
||||
/*
|
||||
Add shader to caches (add dummy shaders too)
|
||||
|
@ -518,7 +513,7 @@ void ShaderSource::rebuildShaders()
|
|||
ShaderInfo *info = &m_shaderinfo_cache[i];
|
||||
if(info->name != ""){
|
||||
*info = generate_shader(info->name, info->material_type,
|
||||
info->drawtype, m_device, m_callbacks,
|
||||
info->drawtype, m_callbacks,
|
||||
m_setter_factories, &m_sourcecache);
|
||||
}
|
||||
}
|
||||
|
@ -526,8 +521,8 @@ void ShaderSource::rebuildShaders()
|
|||
|
||||
|
||||
ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtype,
|
||||
IrrlichtDevice *device, std::vector<ShaderCallback *> &callbacks,
|
||||
const std::vector<IShaderConstantSetterFactory*> &setter_factories,
|
||||
std::vector<ShaderCallback *> &callbacks,
|
||||
const std::vector<IShaderConstantSetterFactory *> &setter_factories,
|
||||
SourceShaderCache *sourcecache)
|
||||
{
|
||||
ShaderInfo shaderinfo;
|
||||
|
@ -535,7 +530,7 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
|
|||
shaderinfo.material_type = material_type;
|
||||
shaderinfo.drawtype = drawtype;
|
||||
shaderinfo.material = video::EMT_SOLID;
|
||||
switch(material_type){
|
||||
switch (material_type) {
|
||||
case TILE_MATERIAL_BASIC:
|
||||
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
break;
|
||||
|
@ -553,15 +548,16 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
|
|||
break;
|
||||
case TILE_MATERIAL_WAVING_PLANTS:
|
||||
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bool enable_shaders = g_settings->getBool("enable_shaders");
|
||||
if (!enable_shaders)
|
||||
return shaderinfo;
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
sanity_check(driver);
|
||||
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
|
||||
|
||||
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices();
|
||||
if(!gpu){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue