Added Image
Added pixel format support Added MemoryStream Added Rect Added ResourceLoader Added generic loader (bmp, gif, hdr, jpg, jpeg, pic, png, psd, tga) Added PCX loader Added utility module initializer Fixed Config.hpp include Prerequesites.hpp now overwrites _WIN32_WINNT when defined version is less than requiered version Renderer's initialisation will implicitly initialize utility module Removed RENDERER_SINGLETON option Shaders are now resources
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#define NAZARA_BASIC_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
#ifndef M_PI
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <cmath>
|
||||
|
||||
@@ -106,8 +106,7 @@ template<typename T> class NzMatrix4
|
||||
T m31, m32, m33, m34;
|
||||
T m41, m42, m43, m44;
|
||||
|
||||
unsigned int refCount;
|
||||
|
||||
unsigned short refCount;
|
||||
NazaraMutex(mutex)
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
@@ -267,10 +268,7 @@ void NzMatrix4<T>::Set(const NzMatrix4& matrix)
|
||||
template<typename T>
|
||||
void NzMatrix4<T>::Set(NzMatrix4&& matrix)
|
||||
{
|
||||
ReleaseMatrix();
|
||||
|
||||
m_sharedMatrix = matrix.m_sharedMatrix;
|
||||
matrix.m_sharedMatrix = nullptr;
|
||||
std::swap(m_sharedMatrix, matrix.m_sharedMatrix);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Math/Basic.hpp>
|
||||
#include <Nazara/Math/Config.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
56
include/Nazara/Math/Rect.hpp
Normal file
56
include/Nazara/Math/Rect.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_RECT_HPP
|
||||
#define NAZARA_RECT_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
template<typename T>
|
||||
class NzRect
|
||||
{
|
||||
public:
|
||||
NzRect();
|
||||
NzRect(T X, T Y, T Width, T Height);
|
||||
NzRect(T rect[4]);
|
||||
template<typename U> explicit NzRect(const NzRect<U>& rect);
|
||||
NzRect(const NzRect& rect) = default;
|
||||
~NzRect() = default;
|
||||
|
||||
bool Contains(T X, T Y) const;
|
||||
bool Contains(const NzVector2<T>& point) const;
|
||||
bool Contains(const NzRect& rect) const;
|
||||
|
||||
void ExtendTo(const NzVector2<T>& point);
|
||||
void ExtendTo(const NzRect& rect);
|
||||
|
||||
bool Intersect(const NzRect& rect) const;
|
||||
bool Intersect(const NzRect& rect, NzRect& intersection) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
NzString ToString() const;
|
||||
|
||||
operator NzString() const;
|
||||
|
||||
T& operator[](unsigned int i);
|
||||
T operator[](unsigned int i) const;
|
||||
|
||||
T x, y, width, height;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzRect<T>& vec);
|
||||
|
||||
typedef NzRect<double> NzRectd;
|
||||
typedef NzRect<float> NzRectf;
|
||||
typedef NzRect<int> NzRecti;
|
||||
typedef NzRect<unsigned int> NzRectui;
|
||||
|
||||
#include <Nazara/Math/Rect.inl>
|
||||
|
||||
#endif // NAZARA_RECT_HPP
|
||||
162
include/Nazara/Math/Rect.inl
Normal file
162
include/Nazara/Math/Rect.inl
Normal file
@@ -0,0 +1,162 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <algorithm>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>::NzRect()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>::NzRect(T X, T Y, T Width, T Height) :
|
||||
x(X),
|
||||
y(Y),
|
||||
width(Width),
|
||||
height(Height)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>::NzRect(T vec[4]) :
|
||||
x(vec[0]),
|
||||
y(vec[1]),
|
||||
width(vec[2]),
|
||||
height(vec[3])
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
NzRect<T>::NzRect(const NzRect<U>& rect) :
|
||||
x(static_cast<T>(rect.x)),
|
||||
y(static_cast<T>(rect.y)),
|
||||
width(static_cast<T>(rect.width)),
|
||||
height(static_cast<T>(rect.height))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzRect<T>::Contains(T X, T Y) const
|
||||
{
|
||||
return X >= x && X < x+width &&
|
||||
Y >= y && Y < y+height;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzRect<T>::Contains(const NzVector2<T>& point) const
|
||||
{
|
||||
return Contains(point.x, point.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzRect<T>::Contains(const NzRect<T>& rect) const
|
||||
{
|
||||
return Contains(rect.x, rect.y) &&
|
||||
Contains(rect.x + rect.width, rect.y + rect.height);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzRect<T>::ExtendTo(const NzVector2<T>& point)
|
||||
{
|
||||
x = std::min(x, point.x);
|
||||
y = std::min(y, point.y);
|
||||
width = std::max(x+width, point.x)-x;
|
||||
height = std::max(x+width, point.x)-y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzRect<T>::ExtendTo(const NzRect& rect)
|
||||
{
|
||||
x = std::min(x, rect.x);
|
||||
y = std::min(y, rect.y);
|
||||
width = std::max(x+width, rect.x+rect.width)-x;
|
||||
height = std::max(x+width, rect.x+rect.height)-y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzRect<T>::Intersect(const NzRect& rect) const
|
||||
{
|
||||
NzRect intersection; // Optimisé par le compilateur
|
||||
return Intersect(rect, intersection);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzRect<T>::Intersect(const NzRect& rect, NzRect& intersection) const
|
||||
{
|
||||
T left = std::max(x, rect.x);
|
||||
T right = std::min(x+width, rect.x+rect.width);
|
||||
T top = std::max(y, rect.y);
|
||||
T bottom = std::min(y+height, rect.y+rect.height);
|
||||
|
||||
if (left < right && top < bottom)
|
||||
{
|
||||
intersection.x = left;
|
||||
intersection.y = top;
|
||||
intersection.width = right-left;
|
||||
intersection.height = top-bottom;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool NzRect<T>::IsValid() const
|
||||
{
|
||||
return width > 0 && height > 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzString NzRect<T>::ToString() const
|
||||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "Rect(" << x << ", " << y << ", " << width << ", " << height << ')';
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>::operator NzString() const
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T& NzRect<T>::operator[](unsigned int i)
|
||||
{
|
||||
if (i >= 4)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T NzRect<T>::operator[](unsigned int i) const
|
||||
{
|
||||
if (i >= 4)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)";
|
||||
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return *(&x+i);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzRect<T>& rect)
|
||||
{
|
||||
return out << rect.ToString();
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
@@ -74,6 +74,7 @@ template<typename T> NzVector2<T> operator/(T scale, const NzVector2<T>& vec);
|
||||
typedef NzVector2<double> NzVector2d;
|
||||
typedef NzVector2<float> NzVector2f;
|
||||
typedef NzVector2<int> NzVector2i;
|
||||
typedef NzVector2<unsigned int> NzVector2ui;
|
||||
|
||||
#include <Nazara/Math/Vector2.inl>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user