Moved resources includes to the top of the implementations

Former-commit-id: 788a62f66aa47fe76e32ef0b76e9e962b1c5f2e6
This commit is contained in:
Lynix 2015-01-19 20:34:09 +01:00
parent e2d4ba030c
commit 47fa5dc731
4 changed files with 83 additions and 80 deletions

View File

@ -35,6 +35,34 @@
namespace
{
const nzUInt8 r_fragmentSource_BloomBright[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/BloomBright.frag.h>
};
const nzUInt8 r_fragmentSource_BloomFinal[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/BloomFinal.frag.h>
};
const nzUInt8 r_fragmentSource_DirectionalLight[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h>
};
const nzUInt8 r_fragmentSource_FXAA[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/FXAA.frag.h>
};
const nzUInt8 r_fragmentSource_GBufferClear[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/GBufferClear.frag.h>
};
const nzUInt8 r_fragmentSource_GaussianBlur[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/GaussianBlur.frag.h>
};
const nzUInt8 r_fragmentSource_PointSpotLight[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h>
};
unsigned int RenderPassPriority[] =
{
6, // nzRenderPassType_AA
@ -412,34 +440,6 @@ bool NzDeferredRenderTechnique::Resize(const NzVector2ui& dimensions) const
bool NzDeferredRenderTechnique::Initialize()
{
const nzUInt8 fragmentSource_BloomBright[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/BloomBright.frag.h>
};
const nzUInt8 fragmentSource_BloomFinal[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/BloomFinal.frag.h>
};
const nzUInt8 fragmentSource_DirectionalLight[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h>
};
const nzUInt8 fragmentSource_FXAA[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/FXAA.frag.h>
};
const nzUInt8 fragmentSource_GBufferClear[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/GBufferClear.frag.h>
};
const nzUInt8 fragmentSource_GaussianBlur[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/GaussianBlur.frag.h>
};
const nzUInt8 fragmentSource_PointSpotLight[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h>
};
const char vertexSource_Basic[] =
"#version 140\n"
@ -497,7 +497,7 @@ bool NzDeferredRenderTechnique::Initialize()
NzShader* shader;
// Shaders critiques (Nécessaires pour le Deferred Shading minimal)
shader = RegisterDeferredShader("DeferredGBufferClear", fragmentSource_GBufferClear, sizeof(fragmentSource_GBufferClear), ppVertexStage, &error);
shader = RegisterDeferredShader("DeferredGBufferClear", r_fragmentSource_GBufferClear, sizeof(r_fragmentSource_GBufferClear), ppVertexStage, &error);
if (!shader)
{
NazaraError("Failed to register critical shader: " + error);
@ -505,7 +505,7 @@ bool NzDeferredRenderTechnique::Initialize()
}
shader = RegisterDeferredShader("DeferredDirectionnalLight", fragmentSource_DirectionalLight, sizeof(fragmentSource_DirectionalLight), ppVertexStage, &error);
shader = RegisterDeferredShader("DeferredDirectionnalLight", r_fragmentSource_DirectionalLight, sizeof(r_fragmentSource_DirectionalLight), ppVertexStage, &error);
if (!shader)
{
NazaraError("Failed to register critical shader: " + error);
@ -517,7 +517,7 @@ bool NzDeferredRenderTechnique::Initialize()
shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2);
shader = RegisterDeferredShader("DeferredPointSpotLight", fragmentSource_PointSpotLight, sizeof(fragmentSource_PointSpotLight), basicVertexStage, &error);
shader = RegisterDeferredShader("DeferredPointSpotLight", r_fragmentSource_PointSpotLight, sizeof(r_fragmentSource_PointSpotLight), basicVertexStage, &error);
if (!shader)
{
NazaraError("Failed to register critical shader: " + error);
@ -530,7 +530,7 @@ bool NzDeferredRenderTechnique::Initialize()
// Shaders optionnels (S'ils ne sont pas présents, le rendu minimal sera quand même assuré)
shader = RegisterDeferredShader("DeferredBloomBright", fragmentSource_BloomBright, sizeof(fragmentSource_BloomBright), ppVertexStage, &error);
shader = RegisterDeferredShader("DeferredBloomBright", r_fragmentSource_BloomBright, sizeof(r_fragmentSource_BloomBright), ppVertexStage, &error);
if (shader)
shader->SendInteger(shader->GetUniformLocation("ColorTexture"), 0);
else
@ -539,7 +539,7 @@ bool NzDeferredRenderTechnique::Initialize()
}
shader = RegisterDeferredShader("DeferredBloomFinal", fragmentSource_BloomFinal, sizeof(fragmentSource_BloomFinal), ppVertexStage, &error);
shader = RegisterDeferredShader("DeferredBloomFinal", r_fragmentSource_BloomFinal, sizeof(r_fragmentSource_BloomFinal), ppVertexStage, &error);
if (shader)
{
shader->SendInteger(shader->GetUniformLocation("ColorTexture"), 0);
@ -551,7 +551,7 @@ bool NzDeferredRenderTechnique::Initialize()
}
shader = RegisterDeferredShader("DeferredFXAA", fragmentSource_FXAA, sizeof(fragmentSource_FXAA), ppVertexStage, &error);
shader = RegisterDeferredShader("DeferredFXAA", r_fragmentSource_FXAA, sizeof(r_fragmentSource_FXAA), ppVertexStage, &error);
if (shader)
shader->SendInteger(shader->GetUniformLocation("ColorTexture"), 0);
else
@ -560,7 +560,7 @@ bool NzDeferredRenderTechnique::Initialize()
}
shader = RegisterDeferredShader("DeferredGaussianBlur", fragmentSource_GaussianBlur, sizeof(fragmentSource_GaussianBlur), ppVertexStage, &error);
shader = RegisterDeferredShader("DeferredGaussianBlur", r_fragmentSource_GaussianBlur, sizeof(r_fragmentSource_GaussianBlur), ppVertexStage, &error);
if (shader)
shader->SendInteger(shader->GetUniformLocation("ColorTexture"), 0);
else

View File

@ -15,6 +15,25 @@
#include <memory>
#include <Nazara/Graphics/Debug.hpp>
namespace
{
const nzUInt8 r_coreFragmentShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/core.frag.h>
};
const nzUInt8 r_coreVertexShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/core.vert.h>
};
const nzUInt8 r_compatibilityFragmentShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/compatibility.frag.h>
};
const nzUInt8 r_compatibilityVertexShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/compatibility.vert.h>
};
}
bool NzMaterialParams::IsValid() const
{
if (!NzUberShaderLibrary::Has(shaderName))
@ -719,29 +738,13 @@ bool NzMaterial::Initialize()
NzString vertexShader;
if (glsl140)
{
const nzUInt8 coreFragmentShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/core.frag.h>
};
const nzUInt8 coreVertexShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/core.vert.h>
};
fragmentShader.Set(reinterpret_cast<const char*>(coreFragmentShader), sizeof(coreFragmentShader));
vertexShader.Set(reinterpret_cast<const char*>(coreVertexShader), sizeof(coreVertexShader));
fragmentShader.Set(reinterpret_cast<const char*>(r_coreFragmentShader), sizeof(r_coreFragmentShader));
vertexShader.Set(reinterpret_cast<const char*>(r_coreVertexShader), sizeof(r_coreVertexShader));
}
else
{
const nzUInt8 compatibilityFragmentShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/compatibility.frag.h>
};
const nzUInt8 compatibilityVertexShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/compatibility.vert.h>
};
fragmentShader.Set(reinterpret_cast<const char*>(compatibilityFragmentShader), sizeof(compatibilityFragmentShader));
vertexShader.Set(reinterpret_cast<const char*>(compatibilityVertexShader), sizeof(compatibilityVertexShader));
fragmentShader.Set(reinterpret_cast<const char*>(r_compatibilityFragmentShader), sizeof(r_compatibilityFragmentShader));
vertexShader.Set(reinterpret_cast<const char*>(r_compatibilityVertexShader), sizeof(r_compatibilityVertexShader));
}
uberShader->SetShader(nzShaderStage_Fragment, fragmentShader, "FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING");

View File

@ -279,7 +279,7 @@ void NzParticleSystem::ResizeBuffer()
// Histoire de décrire un peu mieux l'erreur en cas d'échec
try
{
m_buffer.resize(m_maxParticleCount*m_particleSize);
m_buffer.resize(m_maxParticleCount*m_particleSize*2);
}
catch (const std::exception& e)
{

View File

@ -34,6 +34,22 @@
namespace
{
const nzUInt8 r_coreFragmentShader[] = {
#include <Nazara/Renderer/Resources/Shaders/Debug/core.frag.h>
};
const nzUInt8 r_coreVertexShader[] = {
#include <Nazara/Renderer/Resources/Shaders/Debug/core.vert.h>
};
const nzUInt8 r_compatibilityFragmentShader[] = {
#include <Nazara/Renderer/Resources/Shaders/Debug/compatibility.frag.h>
};
const nzUInt8 r_compatibilityVertexShader[] = {
#include <Nazara/Renderer/Resources/Shaders/Debug/compatibility.vert.h>
};
enum ResourceType
{
ResourceType_Context,
@ -876,39 +892,23 @@ bool NzRenderer::Initialize()
return false;
}
const nzUInt8 coreFragmentShader[] = {
#include <Nazara/Renderer/Resources/Shaders/Debug/core.frag.h>
};
const nzUInt8 coreVertexShader[] = {
#include <Nazara/Renderer/Resources/Shaders/Debug/core.vert.h>
};
const nzUInt8 compatibilityFragmentShader[] = {
#include <Nazara/Renderer/Resources/Shaders/Debug/compatibility.frag.h>
};
const nzUInt8 compatibilityVertexShader[] = {
#include <Nazara/Renderer/Resources/Shaders/Debug/compatibility.vert.h>
};
const char* fragmentShader;
const char* vertexShader;
unsigned int fragmentShaderLength;
unsigned int vertexShaderLength;
if (NzOpenGL::GetGLSLVersion() >= 140)
{
fragmentShader = reinterpret_cast<const char*>(coreFragmentShader);
fragmentShaderLength = sizeof(coreFragmentShader);
vertexShader = reinterpret_cast<const char*>(coreVertexShader);
vertexShaderLength = sizeof(coreVertexShader);
fragmentShader = reinterpret_cast<const char*>(r_coreFragmentShader);
fragmentShaderLength = sizeof(r_coreFragmentShader);
vertexShader = reinterpret_cast<const char*>(r_coreVertexShader);
vertexShaderLength = sizeof(r_coreVertexShader);
}
else
{
fragmentShader = reinterpret_cast<const char*>(compatibilityFragmentShader);
fragmentShaderLength = sizeof(compatibilityFragmentShader);
vertexShader = reinterpret_cast<const char*>(compatibilityVertexShader);
vertexShaderLength = sizeof(compatibilityVertexShader);
fragmentShader = reinterpret_cast<const char*>(r_compatibilityFragmentShader);
fragmentShaderLength = sizeof(r_compatibilityFragmentShader);
vertexShader = reinterpret_cast<const char*>(r_compatibilityVertexShader);
vertexShaderLength = sizeof(r_compatibilityVertexShader);
}
if (!shader->AttachStageFromSource(nzShaderStage_Fragment, fragmentShader, fragmentShaderLength))