Added Meshes and Animations (And many more)

Added NzTexture::IsMipmappingSupported
Color::(FromTo)HSV now takes hue and saturation in degrees
Fixed Context::EnsureContext
Fixed COW thread-safety (String, Image, Matrix4)
Fixed Quatenion<T>::operator*(const Vector3<T>&)
Fixed ResourceLoader
Fixed String::Resize with a size of 0
Fixed Texture mipmapping crash
Fixed per-class thread-safety
IndexBuffer and VertexBuffer are now resources
It is now possible to use more than 8 texcoords per shader
Moved all enumerations into separate files (Core/Enums.hpp,
Utility/Enums.hpp, ..)
Removed NzContextParameters::defaultWindow
VertexDeclaration has been rewritten (New interface/COW)
This commit is contained in:
Lynix
2012-07-13 15:22:14 +02:00
parent 5f95f0b677
commit 06eda4eba9
75 changed files with 3385 additions and 861 deletions

View File

@@ -341,7 +341,7 @@ bool NzTexture::Bind() const
glBindTexture(openglTarget[m_impl->type], m_impl->id);
if (!m_impl->mipmapsUpdated)
if (m_impl->mipmapping && !m_impl->mipmapsUpdated)
{
glGenerateMipmap(openglTarget[m_impl->type]);
m_impl->mipmapsUpdated = true;
@@ -433,7 +433,13 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt
NzContext::EnsureContext();
levelCount = std::min(levelCount, NzImage::GetMaxLevel(width, height, depth));
if (IsMipmappingSupported())
levelCount = std::min(levelCount, NzImage::GetMaxLevel(width, height, depth));
else if (levelCount > 1)
{
NazaraWarning("Mipmapping not supported, reducing level count to 1");
levelCount = 1;
}
NzTextureImpl* impl = new NzTextureImpl;
glGenTextures(1, &impl->id);
@@ -477,10 +483,7 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt
SetWrapMode(nzTextureWrap_Repeat);
if (m_impl->levelCount > 1U)
{
m_impl->mipmapping = true;
m_impl->mipmapsUpdated = false;
}
EnableMipmapping(true);
if (!lock)
UnlockTexture(impl);
@@ -577,25 +580,17 @@ bool NzTexture::EnableMipmapping(bool enable)
}
#endif
if (!glGenerateMipmap)
if (m_impl->levelCount == 1)
return true;
if (!IsMipmappingSupported())
{
NazaraError("Mipmapping not supported");
return false;
}
if (!m_impl->mipmapping && enable)
{
GLint tex;
glGetIntegerv(openglTargetBinding[m_impl->type], &tex);
if (m_impl->id == static_cast<GLuint>(tex))
{
glGenerateMipmap(openglTarget[m_impl->type]);
m_impl->mipmapsUpdated = true;
}
else
m_impl->mipmapsUpdated = false;
}
m_impl->mipmapsUpdated = false;
m_impl->mipmapping = enable;
@@ -848,7 +843,6 @@ bool NzTexture::LoadFromImage(const NzImage& image)
if (!IsFormatSupported(format))
{
nzPixelFormat newFormat = (NzPixelFormat::HasAlpha(format)) ? nzPixelFormat_BGRA8 : nzPixelFormat_BGR8;
NazaraWarning("Format not supported, trying to convert it to " + NzPixelFormat::ToString(newFormat) + "...");
if (NzPixelFormat::IsConversionSupported(format, newFormat))
@@ -872,14 +866,13 @@ bool NzTexture::LoadFromImage(const NzImage& image)
}
nzImageType type = newImage.GetType();
nzUInt8 levelCount = newImage.GetLevelCount();
if (!Create(type, format, newImage.GetWidth(), newImage.GetHeight(), newImage.GetDepth(), levelCount, true))
if (!Create(type, format, newImage.GetWidth(), newImage.GetHeight(), newImage.GetDepth(), newImage.GetLevelCount(), true))
{
NazaraError("Failed to create texture");
return false;
}
for (nzUInt8 level = 0; level < levelCount; ++level)
for (nzUInt8 level = 0; level < m_impl->levelCount; ++level)
{
if (!Update(newImage.GetConstPixels(level), level))
{
@@ -942,13 +935,13 @@ bool NzTexture::SetAnisotropyLevel(unsigned int anistropyLevel)
NazaraError("Texture must be valid");
return false;
}
#endif
if (!NzOpenGL::IsSupported(NzOpenGL::AnisotropicFilter))
{
NazaraError("Anisotropic filter not supported");
return false;
}
#endif
LockTexture(m_impl);
@@ -981,7 +974,7 @@ bool NzTexture::SetFilterMode(nzTextureFilter filter)
switch (filter)
{
case nzTextureFilter_Bilinear:
if (m_impl->levelCount > 1)
if (m_impl->mipmapping > 1)
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
else
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -990,7 +983,7 @@ bool NzTexture::SetFilterMode(nzTextureFilter filter)
break;
case nzTextureFilter_Nearest:
if (m_impl->levelCount > 1)
if (m_impl->mipmapping > 1)
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
else
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -1588,6 +1581,11 @@ bool NzTexture::IsFormatSupported(nzPixelFormat format)
return false;
}
bool NzTexture::IsMipmappingSupported()
{
return glGenerateMipmap != nullptr;
}
bool NzTexture::IsTypeSupported(nzImageType type)
{
switch (type)