mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
~ fixed segmentation fault when creating a scene
+ added check for texture rendering on startup ~ fixed possibly wrong texture size for passes ~ changed camera position Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
f7be32eed3
commit
3371e10b01
7
main.cpp
7
main.cpp
@ -132,6 +132,12 @@ int init_irrlicht()
|
||||
IrrlichtContext->getDevice ()->getLogger ()->log ("WARNING: Vertex shaders disabled because of missing driver/hardware support");
|
||||
}
|
||||
|
||||
if (IrrlichtContext->getDevice ()->getVideoDriver ()->queryFeature (irr::video::EVDF_RENDER_TO_TARGET) == false)
|
||||
{
|
||||
IrrlichtContext->getDevice ()->getLogger ()->log ("ERROR: Your hardware or this renderer do not support rendering to texture");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -299,6 +305,7 @@ int main (int argc, char* argv[])
|
||||
irr::u32 startTime = 0;
|
||||
irr::u32 endTime = 0;
|
||||
|
||||
IrrlichtContext->getDevice ()->getSceneManager ()->setAmbientLight (sceneRender->getScene ()->getAmbientColor ().toSColor ());
|
||||
while (IrrlichtContext && IrrlichtContext->getDevice () && IrrlichtContext->getDevice ()->run ())
|
||||
{
|
||||
if (IrrlichtContext->getDevice ()->getVideoDriver () == nullptr)
|
||||
|
@ -47,8 +47,8 @@ CCamera* CCamera::fromJSON (json data)
|
||||
}
|
||||
|
||||
return new CCamera (
|
||||
WallpaperEngine::Core::ato3vf (*center_it),
|
||||
WallpaperEngine::Core::ato3vf (*eye_it),
|
||||
WallpaperEngine::Core::ato3vf (*up_it)
|
||||
WallpaperEngine::Core::ato3vf (*center_it),
|
||||
WallpaperEngine::Core::ato3vf (*eye_it),
|
||||
WallpaperEngine::Core::ato3vf (*up_it)
|
||||
);
|
||||
}
|
@ -8,7 +8,7 @@ CCamera::CCamera (CScene* scene, Core::Scenes::CCamera* camera) :
|
||||
m_scene (scene)
|
||||
{
|
||||
this->m_sceneCamera = scene->getContext ()->getDevice ()->getSceneManager ()->addCameraSceneNode (
|
||||
scene, *this->getCenter (), *this->getEye (), scene->nextId ()
|
||||
scene, *this->getEye (), *this->getCenter (), scene->nextId ()
|
||||
);
|
||||
}
|
||||
|
||||
@ -37,8 +37,8 @@ void CCamera::setOrthogonalProjection (irr::f32 width, irr::f32 height)
|
||||
irr::core::matrix4 identity; identity.makeIdentity ();
|
||||
irr::core::matrix4 orthogonalProjection; orthogonalProjection.buildProjectionMatrixOrthoLH (
|
||||
width, height,
|
||||
this->getEye ()->Z,
|
||||
this->getCenter ()->Z
|
||||
this->getCenter ()->Z,
|
||||
this->getEye ()->Z
|
||||
);
|
||||
|
||||
this->m_sceneCamera->setProjectionMatrix (orthogonalProjection);
|
||||
|
@ -18,6 +18,12 @@ CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) :
|
||||
m_scene (project->getScene ()),
|
||||
m_context (context)
|
||||
{
|
||||
this->m_camera = new CCamera (this, this->m_project->getScene ()->getCamera ());
|
||||
this->m_camera->setOrthogonalProjection (
|
||||
this->m_scene->getOrthogonalProjection ()->getWidth (),
|
||||
this->m_scene->getOrthogonalProjection ()->getHeight ()
|
||||
);
|
||||
|
||||
std::vector<Core::CObject*>::const_iterator cur = this->m_scene->getObjects ()->begin ();
|
||||
std::vector<Core::CObject*>::const_iterator end = this->m_scene->getObjects ()->end ();
|
||||
|
||||
@ -41,12 +47,6 @@ CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) :
|
||||
this->m_nextId = ++highestId;
|
||||
this->setAutomaticCulling (irr::scene::EAC_OFF);
|
||||
this->m_boundingBox = irr::core::aabbox3d<irr::f32>(0, 0, 0, 0, 0, 0);
|
||||
|
||||
this->m_camera = new CCamera (this, this->m_project->getScene ()->getCamera ());
|
||||
this->m_camera->setOrthogonalProjection (
|
||||
this->m_scene->getOrthogonalProjection ()->getWidth (),
|
||||
this->m_scene->getOrthogonalProjection ()->getHeight ()
|
||||
);
|
||||
}
|
||||
|
||||
CScene::~CScene ()
|
||||
@ -77,7 +77,7 @@ void CScene::render ()
|
||||
{
|
||||
}
|
||||
|
||||
const irr::core::aabbox3d<irr::f32>& CScene::getBoundingBox() const
|
||||
const irr::core::aabbox3d<irr::f32>& CScene::getBoundingBox () const
|
||||
{
|
||||
return this->m_boundingBox;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ void CImage::render()
|
||||
{
|
||||
uint16_t indices [] =
|
||||
{
|
||||
0, 1, 2, 3
|
||||
3, 2, 1, 0
|
||||
};
|
||||
|
||||
irr::video::IVideoDriver* driver = SceneManager->getVideoDriver ();
|
||||
@ -69,7 +69,7 @@ void CImage::render()
|
||||
{
|
||||
if (textureCur == textureEnd)
|
||||
{
|
||||
driver->setRenderTarget (0, false, false);
|
||||
driver->setRenderTarget (irr::video::ERT_FRAME_BUFFER, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -87,9 +87,6 @@ void CImage::render()
|
||||
|
||||
void CImage::generateMaterial ()
|
||||
{
|
||||
if (this->m_image->getMaterial ()->getPasses ()->empty () == true)
|
||||
return;
|
||||
|
||||
std::vector<Core::Objects::Images::Materials::CPassess*>::const_iterator cur = this->m_image->getMaterial ()->getPasses ()->begin ();
|
||||
std::vector<Core::Objects::Images::Materials::CPassess*>::const_iterator end = this->m_image->getMaterial ()->getPasses ()->end ();
|
||||
|
||||
@ -135,13 +132,17 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass)
|
||||
|
||||
if (textureNumber == 0 && this->m_passes > 0)
|
||||
{
|
||||
irr::video::ITexture* originalTexture = this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->getTexture (texturepath);
|
||||
|
||||
texture = this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->addRenderTargetTexture (
|
||||
irr::core::dimension2d<irr::u32> (
|
||||
this->getScene ()->getScene ()->getOrthogonalProjection()->getWidth (),
|
||||
this->getScene ()->getScene ()->getOrthogonalProjection()->getHeight ()
|
||||
originalTexture->getSize ().Width,
|
||||
originalTexture->getSize ().Height
|
||||
), ("_RT_" + this->m_image->getName () + std::to_string (textureNumber) + "_" + std::to_string (this->m_passes)).c_str ()
|
||||
);
|
||||
|
||||
//originalTexture->drop ();
|
||||
|
||||
this->m_renderTextures.push_back (texture);
|
||||
}
|
||||
else
|
||||
@ -149,6 +150,8 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass)
|
||||
texture = this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->getTexture (texturepath);
|
||||
}
|
||||
|
||||
//texture->grab ();
|
||||
|
||||
material.setTexture (textureNumber, texture);
|
||||
}
|
||||
|
||||
@ -165,6 +168,7 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass)
|
||||
this, irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL, this->m_passes, irr::video::EGSL_DEFAULT
|
||||
);
|
||||
|
||||
// TODO: TAKE INTO ACCOUNT BLENDING AND CULLING METHODS FROM THE JSON
|
||||
material.setFlag (irr::video::EMF_LIGHTING, false);
|
||||
material.setFlag (irr::video::EMF_BLEND_OPERATION, true);
|
||||
material.Wireframe = false;
|
||||
@ -192,30 +196,30 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
|
||||
irr::f32 g_Texture6 = 6;
|
||||
irr::f32 g_Texture7 = 7;
|
||||
|
||||
irr::f32 g_Texture0Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture1Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture2Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture3Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture4Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture5Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture6Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture7Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture0Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z };
|
||||
irr::f32 g_Texture1Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z };
|
||||
irr::f32 g_Texture2Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z };
|
||||
irr::f32 g_Texture3Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z };
|
||||
irr::f32 g_Texture4Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z };
|
||||
irr::f32 g_Texture5Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z };
|
||||
irr::f32 g_Texture6Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z };
|
||||
irr::f32 g_Texture7Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z };
|
||||
|
||||
irr::f32 g_Texture0Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture1Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture2Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture3Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture4Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture5Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture6Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture7Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture0Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y };
|
||||
irr::f32 g_Texture1Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y };
|
||||
irr::f32 g_Texture2Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y };
|
||||
irr::f32 g_Texture3Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y };
|
||||
irr::f32 g_Texture4Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y };
|
||||
irr::f32 g_Texture5Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y };
|
||||
irr::f32 g_Texture6Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y };
|
||||
irr::f32 g_Texture7Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y };
|
||||
|
||||
irr::video::IVideoDriver* driver = services->getVideoDriver ();
|
||||
|
||||
irr::core::matrix4 worldViewProj;worldViewProj.makeIdentity();
|
||||
worldViewProj = driver->getTransform(irr::video::ETS_PROJECTION);
|
||||
worldViewProj *= driver->getTransform(irr::video::ETS_VIEW);
|
||||
worldViewProj *= driver->getTransform(irr::video::ETS_WORLD);
|
||||
irr::core::matrix4 worldViewProj;
|
||||
worldViewProj = driver->getTransform (irr::video::ETS_PROJECTION);
|
||||
worldViewProj *= driver->getTransform (irr::video::ETS_VIEW);
|
||||
worldViewProj *= driver->getTransform (irr::video::ETS_WORLD);
|
||||
|
||||
Render::Shaders::Compiler* vertexShader = this->m_vertexShaders.at (userData);
|
||||
Render::Shaders::Compiler* pixelShader = this->m_pixelShaders.at (userData);
|
||||
|
Loading…
Reference in New Issue
Block a user