Merge branch 'NDK-Refactor' into NDK

Conflicts:
	examples/HardwareInfo/main.cpp
	include/Nazara/Renderer/Enums.hpp
	include/Nazara/Renderer/GpuQuery.hpp
	include/Nazara/Renderer/OpenGL.hpp
	include/Nazara/Renderer/RenderBuffer.hpp
	include/Nazara/Renderer/RenderTexture.hpp
	include/Nazara/Renderer/Texture.hpp
	src/Nazara/Graphics/AbstractRenderTechnique.cpp
	src/Nazara/Graphics/DeferredRenderTechnique.cpp
	src/Nazara/Graphics/Material.cpp
	src/Nazara/Graphics/SkyboxBackground.cpp
	src/Nazara/Renderer/GpuQuery.cpp
	src/Nazara/Renderer/OpenGL.cpp
	src/Nazara/Renderer/RenderBuffer.cpp
	src/Nazara/Renderer/RenderTexture.cpp
	src/Nazara/Renderer/Renderer.cpp
	src/Nazara/Renderer/Shader.cpp
	src/Nazara/Renderer/ShaderStage.cpp
	src/Nazara/Renderer/Texture.cpp

Former-commit-id: 2f1c7e9f9766f59ab83d9405856a1898ac4ab48f
This commit is contained in:
Lynix
2015-09-25 23:16:58 +02:00
613 changed files with 68051 additions and 66125 deletions

View File

@@ -18,7 +18,7 @@
int main()
{
// NzKeyboard ne nécessite pas l'initialisation du module Utilitaire
NzInitializer<NzAudio> audio;
Nz::Initializer<Nz::Audio> audio;
if (!audio)
{
std::cout << "Failed to initialize audio module" << std::endl;
@@ -26,7 +26,7 @@ int main()
return 1;
}
NzSound sound;
Nz::Sound sound;
if (!sound.LoadFromFile("resources/siren.wav"))
{
std::cout << "Failed to load sound" << std::endl;
@@ -44,32 +44,32 @@ int main()
sound.EnableLooping(true);
// La source du son se situe vers la gauche (Et un peu en avant)
sound.SetPosition(NzVector3f::Left()*50.f + NzVector3f::Forward()*5.f);
sound.SetPosition(Nz::Vector3f::Left()*50.f + Nz::Vector3f::Forward()*5.f);
// Et possède une vitesse de 10 par seconde vers la droite
sound.SetVelocity(NzVector3f::Left()*-10.f);
sound.SetVelocity(Nz::Vector3f::Left()*-10.f);
// On joue le son
sound.Play();
// La boucle du programme (Pour déplacer le son)
NzClock clock;
while (sound.GetStatus() == nzSoundStatus_Playing)
Nz::Clock clock;
while (sound.GetStatus() == Nz::SoundStatus_Playing)
{
// Comme le son se joue dans un thread séparé, on peut mettre en pause le principal régulièrement
int sleepTime = int(1000/60 - clock.GetMilliseconds()); // 60 FPS
if (sleepTime > 0)
NzThread::Sleep(sleepTime);
Nz::Thread::Sleep(sleepTime);
// On bouge la source du son en fonction du temps depuis chaque mise à jour
NzVector3f pos = sound.GetPosition() + sound.GetVelocity()*clock.GetSeconds();
Nz::Vector3f pos = sound.GetPosition() + sound.GetVelocity()*clock.GetSeconds();
sound.SetPosition(pos);
std::cout << "Sound position: " << pos << std::endl;
// Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
if (pos.x > NzVector3f::Left().x*-50.f || NzKeyboard::IsKeyPressed(NzKeyboard::Escape))
if (pos.x > Nz::Vector3f::Left().x*-50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Escape))
sound.Stop(); // On arrête le son (Stoppant également la boucle)
clock.Restart();

View File

@@ -1,5 +1,5 @@
/*
** HardwareInfo - Récupération des caractéristiques de l'ordinateur
** Nz::HardwareInfo - Récupération des caractéristiques de l'ordinateur
** Prérequis: Aucun
** Utilisation du noyau et du module de rendu
** Présente:
@@ -15,7 +15,7 @@
#include <iostream>
#include <sstream>
void printCap(std::ostream& o, const NzString& cap, bool b);
void printCap(std::ostream& o, const Nz::String& cap, bool b);
int main()
{
@@ -28,63 +28,63 @@ int main()
// Plutôt que d'initialiser le Renderer de Nazara, nous initialisons les deux classes utilisées ici
// Elles sont compatibles avec NzInitialiser et seront donc libérées automatiquement
// Cela permet d'avoir une initialisation plus rapide et un coût en mémoire moindre
NzInitializer<NzHardwareInfo> hardwareInfo;
Nz::Initializer<Nz::HardwareInfo> hardwareInfo;
if (hardwareInfo)
{
// On commence par les informations sur le processeur, Nazara en récupère trois caractéristiques:
// 1) La "brand string", qui est une chaîne de 48 caractères identifiant le processeur
// 2) Le concepteur du processeur, accessible via une énumération (GetProcessorVendor) ou une chaîne de caractère (GetProcessorVendorName)
// 3) Le nombre de processeurs logique, alias bien souvent le nombre de coeurs (logiques), cette valeur est renvoyée par l'OS (Le SMT multiplie donc la valeur réelle)
oss << "Identification: " << NzHardwareInfo::GetProcessorBrandString() << std::endl;
oss << "Concepteur: " << NzHardwareInfo::GetProcessorVendorName() << std::endl;
oss << "Nombre de coeurs logiques: " << NzHardwareInfo::GetProcessorCount() << std::endl;
oss << "Identification: " << Nz::HardwareInfo::GetProcessorBrandString() << std::endl;
oss << "Concepteur: " << Nz::HardwareInfo::GetProcessorVendorName() << std::endl;
oss << "Nombre de coeurs logiques: " << Nz::HardwareInfo::GetProcessorCount() << std::endl;
oss << std::endl;
// Ensuite, Nazara récupère les capacités du processeur, dont des jeux d'extensions supplémentaires
oss << "Rapport des capacites: " << std::endl;// Pas d'accent car écriture dans un fichier (et on ne va pas s'embêter avec ça)
printCap(oss, "-64bits", NzHardwareInfo::HasCapability(nzProcessorCap_x64));
printCap(oss, "-AVX", NzHardwareInfo::HasCapability(nzProcessorCap_AVX));
printCap(oss, "-FMA3", NzHardwareInfo::HasCapability(nzProcessorCap_FMA3));
printCap(oss, "-FMA4", NzHardwareInfo::HasCapability(nzProcessorCap_FMA4));
printCap(oss, "-MMX", NzHardwareInfo::HasCapability(nzProcessorCap_MMX));
printCap(oss, "-SSE", NzHardwareInfo::HasCapability(nzProcessorCap_SSE));
printCap(oss, "-SSE2", NzHardwareInfo::HasCapability(nzProcessorCap_SSE2));
printCap(oss, "-SSE3", NzHardwareInfo::HasCapability(nzProcessorCap_SSE3));
printCap(oss, "-SSSE3", NzHardwareInfo::HasCapability(nzProcessorCap_SSSE3));
printCap(oss, "-SSE4.1", NzHardwareInfo::HasCapability(nzProcessorCap_SSE41));
printCap(oss, "-SSE4.2", NzHardwareInfo::HasCapability(nzProcessorCap_SSE42));
printCap(oss, "-SSE4.a", NzHardwareInfo::HasCapability(nzProcessorCap_SSE4a));
printCap(oss, "-64bits", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_x64));
printCap(oss, "-AVX", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_AVX));
printCap(oss, "-FMA3", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_FMA3));
printCap(oss, "-FMA4", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_FMA4));
printCap(oss, "-MMX", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_MMX));
printCap(oss, "-SSE", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE));
printCap(oss, "-SSE2", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE2));
printCap(oss, "-SSE3", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE3));
printCap(oss, "-SSSE3", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSSE3));
printCap(oss, "-SSE4.1", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE41));
printCap(oss, "-SSE4.2", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE42));
printCap(oss, "-SSE4.a", Nz::HardwareInfo::HasCapability(Nz::ProcessorCap_SSE4a));
}
else
oss << "Impossible de retrouver les informations du processeur" << std::endl;
oss << std::endl << "--Carte graphique--" << std::endl;
// La classe NzOpenGL nous donne accès à des informations sur la carte graphique
// La classe OpenGL nous donne accès à des informations sur la carte graphique
// Cependant celle-ci n'est accessible que si le projet est compilé avec NAZARA_RENDERER_OPENGL
// et que les répertoires d'inclusions donnent accès aux includes d'OpenGL (Cette démo utilisent ceux de Nazara)
NzInitializer<NzOpenGL> openGL;
Nz::Initializer<Nz::OpenGL> openGL;
if (openGL)
{
// Nous récupérons ensuite la version d'OpenGL sous forme d'entier (ex: OpenGL 3.3 donnera 330)
unsigned int openglVersion = NzOpenGL::GetVersion();
unsigned int openglVersion = Nz::OpenGL::GetVersion();
// NzOpenGL nous donne accès à trois informations principales:
// OpenGL nous donne accès à trois informations principales:
// 1) La chaîne d'identification du driver ("Renderer name")
// 2) La chaîne d'identification du concepteur ("Vendor name")
// 3) La version d'OpenGL
oss << "Identification: " << NzOpenGL::GetRendererName() << std::endl;
oss << "Concepteur: " << NzOpenGL::GetVendorName() << std::endl;
oss << "Identification: " << Nz::OpenGL::GetRendererName() << std::endl;
oss << "Concepteur: " << Nz::OpenGL::GetVendorName() << std::endl;
oss << "Version d'OpenGL: " << openglVersion/100 << '.' << openglVersion%100 << std::endl;
oss << std::endl;
// Ainsi qu'un report des capacités de la carte graphique (avec le driver actuel)
oss << "Rapport des capacites: " << std::endl; // Pas d'accent car écriture dans un fichier (et on ne va pas s'embêter avec ça)
printCap(oss, "-Calculs 64bits", NzOpenGL::IsSupported(nzOpenGLExtension_FP64));
printCap(oss, "-Compression de textures (s3tc)", NzOpenGL::IsSupported(nzOpenGLExtension_TextureCompression_s3tc));
printCap(oss, "-Filtrage anisotrope", NzOpenGL::IsSupported(nzOpenGLExtension_AnisotropicFilter));
printCap(oss, "-Mode debug", NzOpenGL::IsSupported(nzOpenGLExtension_DebugOutput));
printCap(oss, "-Separate shader objects", NzOpenGL::IsSupported(nzOpenGLExtension_SeparateShaderObjects));
printCap(oss, "-Texture storage", NzOpenGL::IsSupported(nzOpenGLExtension_TextureStorage));
printCap(oss, "-Calculs 64bits", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_FP64));
printCap(oss, "-Compression de textures (s3tc)", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_TextureCompression_s3tc));
printCap(oss, "-Filtrage anisotrope", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_AnisotropicFilter));
printCap(oss, "-Mode debug", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_DebugOutput));
printCap(oss, "-Separate shader objects", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_SeparateShaderObjects));
printCap(oss, "-Texture storage", Nz::OpenGL::IsSupported(Nz::OpenGLExtension_TextureStorage));
}
else
oss << "Impossible de retrouver les informations de la carte graphique" << std::endl;
@@ -94,14 +94,14 @@ int main()
std::cout << oss.str() << std::endl;
NzFile reportFile("RapportHardwareInfo.txt");
if (reportFile.Open(nzOpenMode_Text | nzOpenMode_Truncate | nzOpenMode_WriteOnly))
Nz::File reportFile("RapportNz::HardwareInfo.txt");
if (reportFile.Open(Nz::OpenMode_Text | Nz::OpenMode_Truncate | Nz::OpenMode_WriteOnly))
{
reportFile.Write(oss.str()); // Conversion implicite en NzString
reportFile.Write(oss.str()); // Conversion implicite en Nz::String
reportFile.Close();
char accentAigu = static_cast<char>(130); // C'est crade, mais ça marche chez 95% des Windowsiens
std::cout << "Un fichier (RapportHardwareInfo.txt) contenant le rapport a " << accentAigu << 't' << accentAigu << " cr" << accentAigu << accentAigu << std::endl;
std::cout << "Un fichier (RapportNz::HardwareInfo.txt) contenant le rapport a " << accentAigu << 't' << accentAigu << " cr" << accentAigu << accentAigu << std::endl;
}
else
std::cout << "Impossible de sauvegarder le rapport" << std::endl;
@@ -111,7 +111,7 @@ int main()
return 0;
}
void printCap(std::ostream& o, const NzString& cap, bool b)
void printCap(std::ostream& o, const Nz::String& cap, bool b)
{
if (b)
o << cap << ": Oui" << std::endl;

View File

@@ -11,7 +11,7 @@
int main()
{
// Pour charger des ressources, il est impératif d'initialiser le module utilitaire
NzInitializer<NzUtility> utility;
Initializer<Utility> utility;
if (!utility)
{
// Ça n'a pas fonctionné, le pourquoi se trouve dans le fichier NazaraLog.log
@@ -22,7 +22,7 @@ int main()
for (;;)
{
NzDirectory resourceDirectory("resources/");
Directory resourceDirectory("resources/");
if (!resourceDirectory.Open())
{
std::cerr << "Failed to open resource directory" << std::endl;
@@ -30,12 +30,12 @@ int main()
return EXIT_FAILURE;
}
std::vector<NzString> models;
std::vector<String> models;
while (resourceDirectory.NextResult())
{
NzString path = resourceDirectory.GetResultName();
NzString ext = path.SubStringFrom('.', -1, true); // Tout ce qui vient après le dernier '.' de la chaîne
if (NzMeshLoader::IsExtensionSupported(ext)) // L'extension est-elle supportée par le MeshLoader ?
String path = resourceDirectory.GetResultName();
String ext = path.SubStringFrom('.', -1, true); // Tout ce qui vient après le dernier '.' de la chaîne
if (MeshLoader::IsExtensionSupported(ext)) // L'extension est-elle supportée par le MeshLoader ?
models.push_back(path);
}
@@ -67,7 +67,7 @@ int main()
if (iChoice == 0)
break;
NzMesh mesh;
Mesh mesh;
if (!mesh.LoadFromFile("resources/" + models[iChoice-1]))
{
std::cout << "Failed to load mesh" << std::endl;
@@ -77,11 +77,11 @@ int main()
switch (mesh.GetAnimationType())
{
case nzAnimationType_Skeletal:
case AnimationType_Skeletal:
std::cout << "This is a skeletal-animated mesh" << std::endl;
break;
case nzAnimationType_Static:
case AnimationType_Static:
std::cout << "This is a static mesh" << std::endl;
break;
@@ -92,9 +92,9 @@ int main()
if (mesh.IsAnimable())
{
if (mesh.GetAnimationType() == nzAnimationType_Skeletal)
if (mesh.GetAnimationType() == AnimationType_Skeletal)
{
const NzSkeleton* skeleton = mesh.GetSkeleton();
const Skeleton* skeleton = mesh.GetSkeleton();
unsigned int jointCount = skeleton->GetJointCount();
std::cout << "It has a skeleton made of " << skeleton->GetJointCount() << " joint(s)." << std::endl;
std::cout << "Print joints ? (Y/N) ";
@@ -107,10 +107,10 @@ int main()
{
for (unsigned int i = 0; i < jointCount; ++i)
{
const NzJoint* joint = skeleton->GetJoint(i);
const Joint* joint = skeleton->GetJoint(i);
std::cout << "\t" << (i+1) << ": " << joint->GetName();
const NzJoint* parent = static_cast<const NzJoint*>(joint->GetParent());
const Joint* parent = static_cast<const Joint*>(joint->GetParent());
if (parent)
std::cout << " (Parent: " << parent->GetName() << ')';
@@ -119,10 +119,10 @@ int main()
}
}
NzString animationPath = mesh.GetAnimation();
String animationPath = mesh.GetAnimation();
if (!animationPath.IsEmpty())
{
NzAnimation animation;
Animation animation;
if (animation.LoadFromFile(animationPath))
{
unsigned int sequenceCount = animation.GetSequenceCount();
@@ -137,7 +137,7 @@ int main()
{
for (unsigned int i = 0; i < sequenceCount; ++i)
{
const NzSequence* sequence = animation.GetSequence(i);
const Sequence* sequence = animation.GetSequence(i);
std::cout << "\t" << (i+1) << ": " << sequence->name << std::endl;
std::cout << "\t\tStart frame: " << sequence->firstFrame << std::endl;
std::cout << "\t\tFrame count: " << sequence->frameCount << std::endl;
@@ -153,7 +153,7 @@ int main()
std::cout << "It's animable but has no animation information" << std::endl;
}
NzBoxf cube = mesh.GetAABB();
Boxf cube = mesh.GetAABB();
std::cout << "Mesh is " << cube.width << " units wide, " << cube.height << " units height and " << cube.depth << " units depth" << std::endl;
unsigned int materialCount = mesh.GetMaterialCount();