Merge branch 'NDK-ShadowMapping'

Former-commit-id: e77949168073f06d52d10785afb41bad2f7f86c0
This commit is contained in:
Lynix
2016-05-13 13:06:23 +02:00
39 changed files with 2338 additions and 690 deletions

View File

@@ -995,6 +995,7 @@ namespace Nz
glUniformMatrix4fv = reinterpret_cast<PFNGLUNIFORMMATRIX4FVPROC>(LoadEntry("glUniformMatrix4fv"));
glUnmapBuffer = reinterpret_cast<PFNGLUNMAPBUFFERPROC>(LoadEntry("glUnmapBuffer"));
glUseProgram = reinterpret_cast<PFNGLUSEPROGRAMPROC>(LoadEntry("glUseProgram"));
glValidateProgram = reinterpret_cast<PFNGLVALIDATEPROGRAMPROC>(LoadEntry("glValidateProgram"));
glVertexAttrib4f = reinterpret_cast<PFNGLVERTEXATTRIB4FPROC>(LoadEntry("glVertexAttrib4f"));
glVertexAttribDivisor = reinterpret_cast<PFNGLVERTEXATTRIBDIVISORPROC>(LoadEntry("glVertexAttribDivisor"));
glVertexAttribPointer = reinterpret_cast<PFNGLVERTEXATTRIBPOINTERPROC>(LoadEntry("glVertexAttribPointer"));
@@ -1684,24 +1685,44 @@ namespace Nz
format->dataFormat = GL_DEPTH_COMPONENT;
format->dataType = GL_UNSIGNED_SHORT;
format->internalFormat = GL_DEPTH_COMPONENT16;
format->swizzle[0] = GL_RED;
format->swizzle[1] = GL_RED;
format->swizzle[2] = GL_RED;
format->swizzle[3] = GL_ONE;
return true;
case PixelFormatType_Depth24:
format->dataFormat = GL_DEPTH_COMPONENT;
format->dataType = GL_UNSIGNED_INT;
format->internalFormat = GL_DEPTH_COMPONENT24;
format->swizzle[0] = GL_RED;
format->swizzle[1] = GL_RED;
format->swizzle[2] = GL_RED;
format->swizzle[3] = GL_ONE;
return true;
case PixelFormatType_Depth24Stencil8:
format->dataFormat = GL_DEPTH_STENCIL;
format->dataType = GL_UNSIGNED_INT_24_8;
format->internalFormat = GL_DEPTH24_STENCIL8;
format->swizzle[0] = GL_RED;
format->swizzle[1] = GL_RED;
format->swizzle[2] = GL_RED;
format->swizzle[3] = GL_GREEN;
return true;
case PixelFormatType_Depth32:
format->dataFormat = GL_DEPTH_COMPONENT;
format->dataType = GL_UNSIGNED_BYTE;
format->internalFormat = GL_DEPTH_COMPONENT32;
format->swizzle[0] = GL_RED;
format->swizzle[1] = GL_RED;
format->swizzle[2] = GL_RED;
format->swizzle[3] = GL_ONE;
return true;
case PixelFormatType_Stencil1:
@@ -2248,12 +2269,14 @@ PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv = nullptr;
PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = nullptr;
PFNGLUNMAPBUFFERPROC glUnmapBuffer = nullptr;
PFNGLUSEPROGRAMPROC glUseProgram = nullptr;
PFNGLVALIDATEPROGRAMPROC glValidateProgram = nullptr;
PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = nullptr;
PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor = nullptr;
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = nullptr;
PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = nullptr;
PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer = nullptr;
PFNGLVIEWPORTPROC glViewport = nullptr;
#if defined(NAZARA_PLATFORM_WINDOWS)
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat = nullptr;
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = nullptr;

View File

@@ -156,9 +156,6 @@ namespace Nz
InvalidateSize();
InvalidateTargets();
if (attachmentPoint == AttachmentPoint_Color && !m_impl->userDefinedTargets)
m_impl->colorTargets.push_back(index);
return true;
}
@@ -293,9 +290,6 @@ namespace Nz
InvalidateSize();
InvalidateTargets();
if (attachmentPoint == AttachmentPoint_Color && !m_impl->userDefinedTargets)
m_impl->colorTargets.push_back(index);
return true;
}
@@ -819,6 +813,15 @@ namespace Nz
void RenderTexture::UpdateTargets() const
{
if (!m_impl->userDefinedTargets)
{
m_impl->colorTargets.clear();
unsigned int colorIndex = 0;
for (unsigned int index = attachmentIndex[AttachmentPoint_Color]; index < m_impl->attachments.size(); ++index)
m_impl->colorTargets.push_back(colorIndex++);
}
if (m_impl->colorTargets.empty())
{
m_impl->drawBuffers.resize(1);

View File

@@ -1713,6 +1713,14 @@ namespace Nz
// Et on termine par envoyer nos états au driver
OpenGL::ApplyStates(s_states);
#ifdef NAZARA_DEBUG
if (!s_shader->Validate())
{
NazaraError(Error::GetLastError());
return false;
}
#endif
return true;
}

View File

@@ -747,6 +747,31 @@ namespace Nz
}
}
bool Shader::Validate() const
{
#if NAZARA_RENDERER_SAFE
if (!m_program)
{
NazaraError("Shader is not initialized");
return false;
}
#endif
glValidateProgram(m_program);
GLint success;
glGetProgramiv(m_program, GL_VALIDATE_STATUS, &success);
if (success == GL_TRUE)
return true;
else
{
NazaraError("Failed to validate shader: " + GetLog());
return false;
}
}
unsigned int Shader::GetOpenGLID() const
{
return m_program;

View File

@@ -1306,6 +1306,12 @@ namespace Nz
glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, openGLFormat.swizzle[3]);
}
if (!proxy && PixelFormat::GetType(m_impl->format) == PixelFormatTypeType_Depth)
{
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
}
return true;
}