diff --git a/NazaraModuleTemplate/include/Nazara/ModuleName/ModuleName.hpp b/NazaraModuleTemplate/include/Nazara/ModuleName/ModuleName.hpp index 70d8f6918..54bc0f3b8 100644 --- a/NazaraModuleTemplate/include/Nazara/ModuleName/ModuleName.hpp +++ b/NazaraModuleTemplate/include/Nazara/ModuleName/ModuleName.hpp @@ -8,20 +8,22 @@ #define NAZARA_MODULENAME_HPP #include +#include class NAZARA_API NzModuleName { public: - NzModuleName(); - ~NzModuleName(); + NzModuleName() = delete; + ~NzModuleName() = delete; - bool Initialize(); - void Uninitialize(); + static bool Initialize(); static bool IsInitialized(); + static void Uninitialize(); + private: - static bool s_initialized; + static unsigned int s_moduleReferenceCouter; }; #endif // NAZARA_MODULENAME_HPP diff --git a/NazaraModuleTemplate/src/Nazara/ModuleName/ModuleName.cpp b/NazaraModuleTemplate/src/Nazara/ModuleName/ModuleName.cpp index f6cbd4530..7c600b5de 100644 --- a/NazaraModuleTemplate/src/Nazara/ModuleName/ModuleName.cpp +++ b/NazaraModuleTemplate/src/Nazara/ModuleName/ModuleName.cpp @@ -3,55 +3,47 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include +#include #include #include -NzModuleName::NzModuleName() -{ -} - -NzModuleName::~NzModuleName() -{ - if (s_initialized) - Uninitialize(); -} - bool NzModuleName::Initialize() { - #if NAZARA_MODULENAME_SAFE - if (s_initialized) + if (s_moduleReferenceCouter++ != 0) + return true; // Déjà initialisé + + // Initialisation des dépendances + if (!NzCore::Initialize()) { - NazaraError("ModuleName already initialized"); - return true; + NazaraError("Failed to initialize core module"); + return false; } - #endif // Initialisation du module - s_initialized = true; + NazaraNotice("Initialized: ModuleName module"); return true; } +bool NzModuleName::IsInitialized() +{ + return s_moduleReferenceCouter != 0; +} + void NzModuleName::Uninitialize() { - #if NAZARA_MODULENAME_SAFE - if (!s_initialized) - { - NazaraError("ModuleName not initialized"); - return; - } - #endif + if (--s_moduleReferenceCouter != 0) + return; // Encore utilisé // Libération du module - s_initialized = false; + NazaraNotice("Uninitialized: ModuleName module"); + + // Libération des dépendances + NzCore::Uninitialize(); } -bool NzModuleName::IsInitialized() -{ - return s_initialized; -} - -bool NzModuleName::s_initialized = false; +unsigned int NzModuleName::s_moduleReferenceCouter = 0; diff --git a/build/Build CodeBlocks + examples.bat b/build/Build CodeBlocks + examples.bat new file mode 100644 index 000000000..d56d06eac --- /dev/null +++ b/build/Build CodeBlocks + examples.bat @@ -0,0 +1 @@ +premake4 --with-examples codeblocks \ No newline at end of file diff --git a/build/Build Visual Studio 2010 + examples.bat b/build/Build Visual Studio 2010 + examples.bat new file mode 100644 index 000000000..b6e707acd --- /dev/null +++ b/build/Build Visual Studio 2010 + examples.bat @@ -0,0 +1 @@ +premake4 --with-examples vs2010 \ No newline at end of file diff --git a/build/Generate Headers.bat b/build/Generate Headers.bat new file mode 100644 index 000000000..41ac7b82a --- /dev/null +++ b/build/Generate Headers.bat @@ -0,0 +1,2 @@ +premake4 generateheaders +pause \ No newline at end of file diff --git a/build/scripts/actions/examples.lua b/build/scripts/actions/examples.lua new file mode 100644 index 000000000..0cb6d9ef7 --- /dev/null +++ b/build/scripts/actions/examples.lua @@ -0,0 +1,10 @@ +function examples() + dofile("../examples/build/common.lua") +end + +newaction +{ + trigger = "examples", + description = "Generate examples", + execute = examples +} \ No newline at end of file diff --git a/build/scripts/actions/headergenerator.lua b/build/scripts/actions/headergenerator.lua new file mode 100644 index 000000000..0553807f4 --- /dev/null +++ b/build/scripts/actions/headergenerator.lua @@ -0,0 +1,54 @@ +function generateHeaders() + local modules = os.matchdirs("../include/Nazara/*") + for k, modulePath in pairs(modules) do + local moduleName = modulePath:match(".*/(.*)") + print(moduleName) + + local config, err = io.open(modulePath .. "/Config.hpp", "r") + local head = "" + if (not config) then + error("Failed to read config file: " .. err) + end + + for line in config:lines() do + head = head .. line .. "\n" + if (line == "#pragma once") then -- On s'arrête au #pragma once, qu'on inclut quand même + break + end + end + + config:close() + + local header, err = io.open(modulePath .. ".hpp", "w+") + if (not header) then + error("Failed to create header file: " .. err) + end + + header:write("// This file was automatically generated by Nazara\n\n") + header:write(head .. "\n") + + local files = os.matchfiles(modulePath .. "/*.hpp") + local count = 0 + for k, filePath in pairs(files) do + local include, fileName = filePath:match(".*(Nazara/.*/(.*))") + if (fileName ~= "Debug.hpp" and + fileName ~= "DebugOff.hpp" and + fileName ~= "ThreadSafety.hpp" and + fileName ~= "ThreadSafetyOff.hpp") then + header:write("#include <" .. include .. ">\n") + count = count + 1 + end + end + + print(string.format("-# of includes: %d", count)) + + header:close() + end +end + +newaction +{ + trigger = "generateheaders", + description = "Generate a global header for each module", + execute = generateHeaders +} \ No newline at end of file diff --git a/build/scripts/common.lua b/build/scripts/common.lua index d2df3aa9a..75b85d056 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -9,11 +9,14 @@ configurations defines "NAZARA_BUILD" language "C++" +location(_ACTION) + includedirs { "../include", "../src/" } + libdirs "../lib" targetdir "../lib" @@ -22,7 +25,7 @@ configuration "Debug*" flags "Symbols" configuration "Release*" - flags { "Optimize", "OptimizeSpeed" } + flags { "EnableSSE2", "Optimize", "OptimizeSpeed", "NoFramePointer", "NoRTTI" } configuration "*Static" defines "NAZARA_STATIC" diff --git a/build/scripts/common_examples.lua b/build/scripts/common_examples.lua new file mode 100644 index 000000000..0fcc880f7 --- /dev/null +++ b/build/scripts/common_examples.lua @@ -0,0 +1,33 @@ +-- Configuration générale +configurations +{ + "DebugStatic", + "ReleaseStatic", + "DebugDLL", + "ReleaseDLL" +} + +language "C++" +location("../examples/build/" .. _ACTION) + +includedirs +{ + "../include" +} + +debugdir "../examples/bin" +libdirs "../lib" +targetdir "../examples/bin" + +configuration "Debug*" + defines "NAZARA_DEBUG" + flags "Symbols" + +configuration "Release*" + flags { "EnableSSE2", "Optimize", "OptimizeSpeed", "NoFramePointer", "NoRTTI" } + +configuration "*Static" + defines "NAZARA_STATIC" + +configuration "gmake" + buildoptions "-std=c++11" diff --git a/build/scripts/module/audio.lua b/build/scripts/module/audio.lua deleted file mode 100644 index f8a123635..000000000 --- a/build/scripts/module/audio.lua +++ /dev/null @@ -1,31 +0,0 @@ -project "NazaraAudio" - -files -{ - "../include/Nazara/Audio/**.hpp", - "../include/Nazara/Audio/**.inl", - "../src/Nazara/Audio/**.hpp", - "../src/Nazara/Audio/**.cpp" -} - -if (os.is("windows")) then - excludes { "../src/Nazara/Audio/Posix/*.hpp", "../src/Nazara/Audio/Posix/*.cpp" } -else - excludes { "../src/Nazara/Audio/Win32/*.hpp", "../src/Nazara/Audio/Win32/*.cpp" } -end - -configuration "DebugStatic" - links "NazaraCored-s" - targetname "NazaraAudiod" - -configuration "ReleaseStatic" - links "NazaraCore-s" - targetname "NazaraAudio" - -configuration "DebugDLL" - links "NazaraCored" - targetname "NazaraAudiod" - -configuration "ReleaseDLL" - links "NazaraCore" - targetname "NazaraAudio" \ No newline at end of file diff --git a/build/scripts/module/core.lua b/build/scripts/module/core.lua index d2842982b..4efb6b578 100644 --- a/build/scripts/module/core.lua +++ b/build/scripts/module/core.lua @@ -5,6 +5,8 @@ files "../include/Nazara/Prerequesites.hpp", "../include/Nazara/Core/**.hpp", "../include/Nazara/Core/**.inl", + "../include/Nazara/Math/**.hpp", + "../include/Nazara/Math/**.inl", "../src/Nazara/Core/**.hpp", "../src/Nazara/Core/**.cpp" } diff --git a/build/scripts/module/network.lua b/build/scripts/module/network.lua deleted file mode 100644 index 49ba48744..000000000 --- a/build/scripts/module/network.lua +++ /dev/null @@ -1,35 +0,0 @@ -project "NazaraNetwork" - -if (os.is("windows")) then - links "ws2_32" -end - -files -{ - "../include/Nazara/Network/**.hpp", - "../include/Nazara/Network/**.inl", - "../src/Nazara/Network/**.hpp", - "../src/Nazara/Network/**.cpp" -} - -if (os.is("windows")) then - excludes { "../src/Nazara/Network/Posix/*.hpp", "../src/Nazara/Network/Posix/*.cpp" } -else - excludes { "../src/Nazara/Network/Win32/*.hpp", "../src/Nazara/Network/Win32/*.cpp" } -end - -configuration "DebugStatic" - links "NazaraCored-s" - targetname "NazaraNetworkd" - -configuration "ReleaseStatic" - links "NazaraCore-s" - targetname "NazaraNetwork" - -configuration "DebugDLL" - links "NazaraCored" - targetname "NazaraNetworkd" - -configuration "ReleaseDLL" - links "NazaraCore" - targetname "NazaraNetwork" \ No newline at end of file diff --git a/examples/AnimatedMesh/build.lua b/examples/AnimatedMesh/build.lua new file mode 100644 index 000000000..4d93b53c9 --- /dev/null +++ b/examples/AnimatedMesh/build.lua @@ -0,0 +1,23 @@ +kind "ConsoleApp" + +files "main.cpp" + +configuration "DebugStatic" + links "NazaraCored-s" + links "NazaraRendererd-s" + links "NazaraUtilityd-s" + +configuration "ReleaseStatic" + links "NazaraCore-s" + links "NazaraRenderer-s" + links "NazaraUtility-s" + +configuration "DebugDLL" + links "NazaraCored" + links "NazaraRendererd" + links "NazaraUtilityd" + +configuration "ReleaseDLL" + links "NazaraCore" + links "NazaraRenderer" + links "NazaraUtility" \ No newline at end of file diff --git a/examples/AnimatedMesh/main.cpp b/examples/AnimatedMesh/main.cpp new file mode 100644 index 000000000..0617aaa5d --- /dev/null +++ b/examples/AnimatedMesh/main.cpp @@ -0,0 +1,623 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Une structure pour contenir nos informations (Cette structure est très simpliste) +struct Model +{ + NzMatrix4f matrix; // Les transformations subies par le modèle + NzMesh mesh; // Le mesh + NzTexture texture; // Sa texture +}; + +struct AnimatedModel : public Model +{ + // Quelques variables pour l'animation + const NzSequence* currentSequence = nullptr; // La séquence en cours + float interpolation = 0.f; // La valeur de l'interpolation ([0..1], si dépasse 1, on passe à la frame suivante) + unsigned int currentFrame = 0; // La première frame + unsigned int nextFrame; // La seconde frame, l'animation est interpollée entre ces deux-là +}; + +void AnimateModel(AnimatedModel& moedel, float elapsed); +bool CreateCheckerTexture(NzTexture* texture); +bool CreateFloorMesh(NzMesh* mesh); +void DrawModel(const Model& model); +void SetSequence(AnimatedModel& model, const NzString& name); + +int main() +{ + // Tout d'abord on affiche les instructions + std::cout << "Camera controls: ZQSD" << std::endl; + std::cout << "Dr. Freak controls: Up, down, left and right" << std::endl; + std::cout << "Escape to quit" << std::endl; + + // Cette ligne active le mode de compatibilité d'OpenGL lors de l'initialisation de Nazara (Nécessaire pour le shader) + NzContextParameters::defaultCompatibilityProfile = true; + + // Maintenant nous initialisons le Renderer (Qui initialisera le noyau ainsi que le module utlitaire) + // Cette étape est obligatoire pour beaucoup de classes + NzInitializer renderer; + if (!renderer) + { + // Ça n'a pas fonctionné, le pourquoi se trouve dans le fichier NazaraLog.log + std::cout << "Failed to initialize Nazara, see NazaraLog.log for further informations" << std::endl; + std::getchar(); // On laise le temps de voir l'erreur + return EXIT_FAILURE; + } + + // Maintenant nous pouvons utiliser le moteur comme bon nous semble, tout d'abord nous allons charger les ressources + + // Charger une ressource se fait actuellement manuellement, mais un ResourceManager est à venir + // Vous initialisez une ressource, et la chargez via sa méthode LoadFrom[File|Memory|Stream] + // Note: il est possible de donner des instructions au loader (qui va charger le fichier en ressource) via les ResourceParameters + NzMeshParams parameters; + + // Le loader doit-il automatiquement charger les animations ? + // Attention, ce paramètre possède une signification différente selon le type d'animation du mesh. + // -Pour les animations keyframe (image-clé), c'est la seule et unique façon de charger les animations, étant donné + // qu'elles sont fourniees avec le mesh. + // -Pour les animations squelettiques, le loader ne fera que charger automatiquement l'animation associée au mesh s'il le peut + // Dans les deux cas, les paramètres d'animations (parameters.animation) seront utilisés + parameters.loadAnimations = true; // Vaut true par défaut + + // Pour qu'un mesh puisse être rendu, il doit être stocké du côté de la carte graphique (Hardware), mais il est parfois utile de + // le stocker côté RAM, par exemple pour le moteur physique. En sachant qu'il est facile de changer le stockage d'un buffer. + parameters.storage = nzBufferStorage_Hardware; // Vaut nzBufferStorage_Hardware par défaut + + AnimatedModel drfreak; + if (!drfreak.mesh.LoadFromFile("resources/drfreak.md2", parameters)) // On charge notre bon vieux docteur avec les paramètres de chargement. + { + // Le chargement n'a pas fonctionné, le modèle est peut-être corrompu/non-supporté, ou alors n'existe pas. + std::cout << "Failed to load mesh" << std::endl; + std::getchar(); // On laise le temps de voir l'erreur + return EXIT_FAILURE; + } + + if (!drfreak.mesh.HasAnimation()) // Le mesh possède-t-il des animations ? + { + // Cette démo n'a aucun intérêt sans animations + std::cout << "Mesh has no animation" << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + SetSequence(drfreak, "stand"); + + // Il est possible que le mesh possède un ou plusieurs skin, nous utiliserons cette information pour charger une texture + if (drfreak.mesh.HasSkin()) + { + // Contrairement aux autres ressources, la texture n'est pas critique + if (drfreak.texture.LoadFromFile("resources/" + drfreak.mesh.GetSkin())) + drfreak.texture.SetFilterMode(nzTextureFilter_Bilinear); // Appliquons-lui un filtrage bilinéaire + else + std::cout << "Failed to load texture" << std::endl; + } + + if (!drfreak.texture.IsValid()) // Les méthodes Resource::IsValid indiquent si la ressource a été correctement créée + { + std::cout << "Creating checker texture for mesh" << std::endl; + + if (!CreateCheckerTexture(&drfreak.texture)) + { + std::cout << "Failed to create mesh texture" << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + } + + // Nous créons maintenant notre sol + Model floor; + if (!CreateFloorMesh(&floor.mesh)) + { + std::cout << "Failed to create floor" << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + if (!CreateCheckerTexture(&floor.texture)) + { + std::cout << "Failed to create floor texture" << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + // Le sol ne subit aucune transformation + floor.matrix.MakeIdentity(); + + // Pour effectuer un rendu, il faut que la carte graphique sache quoi faire. + // Les shaders sont de petits programmes qui donnent des instructions à la carte graphique lors du pipeline. + // Ils sont aujourd'hui indispensables pour un rendu 3D, mais sont très utiles pour divers effets ! + // Il existe plusieurs langages de shaders, GLSL pour OpenGL, HLSL pour Direct3D et Cg qui peut être utilisé pour les deux. + // Le Renderer de Nazara utilise OpenGL, par conséquent nous utiliserons le GLSL + // La méthode NzShader::IsLanguageSupported permet de savoir si un langage est supporté. + NzShader shader; + if (!shader.Create(nzShaderLanguage_GLSL)) + { + std::cout << "Failed to load shader" << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + // Une fois le shader créé, nous devons lui spécifier les codes sources de nos shaders + // Pour notre exemple nous prendrons un shader très simple + // Un shader doit obligatoirement posséder au moins deux codes, un pour le fragment shader et un pour le vertex shader + if (!shader.LoadFromFile(nzShaderType_Fragment, "shaders/basic.frag")) + { + std::cout << "Failed to load fragment shader from file" << std::endl; + // À la différence des autres ressources, le shader possède un log qui peut indiquer les erreurs en cas d'échec + std::cout << "Log: " << shader.GetLog() << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + // Maintenant le vertex shader + if (!shader.LoadFromFile(nzShaderType_Vertex, "shaders/basic.vert")) + { + std::cout << "Failed to load vertex shader from file" << std::endl; + std::cout << "Log: " << shader.GetLog() << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + // Une fois le code source de nos shaders chargé, nous pouvons le compiler, afin de le rendre utilisable + if (!shader.Compile()) + { + std::cout << "Failed to compile shader" << std::endl; + std::cout << "Log: " << shader.GetLog() << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + // Nos ressources sont chargées, et c'est bien beau, mais il nous faudrait une fenêtre pour afficher tout ça + // Window représente une fenêtre singulière, pour y effectuer un rendu il nous faut une RenderWindow + // Tout d'abord, sa taille, disons celle du bureau divisé par deux + NzVideoMode mode = NzVideoMode::GetDesktopMode(); + mode.width /= 2; + mode.height /= 2; + + NzString title = "Nazara Demo - AnimatedMesh"; + + NzRenderWindow window; + // Le premier argument définit la taille de rendu de la fenêtre (Si elle possède des bordures elle sera légèrement plus grande) + // Le deuxième argument est le titre de la fenêtre lors de sa création, vous pouvez le modifier à tout moment via window.SetTitle + // Le troisième argument représente la décoration de la fenêtre, sa bordure, ses boutons. + // Attention que cela permet à la fenêtre d'envoyer des évènements, et de changer sa taille + // Par défaut le troisième argument vaut nzWindowStyle_Default (Bordure + Bouton de fermeture + Redimensionnement) + if (!window.Create(mode, title, nzWindowStyle_Default)) + { + std::cout << "Failed to create window" << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + // On cache le curseur + window.SetCursor(nzWindowCursor_None); + + // Nous limitons les FPS à 100 + window.SetFramerateLimit(100); + + // La matrice de projection définit la transformation du vertice 3D à un point 2D + NzRenderer::SetMatrix(nzMatrixType_Projection, NzMatrix4f::Perspective(NzDegrees(70.f), static_cast(window.GetWidth())/window.GetHeight(), 1.f, 1000.f)); + + // Notre fenêtre est créée, cependant il faut s'occuper d'elle, pour le rendu et les évènements + NzClock secondClock, updateClock; // Des horloges pour gérer le temps + unsigned int fps = 0; // Compteur de FPS + + // Quelques variables pour notre improvisation de physique + float groundPos = drfreak.mesh.GetAABB().GetMinimum().y; // Pas très exact + NzVector3f modelPos(0.f, groundPos, -50.f); + NzVector3f modelVel(0.f, 0.f, 0.f); + NzQuaternionf modelRot(NzEulerAnglesf(0.f, 0.f, 0.f)); // Les angles d'eulers sont bien plus facile à se représenter + float speed = 60.f; + + // Nous initialisons la matrice + drfreak.matrix = NzMatrix4f::Rotate(modelRot) * NzMatrix4f::Translate(modelPos); + + // Notre caméra + NzVector3f camPos(0.f, 25.f, -20.f); + NzEulerAnglesf camRot(0.f, 0.f, 0.f); + NzMatrix4f camMatrix = NzMatrix4f::Translate(camPos); + float camSpeed = 2.f; + float sensitivity = 0.5; + + // Dernière étape, nos touches + + // Chaque touche fera bouger + struct Movement + { + NzVector3f direction; // La direction + NzQuaternionf rotation; // La rotation du modèle + }; + + std::map movements; + movements[NzKeyboard::Up] = Movement{NzVector3f(0.f, 0.f, -1.f), NzQuaternionf(NzEulerAnglesf(0.f, 180.f, 0.f))}; + movements[NzKeyboard::Down] = Movement{NzVector3f(0.f, 0.f, 1.f), NzQuaternionf(NzEulerAnglesf(0.f, 0.f, 0.f))}; + movements[NzKeyboard::Left] = Movement{NzVector3f(-1.f, 0.f, 0.f), NzQuaternionf(NzEulerAnglesf(0.f, 90.f, 0.f))}; + movements[NzKeyboard::Right] = Movement{NzVector3f(1.f, 0.f, 0.f), NzQuaternionf(NzEulerAnglesf(0.f, -90.f, 0.f))}; + NzKeyboard::Key currentKey = NzKeyboard::Undefined; + + // Quelques booléens + bool camMode = true; + bool windowOpen = true; + while (windowOpen) + { + // Ici nous gérons les évènements + NzEvent event; + while (window.PollEvent(&event)) // Avons-nous un évènement dans la file ? + { + // Nous avons un évènement + switch (event.type) // De quel type est cet évènement ? + { + case nzEventType_Quit: // L'utilisateur/L'OS nous a demandé de terminer notre exécution + windowOpen = false; // Nous fermons alors la boucle + break; + + case nzEventType_MouseMoved: + { + // Si nous ne sommes pas en mode caméra, on ne traite pas l'évènement + if (!camMode) + break; + + // On modifie l'angle de la caméra grâce au déplacement relatif de la souris + camRot.yaw = NzNormalizeAngle(camRot.yaw - event.mouseMove.deltaX*sensitivity); + + // Pour éviter les loopings, on restreint les angles + camRot.pitch = NzClamp(camRot.pitch + event.mouseMove.deltaY*sensitivity, -90.f, 90.f); + + // La matrice vue représente les transformations effectuées par la caméra + // On recalcule la matrice de la caméra et on l'envoie au renderer + NzRenderer::SetMatrix(nzMatrixType_View, NzMatrix4f::Translate(camPos) * NzMatrix4f::Rotate(camRot)); + + // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre + NzMouse::SetPosition(window.GetWidth()/2, window.GetHeight()/2, window); + break; + } + + case nzEventType_MouseButtonPressed: + if (event.mouseButton.button == NzMouse::Left) + { + // L'utilisateur vient d'appuyer sur le bouton left de la souris + // Nous allons inverser le mode caméra et montrer/cacher le curseur en conséquence + if (camMode) + { + camMode = false; + window.SetCursor(nzWindowCursor_Default); + } + else + { + camMode = true; + window.SetCursor(nzWindowCursor_None); + } + + } + break; + + case nzEventType_Resized: // L'utilisateur a changé notre taille, le coquin ! + NzRenderer::SetViewport(NzRectui(0, 0, event.size.width, event.size.height)); // Adaptons l'affichage + + // Il nous faut aussi mettre à jour notre matrice de projection + NzRenderer::SetMatrix(nzMatrixType_Projection, NzMatrix4f::Perspective(NzDegrees(70.f), static_cast(event.size.width)/event.size.height, 1.f, 1000.f)); + break; + + case nzEventType_KeyPressed: + if (!event.key.repeated) // Si la touche n'est pas répétée + { + auto it = movements.find(event.key.code); + if (it != movements.end()) + { + // Si la touche est une touche de mouvement + SetSequence(drfreak, "run"); // On anime le personnage pour qu'il ait une animation de déplacement + + modelRot = it->second.rotation; // On change la rotation du modèle + drfreak.matrix = NzMatrix4f::Rotate(modelRot) * NzMatrix4f::Translate(modelPos); // On recalcule sa matrice + modelVel = it->second.direction * speed; // On change la vitesse de déplacement + currentKey = event.key.code; + } + } + + if (event.key.code == NzKeyboard::Escape) + windowOpen = false; + + break; + + case nzEventType_KeyReleased: + if (event.key.code == currentKey) + { + SetSequence(drfreak, "stand"); + modelVel = NzVector3f(0.f); // On arrête le déplacement + break; + } + + break; + + default: // Les autres évènements, on s'en fiche + break; + } + } + + // On active le shader et paramètrons le rendu + NzRenderer::SetShader(&shader); + NzRenderer::Enable(nzRendererParameter_DepthTest, true); + + NzRenderer::SetClearColor(128, 128, 128); + NzRenderer::Clear(nzRendererClear_Color | nzRendererClear_Depth); + + if (updateClock.GetMilliseconds() >= 1000/60) // 60 fois par seconde + { + float elapsedTime = updateClock.GetSeconds(); // Le temps depuis la dernière mise à jour + + // Déplacement de la caméra + static const NzVector3f forward(NzVector3f::UnitZ()); + static const NzVector3f left(NzVector3f::UnitX()); + static const NzVector3f up(NzVector3f::UnitY()); + + // Notre rotation sous forme de quaternion nous permet de tourner un vecteur + NzQuaternionf quaternion(camRot); + + // Par exemple ici, quaternion * forward nous permet de récupérer le vecteur de la direction "avant" + if (NzKeyboard::IsKeyPressed(NzKeyboard::Z)) + camPos += quaternion * forward * camSpeed; + + if (NzKeyboard::IsKeyPressed(NzKeyboard::S)) + camPos -= quaternion * forward * camSpeed; + + if (NzKeyboard::IsKeyPressed(NzKeyboard::Q)) + camPos += quaternion * left * camSpeed; + + if (NzKeyboard::IsKeyPressed(NzKeyboard::D)) + camPos -= quaternion * left * camSpeed; + + // En revanche, ici la hauteur est toujours la même, peu importe notre orientation + if (NzKeyboard::IsKeyPressed(NzKeyboard::Space)) + camPos += up * camSpeed; + + if (NzKeyboard::IsKeyPressed(NzKeyboard::LControl)) + camPos -= up * camSpeed; + + // Oui le quaternion et la matrice sont calculés même si la caméra ne bouge pas + // C'est une limitation de mon implémentation, qui ne sera pas présente une fois les NzSceneNode intégrés + NzRenderer::SetMatrix(nzMatrixType_View, NzMatrix4f::Translate(camPos) * NzMatrix4f::Rotate(camRot)); + + // Animation + AnimateModel(drfreak, elapsedTime); + updateClock.Restart(); + + // "Physique" + if (modelVel != NzVector3f::Zero()) + { + modelPos += modelVel * elapsedTime; + /*if (jumping) + { + velocity.y -= 500.f * elapsedTime; // Un simulacre de gravité + if (modelPos.y <= groundPos) + { + // On stoppe net + modelPos.y = groundPos; + velocity.y = 0.f; + jumping = false; + SetSequence(drfreak, "stand"); + } + }*/ + + // Mise à jour de la matrice + drfreak.matrix = NzMatrix4f::Rotate(modelRot) * NzMatrix4f::Translate(modelPos); + } + } + + // Affichage des meshs + DrawModel(floor); + + // Notre Dr. Freak possède des normales, nous pouvons alors culler les faces qu'on ne voit pas + NzRenderer::Enable(nzRendererParameter_FaceCulling, true); + + DrawModel(drfreak); + + NzRenderer::Enable(nzRendererParameter_FaceCulling, false); + + window.Display(); // Nous mettons à jour l'écran + + fps++; + + // Toutes les secondes + if (secondClock.GetMilliseconds() >= 1000) + { + window.SetTitle(title + " (FPS: " + NzString::Number(fps) + ')'); + fps = 0; + secondClock.Restart(); + } + } + + return EXIT_SUCCESS; +} + +void AnimateModel(AnimatedModel& model, float elapsed) +{ + model.interpolation += model.currentSequence->framePerSecond * elapsed; + while (model.interpolation > 1.f) + { + model.interpolation -= 1.f; + + model.currentFrame = model.nextFrame; + if (++model.nextFrame > model.currentSequence->lastFrame) + model.nextFrame = model.currentSequence->firstFrame; + } + + model.mesh.Animate(model.currentFrame, model.nextFrame, (NzKeyboard::IsKeyPressed(NzKeyboard::A)) ? 0.f : model.interpolation); +} + +bool CreateCheckerTexture(NzTexture* texture) +{ + NzImage image; + // Nous crééons une image 2D, au format RGBA8 de dimensions 128*128 (8 blocs de 16 pixels de côté) + if (!image.Create(nzImageType_2D, nzPixelFormat_RGBA8, 8*16, 8*16)) + { + // Ne devrait pas arriver (La création d'une image ne peut échouer que si l'un des argument est incorrect) + std::cout << "Failed to create image, this means a bug has been found in Nazara" << std::endl; + return false; + } + + // Pour modifier les pixels, nous pouvons accéder directement à ces derniers avec GetPixels(), ou bien à un pixel + // via [Get|Set]PixelColor, mais pour cette occasion nous utiliserons une méthode bien pratique, Fill. + unsigned int blockCountX = image.GetWidth()/16; + unsigned int blockCountY = image.GetHeight()/16; + for (unsigned int x = 0; x < blockCountX; ++x) + { + for (unsigned int y = 0; y < blockCountY; ++y) + { + // Une belle texture de damier + NzColor color = (x%2 == y%2) ? NzColor::White : NzColor::Black; + // Fill remplit une zone de la texture avec une couleur + image.Fill(color, NzRectui(x*16, y*16, 16, 16)); + } + } + + if (!texture->LoadFromImage(image)) // Nous créons notre texture depuis notre image + { + // Nous n'avons vraiment pas beaucoup de chance.. + std::cout << "Failed to load image" << std::endl; + return false; + } + + texture->SetAnisotropyLevel(NzRenderer::GetMaxAnisotropyLevel()); // Un filtrage anisotropique pour la texture + texture->SetWrapMode(nzTextureWrap_Repeat); // Si les coordonnées de texture dépassent 1.f, la texture sera répétée + + return true; +} + +bool CreateFloorMesh(NzMesh* mesh) +{ + // Cette fonction créé un mesh statique simpliste pour servir de sol + + // Nous créons un mesh statique + if (!mesh->Create(nzAnimationType_Static)) + { + // L'échec est techniquement impossible mais le moteur étant en constante évolution ... + std::cout << "Failed to create mesh" << std::endl; + return false; + } + + // Les vertex declaration ont pour seul but de décrire l'agencement d'un vertex buffer + // Elles sont composées de VertexElement, chacun décrivant un élément du buffer + NzVertexDeclaration* declaration = new NzVertexDeclaration; + + // Il y a cinq paramètres différents (stream, usage, type, offset, usageIndex) + // -Stream: À quoi serviront les données ? À définir des sommets (nzElementStream_VertexData) ou à l'instancing (nzElementStream_InstancedData) + // -Usage: Comment cette donnée doit-elle être envoyée au shader + // -Type: Comment sont stockées ces données ? (Un triplet de float ? Deux double ? ..) + // -Offset: La position de la donnée dans le buffer (les données sont entrelacées) + // -UsageIndex: Pour les coordonnées de texture, définit l'indice de texture utilisé. + NzVertexElement elements[2]; + elements[0].usage = nzElementUsage_Position; // Notre premier élément sera la position des vertices + elements[0].offset = 0; // Celles-ci sont placées au début + elements[0].type = nzElementType_Float3; // Sont composées de trois flottants + + elements[1].usage = nzElementUsage_TexCoord; + elements[1].offset = 3*sizeof(float); + elements[1].type = nzElementType_Float2; + + if (!declaration->Create(elements, 2)) + { + // Nos éléments sont invalides ! + std::cout << "Failed to create vertex declaration" << std::endl; + return false; + } + + // Nous créons ensuite un buffer de 4 vertices (le second argument précise l'espace pris par chaque vertex), le stockage + // Et nous indiquons que nous n'y toucherons plus + NzVertexBuffer* buffer = new NzVertexBuffer(4, declaration->GetStride(nzElementStream_VertexData), nzBufferStorage_Hardware, nzBufferUsage_Static); + + // Doit respecter la declaration + float vertices[] = + { + // Vertex 1 + -1000.f, 0.f, -1000.f, // Position + 0.f, 0.f, // UV + + // Vertex 2 + -1000.f, 0.f, 1000.f, // Position + 0.f, 10.f, // UV + + // Vertex 3 + 1000.f, 0.f, -1000.f, // Position + 10.f, 0.f, // UV + + // Vertex 4 + 1000.f, 0.f, 1000.f, // Position + 10.f, 10.f // UV + }; + + // Afin de modifier un buffer, il nous faut soit le verrouiller (accès bas-niveau), soit le remplir (accès de plus haut niveau) + if (!buffer->Fill(vertices, 0, 4)) // Nous remplissons à partir de l'index 0, et nous envoyons 4 vertices + { + std::cout << "Failed to fill buffer" << std::endl; + return false; + } + + NzStaticMesh* subMesh = new NzStaticMesh(mesh); + if (!subMesh->Create(declaration, buffer)) + { + std::cout << "Failed to create subMesh" << std::endl; + return false; + } + + subMesh->SetPrimitiveType(nzPrimitiveType_TriangleStrip); + + // On ajoute le submesh au mesh + mesh->AddSubMesh(subMesh); + + // Nos ressources sont notifiées utilisées par le mesh et le submesh, nous pouvons les rendre éphèmères. + // Les ressources seront donc automatiquement libérées lorsque plus aucune classe n'en aura besoin + buffer->SetPersistent(false); + declaration->SetPersistent(false); + subMesh->SetPersistent(false); // Pour le submesh, c'est déjà à false à la base + + return true; +} + +void DrawModel(const Model& model) +{ + // La matrice world est celle qui représente les transformations du modèle + NzRenderer::SetMatrix(nzMatrixType_World, model.matrix); + + NzShader* shader = NzRenderer::GetShader();// On récupère le shader du rendu + shader->SendTexture(shader->GetUniformLocation("texture"), &model.texture); + + // Un mesh est divisé en plusieurs submeshes + unsigned int subMeshCount = model.mesh.GetSubMeshCount(); + for (unsigned int i = 0; i < subMeshCount; ++i) + { + // On récupère le submesh + const NzSubMesh* subMesh = model.mesh.GetSubMesh(i); + + // On paramètre le Renderer avec ses données + NzRenderer::SetIndexBuffer(subMesh->GetIndexBuffer()); + NzRenderer::SetVertexBuffer(subMesh->GetVertexBuffer()); + NzRenderer::SetVertexDeclaration(subMesh->GetVertexDeclaration()); + + // On fait le rendu + NzRenderer::DrawPrimitives(subMesh->GetPrimitiveType(), 0, subMesh->GetVertexCount()); + } +} + +void SetSequence(AnimatedModel& model, const NzString& sequenceName) +{ + // On récupère l'animation du mesh + const NzAnimation* animation = model.mesh.GetAnimation(); + + // Nous nous basons sur l'assertion que la séquence existe (Chose que nous pouvons tester avec HasSequence()) + model.currentSequence = animation->GetSequence(sequenceName); + + // Pour avoir une interpolation entre la séquence précédente et celle-ci, nous n'affectons que nextFrame + model.nextFrame = model.currentSequence->firstFrame; +} diff --git a/examples/ListSequences/build.lua b/examples/ListSequences/build.lua new file mode 100644 index 000000000..4d93b53c9 --- /dev/null +++ b/examples/ListSequences/build.lua @@ -0,0 +1,23 @@ +kind "ConsoleApp" + +files "main.cpp" + +configuration "DebugStatic" + links "NazaraCored-s" + links "NazaraRendererd-s" + links "NazaraUtilityd-s" + +configuration "ReleaseStatic" + links "NazaraCore-s" + links "NazaraRenderer-s" + links "NazaraUtility-s" + +configuration "DebugDLL" + links "NazaraCored" + links "NazaraRendererd" + links "NazaraUtilityd" + +configuration "ReleaseDLL" + links "NazaraCore" + links "NazaraRenderer" + links "NazaraUtility" \ No newline at end of file diff --git a/examples/ListSequences/main.cpp b/examples/ListSequences/main.cpp new file mode 100644 index 000000000..5544e82eb --- /dev/null +++ b/examples/ListSequences/main.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +int main() +{ + // Pour charger des ressources, il est impératif d'initialiser le module utilitaire + NzInitializer utility; + if (!utility) + { + // Ça n'a pas fonctionné, le pourquoi se trouve dans le fichier NazaraLog.log + std::cout << "Failed to initialize Nazara, see NazaraLog.log for further informations" << std::endl; + std::getchar(); // On laise le temps de voir l'erreur + return EXIT_FAILURE; + } + + // Le Renderer n'étant pas chargé, nous devons indiquer que nous désirons un stockage software de notre mesh + NzMeshParams parameters; + parameters.storage = nzBufferStorage_Software; + + NzMesh drfreak; + if (!drfreak.LoadFromFile("resources/drfreak.md2", parameters)) + { + std::cout << "Failed to load Dr. Freak's mesh" << std::endl; + std::getchar(); + return EXIT_FAILURE; + } + + if (drfreak.HasAnimation()) // Si le mesh possède des animations + { + std::cout << "Mesh has animation" << std::endl; + + // Un objet NzAnimation représente un ensemble d'informations sur des animations + const NzAnimation* animation = drfreak.GetAnimation(); + + // Une séquence définit une "action", chaque séquence possède un nom, une frame de départ, une d'arrivée ainsi qu'un framerate + unsigned int sequenceCount = animation->GetSequenceCount(); + std::cout << sequenceCount << " sequences:" << std::endl; + for (unsigned int i = 0; i < sequenceCount; ++i) + std::cout << "-" << (i+1) << ": " << animation->GetSequence(i)->name << std::endl; + } + else + std::cout << "Mesh has no animation" << std::endl; + + std::getchar(); // Une attente pour avoir le temps de lire :-) + + // Le module utilitaire et le mesh sont déchargés automatiquement + return EXIT_SUCCESS; +} diff --git a/include/GL3/gl3.h b/include/GL3/glcorearb.h similarity index 79% rename from include/GL3/gl3.h rename to include/GL3/glcorearb.h index 9c17d418c..df7ca48bc 100644 --- a/include/GL3/gl3.h +++ b/include/GL3/glcorearb.h @@ -1,5 +1,5 @@ -#ifndef __gl3_h_ -#define __gl3_h_ +#ifndef __glcorearb_h_ +#define __glcorearb_h_ #ifdef __cplusplus extern "C" { @@ -28,41 +28,29 @@ extern "C" { ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ -/* This is a draft release of gl3.h, a header for use with OpenGL 3.1, and - * 3.2 and later core profile implementations. The current version is - * available at http://www.opengl.org/registry/ . Please don't package - * gl3.h for release with other software until it's out of draft status. - * The structure of the file may change significantly, and the details - * will probably change slightly as we make sure exactly the right set - * of interfaces is included. +/* glcorearb.h replaces gl3.h. It is for use with OpenGL core + * profile implementations. * - * gl3.h last updated on $Date: 2012-06-18 11:26:35 -0700 (Mon, 18 Jun 2012) $ + * glcorearb.h last updated on $Date: 2012-08-06 01:59:22 -0700 (Mon, 06 Aug 2012) $ * - * RELEASE NOTES - 2012/06/18 + * RELEASE NOTES - 2012/08/06 * - * gl3.h should be placed under a directory 'GL3' and included as - * ''. + * glcorearb.h should be placed in the same directory as gl.h and + * included as + * ''. * - * gl3.h is supposed to only include APIs in a OpenGL 3.1 (without - * GL_ARB_compatibility) or OpenGL 3.2-4.2 (inclusive) core profile - * implementation, as well as interfaces for newer ARB extensions which + * gl3.h includes only APIs in the latest OpenGL core profile + * implementation together with APIs in newer ARB extensions which can be * can be supported by the core profile. It does not, and never will * include functionality removed from the core profile, such as * fixed-function vertex and fragment processing. * - * Implementations of OpenGL 3.1 supporting the optional - * GL_ARB_compatibility extension continue to provide that functionality, - * as do implementations of the OpenGL 3.2+ compatibility profiles, and - * source code requiring it should use the traditional and - * headers instead of . - * - * It is not possible to #include both and either of + * It is not possible to #include both and either of * or in the same source file. * - * We welcome feedback on gl3.h. Please register for the Khronos Bugzilla - * (www.khronos.org/bugzilla) and file issues there under product - * "OpenGL", category "Registry". Feedback on the opengl.org forums - * may not be responded to in a timely fashion. + * Feedback can be given by register for the Khronos Bugzilla + * (www.khronos.org/bugzilla) and filing issues there under product + * "OpenGL", category "Registry". */ /* Function declaration macros - to move into glplatform.h */ @@ -250,6 +238,9 @@ typedef void GLvoid; #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 #define GL_DOUBLE 0x140A +/* ErrorCode */ +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 /* LogicOp */ #define GL_CLEAR 0x1500 #define GL_AND 0x1501 @@ -1251,6 +1242,290 @@ typedef void GLvoid; /* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ #endif +#ifndef GL_VERSION_4_3 +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +/* Reuse tokens from ARB_arrays_of_arrays (none, GLSL only) */ +/* Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only) */ +/* Reuse tokens from ARB_shader_image_size (none, GLSL only) */ +/* Reuse tokens from ARB_ES3_compatibility */ +/* reuse GL_COMPRESSED_RGB8_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_ETC2 */ +/* reuse GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_RGBA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_R11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_R11_EAC */ +/* reuse GL_COMPRESSED_RG11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_RG11_EAC */ +/* reuse GL_PRIMITIVE_RESTART_FIXED_INDEX */ +/* reuse GL_ANY_SAMPLES_PASSED_CONSERVATIVE */ +/* reuse GL_MAX_ELEMENT_INDEX */ +/* Reuse tokens from ARB_clear_buffer_object (none) */ +/* Reuse tokens from ARB_compute_shader */ +/* reuse GL_COMPUTE_SHADER */ +/* reuse GL_MAX_COMPUTE_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_COMPUTE_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */ +/* reuse GL_MAX_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_LOCAL_INVOCATIONS */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_COUNT */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_SIZE */ +/* reuse GL_COMPUTE_LOCAL_WORK_SIZE */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_copy_image (none) */ +/* Reuse tokens from KHR_debug */ +/* reuse GL_DEBUG_OUTPUT_SYNCHRONOUS */ +/* reuse GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH */ +/* reuse GL_DEBUG_CALLBACK_FUNCTION */ +/* reuse GL_DEBUG_CALLBACK_USER_PARAM */ +/* reuse GL_DEBUG_SOURCE_API */ +/* reuse GL_DEBUG_SOURCE_WINDOW_SYSTEM */ +/* reuse GL_DEBUG_SOURCE_SHADER_COMPILER */ +/* reuse GL_DEBUG_SOURCE_THIRD_PARTY */ +/* reuse GL_DEBUG_SOURCE_APPLICATION */ +/* reuse GL_DEBUG_SOURCE_OTHER */ +/* reuse GL_DEBUG_TYPE_ERROR */ +/* reuse GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_PORTABILITY */ +/* reuse GL_DEBUG_TYPE_PERFORMANCE */ +/* reuse GL_DEBUG_TYPE_OTHER */ +/* reuse GL_MAX_DEBUG_MESSAGE_LENGTH */ +/* reuse GL_MAX_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_SEVERITY_HIGH */ +/* reuse GL_DEBUG_SEVERITY_MEDIUM */ +/* reuse GL_DEBUG_SEVERITY_LOW */ +/* reuse GL_DEBUG_TYPE_MARKER */ +/* reuse GL_DEBUG_TYPE_PUSH_GROUP */ +/* reuse GL_DEBUG_TYPE_POP_GROUP */ +/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */ +/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_BUFFER */ +/* reuse GL_SHADER */ +/* reuse GL_PROGRAM */ +/* reuse GL_QUERY */ +/* reuse GL_PROGRAM_PIPELINE */ +/* reuse GL_SAMPLER */ +/* reuse GL_DISPLAY_LIST */ +/* reuse GL_MAX_LABEL_LENGTH */ +/* reuse GL_DEBUG_OUTPUT */ +/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */ +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +/* Reuse tokens from ARB_explicit_uniform_location */ +/* reuse GL_MAX_UNIFORM_LOCATIONS */ +/* Reuse tokens from ARB_framebuffer_no_attachments */ +/* reuse GL_FRAMEBUFFER_DEFAULT_WIDTH */ +/* reuse GL_FRAMEBUFFER_DEFAULT_HEIGHT */ +/* reuse GL_FRAMEBUFFER_DEFAULT_LAYERS */ +/* reuse GL_FRAMEBUFFER_DEFAULT_SAMPLES */ +/* reuse GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_MAX_FRAMEBUFFER_WIDTH */ +/* reuse GL_MAX_FRAMEBUFFER_HEIGHT */ +/* reuse GL_MAX_FRAMEBUFFER_LAYERS */ +/* reuse GL_MAX_FRAMEBUFFER_SAMPLES */ +/* Reuse tokens from ARB_internalformat_query2 */ +/* reuse GL_INTERNALFORMAT_SUPPORTED */ +/* reuse GL_INTERNALFORMAT_PREFERRED */ +/* reuse GL_INTERNALFORMAT_RED_SIZE */ +/* reuse GL_INTERNALFORMAT_GREEN_SIZE */ +/* reuse GL_INTERNALFORMAT_BLUE_SIZE */ +/* reuse GL_INTERNALFORMAT_ALPHA_SIZE */ +/* reuse GL_INTERNALFORMAT_DEPTH_SIZE */ +/* reuse GL_INTERNALFORMAT_STENCIL_SIZE */ +/* reuse GL_INTERNALFORMAT_SHARED_SIZE */ +/* reuse GL_INTERNALFORMAT_RED_TYPE */ +/* reuse GL_INTERNALFORMAT_GREEN_TYPE */ +/* reuse GL_INTERNALFORMAT_BLUE_TYPE */ +/* reuse GL_INTERNALFORMAT_ALPHA_TYPE */ +/* reuse GL_INTERNALFORMAT_DEPTH_TYPE */ +/* reuse GL_INTERNALFORMAT_STENCIL_TYPE */ +/* reuse GL_MAX_WIDTH */ +/* reuse GL_MAX_HEIGHT */ +/* reuse GL_MAX_DEPTH */ +/* reuse GL_MAX_LAYERS */ +/* reuse GL_MAX_COMBINED_DIMENSIONS */ +/* reuse GL_COLOR_COMPONENTS */ +/* reuse GL_DEPTH_COMPONENTS */ +/* reuse GL_STENCIL_COMPONENTS */ +/* reuse GL_COLOR_RENDERABLE */ +/* reuse GL_DEPTH_RENDERABLE */ +/* reuse GL_STENCIL_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE_LAYERED */ +/* reuse GL_FRAMEBUFFER_BLEND */ +/* reuse GL_READ_PIXELS */ +/* reuse GL_READ_PIXELS_FORMAT */ +/* reuse GL_READ_PIXELS_TYPE */ +/* reuse GL_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_TEXTURE_IMAGE_TYPE */ +/* reuse GL_GET_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_GET_TEXTURE_IMAGE_TYPE */ +/* reuse GL_MIPMAP */ +/* reuse GL_MANUAL_GENERATE_MIPMAP */ +/* reuse GL_AUTO_GENERATE_MIPMAP */ +/* reuse GL_COLOR_ENCODING */ +/* reuse GL_SRGB_READ */ +/* reuse GL_SRGB_WRITE */ +/* reuse GL_FILTER */ +/* reuse GL_VERTEX_TEXTURE */ +/* reuse GL_TESS_CONTROL_TEXTURE */ +/* reuse GL_TESS_EVALUATION_TEXTURE */ +/* reuse GL_GEOMETRY_TEXTURE */ +/* reuse GL_FRAGMENT_TEXTURE */ +/* reuse GL_COMPUTE_TEXTURE */ +/* reuse GL_TEXTURE_SHADOW */ +/* reuse GL_TEXTURE_GATHER */ +/* reuse GL_TEXTURE_GATHER_SHADOW */ +/* reuse GL_SHADER_IMAGE_LOAD */ +/* reuse GL_SHADER_IMAGE_STORE */ +/* reuse GL_SHADER_IMAGE_ATOMIC */ +/* reuse GL_IMAGE_TEXEL_SIZE */ +/* reuse GL_IMAGE_COMPATIBILITY_CLASS */ +/* reuse GL_IMAGE_PIXEL_FORMAT */ +/* reuse GL_IMAGE_PIXEL_TYPE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_CLEAR_BUFFER */ +/* reuse GL_TEXTURE_VIEW */ +/* reuse GL_VIEW_COMPATIBILITY_CLASS */ +/* reuse GL_FULL_SUPPORT */ +/* reuse GL_CAVEAT_SUPPORT */ +/* reuse GL_IMAGE_CLASS_4_X_32 */ +/* reuse GL_IMAGE_CLASS_2_X_32 */ +/* reuse GL_IMAGE_CLASS_1_X_32 */ +/* reuse GL_IMAGE_CLASS_4_X_16 */ +/* reuse GL_IMAGE_CLASS_2_X_16 */ +/* reuse GL_IMAGE_CLASS_1_X_16 */ +/* reuse GL_IMAGE_CLASS_4_X_8 */ +/* reuse GL_IMAGE_CLASS_2_X_8 */ +/* reuse GL_IMAGE_CLASS_1_X_8 */ +/* reuse GL_IMAGE_CLASS_11_11_10 */ +/* reuse GL_IMAGE_CLASS_10_10_10_2 */ +/* reuse GL_VIEW_CLASS_128_BITS */ +/* reuse GL_VIEW_CLASS_96_BITS */ +/* reuse GL_VIEW_CLASS_64_BITS */ +/* reuse GL_VIEW_CLASS_48_BITS */ +/* reuse GL_VIEW_CLASS_32_BITS */ +/* reuse GL_VIEW_CLASS_24_BITS */ +/* reuse GL_VIEW_CLASS_16_BITS */ +/* reuse GL_VIEW_CLASS_8_BITS */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGB */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT3_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT5_RGBA */ +/* reuse GL_VIEW_CLASS_RGTC1_RED */ +/* reuse GL_VIEW_CLASS_RGTC2_RG */ +/* reuse GL_VIEW_CLASS_BPTC_UNORM */ +/* reuse GL_VIEW_CLASS_BPTC_FLOAT */ +/* Reuse tokens from ARB_invalidate_subdata (none) */ +/* Reuse tokens from ARB_multi_draw_indirect (none) */ +/* Reuse tokens from ARB_program_interface_query */ +/* reuse GL_UNIFORM */ +/* reuse GL_UNIFORM_BLOCK */ +/* reuse GL_PROGRAM_INPUT */ +/* reuse GL_PROGRAM_OUTPUT */ +/* reuse GL_BUFFER_VARIABLE */ +/* reuse GL_SHADER_STORAGE_BLOCK */ +/* reuse GL_VERTEX_SUBROUTINE */ +/* reuse GL_TESS_CONTROL_SUBROUTINE */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE */ +/* reuse GL_GEOMETRY_SUBROUTINE */ +/* reuse GL_FRAGMENT_SUBROUTINE */ +/* reuse GL_COMPUTE_SUBROUTINE */ +/* reuse GL_VERTEX_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_CONTROL_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE_UNIFORM */ +/* reuse GL_GEOMETRY_SUBROUTINE_UNIFORM */ +/* reuse GL_FRAGMENT_SUBROUTINE_UNIFORM */ +/* reuse GL_COMPUTE_SUBROUTINE_UNIFORM */ +/* reuse GL_TRANSFORM_FEEDBACK_VARYING */ +/* reuse GL_ACTIVE_RESOURCES */ +/* reuse GL_MAX_NAME_LENGTH */ +/* reuse GL_MAX_NUM_ACTIVE_VARIABLES */ +/* reuse GL_MAX_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_NAME_LENGTH */ +/* reuse GL_TYPE */ +/* reuse GL_ARRAY_SIZE */ +/* reuse GL_OFFSET */ +/* reuse GL_BLOCK_INDEX */ +/* reuse GL_ARRAY_STRIDE */ +/* reuse GL_MATRIX_STRIDE */ +/* reuse GL_IS_ROW_MAJOR */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_BUFFER_BINDING */ +/* reuse GL_BUFFER_DATA_SIZE */ +/* reuse GL_NUM_ACTIVE_VARIABLES */ +/* reuse GL_ACTIVE_VARIABLES */ +/* reuse GL_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_TOP_LEVEL_ARRAY_SIZE */ +/* reuse GL_TOP_LEVEL_ARRAY_STRIDE */ +/* reuse GL_LOCATION */ +/* reuse GL_LOCATION_INDEX */ +/* reuse GL_IS_PER_PATCH */ +/* Reuse tokens from ARB_robust_buffer_access_behavior (none) */ +/* Reuse tokens from ARB_shader_storage_buffer_object */ +/* reuse GL_SHADER_STORAGE_BUFFER */ +/* reuse GL_SHADER_STORAGE_BUFFER_BINDING */ +/* reuse GL_SHADER_STORAGE_BUFFER_START */ +/* reuse GL_SHADER_STORAGE_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS */ +/* reuse GL_MAX_SHADER_STORAGE_BLOCK_SIZE */ +/* reuse GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_SHADER_STORAGE_BARRIER_BIT */ +/* reuse GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES */ +/* Reuse tokens from ARB_stencil_texturing */ +/* reuse GL_DEPTH_STENCIL_TEXTURE_MODE */ +/* Reuse tokens from ARB_texture_buffer_range */ +/* reuse GL_TEXTURE_BUFFER_OFFSET */ +/* reuse GL_TEXTURE_BUFFER_SIZE */ +/* reuse GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT */ +/* Reuse tokens from ARB_texture_query_levels (none) */ +/* Reuse tokens from ARB_texture_storage_multisample (none) */ +/* Reuse tokens from ARB_texture_view */ +/* reuse GL_TEXTURE_VIEW_MIN_LEVEL */ +/* reuse GL_TEXTURE_VIEW_NUM_LEVELS */ +/* reuse GL_TEXTURE_VIEW_MIN_LAYER */ +/* reuse GL_TEXTURE_VIEW_NUM_LAYERS */ +/* reuse GL_TEXTURE_IMMUTABLE_LEVELS */ +/* Reuse tokens from ARB_vertex_attrib_binding */ +/* reuse GL_VERTEX_ATTRIB_BINDING */ +/* reuse GL_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_VERTEX_BINDING_DIVISOR */ +/* reuse GL_VERTEX_BINDING_OFFSET */ +/* reuse GL_VERTEX_BINDING_STRIDE */ +/* reuse GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_MAX_VERTEX_ATTRIB_BINDINGS */ +#endif + #ifndef GL_ARB_depth_buffer_float #define GL_DEPTH_COMPONENT32F 0x8CAC #define GL_DEPTH32F_STENCIL8 0x8CAD @@ -1940,6 +2215,414 @@ typedef void GLvoid; #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F #endif +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +#ifndef GL_KHR_debug +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_DISPLAY_LIST 0x82E7 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +#endif + +#ifndef GL_ARB_arrays_of_arrays +#endif + +#ifndef GL_ARB_clear_buffer_object +#endif + +#ifndef GL_ARB_compute_shader +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif + +#ifndef GL_ARB_copy_image +#endif + +#ifndef GL_ARB_debug_group +/* reuse GL_DEBUG_TYPE_MARKER */ +/* reuse GL_DEBUG_TYPE_PUSH_GROUP */ +/* reuse GL_DEBUG_TYPE_POP_GROUP */ +/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */ +/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +#endif + +#ifndef GL_ARB_debug_label +/* reuse GL_BUFFER */ +/* reuse GL_SHADER */ +/* reuse GL_PROGRAM */ +/* reuse GL_QUERY */ +/* reuse GL_PROGRAM_PIPELINE */ +/* reuse GL_SAMPLER */ +/* DISPLAY_LIST used in compatibility profile only */ +/* reuse GL_DISPLAY_LIST */ +/* reuse GL_MAX_LABEL_LENGTH */ +/* reuse GL_VERTEX_ARRAY */ +#endif + +#ifndef GL_ARB_debug_output2 +/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */ +/* reuse GL_DEBUG_OUTPUT */ +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#endif + +#ifndef GL_ARB_internalformat_query2 +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_SAMPLES */ +/* reuse GL_TEXTURE_1D */ +/* reuse GL_TEXTURE_1D_ARRAY */ +/* reuse GL_TEXTURE_2D */ +/* reuse GL_TEXTURE_2D_ARRAY */ +/* reuse GL_TEXTURE_3D */ +/* reuse GL_TEXTURE_CUBE_MAP */ +/* reuse GL_TEXTURE_CUBE_MAP_ARRAY */ +/* reuse GL_TEXTURE_RECTANGLE */ +/* reuse GL_TEXTURE_BUFFER */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_COMPRESSED */ +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#endif + +#ifndef GL_ARB_invalidate_subdata +#endif + +#ifndef GL_ARB_multi_draw_indirect +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#endif + +#ifndef GL_ARB_shader_image_size +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x2000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#endif + +#ifndef GL_ARB_texture_query_levels +#endif + +#ifndef GL_ARB_texture_storage_multisample +#endif + +#ifndef GL_ARB_texture_view +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#endif + +#ifndef GL_ARB_robustness_isolation +#endif + /*************************************************************/ @@ -2039,13 +2722,17 @@ typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLen typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); #endif +#ifndef GL_KHR_debug +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + #ifndef GL_NV_vdpau_interop typedef GLintptr GLvdpauSurfaceNV; #endif #ifndef GL_VERSION_1_0 #define GL_VERSION_1_0 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glCullFace (GLenum mode); GLAPI void APIENTRY glFrontFace (GLenum mode); GLAPI void APIENTRY glHint (GLenum target, GLenum mode); @@ -2094,7 +2781,7 @@ GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); GLAPI void APIENTRY glDepthRange (GLdouble near, GLdouble far); GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); @@ -2147,7 +2834,7 @@ typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLs #ifndef GL_VERSION_1_1 #define GL_VERSION_1_1 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); GLAPI void APIENTRY glGetPointerv (GLenum pname, GLvoid* *params); @@ -2162,7 +2849,7 @@ GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); GLAPI GLboolean APIENTRY glIsTexture (GLuint texture); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); typedef void (APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, GLvoid* *params); @@ -2181,14 +2868,14 @@ typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); #ifndef GL_VERSION_1_2 #define GL_VERSION_1_2 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void APIENTRY glBlendEquation (GLenum mode); GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); @@ -2199,7 +2886,7 @@ typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, #ifndef GL_VERSION_1_3 #define GL_VERSION_1_3 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glActiveTexture (GLenum texture); GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); @@ -2209,7 +2896,7 @@ GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); @@ -2223,18 +2910,18 @@ typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint le #ifndef GL_VERSION_1_4 #define GL_VERSION_1_4 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); @@ -2243,7 +2930,7 @@ typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *p #ifndef GL_VERSION_1_5 #define GL_VERSION_1_5 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); GLAPI GLboolean APIENTRY glIsQuery (GLuint id); @@ -2263,7 +2950,7 @@ GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); @@ -2287,7 +2974,7 @@ typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname #ifndef GL_VERSION_2_0 #define GL_VERSION_2_0 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); @@ -2381,7 +3068,7 @@ GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); @@ -2479,14 +3166,14 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, #ifndef GL_VERSION_2_1 #define GL_VERSION_2_1 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); @@ -2501,7 +3188,7 @@ typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei co /* ARB_framebuffer_object */ /* ARB_map_buffer_range */ /* ARB_vertex_array_object */ -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); @@ -2560,7 +3247,7 @@ GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLu GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); @@ -2626,14 +3313,14 @@ typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint ind /* OpenGL 3.1 also reuses entry points from these extensions: */ /* ARB_copy_buffer */ /* ARB_uniform_buffer_object */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); #endif @@ -2645,11 +3332,11 @@ typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); /* ARB_provoking_vertex */ /* ARB_sync */ /* ARB_texture_multisample */ -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); @@ -2667,9 +3354,9 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum atta /* ARB_texture_swizzle (no entry points) */ /* ARB_timer_query */ /* ARB_vertex_type_2_10_10_10_rev */ -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); #endif @@ -2687,13 +3374,13 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divi /* ARB_texture_gather (no entry points) */ /* ARB_transform_feedback2 */ /* ARB_transform_feedback3 */ -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glMinSampleShading (GLfloat value); GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); @@ -2728,13 +3415,43 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, /* ARB_texture_storage */ #endif +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +/* OpenGL 4.3 reuses entry points from these extensions: */ +/* ARB_arrays_of_arrays (no entry points, GLSL only) */ +/* ARB_fragment_layer_viewport (no entry points, GLSL only) */ +/* ARB_shader_image_size (no entry points, GLSL only) */ +/* ARB_ES3_compatibility (no entry points) */ +/* ARB_clear_buffer_object */ +/* ARB_compute_shader */ +/* ARB_copy_image */ +/* ARB_debug_group */ +/* ARB_debug_label */ +/* KHR_debug (ARB_debug_output promoted to KHR without suffixes) */ +/* ARB_debug_output2 (no entry points) */ +/* ARB_explicit_uniform_location (no entry points) */ +/* ARB_framebuffer_no_attachments */ +/* ARB_internalformat_query2 */ +/* ARB_invalidate_subdata */ +/* ARB_multi_draw_indirect */ +/* ARB_program_interface_query */ +/* ARB_robust_buffer_access_behavior (no entry points) */ +/* ARB_shader_storage_buffer_object */ +/* ARB_stencil_texturing (no entry points) */ +/* ARB_texture_buffer_range */ +/* ARB_texture_query_levels (no entry points) */ +/* ARB_texture_storage_multisample */ +/* ARB_texture_view */ +/* ARB_vertex_attrib_binding */ +#endif + #ifndef GL_ARB_depth_buffer_float #define GL_ARB_depth_buffer_float 1 #endif #ifndef GL_ARB_framebuffer_object #define GL_ARB_framebuffer_object 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); @@ -2755,7 +3472,7 @@ GLAPI void APIENTRY glGenerateMipmap (GLenum target); GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); @@ -2788,10 +3505,10 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum #ifndef GL_ARB_map_buffer_range #define GL_ARB_map_buffer_range 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); #endif @@ -2806,12 +3523,12 @@ typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintpt #ifndef GL_ARB_vertex_array_object #define GL_ARB_vertex_array_object 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glBindVertexArray (GLuint array); GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); @@ -2820,7 +3537,7 @@ typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); #ifndef GL_ARB_uniform_buffer_object #define GL_ARB_uniform_buffer_object 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); @@ -2828,7 +3545,7 @@ GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *unif GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); @@ -2840,9 +3557,9 @@ typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint un #ifndef GL_ARB_copy_buffer #define GL_ARB_copy_buffer 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #endif @@ -2852,16 +3569,16 @@ typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum w #ifndef GL_ARB_draw_elements_base_vertex #define GL_ARB_draw_elements_base_vertex 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, const GLint *basevertex); -#endif /* GL3_PROTOTYPES */ +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); #endif #ifndef GL_ARB_fragment_coord_conventions @@ -2870,9 +3587,9 @@ typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, cons #ifndef GL_ARB_provoking_vertex #define GL_ARB_provoking_vertex 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glProvokingVertex (GLenum mode); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); #endif @@ -2882,7 +3599,7 @@ typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); #ifndef GL_ARB_sync #define GL_ARB_sync 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); GLAPI GLboolean APIENTRY glIsSync (GLsync sync); GLAPI void APIENTRY glDeleteSync (GLsync sync); @@ -2890,7 +3607,7 @@ GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); @@ -2902,12 +3619,12 @@ typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei #ifndef GL_ARB_texture_multisample #define GL_ARB_texture_multisample 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); @@ -2920,12 +3637,12 @@ typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); #ifndef GL_ARB_draw_buffers_blend #define GL_ARB_draw_buffers_blend 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); @@ -2934,9 +3651,9 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcR #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); #endif @@ -2954,14 +3671,14 @@ typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); #ifndef GL_ARB_shading_language_include #define GL_ARB_shading_language_include 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); @@ -2976,10 +3693,10 @@ typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLch #ifndef GL_ARB_blend_func_extended #define GL_ARB_blend_func_extended 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); #endif @@ -2994,7 +3711,7 @@ typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLcha #ifndef GL_ARB_sampler_objects #define GL_ARB_sampler_objects 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); @@ -3009,7 +3726,7 @@ GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); @@ -3040,11 +3757,11 @@ typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenu #ifndef GL_ARB_timer_query #define GL_ARB_timer_query 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); @@ -3052,7 +3769,7 @@ typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, #ifndef GL_ARB_vertex_type_2_10_10_10_rev #define GL_ARB_vertex_type_2_10_10_10_rev 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); @@ -3091,7 +3808,7 @@ GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean nor GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); @@ -3134,10 +3851,10 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, #ifndef GL_ARB_draw_indirect #define GL_ARB_draw_indirect 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); #endif @@ -3148,7 +3865,7 @@ typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type #ifndef GL_ARB_gpu_shader_fp64 #define GL_ARB_gpu_shader_fp64 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); @@ -3167,7 +3884,7 @@ GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboole GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); @@ -3190,7 +3907,7 @@ typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, #ifndef GL_ARB_shader_subroutine #define GL_ARB_shader_subroutine 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); @@ -3199,7 +3916,7 @@ GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); @@ -3212,10 +3929,10 @@ typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shad #ifndef GL_ARB_tessellation_shader #define GL_ARB_tessellation_shader 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); #endif @@ -3226,7 +3943,7 @@ typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat #ifndef GL_ARB_transform_feedback2 #define GL_ARB_transform_feedback2 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); @@ -3234,7 +3951,7 @@ GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); GLAPI void APIENTRY glPauseTransformFeedback (void); GLAPI void APIENTRY glResumeTransformFeedback (void); GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); @@ -3246,12 +3963,12 @@ typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id) #ifndef GL_ARB_transform_feedback3 #define GL_ARB_transform_feedback3 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); @@ -3260,13 +3977,13 @@ typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glReleaseShaderCompiler (void); GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); GLAPI void APIENTRY glClearDepthf (GLfloat d); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); @@ -3276,11 +3993,11 @@ typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); #ifndef GL_ARB_get_program_binary #define GL_ARB_get_program_binary 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); @@ -3288,7 +4005,7 @@ typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pnam #ifndef GL_ARB_separate_shader_objects #define GL_ARB_separate_shader_objects 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings); @@ -3349,7 +4066,7 @@ GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings); @@ -3414,7 +4131,7 @@ typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GL #ifndef GL_ARB_vertex_attrib_64bit #define GL_ARB_vertex_attrib_64bit 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); @@ -3425,7 +4142,7 @@ GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); @@ -3440,7 +4157,7 @@ typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname #ifndef GL_ARB_viewport_array #define GL_ARB_viewport_array 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); @@ -3451,7 +4168,7 @@ GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdou GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); @@ -3466,20 +4183,20 @@ typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLd #ifndef GL_ARB_cl_event #define GL_ARB_cl_event 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); #endif #ifndef GL_ARB_debug_output #define GL_ARB_debug_output 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); @@ -3488,7 +4205,7 @@ typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei #ifndef GL_ARB_robustness #define GL_ARB_robustness 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); @@ -3509,7 +4226,7 @@ GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); @@ -3538,14 +4255,14 @@ typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint locati #ifndef GL_ARB_base_instance #define GL_ARB_base_instance 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); #endif #ifndef GL_ARB_shading_language_420pack @@ -3554,12 +4271,12 @@ typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (G #ifndef GL_ARB_transform_feedback_instanced #define GL_ARB_transform_feedback_instanced 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #endif #ifndef GL_ARB_compressed_texture_pixel_storage @@ -3572,9 +4289,9 @@ typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum m #ifndef GL_ARB_internalformat_query #define GL_ARB_internalformat_query 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); #endif @@ -3584,18 +4301,18 @@ typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum int #ifndef GL_ARB_shader_atomic_counters #define GL_ARB_shader_atomic_counters 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); #endif #ifndef GL_ARB_shader_image_load_store #define GL_ARB_shader_image_load_store 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); #endif @@ -3606,14 +4323,14 @@ typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); #ifndef GL_ARB_texture_storage #define GL_ARB_texture_storage 1 -#ifdef GL3_PROTOTYPES +#ifdef GLCOREARB_PROTOTYPES GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL3_PROTOTYPES */ +#endif /* GLCOREARB_PROTOTYPES */ typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); @@ -3622,6 +4339,257 @@ typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum ta typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +/* KHR_debug also reuses entry points from ARB_debug_group and ARB_debug_label */ +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +#endif + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif + +#ifndef GL_ARB_debug_group +#define GL_ARB_debug_group 1 +/* ARB_debug_group reuses entry points from KHR_debug */ +#endif + +#ifndef GL_ARB_debug_label +#define GL_ARB_debug_label 1 +/* ARB_debug_label reuses entry points from KHR_debug */ +#endif + +#ifndef GL_ARB_debug_output2 +#define GL_ARB_debug_output2 1 +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#ifdef GLCOREARB_PROTOTYPES +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif /* GLCOREARB_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif + #ifdef __cplusplus } diff --git a/include/GL3/glext.h b/include/GL3/glext.h index 90e013421..6175ad450 100644 --- a/include/GL3/glext.h +++ b/include/GL3/glext.h @@ -29,9 +29,9 @@ extern "C" { */ /* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated $Date: 2012-06-18 11:26:35 -0700 (Mon, 18 Jun 2012) $ */ +/* glext.h last updated $Date: 2012-08-06 02:01:01 -0700 (Mon, 06 Aug 2012) $ */ /* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 82 +#define GL_GLEXT_VERSION 83 /* Function declaration macros - to move into glplatform.h */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -1164,6 +1164,290 @@ extern "C" { /* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ #endif +#ifndef GL_VERSION_4_3 +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +/* Reuse tokens from ARB_arrays_of_arrays (none, GLSL only) */ +/* Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only) */ +/* Reuse tokens from ARB_shader_image_size (none, GLSL only) */ +/* Reuse tokens from ARB_ES3_compatibility */ +/* reuse GL_COMPRESSED_RGB8_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_ETC2 */ +/* reuse GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_RGBA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_R11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_R11_EAC */ +/* reuse GL_COMPRESSED_RG11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_RG11_EAC */ +/* reuse GL_PRIMITIVE_RESTART_FIXED_INDEX */ +/* reuse GL_ANY_SAMPLES_PASSED_CONSERVATIVE */ +/* reuse GL_MAX_ELEMENT_INDEX */ +/* Reuse tokens from ARB_clear_buffer_object (none) */ +/* Reuse tokens from ARB_compute_shader */ +/* reuse GL_COMPUTE_SHADER */ +/* reuse GL_MAX_COMPUTE_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_COMPUTE_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */ +/* reuse GL_MAX_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_LOCAL_INVOCATIONS */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_COUNT */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_SIZE */ +/* reuse GL_COMPUTE_LOCAL_WORK_SIZE */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_copy_image (none) */ +/* Reuse tokens from KHR_debug */ +/* reuse GL_DEBUG_OUTPUT_SYNCHRONOUS */ +/* reuse GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH */ +/* reuse GL_DEBUG_CALLBACK_FUNCTION */ +/* reuse GL_DEBUG_CALLBACK_USER_PARAM */ +/* reuse GL_DEBUG_SOURCE_API */ +/* reuse GL_DEBUG_SOURCE_WINDOW_SYSTEM */ +/* reuse GL_DEBUG_SOURCE_SHADER_COMPILER */ +/* reuse GL_DEBUG_SOURCE_THIRD_PARTY */ +/* reuse GL_DEBUG_SOURCE_APPLICATION */ +/* reuse GL_DEBUG_SOURCE_OTHER */ +/* reuse GL_DEBUG_TYPE_ERROR */ +/* reuse GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_PORTABILITY */ +/* reuse GL_DEBUG_TYPE_PERFORMANCE */ +/* reuse GL_DEBUG_TYPE_OTHER */ +/* reuse GL_MAX_DEBUG_MESSAGE_LENGTH */ +/* reuse GL_MAX_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_SEVERITY_HIGH */ +/* reuse GL_DEBUG_SEVERITY_MEDIUM */ +/* reuse GL_DEBUG_SEVERITY_LOW */ +/* reuse GL_DEBUG_TYPE_MARKER */ +/* reuse GL_DEBUG_TYPE_PUSH_GROUP */ +/* reuse GL_DEBUG_TYPE_POP_GROUP */ +/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */ +/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_BUFFER */ +/* reuse GL_SHADER */ +/* reuse GL_PROGRAM */ +/* reuse GL_QUERY */ +/* reuse GL_PROGRAM_PIPELINE */ +/* reuse GL_SAMPLER */ +/* reuse GL_DISPLAY_LIST */ +/* reuse GL_MAX_LABEL_LENGTH */ +/* reuse GL_DEBUG_OUTPUT */ +/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */ +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +/* Reuse tokens from ARB_explicit_uniform_location */ +/* reuse GL_MAX_UNIFORM_LOCATIONS */ +/* Reuse tokens from ARB_framebuffer_no_attachments */ +/* reuse GL_FRAMEBUFFER_DEFAULT_WIDTH */ +/* reuse GL_FRAMEBUFFER_DEFAULT_HEIGHT */ +/* reuse GL_FRAMEBUFFER_DEFAULT_LAYERS */ +/* reuse GL_FRAMEBUFFER_DEFAULT_SAMPLES */ +/* reuse GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_MAX_FRAMEBUFFER_WIDTH */ +/* reuse GL_MAX_FRAMEBUFFER_HEIGHT */ +/* reuse GL_MAX_FRAMEBUFFER_LAYERS */ +/* reuse GL_MAX_FRAMEBUFFER_SAMPLES */ +/* Reuse tokens from ARB_internalformat_query2 */ +/* reuse GL_INTERNALFORMAT_SUPPORTED */ +/* reuse GL_INTERNALFORMAT_PREFERRED */ +/* reuse GL_INTERNALFORMAT_RED_SIZE */ +/* reuse GL_INTERNALFORMAT_GREEN_SIZE */ +/* reuse GL_INTERNALFORMAT_BLUE_SIZE */ +/* reuse GL_INTERNALFORMAT_ALPHA_SIZE */ +/* reuse GL_INTERNALFORMAT_DEPTH_SIZE */ +/* reuse GL_INTERNALFORMAT_STENCIL_SIZE */ +/* reuse GL_INTERNALFORMAT_SHARED_SIZE */ +/* reuse GL_INTERNALFORMAT_RED_TYPE */ +/* reuse GL_INTERNALFORMAT_GREEN_TYPE */ +/* reuse GL_INTERNALFORMAT_BLUE_TYPE */ +/* reuse GL_INTERNALFORMAT_ALPHA_TYPE */ +/* reuse GL_INTERNALFORMAT_DEPTH_TYPE */ +/* reuse GL_INTERNALFORMAT_STENCIL_TYPE */ +/* reuse GL_MAX_WIDTH */ +/* reuse GL_MAX_HEIGHT */ +/* reuse GL_MAX_DEPTH */ +/* reuse GL_MAX_LAYERS */ +/* reuse GL_MAX_COMBINED_DIMENSIONS */ +/* reuse GL_COLOR_COMPONENTS */ +/* reuse GL_DEPTH_COMPONENTS */ +/* reuse GL_STENCIL_COMPONENTS */ +/* reuse GL_COLOR_RENDERABLE */ +/* reuse GL_DEPTH_RENDERABLE */ +/* reuse GL_STENCIL_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE_LAYERED */ +/* reuse GL_FRAMEBUFFER_BLEND */ +/* reuse GL_READ_PIXELS */ +/* reuse GL_READ_PIXELS_FORMAT */ +/* reuse GL_READ_PIXELS_TYPE */ +/* reuse GL_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_TEXTURE_IMAGE_TYPE */ +/* reuse GL_GET_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_GET_TEXTURE_IMAGE_TYPE */ +/* reuse GL_MIPMAP */ +/* reuse GL_MANUAL_GENERATE_MIPMAP */ +/* reuse GL_AUTO_GENERATE_MIPMAP */ +/* reuse GL_COLOR_ENCODING */ +/* reuse GL_SRGB_READ */ +/* reuse GL_SRGB_WRITE */ +/* reuse GL_FILTER */ +/* reuse GL_VERTEX_TEXTURE */ +/* reuse GL_TESS_CONTROL_TEXTURE */ +/* reuse GL_TESS_EVALUATION_TEXTURE */ +/* reuse GL_GEOMETRY_TEXTURE */ +/* reuse GL_FRAGMENT_TEXTURE */ +/* reuse GL_COMPUTE_TEXTURE */ +/* reuse GL_TEXTURE_SHADOW */ +/* reuse GL_TEXTURE_GATHER */ +/* reuse GL_TEXTURE_GATHER_SHADOW */ +/* reuse GL_SHADER_IMAGE_LOAD */ +/* reuse GL_SHADER_IMAGE_STORE */ +/* reuse GL_SHADER_IMAGE_ATOMIC */ +/* reuse GL_IMAGE_TEXEL_SIZE */ +/* reuse GL_IMAGE_COMPATIBILITY_CLASS */ +/* reuse GL_IMAGE_PIXEL_FORMAT */ +/* reuse GL_IMAGE_PIXEL_TYPE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_CLEAR_BUFFER */ +/* reuse GL_TEXTURE_VIEW */ +/* reuse GL_VIEW_COMPATIBILITY_CLASS */ +/* reuse GL_FULL_SUPPORT */ +/* reuse GL_CAVEAT_SUPPORT */ +/* reuse GL_IMAGE_CLASS_4_X_32 */ +/* reuse GL_IMAGE_CLASS_2_X_32 */ +/* reuse GL_IMAGE_CLASS_1_X_32 */ +/* reuse GL_IMAGE_CLASS_4_X_16 */ +/* reuse GL_IMAGE_CLASS_2_X_16 */ +/* reuse GL_IMAGE_CLASS_1_X_16 */ +/* reuse GL_IMAGE_CLASS_4_X_8 */ +/* reuse GL_IMAGE_CLASS_2_X_8 */ +/* reuse GL_IMAGE_CLASS_1_X_8 */ +/* reuse GL_IMAGE_CLASS_11_11_10 */ +/* reuse GL_IMAGE_CLASS_10_10_10_2 */ +/* reuse GL_VIEW_CLASS_128_BITS */ +/* reuse GL_VIEW_CLASS_96_BITS */ +/* reuse GL_VIEW_CLASS_64_BITS */ +/* reuse GL_VIEW_CLASS_48_BITS */ +/* reuse GL_VIEW_CLASS_32_BITS */ +/* reuse GL_VIEW_CLASS_24_BITS */ +/* reuse GL_VIEW_CLASS_16_BITS */ +/* reuse GL_VIEW_CLASS_8_BITS */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGB */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT3_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT5_RGBA */ +/* reuse GL_VIEW_CLASS_RGTC1_RED */ +/* reuse GL_VIEW_CLASS_RGTC2_RG */ +/* reuse GL_VIEW_CLASS_BPTC_UNORM */ +/* reuse GL_VIEW_CLASS_BPTC_FLOAT */ +/* Reuse tokens from ARB_invalidate_subdata (none) */ +/* Reuse tokens from ARB_multi_draw_indirect (none) */ +/* Reuse tokens from ARB_program_interface_query */ +/* reuse GL_UNIFORM */ +/* reuse GL_UNIFORM_BLOCK */ +/* reuse GL_PROGRAM_INPUT */ +/* reuse GL_PROGRAM_OUTPUT */ +/* reuse GL_BUFFER_VARIABLE */ +/* reuse GL_SHADER_STORAGE_BLOCK */ +/* reuse GL_VERTEX_SUBROUTINE */ +/* reuse GL_TESS_CONTROL_SUBROUTINE */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE */ +/* reuse GL_GEOMETRY_SUBROUTINE */ +/* reuse GL_FRAGMENT_SUBROUTINE */ +/* reuse GL_COMPUTE_SUBROUTINE */ +/* reuse GL_VERTEX_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_CONTROL_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE_UNIFORM */ +/* reuse GL_GEOMETRY_SUBROUTINE_UNIFORM */ +/* reuse GL_FRAGMENT_SUBROUTINE_UNIFORM */ +/* reuse GL_COMPUTE_SUBROUTINE_UNIFORM */ +/* reuse GL_TRANSFORM_FEEDBACK_VARYING */ +/* reuse GL_ACTIVE_RESOURCES */ +/* reuse GL_MAX_NAME_LENGTH */ +/* reuse GL_MAX_NUM_ACTIVE_VARIABLES */ +/* reuse GL_MAX_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_NAME_LENGTH */ +/* reuse GL_TYPE */ +/* reuse GL_ARRAY_SIZE */ +/* reuse GL_OFFSET */ +/* reuse GL_BLOCK_INDEX */ +/* reuse GL_ARRAY_STRIDE */ +/* reuse GL_MATRIX_STRIDE */ +/* reuse GL_IS_ROW_MAJOR */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_BUFFER_BINDING */ +/* reuse GL_BUFFER_DATA_SIZE */ +/* reuse GL_NUM_ACTIVE_VARIABLES */ +/* reuse GL_ACTIVE_VARIABLES */ +/* reuse GL_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_TOP_LEVEL_ARRAY_SIZE */ +/* reuse GL_TOP_LEVEL_ARRAY_STRIDE */ +/* reuse GL_LOCATION */ +/* reuse GL_LOCATION_INDEX */ +/* reuse GL_IS_PER_PATCH */ +/* Reuse tokens from ARB_robust_buffer_access_behavior (none) */ +/* Reuse tokens from ARB_shader_storage_buffer_object */ +/* reuse GL_SHADER_STORAGE_BUFFER */ +/* reuse GL_SHADER_STORAGE_BUFFER_BINDING */ +/* reuse GL_SHADER_STORAGE_BUFFER_START */ +/* reuse GL_SHADER_STORAGE_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS */ +/* reuse GL_MAX_SHADER_STORAGE_BLOCK_SIZE */ +/* reuse GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_SHADER_STORAGE_BARRIER_BIT */ +/* reuse GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES */ +/* Reuse tokens from ARB_stencil_texturing */ +/* reuse GL_DEPTH_STENCIL_TEXTURE_MODE */ +/* Reuse tokens from ARB_texture_buffer_range */ +/* reuse GL_TEXTURE_BUFFER_OFFSET */ +/* reuse GL_TEXTURE_BUFFER_SIZE */ +/* reuse GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT */ +/* Reuse tokens from ARB_texture_query_levels (none) */ +/* Reuse tokens from ARB_texture_storage_multisample (none) */ +/* Reuse tokens from ARB_texture_view */ +/* reuse GL_TEXTURE_VIEW_MIN_LEVEL */ +/* reuse GL_TEXTURE_VIEW_NUM_LEVELS */ +/* reuse GL_TEXTURE_VIEW_MIN_LAYER */ +/* reuse GL_TEXTURE_VIEW_NUM_LAYERS */ +/* reuse GL_TEXTURE_IMMUTABLE_LEVELS */ +/* Reuse tokens from ARB_vertex_attrib_binding */ +/* reuse GL_VERTEX_ATTRIB_BINDING */ +/* reuse GL_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_VERTEX_BINDING_DIVISOR */ +/* reuse GL_VERTEX_BINDING_OFFSET */ +/* reuse GL_VERTEX_BINDING_STRIDE */ +/* reuse GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_MAX_VERTEX_ATTRIB_BINDINGS */ +#endif + #ifndef GL_ARB_multitexture #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 @@ -2399,6 +2683,414 @@ extern "C" { #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F #endif +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +#ifndef GL_KHR_debug +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_DISPLAY_LIST 0x82E7 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +#endif + +#ifndef GL_ARB_arrays_of_arrays +#endif + +#ifndef GL_ARB_clear_buffer_object +#endif + +#ifndef GL_ARB_compute_shader +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif + +#ifndef GL_ARB_copy_image +#endif + +#ifndef GL_ARB_debug_group +/* reuse GL_DEBUG_TYPE_MARKER */ +/* reuse GL_DEBUG_TYPE_PUSH_GROUP */ +/* reuse GL_DEBUG_TYPE_POP_GROUP */ +/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */ +/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +#endif + +#ifndef GL_ARB_debug_label +/* reuse GL_BUFFER */ +/* reuse GL_SHADER */ +/* reuse GL_PROGRAM */ +/* reuse GL_QUERY */ +/* reuse GL_PROGRAM_PIPELINE */ +/* reuse GL_SAMPLER */ +/* DISPLAY_LIST used in compatibility profile only */ +/* reuse GL_DISPLAY_LIST */ +/* reuse GL_MAX_LABEL_LENGTH */ +/* reuse GL_VERTEX_ARRAY */ +#endif + +#ifndef GL_ARB_debug_output2 +/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */ +/* reuse GL_DEBUG_OUTPUT */ +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#endif + +#ifndef GL_ARB_internalformat_query2 +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_SAMPLES */ +/* reuse GL_TEXTURE_1D */ +/* reuse GL_TEXTURE_1D_ARRAY */ +/* reuse GL_TEXTURE_2D */ +/* reuse GL_TEXTURE_2D_ARRAY */ +/* reuse GL_TEXTURE_3D */ +/* reuse GL_TEXTURE_CUBE_MAP */ +/* reuse GL_TEXTURE_CUBE_MAP_ARRAY */ +/* reuse GL_TEXTURE_RECTANGLE */ +/* reuse GL_TEXTURE_BUFFER */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_COMPRESSED */ +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#endif + +#ifndef GL_ARB_invalidate_subdata +#endif + +#ifndef GL_ARB_multi_draw_indirect +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#endif + +#ifndef GL_ARB_shader_image_size +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x2000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#endif + +#ifndef GL_ARB_texture_query_levels +#endif + +#ifndef GL_ARB_texture_storage_multisample +#endif + +#ifndef GL_ARB_texture_view +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#endif + +#ifndef GL_ARB_robustness_isolation +#endif + #ifndef GL_EXT_abgr #define GL_ABGR_EXT 0x8000 #endif @@ -5583,6 +6275,10 @@ typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLen typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); #endif +#ifndef GL_KHR_debug +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + #ifndef GL_NV_vdpau_interop typedef GLintptr GLvdpauSurfaceNV; #endif @@ -5783,16 +6479,16 @@ typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); #define GL_VERSION_1_4 1 #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); @@ -6267,13 +6963,13 @@ typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint ind /* ARB_copy_buffer */ /* ARB_uniform_buffer_object */ #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); #endif @@ -6368,6 +7064,36 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, /* ARB_texture_storage */ #endif +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +/* OpenGL 4.3 reuses entry points from these extensions: */ +/* ARB_arrays_of_arrays (no entry points, GLSL only) */ +/* ARB_fragment_layer_viewport (no entry points, GLSL only) */ +/* ARB_shader_image_size (no entry points, GLSL only) */ +/* ARB_ES3_compatibility (no entry points) */ +/* ARB_clear_buffer_object */ +/* ARB_compute_shader */ +/* ARB_copy_image */ +/* ARB_debug_group */ +/* ARB_debug_label */ +/* KHR_debug (ARB_debug_output promoted to KHR without suffixes) */ +/* ARB_debug_output2 (no entry points) */ +/* ARB_explicit_uniform_location (no entry points) */ +/* ARB_framebuffer_no_attachments */ +/* ARB_internalformat_query2 */ +/* ARB_invalidate_subdata */ +/* ARB_multi_draw_indirect */ +/* ARB_program_interface_query */ +/* ARB_robust_buffer_access_behavior (no entry points) */ +/* ARB_shader_storage_buffer_object */ +/* ARB_stencil_texturing (no entry points) */ +/* ARB_texture_buffer_range */ +/* ARB_texture_query_levels (no entry points) */ +/* ARB_texture_storage_multisample */ +/* ARB_texture_view */ +/* ARB_vertex_attrib_binding */ +#endif + #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #ifdef GL_GLEXT_PROTOTYPES @@ -7122,13 +7848,13 @@ typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum w #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, const GLint *basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); #endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); #endif #ifndef GL_ARB_fragment_coord_conventions @@ -7806,13 +8532,13 @@ typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint locati #ifndef GL_ARB_base_instance #define GL_ARB_base_instance 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); #endif #ifndef GL_ARB_shading_language_420pack @@ -7822,11 +8548,11 @@ typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (G #ifndef GL_ARB_transform_feedback_instanced #define GL_ARB_transform_feedback_instanced 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #endif #ifndef GL_ARB_compressed_texture_pixel_storage @@ -7889,6 +8615,257 @@ typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum ta typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +/* KHR_debug also reuses entry points from ARB_debug_group and ARB_debug_label */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +#endif + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif + +#ifndef GL_ARB_debug_group +#define GL_ARB_debug_group 1 +/* ARB_debug_group reuses entry points from KHR_debug */ +#endif + +#ifndef GL_ARB_debug_label +#define GL_ARB_debug_label 1 +/* ARB_debug_label reuses entry points from KHR_debug */ +#endif + +#ifndef GL_ARB_debug_output2 +#define GL_ARB_debug_output2 1 +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif + #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #endif @@ -10054,10 +11031,10 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, c #ifndef GL_NV_pixel_data_range #define GL_NV_pixel_data_range 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer); GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer); typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); #endif diff --git a/include/Nazara/Audio/Debug.hpp b/include/Nazara/Audio/Debug.hpp deleted file mode 100644 index 96ed6ccef..000000000 --- a/include/Nazara/Audio/Debug.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// 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 -#if NAZARA_AUDIO_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG) - #include - - #define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete - #define new new(__FILE__, __LINE__) -#endif diff --git a/include/Nazara/Core.hpp b/include/Nazara/Core.hpp new file mode 100644 index 000000000..2fdf36497 --- /dev/null +++ b/include/Nazara/Core.hpp @@ -0,0 +1,60 @@ +// This file was automatically generated by Nazara + +/* + Nazara Engine + + Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/include/Nazara/Core/ByteArray.hpp b/include/Nazara/Core/ByteArray.hpp index aaef8e65a..94b64654e 100644 --- a/include/Nazara/Core/ByteArray.hpp +++ b/include/Nazara/Core/ByteArray.hpp @@ -8,10 +8,10 @@ #define NAZARA_BYTEARRAY_HPP #include -#include +#include #include -#if NAZARA_THREADSAFETY_BYTEARRAY +#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_BYTEARRAY #include #else #include @@ -28,7 +28,7 @@ class NAZARA_API NzByteArray : public NzHashable NzByteArray(); NzByteArray(const nzUInt8* buffer, unsigned int bufferLength); NzByteArray(const NzByteArray& buffer); - NzByteArray(NzByteArray&& buffer); + NzByteArray(NzByteArray&& buffer) noexcept; NzByteArray(SharedArray* sharedArray); ~NzByteArray(); @@ -80,7 +80,7 @@ class NAZARA_API NzByteArray : public NzHashable nzUInt8 operator[](unsigned int pos) const; NzByteArray& operator=(const NzByteArray& byteArray); - NzByteArray& operator=(NzByteArray&& byteArray); + NzByteArray& operator=(NzByteArray&& byteArray) noexcept; NzByteArray operator+(const NzByteArray& byteArray) const; NzByteArray& operator+=(const NzByteArray& byteArray); @@ -89,10 +89,7 @@ class NAZARA_API NzByteArray : public NzHashable struct NAZARA_API SharedArray { - SharedArray() : - refCount(1) - { - } + SharedArray() = default; SharedArray(unsigned short referenceCount, unsigned int bufferSize, unsigned int arraySize, nzUInt8* ptr) : capacity(bufferSize), @@ -104,7 +101,7 @@ class NAZARA_API NzByteArray : public NzHashable unsigned int capacity; unsigned int size; - unsigned short refCount; + unsigned short refCount = 1; nzUInt8* buffer; NazaraMutex(mutex) diff --git a/include/Nazara/Core/Clock.hpp b/include/Nazara/Core/Clock.hpp index d6e221702..6ade015b7 100644 --- a/include/Nazara/Core/Clock.hpp +++ b/include/Nazara/Core/Clock.hpp @@ -9,7 +9,7 @@ #include -#if NAZARA_THREADSAFETY_CLOCK +#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_CLOCK #include #else #include diff --git a/include/Nazara/Core/Color.inl b/include/Nazara/Core/Color.inl index 6c9cdd758..13fb3fe11 100644 --- a/include/Nazara/Core/Color.inl +++ b/include/Nazara/Core/Color.inl @@ -8,7 +8,7 @@ #include #include #include -#include +#include inline NzColor::NzColor() { @@ -198,26 +198,26 @@ inline NzColor NzColor::FromXYZ(float x, float y, float z) y /= 100; // Y from 0 to 100.000 z /= 100; // Z from 0 to 108.883 - double r = x * 3.2406 + y * -1.5372 + z * -0.4986; - double g = x * -0.9689 + y * 1.8758 + z * 0.0415; - double b = x * 0.0557 + y * -0.2040 + z * 1.0570; + float r = x * 3.2406f + y * -1.5372f + z * -0.4986f; + float g = x * -0.9689f + y * 1.8758f + z * 0.0415f; + float b = x * 0.0557f + y * -0.2040f + z * 1.0570f; if (r > 0.0031308f) - r = 1.055 * (std::pow(r, 1.0/2.4)) - 0.055; + r = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f; else - r *= 12.92; + r *= 12.92f; if (g > 0.0031308f) - g = 1.055 * (std::pow(g, 1.0/2.4)) - 0.055; + g = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f; else - g *= 12.92; + g *= 12.92f; if (b > 0.0031308f) - b = 1.055 * (std::pow(b, 1.0/2.4)) - 0.055; + b = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f; else - b *= 12.92; + b *= 12.92f; - return NzColor(r * 255.0, g * 255.0, b * 255.0); + return NzColor(r * 255.f, g * 255.f, b * 255.f); } inline void NzColor::ToCMY(const NzColor& color, float* cyan, float* magenta, float* yellow) @@ -409,4 +409,4 @@ inline std::ostream& operator<<(std::ostream& out, const NzColor& color) return out << color.ToString(); } -#include +#include diff --git a/include/Nazara/Core/ThreadCondition.hpp b/include/Nazara/Core/ConditionVariable.hpp similarity index 58% rename from include/Nazara/Core/ThreadCondition.hpp rename to include/Nazara/Core/ConditionVariable.hpp index 47a130847..f031a7e57 100644 --- a/include/Nazara/Core/ThreadCondition.hpp +++ b/include/Nazara/Core/ConditionVariable.hpp @@ -4,19 +4,19 @@ #pragma once -#ifndef NAZARA_THREADCONDITION_HPP -#define NAZARA_THREADCONDITION_HPP +#ifndef NAZARA_CONDITIONVARIABLE_HPP +#define NAZARA_CONDITIONVARIABLE_HPP #include +class NzConditionVariableImpl; class NzMutex; -class NzThreadConditionImpl; -class NAZARA_API NzThreadCondition +class NAZARA_API NzConditionVariable { public: - NzThreadCondition(); - ~NzThreadCondition(); + NzConditionVariable(); + ~NzConditionVariable(); void Signal(); void SignalAll(); @@ -25,7 +25,7 @@ class NAZARA_API NzThreadCondition bool Wait(NzMutex* mutex, nzUInt32 timeout); private: - NzThreadConditionImpl* m_impl; + NzConditionVariableImpl* m_impl; }; -#endif // NAZARA_THREADCONDITION_HPP +#endif // NAZARA_CONDITIONVARIABLE_HPP diff --git a/include/Nazara/Core/Config.hpp b/include/Nazara/Core/Config.hpp index ebc710456..7cfef54af 100644 --- a/include/Nazara/Core/Config.hpp +++ b/include/Nazara/Core/Config.hpp @@ -44,34 +44,36 @@ // Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution) #define NAZARA_CORE_MEMORYLEAKTRACKER 0 -// Standardise les séparateurs des dossiers selon le système d'exploitation courant +// Standardise les séparateurs des dossiers selon le système d'exploitation courant (Léger coût à l'exécution) #define NAZARA_CORE_NORMALIZE_DIRECTORY_SEPARATORS 1 // Précision des réels lors de la transformation en texte (Max. chiffres après la virgule) #define NAZARA_CORE_REAL_PRECISION 6 -// Redirige la sortie du log sur le flux d'erreur standard (cerr) en cas d'erreur d'écriture (ou d'ouverture du fichier) -#define NAZARA_CORE_REDIRECT_TO_CERR_ON_LOG_FAILURE 1 +// Duplique la sortie du log sur le flux de sortie standard (cout) +#define NAZARA_CORE_DUPLICATE_TO_COUT 0 // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_CORE_SAFE 1 -// Protège le module des accès concurrentiels +// Protège les classes des accès concurrentiels #define NAZARA_CORE_THREADSAFE 1 -#if NAZARA_CORE_THREADSAFE - #define NAZARA_THREADSAFETY_BYTEARRAY 1 // NzByteArray (COW) - #define NAZARA_THREADSAFETY_CLOCK 0 // NzClock - #define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory - #define NAZARA_THREADSAFETY_DYNLIB 1 // NzDynLib - #define NAZARA_THREADSAFETY_FILE 1 // NzFile - #define NAZARA_THREADSAFETY_HASHDIGEST 0 // NzHashDigest - #define NAZARA_THREADSAFETY_LOG 1 // NzLog - #define NAZARA_THREADSAFETY_STRING 1 // NzString (COW) - #define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream -#endif +// Les classes à protéger des accès concurrentiels +#define NAZARA_THREADSAFETY_BYTEARRAY 1 // NzByteArray (COW) +#define NAZARA_THREADSAFETY_CLOCK 0 // NzClock +#define NAZARA_THREADSAFETY_DIRECTORY 1 // NzDirectory +#define NAZARA_THREADSAFETY_DYNLIB 1 // NzDynLib +#define NAZARA_THREADSAFETY_FILE 1 // NzFile +#define NAZARA_THREADSAFETY_HASHDIGEST 0 // NzHashDigest +#define NAZARA_THREADSAFETY_LOG 1 // NzLog +#define NAZARA_THREADSAFETY_STRING 1 // NzString (COW) +#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream -// Optimise certaines parties du code avec les avancées venues de Windows Vista (Nécessite Vista ou supérieur et compilateur compatible) +// Le nombre de spinlocks à utiliser avec les critical sections de Windows (0 pour désactiver) +#define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096 + +// Optimise certaines parties du code avec certaines avancées venues de Windows Vista (Casse la compatibilité XP mais n'affecte pas les autres OS) #define NAZARA_CORE_WINDOWS_VISTA 0 /* diff --git a/include/Nazara/Core/Core.hpp b/include/Nazara/Core/Core.hpp new file mode 100644 index 000000000..9cf3bd232 --- /dev/null +++ b/include/Nazara/Core/Core.hpp @@ -0,0 +1,29 @@ +// 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_CORE_HPP +#define NAZARA_CORE_HPP + +#include +#include + +class NAZARA_API NzCore +{ + public: + NzCore() = delete; + ~NzCore() = delete; + + static bool Initialize(); + + static bool IsInitialized(); + + static void Uninitialize(); + + private: + static unsigned int s_moduleReferenceCouter; +}; + +#endif // NAZARA_CORE_HPP diff --git a/include/Nazara/Core/Directory.hpp b/include/Nazara/Core/Directory.hpp index c4b0109dc..d39f8d00a 100644 --- a/include/Nazara/Core/Directory.hpp +++ b/include/Nazara/Core/Directory.hpp @@ -19,7 +19,7 @@ #define NAZARA_DIRECTORY_SEPARATOR '/' #endif -#if NAZARA_THREADSAFETY_DIRECTORY +#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DIRECTORY #include #else #include @@ -36,10 +36,12 @@ class NAZARA_API NzDirectory void Close(); + NzString GetPattern() const; NzString GetResultName() const; NzString GetResultPath() const; nzUInt64 GetResultSize() const; + bool IsOpen() const; bool IsResultDirectory() const; bool NextResult(bool skipDots = true); @@ -47,6 +49,7 @@ class NAZARA_API NzDirectory bool Open(); void SetDirectory(const NzString& dirPath); + void SetPattern(const NzString& pattern); static bool Copy(const NzString& sourcePath, const NzString& destPath); static bool Create(const NzString& dirPath, bool recursive = false); @@ -59,7 +62,8 @@ class NAZARA_API NzDirectory NazaraMutexAttrib(m_mutex, mutable) NzString m_dirPath; - NzDirectoryImpl* m_impl; + NzString m_pattern; + NzDirectoryImpl* m_impl = nullptr; }; #endif // NAZARA_DIRECTORY_HPP diff --git a/include/Nazara/Core/DynLib.hpp b/include/Nazara/Core/DynLib.hpp index 3035e08a4..2c05a0eea 100644 --- a/include/Nazara/Core/DynLib.hpp +++ b/include/Nazara/Core/DynLib.hpp @@ -11,7 +11,7 @@ #include #include -#if NAZARA_THREADSAFETY_DYNLIB +#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DYNLIB #include #else #include diff --git a/include/Nazara/Core/File.hpp b/include/Nazara/Core/File.hpp index 9a43c84b6..dc28ff401 100644 --- a/include/Nazara/Core/File.hpp +++ b/include/Nazara/Core/File.hpp @@ -16,7 +16,7 @@ #include #include -#if NAZARA_THREADSAFETY_FILE +#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE #include #else #include @@ -50,7 +50,7 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable NzFile(); NzFile(const NzString& filePath); NzFile(const NzString& filePath, unsigned long openMode); - NzFile(NzFile&& file); + NzFile(NzFile&& file) noexcept; ~NzFile(); bool Copy(const NzString& newFilePath); @@ -92,7 +92,7 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable std::size_t Write(const void* buffer, std::size_t typeSize, unsigned int count); NzFile& operator=(const NzString& filePath); - NzFile& operator=(NzFile&& file); + NzFile& operator=(NzFile&& file) noexcept; static NzString AbsolutePath(const NzString& filePath); static bool Copy(const NzString& sourcePath, const NzString& targetPath); diff --git a/include/Nazara/Core/HashDigest.hpp b/include/Nazara/Core/HashDigest.hpp index 18bc3a99a..0359318b1 100644 --- a/include/Nazara/Core/HashDigest.hpp +++ b/include/Nazara/Core/HashDigest.hpp @@ -17,7 +17,7 @@ class NAZARA_API NzHashDigest NzHashDigest(); NzHashDigest(const NzString& hashName, const nzUInt8* digest, unsigned int length); NzHashDigest(const NzHashDigest& rhs); - NzHashDigest(NzHashDigest&& rhs); + NzHashDigest(NzHashDigest&& rhs) noexcept; ~NzHashDigest(); bool IsValid() const; @@ -31,7 +31,7 @@ class NAZARA_API NzHashDigest nzUInt8 operator[](unsigned short pos) const; NzHashDigest& operator=(const NzHashDigest& rhs); - NzHashDigest& operator=(NzHashDigest&& rhs); + NzHashDigest& operator=(NzHashDigest&& rhs) noexcept; bool operator==(const NzHashDigest& rhs) const; bool operator!=(const NzHashDigest& rhs) const; diff --git a/include/Nazara/Core/Initializer.hpp b/include/Nazara/Core/Initializer.hpp new file mode 100644 index 000000000..592ffb506 --- /dev/null +++ b/include/Nazara/Core/Initializer.hpp @@ -0,0 +1,26 @@ +// 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_INITIALIZER_HPP +#define NAZARA_INITIALIZER_HPP + +#include + +template +class NzInitializer +{ + public: + template NzInitializer(Args... args); + ~NzInitializer(); + + bool IsInitialized() const; + + operator bool() const; +}; + +#include + +#endif // NAZARA_INITIALIZER_HPP diff --git a/include/Nazara/Core/Initializer.inl b/include/Nazara/Core/Initializer.inl new file mode 100644 index 000000000..83cc85612 --- /dev/null +++ b/include/Nazara/Core/Initializer.inl @@ -0,0 +1,35 @@ +// 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 + +// http://www.easyrgb.com/index.php?X=MATH + +#include +#include + +template +template +NzInitializer::NzInitializer(Args... args) +{ + T::Initialize(args...); +} + +template +NzInitializer::~NzInitializer() +{ + T::Uninitialize(); +} + +template +bool NzInitializer::IsInitialized() const +{ + return T::IsInitialized(); +} + +template +NzInitializer::operator bool() const +{ + return T::IsInitialized(); +} + +#include diff --git a/include/Nazara/Core/Log.hpp b/include/Nazara/Core/Log.hpp index b9696c96d..76d6b8776 100644 --- a/include/Nazara/Core/Log.hpp +++ b/include/Nazara/Core/Log.hpp @@ -12,7 +12,7 @@ #include #include -#if NAZARA_THREADSAFETY_LOG +#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_LOG #include #else #include diff --git a/include/Nazara/Core/Mutex.hpp b/include/Nazara/Core/Mutex.hpp index 01b410fcd..fe4821f00 100644 --- a/include/Nazara/Core/Mutex.hpp +++ b/include/Nazara/Core/Mutex.hpp @@ -11,11 +11,11 @@ #include class NzMutexImpl; -class NzThreadCondition; +class NzConditionVariable; class NAZARA_API NzMutex : NzNonCopyable { - friend class NzThreadCondition; + friend class NzConditionVariable; public: NzMutex(); diff --git a/include/Nazara/Utility/Resource.hpp b/include/Nazara/Core/Resource.hpp similarity index 100% rename from include/Nazara/Utility/Resource.hpp rename to include/Nazara/Core/Resource.hpp diff --git a/include/Nazara/Core/String.hpp b/include/Nazara/Core/String.hpp index 7c3deae91..34bee2504 100644 --- a/include/Nazara/Core/String.hpp +++ b/include/Nazara/Core/String.hpp @@ -13,7 +13,7 @@ #include #include -#if NAZARA_THREADSAFETY_STRING +#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_STRING #include #else #include @@ -41,7 +41,7 @@ class NAZARA_API NzString : public NzHashable NzString(const char* string); NzString(const std::string& string); NzString(const NzString& string); - NzString(NzString&& string); + NzString(NzString&& string) noexcept; NzString(SharedString* sharedString); ~NzString(); @@ -112,8 +112,8 @@ class NAZARA_API NzString : public NzHashable unsigned int Replace(const char* oldString, const char* replaceString, int start = 0, nzUInt32 flags = None); unsigned int Replace(const NzString& oldString, const NzString& replaceString, int start = 0, nzUInt32 flags = None); unsigned int ReplaceAny(const char* oldCharacters, char replaceCharacter, int start = 0, nzUInt32 flags = None); - unsigned int ReplaceAny(const char* oldCharacters, const char* replaceString, int start = 0, nzUInt32 flags = None); - unsigned int ReplaceAny(const NzString& oldCharacters, const NzString& replaceString, int start = 0, nzUInt32 flags = None); + //unsigned int ReplaceAny(const char* oldCharacters, const char* replaceString, int start = 0, nzUInt32 flags = None); + //unsigned int ReplaceAny(const NzString& oldCharacters, const NzString& replaceString, int start = 0, nzUInt32 flags = None); void Reserve(unsigned int bufferSize); @@ -184,7 +184,7 @@ class NAZARA_API NzString : public NzHashable NzString& operator=(const char* string); NzString& operator=(const std::string& string); NzString& operator=(const NzString& string); - NzString& operator=(NzString&& string); + NzString& operator=(NzString&& string) noexcept; NzString operator+(char character) const; NzString operator+(const char* string) const; @@ -282,10 +282,7 @@ class NAZARA_API NzString : public NzHashable struct NAZARA_API SharedString { - SharedString() : - refCount(1) - { - } + SharedString() = default; SharedString(unsigned short referenceCount, unsigned int bufferSize, unsigned int stringSize, char* str) : capacity(bufferSize), @@ -299,7 +296,7 @@ class NAZARA_API NzString : public NzHashable unsigned int size; char* string; - unsigned short refCount; + unsigned short refCount = 1; NazaraMutex(mutex) }; diff --git a/include/Nazara/Core/StringStream.hpp b/include/Nazara/Core/StringStream.hpp index 996c06eec..63b975772 100644 --- a/include/Nazara/Core/StringStream.hpp +++ b/include/Nazara/Core/StringStream.hpp @@ -12,7 +12,7 @@ #include #include -#if NAZARA_THREADSAFETY_STRINGSTREAM +#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_STRINGSTREAM #include #else #include diff --git a/include/Nazara/Core/Thread.hpp b/include/Nazara/Core/Thread.hpp index d5bd416ab..5895040b8 100644 --- a/include/Nazara/Core/Thread.hpp +++ b/include/Nazara/Core/Thread.hpp @@ -26,7 +26,7 @@ class NAZARA_API NzThread : NzNonCopyable friend class NzThreadImpl; public: - Id() : m_handle(nullptr) {} + Id() = default; Id(Id&& rhs) = default; ~Id(); @@ -38,7 +38,7 @@ class NAZARA_API NzThread : NzNonCopyable Id(void* handle) : m_handle(handle) {} Id(const NzThreadImpl* thread); - void* m_handle; + void* m_handle = nullptr; }; template NzThread(F function); diff --git a/include/Nazara/Network/DebugOff.hpp b/include/Nazara/Debug.hpp similarity index 50% rename from include/Nazara/Network/DebugOff.hpp rename to include/Nazara/Debug.hpp index 08a1e8b1d..22ca244ef 100644 --- a/include/Nazara/Network/DebugOff.hpp +++ b/include/Nazara/Debug.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_NETWORK_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG) - #undef delete - #undef new -#endif +#include + +#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete +#define new new(__FILE__, __LINE__) diff --git a/include/Nazara/Audio/DebugOff.hpp b/include/Nazara/DebugOff.hpp similarity index 63% rename from include/Nazara/Audio/DebugOff.hpp rename to include/Nazara/DebugOff.hpp index 7cb3c4ac2..e32f36866 100644 --- a/include/Nazara/Audio/DebugOff.hpp +++ b/include/Nazara/DebugOff.hpp @@ -2,7 +2,5 @@ // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp -#if NAZARA_AUDIO_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG) - #undef delete - #undef new -#endif +#undef delete +#undef new diff --git a/include/Nazara/Network/Config.hpp b/include/Nazara/Math.hpp similarity index 69% rename from include/Nazara/Network/Config.hpp rename to include/Nazara/Math.hpp index 1e99c1f0f..e26587f36 100644 --- a/include/Nazara/Network/Config.hpp +++ b/include/Nazara/Math.hpp @@ -1,7 +1,10 @@ +// This file was automatically generated by Nazara + /* Nazara Engine Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + Rémi "overdrivr" Bèges (remi.beges@laposte.net) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -24,12 +27,14 @@ #pragma once -#ifndef NAZARA_CONFIG_NETWORK_HPP -#define NAZARA_CONFIG_NETWORK_HPP - -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci - -// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution) -#define NAZARA_NETWORK_MEMORYLEAKTRACKER 0 - -#endif // NAZARA_CONFIG_NETWORK_HPP +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/include/Nazara/Math/Basic.inl b/include/Nazara/Math/Basic.inl index 8655680f5..867002a92 100644 --- a/include/Nazara/Math/Basic.inl +++ b/include/Nazara/Math/Basic.inl @@ -10,6 +10,8 @@ #include #include +#define F(a) static_cast(a) + template T NzApproach(T value, T objective, T increment) { @@ -45,7 +47,7 @@ T NzDegrees(T degrees) template T NzDegreeToRadian(T degrees) { - return degrees * (M_PI/180.0); + return degrees * F(M_PI/180.0); } unsigned int NzGetNumberLength(signed char number) @@ -53,7 +55,15 @@ unsigned int NzGetNumberLength(signed char number) if (number == 0) return 1; - return static_cast(std::log10(std::abs(number)))+(number < 0 ? 2 : 1); + // Le standard définit le char comme étant codé sur un octet + static_assert(sizeof(number) == 1, "Signed char must be one byte-sized"); + + if (number >= 100) + return 3; + else if (number >= 10) + return 2; + else + return 1; } unsigned int NzGetNumberLength(unsigned char number) @@ -61,7 +71,15 @@ unsigned int NzGetNumberLength(unsigned char number) if (number == 0) return 1; - return static_cast(std::log10(number))+1; + // Le standard définit le char comme étant codé sur un octet + static_assert(sizeof(number) == 1, "Signed char must be one byte-sized"); + + if (number >= 100) + return 3; + else if (number >= 10) + return 2; + else + return 1; } unsigned int NzGetNumberLength(short number) @@ -152,20 +170,20 @@ T NzNormalizeAngle(T angle) #if NAZARA_MATH_ANGLE_RADIAN const T limit = M_PI; #else - const T limit = 180.0; + const T limit = F(180.0); #endif ///TODO: Trouver une solution sans duplication - if (angle > 0.0) + if (angle > F(0.0)) { angle += limit; - angle -= static_cast(angle/(2.0*limit))*(2.0*limit); + angle -= static_cast(angle/(F(2.0)*limit))*(F(2.0)*limit); angle -= limit; } else { angle -= limit; - angle -= static_cast(angle/(2.0*limit))*(2.0*limit); + angle -= static_cast(angle/(F(2.0)*limit))*(F(2.0)*limit); angle += limit; } @@ -175,11 +193,7 @@ T NzNormalizeAngle(T angle) template bool NzNumberEquals(T a, T b) { - if (a > b) - return (a-b) <= std::numeric_limits::epsilon(); - else - return (b-a) <= std::numeric_limits::epsilon(); - + return std::fabs(a-b) <= std::numeric_limits::epsilon(); } NzString NzNumberToString(long long number, nzUInt8 radix) @@ -235,7 +249,7 @@ T NzRadians(T radians) template T NzRadianToDegree(T radians) { - return radians * (180.0/M_PI); + return radians * F(180.0/M_PI); } long long NzStringToNumber(NzString str, nzUInt8 radix, bool* ok) @@ -288,4 +302,6 @@ long long NzStringToNumber(NzString str, nzUInt8 radix, bool* ok) return (negative) ? -static_cast(total) : total; } +#undef F + #include diff --git a/include/Nazara/Math/Config.hpp b/include/Nazara/Math/Config.hpp index e0f53a715..1325d5ad0 100644 --- a/include/Nazara/Math/Config.hpp +++ b/include/Nazara/Math/Config.hpp @@ -36,15 +36,17 @@ // Définit la disposition des matrices en colonnes (Façon OpenGL) #define NAZARA_MATH_MATRIX_COLUMN_MAJOR 1 +// Optimise les opérations entre matrices affines (Demande plusieurs comparaisons pour déterminer si une matrice est affine) +#define NAZARA_MATH_MATRIX4_CHECK_AFFINE 0 + // Active les tests de sécurité basés sur le code (Conseillé pour le développement) #define NAZARA_MATH_SAFE 1 -// Protège le module des accès concurrentiels +// Protège les classes des accès concurrentiels #define NAZARA_MATH_THREADSAFE 1 -#if NAZARA_MATH_THREADSAFE - #define NAZARA_THREADSAFETY_MATRIX3 1 // NzMatrix3 (COW) - #define NAZARA_THREADSAFETY_MATRIX4 1 // NzMatrix4 (COW) -#endif +// Les classes à protéger des accès concurrentiels +#define NAZARA_THREADSAFETY_MATRIX3 1 // NzMatrix3 (COW) +#define NAZARA_THREADSAFETY_MATRIX4 1 // NzMatrix4 (COW) #endif // NAZARA_CONFIG_MATH_HPP diff --git a/include/Nazara/Math/Cube.hpp b/include/Nazara/Math/Cube.hpp index 57aacdf77..7230c1108 100644 --- a/include/Nazara/Math/Cube.hpp +++ b/include/Nazara/Math/Cube.hpp @@ -17,8 +17,9 @@ class NzCube public: NzCube(); NzCube(T X, T Y, T Z, T Width, T Height, T Depth); - NzCube(T cube[6]); + NzCube(const T cube[6]); NzCube(const NzRect& rect); + NzCube(const NzVector3& vec1, const NzVector3& vec2); template explicit NzCube(const NzCube& rect); NzCube(const NzCube& rect) = default; ~NzCube() = default; @@ -32,11 +33,16 @@ class NzCube NzVector3 GetCenter() const; - bool Intersect(const NzCube& rect) const; - bool Intersect(const NzCube& rect, NzCube& intersection) const; + bool Intersect(const NzCube& rect, NzCube* intersection = nullptr) const; bool IsValid() const; + void Set(T X, T Y, T Z, T Width, T Height, T Depth); + void Set(const T rect[6]); + void Set(const NzRect& rect); + void Set(const NzVector3& vec1, const NzVector3& vec2); + template void Set(const NzCube& rect); + NzString ToString() const; operator NzString() const; diff --git a/include/Nazara/Math/Cube.inl b/include/Nazara/Math/Cube.inl index 5fc3b0c2d..64d69bf66 100644 --- a/include/Nazara/Math/Cube.inl +++ b/include/Nazara/Math/Cube.inl @@ -6,54 +6,42 @@ #include #include +#define F(a) static_cast(a) + template NzCube::NzCube() { } template -NzCube::NzCube(T X, T Y, T Z, T Width, T Height, T Depth) : -x(X), -y(Y), -z(Z), -width(Width), -height(Height), -depth(Depth) +NzCube::NzCube(T X, T Y, T Z, T Width, T Height, T Depth) { + Set(X, Y, Z, Width, Height, Depth); } template -NzCube::NzCube(T vec[6]) : -x(vec[0]), -y(vec[1]), -z(vec[2]), -width(vec[3]), -height(vec[4]), -depth(vec[5]) +NzCube::NzCube(const T vec[6]) { + Set(vec); } template -NzCube::NzCube(const NzRect& rect) : -x(rect.x), -y(rect.y), -z(0), -width(rect.width), -height(rect.height), -depth(1) +NzCube::NzCube(const NzRect& rect) { + Set(rect); +} + +template +NzCube::NzCube(const NzVector3& vec1, const NzVector3& vec2) +{ + Set(vec1, vec2); } template template -NzCube::NzCube(const NzCube& rect) : -x(static_cast(rect.x)), -y(static_cast(rect.y)), -z(static_cast(rect.z)), -width(static_cast(rect.width)), -height(static_cast(rect.height)), -depth(static_cast(rect.depth)) +NzCube::NzCube(const NzCube& rect) { + Set(rect); } template @@ -102,18 +90,11 @@ void NzCube::ExtendTo(const NzCube& rect) template NzVector3 NzCube::GetCenter() const { - return NzVector3((x+width)/2, (y+height)/2, (z+depth)/2); + return NzVector3((x+width)/F(2.0), (y+height)/F(2.0), (z+depth)/F(2.0)); } template -bool NzCube::Intersect(const NzCube& rect) const -{ - NzCube intersection; // Optimisé par le compilateur - return Intersect(rect, intersection); -} - -template -bool NzCube::Intersect(const NzCube& rect, NzCube& intersection) const +bool NzCube::Intersect(const NzCube& rect, NzCube* intersection) const { T left = std::max(x, rect.x); T right = std::min(x+width, rect.x+rect.width); @@ -124,12 +105,15 @@ bool NzCube::Intersect(const NzCube& rect, NzCube& intersection) const if (left < right && top < bottom && up < down) { - intersection.x = left; - intersection.y = top; - intersection.z = up; - intersection.width = right-left; - intersection.height = bottom-top; - intersection.depth = down-up; + if (intersection) + { + intersection->x = left; + intersection->y = top; + intersection->z = up; + intersection->width = right-left; + intersection->height = bottom-top; + intersection->depth = down-up; + } return true; } @@ -140,7 +124,63 @@ bool NzCube::Intersect(const NzCube& rect, NzCube& intersection) const template bool NzCube::IsValid() const { - return width > 0 && height > 0 && depth > 0; + return width > F(0.0) && height > F(0.0) && depth > F(0.0); +} + +template +void NzCube::Set(T X, T Y, T Z, T Width, T Height, T Depth) +{ + x = X; + y = Y; + z = Z; + width = Width; + height = Height; + depth = Depth; +} + +template +void NzCube::Set(const T rect[6]) +{ + x = rect[0]; + y = rect[1]; + z = rect[2]; + width = rect[3]; + height = rect[4]; + depth = rect[5]; +} + +template +void NzCube::Set(const NzRect& rect) +{ + x = rect.x; + y = rect.y; + z = 0; + width = rect.width; + height = rect.height; + depth = 1; +} + +template +void NzCube::Set(const NzVector3& vec1, const NzVector3& vec2) +{ + x = std::min(vec1.x, vec2.x); + y = std::min(vec1.y, vec2.y); + z = std::min(vec1.z, vec2.z); + width = (vec2.x > vec1.x) ? vec2.x-vec1.x : vec1.x-vec2.x; + height = (vec2.y > vec1.y) ? vec2.y-vec1.y : vec1.y-vec2.y; + depth = (vec2.z > vec1.z) ? vec2.z-vec1.z : vec1.z-vec2.z; +} + +template +template +void NzCube::Set(const NzCube& cube) +{ + x = F(cube.x); + y = F(cube.y); + z = F(cube.z); + width = F(cube.width); + height = F(cube.height); + depth = F(cube.depth); } template @@ -160,13 +200,15 @@ NzCube::operator NzString() const template T& NzCube::operator[](unsigned int i) { + #if NAZARA_MATH_SAFE if (i >= 6) { NzStringStream ss; - ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)"; + ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 6)"; throw std::domain_error(ss.ToString()); } + #endif return *(&x+i); } @@ -174,13 +216,15 @@ T& NzCube::operator[](unsigned int i) template T NzCube::operator[](unsigned int i) const { + #if NAZARA_MATH_SAFE if (i >= 6) { NzStringStream ss; - ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 4)"; + ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 6)"; throw std::domain_error(ss.ToString()); } + #endif return *(&x+i); } @@ -191,4 +235,6 @@ std::ostream& operator<<(std::ostream& out, const NzCube& rect) return out << rect.ToString(); } +#undef F + #include diff --git a/include/Nazara/Math/EulerAngles.hpp b/include/Nazara/Math/EulerAngles.hpp index be39258fd..a9667186f 100644 --- a/include/Nazara/Math/EulerAngles.hpp +++ b/include/Nazara/Math/EulerAngles.hpp @@ -9,9 +9,8 @@ #define NAZARA_EULERANGLES_HPP #include - -template class NzQuaternion; -template class NzVector3; +#include +#include template class NzEulerAngles { @@ -25,9 +24,7 @@ template class NzEulerAngles NzEulerAngles(const NzEulerAngles& angles) = default; ~NzEulerAngles() = default; - NzVector3 GetForward() const; - NzVector3 GetRight() const; - NzVector3 GetUp() const; + void MakeZero(); void Normalize(); @@ -37,25 +34,28 @@ template class NzEulerAngles //void Set(const NzMatrix3& mat); void Set(const NzQuaternion& quat); template void Set(const NzEulerAngles& angles); - void SetZero(); //NzMatrix3 ToRotationMatrix() const; NzQuaternion ToQuaternion() const; NzString ToString() const; + operator NzString() const; + NzEulerAngles operator+(const NzEulerAngles& angles) const; NzEulerAngles operator-(const NzEulerAngles& angles) const; - NzEulerAngles operator*(const NzEulerAngles& angles) const; - NzEulerAngles operator/(const NzEulerAngles& angles) const; + /*NzEulerAngles operator*(const NzEulerAngles& angles) const; + NzEulerAngles operator/(const NzEulerAngles& angles) const;*/ NzEulerAngles operator+=(const NzEulerAngles& angles); NzEulerAngles operator-=(const NzEulerAngles& angles); - NzEulerAngles operator*=(const NzEulerAngles& angles); - NzEulerAngles operator/=(const NzEulerAngles& angles); + /*NzEulerAngles operator*=(const NzEulerAngles& angles); + NzEulerAngles operator/=(const NzEulerAngles& angles);*/ bool operator==(const NzEulerAngles& angles) const; bool operator!=(const NzEulerAngles& angles) const; + static NzEulerAngles Zero(); + T pitch, yaw, roll; }; diff --git a/include/Nazara/Math/EulerAngles.inl b/include/Nazara/Math/EulerAngles.inl index bf1e54c1a..0752f2948 100644 --- a/include/Nazara/Math/EulerAngles.inl +++ b/include/Nazara/Math/EulerAngles.inl @@ -7,9 +7,10 @@ #include #include #include -#include #include +#define F(a) static_cast(a) + template NzEulerAngles::NzEulerAngles() { @@ -41,33 +42,9 @@ NzEulerAngles::NzEulerAngles(const NzEulerAngles& angles) } template -NzVector3 NzEulerAngles::GetForward() const +void NzEulerAngles::MakeZero() { - #if NAZARA_MATH_ANGLE_RADIAN - return NzVector3(std::cos(yaw), std::sin(roll), std::sin(yaw)); - #else - return NzVector3(std::cos(NzDegreeToRadian(yaw)), std::sin(NzDegreeToRadian(roll)), std::sin(NzDegreeToRadian(yaw))); - #endif -} - -template -NzVector3 NzEulerAngles::GetRight() const -{ - #if NAZARA_MATH_ANGLE_RADIAN - return NzVector3(std::sin(yaw), std::sin(pitch), std::cos(pitch)); - #else - return NzVector3(std::sin(NzDegreeToRadian(yaw)), std::sin(NzDegreeToRadian(pitch)), std::cos(NzDegreeToRadian(pitch))); - #endif -} - -template -NzVector3 NzEulerAngles::GetUp() const -{ - #if NAZARA_MATH_ANGLE_RADIAN - return NzVector3(std::sin(roll), std::cos(pitch), -std::sin(pitch)); - #else - return NzVector3(std::sin(NzDegreeToRadian(roll)), std::cos(NzDegreeToRadian(pitch)), -std::sin(NzDegreeToRadian(pitch))); - #endif + Set(F(0.0), F(0.0), F(0.0)); } template @@ -117,20 +94,14 @@ void NzEulerAngles::Set(const NzEulerAngles& angles) roll = static_cast(angles.roll); } -template -void NzEulerAngles::SetZero() -{ - Set(0.0, 0.0, 0.0); -} - template NzQuaternion NzEulerAngles::ToQuaternion() const { - NzQuaternion Qx(pitch, NzVector3(1.0, 0.0, 0.0)); - NzQuaternion Qy(yaw, NzVector3(0.0, 1.0, 0.0)); - NzQuaternion Qz(roll, NzVector3(0.0, 0.0, 1.0)); + NzQuaternion rotX(pitch, NzVector3(F(1.0), F(0.0), F(0.0))); + NzQuaternion rotY(yaw, NzVector3(F(0.0), F(1.0), F(0.0))); + NzQuaternion rotZ(roll, NzVector3(F(0.0), F(0.0), F(1.0))); - return Qx * Qy * Qz; + return rotY * rotX * rotZ; } template @@ -141,6 +112,12 @@ NzString NzEulerAngles::ToString() const return ss << "EulerAngles(" << pitch << ", " << yaw << ", " << roll << ')'; } +template +NzEulerAngles::operator NzString() const +{ + return ToString(); +} + template NzEulerAngles NzEulerAngles::operator+(const NzEulerAngles& angles) const { @@ -191,10 +168,21 @@ bool NzEulerAngles::operator!=(const NzEulerAngles& angles) const return !operator==(angles); } +template +NzEulerAngles NzEulerAngles::Zero() +{ + NzEulerAngles angles; + angles.MakeZero(); + + return angles; +} + template std::ostream& operator<<(std::ostream& out, const NzEulerAngles& angles) { return out << angles.ToString(); } +#undef F + #include diff --git a/include/Nazara/Audio/Config.hpp b/include/Nazara/Math/Math.hpp similarity index 77% rename from include/Nazara/Audio/Config.hpp rename to include/Nazara/Math/Math.hpp index ac8b47f16..f0212dde6 100644 --- a/include/Nazara/Audio/Config.hpp +++ b/include/Nazara/Math/Math.hpp @@ -20,16 +20,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#pragma once - -#ifndef NAZARA_CONFIG_AUDIO_HPP -#define NAZARA_CONFIG_AUDIO_HPP - -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci - -// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution) -#define NAZARA_AUDIO_MEMORYLEAKTRACKER 0 - -#endif // NAZARA_CONFIG_AUDIOs_HPP +*/ \ No newline at end of file diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index 80d30b25f..f0c136207 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -8,8 +8,9 @@ #define NAZARA_MATRIX4_HPP #include +#include -#if NAZARA_THREADSAFETY_MATRIX4 +#if NAZARA_MATH_THREADSAFE && NAZARA_THREADSAFETY_MATRIX4 #include #else #include @@ -26,18 +27,21 @@ template class NzMatrix4 public: NzMatrix4(); NzMatrix4(T r11, T r12, T r13, T r14, - T r21, T r22, T r23, T r24, - T r31, T r32, T r33, T r34, - T r41, T r42, T r43, T r44); + T r21, T r22, T r23, T r24, + T r31, T r32, T r33, T r34, + T r41, T r42, T r43, T r44); NzMatrix4(const T matrix[16]); //NzMatrix4(const NzMatrix3& matrix); template explicit NzMatrix4(const NzMatrix4& matrix); NzMatrix4(const NzMatrix4& matrix); - NzMatrix4(NzMatrix4&& matrix); + NzMatrix4(NzMatrix4&& matrix) noexcept; ~NzMatrix4(); + NzMatrix4 Concatenate(const NzMatrix4& matrix) const; + T GetDeterminant() const; NzMatrix4 GetInverse() const; + NzQuaternion GetRotation() const; //NzMatrix3 GetRotationMatrix() const; NzVector3 GetScale() const; NzVector3 GetTranslation() const; @@ -46,23 +50,30 @@ template class NzMatrix4 bool HasNegativeScale() const; bool HasScale() const; + bool IsAffine() const; + bool IsDefined() const; + + void MakeIdentity(); + void MakeLookAt(const NzVector3& eye, const NzVector3& center, const NzVector3& up); + void MakeOrtho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0); + void MakePerspective(T angle, T ratio, T zNear, T zFar); + void MakeRotation(const NzQuaternion& rotation); + void MakeScale(const NzVector3& scale); + void MakeTranslation(const NzVector3& translation); + void MakeZero(); + void Set(T r11, T r12, T r13, T r14, - T r21, T r22, T r23, T r24, - T r31, T r32, T r33, T r34, - T r41, T r42, T r43, T r44); + T r21, T r22, T r23, T r24, + T r31, T r32, T r33, T r34, + T r41, T r42, T r43, T r44); void Set(const T matrix[16]); //NzMatrix4(const NzMatrix3& matrix); void Set(const NzMatrix4& matrix); void Set(NzMatrix4&& matrix); template void Set(const NzMatrix4& matrix); - void SetIdentity(); - void SetLookAt(const NzVector3& eye, const NzVector3& center, const NzVector3& up); - void SetOrtho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0); - void SetPerspective(T angle, T ratio, T zNear, T zFar); void SetRotation(const NzQuaternion& rotation); void SetScale(const NzVector3& scale); void SetTranslation(const NzVector3& translation); - void SetZero(); NzString ToString() const; @@ -72,6 +83,8 @@ template class NzMatrix4 NzMatrix4& Transpose(); + operator NzString() const; + operator T*(); operator const T*() const; @@ -79,7 +92,7 @@ template class NzMatrix4 const T& operator()(unsigned int x, unsigned int y) const; NzMatrix4& operator=(const NzMatrix4& matrix); - NzMatrix4& operator=(NzMatrix4&& matrix); + NzMatrix4& operator=(NzMatrix4&& matrix) noexcept; NzMatrix4 operator*(const NzMatrix4& matrix) const; NzVector2 operator*(const NzVector2& vector) const; @@ -90,12 +103,16 @@ template class NzMatrix4 NzMatrix4& operator*=(const NzMatrix4& matrix); NzMatrix4& operator*=(T scalar); + static NzMatrix4 Concatenate(const NzMatrix4& m1, const NzMatrix4& m2); + static NzMatrix4 ConcatenateAffine(const NzMatrix4& m1, const NzMatrix4& m2); + static NzMatrix4 Identity(); static NzMatrix4 LookAt(const NzVector3& eye, const NzVector3& center, const NzVector3& up); static NzMatrix4 Ortho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0); static NzMatrix4 Perspective(T angle, T ratio, T zNear, T zFar); static NzMatrix4 Rotate(const NzQuaternion& rotation); static NzMatrix4 Scale(const NzVector3& scale); static NzMatrix4 Translate(const NzVector3& translation); + static NzMatrix4 Zero(); struct SharedMatrix { @@ -112,11 +129,13 @@ template class NzMatrix4 void EnsureOwnership(); void ReleaseMatrix(); - SharedMatrix* m_sharedMatrix; + SharedMatrix* m_sharedMatrix = nullptr; }; template std::ostream& operator<<(std::ostream& out, const NzMatrix4& matrix); +template NzMatrix4 operator*(T scale, const NzMatrix4& matrix); + typedef NzMatrix4 NzMatrix4d; typedef NzMatrix4 NzMatrix4f; diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 184648cbe..051b10697 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -15,52 +15,49 @@ #include #include #include -#include +//#include +///FIXME: Le MLT détecte de faux-leaks ici (Problème lié aux inline ?) + +#define F(a) static_cast(a) template -NzMatrix4::NzMatrix4() : -m_sharedMatrix(nullptr) +NzMatrix4::NzMatrix4() { } template NzMatrix4::NzMatrix4(T r11, T r12, T r13, T r14, - T r21, T r22, T r23, T r24, - T r31, T r32, T r33, T r34, - T r41, T r42, T r43, T r44) : -m_sharedMatrix(nullptr) + T r21, T r22, T r23, T r24, + T r31, T r32, T r33, T r34, + T r41, T r42, T r43, T r44) { Set(r11, r12, r13, r14, - r21, r22, r23, r24, - r31, r32, r33, r34, - r41, r42, r43, r44); + r21, r22, r23, r24, + r31, r32, r33, r34, + r41, r42, r43, r44); } template -NzMatrix4::NzMatrix4(const T matrix[16]) : -m_sharedMatrix(nullptr) +NzMatrix4::NzMatrix4(const T matrix[16]) { Set(matrix); } template template -NzMatrix4::NzMatrix4(const NzMatrix4& matrix) : -m_sharedMatrix(nullptr) +NzMatrix4::NzMatrix4(const NzMatrix4& matrix) { Set(matrix); } template -NzMatrix4::NzMatrix4(const NzMatrix4& matrix) : -m_sharedMatrix(nullptr) +NzMatrix4::NzMatrix4(const NzMatrix4& matrix) { Set(matrix); } template -NzMatrix4::NzMatrix4(NzMatrix4&& matrix) : -m_sharedMatrix(nullptr) +NzMatrix4::NzMatrix4(NzMatrix4&& matrix) noexcept { Set(matrix); } @@ -71,88 +68,96 @@ NzMatrix4::~NzMatrix4() ReleaseMatrix(); } +template +NzMatrix4 NzMatrix4::Concatenate(const NzMatrix4& matrix) const +{ + return Concatenate(*this, matrix); +} + template T NzMatrix4::GetDeterminant() const { #if NAZARA_MATH_SAFE - if (!m_sharedMatrix) + if (!IsDefined()) { - NazaraError("Undefined matrix"); - return 0.0; + NazaraError("Matrix not defined"); + return F(0.0); } #endif - T A = m_sharedMatrix->m22 * (m_sharedMatrix->m33 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m34) - m_sharedMatrix->m32 * (m_sharedMatrix->m23 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m24) + m_sharedMatrix->m42 * (m_sharedMatrix->m23 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m24); - T B = m_sharedMatrix->m12 * (m_sharedMatrix->m33 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m34) - m_sharedMatrix->m32 * (m_sharedMatrix->m13 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m14) + m_sharedMatrix->m42 * (m_sharedMatrix->m13 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m14); - T C = m_sharedMatrix->m12 * (m_sharedMatrix->m23 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m24) - m_sharedMatrix->m22 * (m_sharedMatrix->m13 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m14) + m_sharedMatrix->m42 * (m_sharedMatrix->m13 * m_sharedMatrix->m24 - m_sharedMatrix->m23 * m_sharedMatrix->m14); - T D = m_sharedMatrix->m12 * (m_sharedMatrix->m23 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m24) - m_sharedMatrix->m22 * (m_sharedMatrix->m13 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m14) + m_sharedMatrix->m32 * (m_sharedMatrix->m13 * m_sharedMatrix->m24 - m_sharedMatrix->m23 * m_sharedMatrix->m14); + T A = m_sharedMatrix->m22*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m34) - m_sharedMatrix->m32*(m_sharedMatrix->m23*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m24) + m_sharedMatrix->m42*(m_sharedMatrix->m23*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m24); + T B = m_sharedMatrix->m12*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m34) - m_sharedMatrix->m32*(m_sharedMatrix->m13*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m14) + m_sharedMatrix->m42*(m_sharedMatrix->m13*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m14); + T C = m_sharedMatrix->m12*(m_sharedMatrix->m23*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m24) - m_sharedMatrix->m22*(m_sharedMatrix->m13*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m14) + m_sharedMatrix->m42*(m_sharedMatrix->m13*m_sharedMatrix->m24 - m_sharedMatrix->m23*m_sharedMatrix->m14); + T D = m_sharedMatrix->m12*(m_sharedMatrix->m23*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m24) - m_sharedMatrix->m22*(m_sharedMatrix->m13*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m14) + m_sharedMatrix->m32*(m_sharedMatrix->m13*m_sharedMatrix->m24 - m_sharedMatrix->m23*m_sharedMatrix->m14); - return m_sharedMatrix->m11 * A - m_sharedMatrix->m21 * B + m_sharedMatrix->m31 * C - m_sharedMatrix->m41 * D; + return m_sharedMatrix->m11*A - m_sharedMatrix->m21*B + m_sharedMatrix->m31*C - m_sharedMatrix->m41*D; } template NzMatrix4 NzMatrix4::GetInverse() const { #if NAZARA_MATH_SAFE - if (!m_sharedMatrix) + if (!IsDefined()) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return NzMatrix4(); } #endif - NzMatrix4 matrix; T det = GetDeterminant(); - - if (!NzNumberEquals(det, static_cast(0.0))) + if (!NzNumberEquals(det, F(0.0))) { - matrix(0, 0) = (m_sharedMatrix->m22 * (m_sharedMatrix->m33 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m43) - m_sharedMatrix->m32 * (m_sharedMatrix->m23 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m24) + m_sharedMatrix->m42 * (m_sharedMatrix->m23 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m24)) / det; - matrix(0, 1) = -(m_sharedMatrix->m12 * (m_sharedMatrix->m33 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m34) - m_sharedMatrix->m32 * (m_sharedMatrix->m13 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m14) + m_sharedMatrix->m42 * (m_sharedMatrix->m13 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m14)) / det; - matrix(0, 2) = (m_sharedMatrix->m12 * (m_sharedMatrix->m23 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m24) - m_sharedMatrix->m22 * (m_sharedMatrix->m13 * m_sharedMatrix->m44 - m_sharedMatrix->m43 * m_sharedMatrix->m14) + m_sharedMatrix->m42 * (m_sharedMatrix->m13 * m_sharedMatrix->m24 - m_sharedMatrix->m23 * m_sharedMatrix->m14)) / det; - matrix(0, 3) = -(m_sharedMatrix->m12 * (m_sharedMatrix->m23 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m24) - m_sharedMatrix->m22 * (m_sharedMatrix->m13 * m_sharedMatrix->m34 - m_sharedMatrix->m33 * m_sharedMatrix->m14) + m_sharedMatrix->m32 * (m_sharedMatrix->m13 * m_sharedMatrix->m24 - m_sharedMatrix->m23 * m_sharedMatrix->m14)) / det; + return NzMatrix4((m_sharedMatrix->m22*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m43) - m_sharedMatrix->m32*(m_sharedMatrix->m23*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m24) + m_sharedMatrix->m42*(m_sharedMatrix->m23*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m24)) / det, + -(m_sharedMatrix->m12*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m34) - m_sharedMatrix->m32*(m_sharedMatrix->m13*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m14) + m_sharedMatrix->m42*(m_sharedMatrix->m13*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m14)) / det, + (m_sharedMatrix->m12*(m_sharedMatrix->m23*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m24) - m_sharedMatrix->m22*(m_sharedMatrix->m13*m_sharedMatrix->m44 - m_sharedMatrix->m43*m_sharedMatrix->m14) + m_sharedMatrix->m42*(m_sharedMatrix->m13*m_sharedMatrix->m24 - m_sharedMatrix->m23*m_sharedMatrix->m14)) / det, + -(m_sharedMatrix->m12*(m_sharedMatrix->m23*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m24) - m_sharedMatrix->m22*(m_sharedMatrix->m13*m_sharedMatrix->m34 - m_sharedMatrix->m33*m_sharedMatrix->m14) + m_sharedMatrix->m32*(m_sharedMatrix->m13*m_sharedMatrix->m24 - m_sharedMatrix->m23*m_sharedMatrix->m14)) / det, - matrix(1, 0) = -(m_sharedMatrix->m21 * (m_sharedMatrix->m33 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m43) - m_sharedMatrix->m23 * (m_sharedMatrix->m31 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m41) + m_sharedMatrix->m24 * (m_sharedMatrix->m31 * m_sharedMatrix->m43 - m_sharedMatrix->m33 * m_sharedMatrix->m41)) / det; - matrix(1, 1) = (m_sharedMatrix->m11 * (m_sharedMatrix->m33 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m43) - m_sharedMatrix->m13 * (m_sharedMatrix->m31 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m41) + m_sharedMatrix->m14 * (m_sharedMatrix->m31 * m_sharedMatrix->m43 - m_sharedMatrix->m33 * m_sharedMatrix->m41)) / det; - matrix(1, 2) = -(m_sharedMatrix->m11 * (m_sharedMatrix->m23 * m_sharedMatrix->m44 - m_sharedMatrix->m24 * m_sharedMatrix->m43) - m_sharedMatrix->m13 * (m_sharedMatrix->m21 * m_sharedMatrix->m44 - m_sharedMatrix->m24 * m_sharedMatrix->m41) + m_sharedMatrix->m14 * (m_sharedMatrix->m21 * m_sharedMatrix->m43 - m_sharedMatrix->m23 * m_sharedMatrix->m41)) / det; - matrix(1, 3) = (m_sharedMatrix->m11 * (m_sharedMatrix->m23 * m_sharedMatrix->m34 - m_sharedMatrix->m24 * m_sharedMatrix->m33) - m_sharedMatrix->m13 * (m_sharedMatrix->m21 * m_sharedMatrix->m34 - m_sharedMatrix->m24 * m_sharedMatrix->m31) + m_sharedMatrix->m14 * (m_sharedMatrix->m21 * m_sharedMatrix->m33 - m_sharedMatrix->m23 * m_sharedMatrix->m31)) / det; + -(m_sharedMatrix->m21*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m43) - m_sharedMatrix->m23*(m_sharedMatrix->m31*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m41) + m_sharedMatrix->m24*(m_sharedMatrix->m31*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m41)) / det, + (m_sharedMatrix->m11*(m_sharedMatrix->m33*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m43) - m_sharedMatrix->m13*(m_sharedMatrix->m31*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m41) + m_sharedMatrix->m14*(m_sharedMatrix->m31*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m41)) / det, + -(m_sharedMatrix->m11*(m_sharedMatrix->m23*m_sharedMatrix->m44 - m_sharedMatrix->m24*m_sharedMatrix->m43) - m_sharedMatrix->m13*(m_sharedMatrix->m21*m_sharedMatrix->m44 - m_sharedMatrix->m24*m_sharedMatrix->m41) + m_sharedMatrix->m14*(m_sharedMatrix->m21*m_sharedMatrix->m43 - m_sharedMatrix->m23*m_sharedMatrix->m41)) / det, + (m_sharedMatrix->m11*(m_sharedMatrix->m23*m_sharedMatrix->m34 - m_sharedMatrix->m24*m_sharedMatrix->m33) - m_sharedMatrix->m13*(m_sharedMatrix->m21*m_sharedMatrix->m34 - m_sharedMatrix->m24*m_sharedMatrix->m31) + m_sharedMatrix->m14*(m_sharedMatrix->m21*m_sharedMatrix->m33 - m_sharedMatrix->m23*m_sharedMatrix->m31)) / det, - matrix(2, 0) = (m_sharedMatrix->m21 * (m_sharedMatrix->m32 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m42) - m_sharedMatrix->m22 * (m_sharedMatrix->m31 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m41) + m_sharedMatrix->m24 * (m_sharedMatrix->m31 * m_sharedMatrix->m42 - m_sharedMatrix->m32 * m_sharedMatrix->m41)) / det; - matrix(2, 1) = -(m_sharedMatrix->m11 * (m_sharedMatrix->m32 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m42) - m_sharedMatrix->m12 * (m_sharedMatrix->m31 * m_sharedMatrix->m44 - m_sharedMatrix->m34 * m_sharedMatrix->m41) + m_sharedMatrix->m14 * (m_sharedMatrix->m31 * m_sharedMatrix->m42 - m_sharedMatrix->m32 * m_sharedMatrix->m41)) / det; - matrix(2, 2) = (m_sharedMatrix->m11 * (m_sharedMatrix->m22 * m_sharedMatrix->m44 - m_sharedMatrix->m24 * m_sharedMatrix->m42) - m_sharedMatrix->m12 * (m_sharedMatrix->m21 * m_sharedMatrix->m44 - m_sharedMatrix->m24 * m_sharedMatrix->m41) + m_sharedMatrix->m14 * (m_sharedMatrix->m21 * m_sharedMatrix->m42 - m_sharedMatrix->m22 * m_sharedMatrix->m41)) / det; - matrix(2, 3) = -(m_sharedMatrix->m11 * (m_sharedMatrix->m22 * m_sharedMatrix->m34 - m_sharedMatrix->m24 * m_sharedMatrix->m32) - m_sharedMatrix->m12 * (m_sharedMatrix->m21 * m_sharedMatrix->m34 - m_sharedMatrix->m24 * m_sharedMatrix->m31) + m_sharedMatrix->m14 * (m_sharedMatrix->m21 * m_sharedMatrix->m32 - m_sharedMatrix->m22 * m_sharedMatrix->m31)) / det; + (m_sharedMatrix->m21*(m_sharedMatrix->m32*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m42) - m_sharedMatrix->m22*(m_sharedMatrix->m31*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m41) + m_sharedMatrix->m24*(m_sharedMatrix->m31*m_sharedMatrix->m42 - m_sharedMatrix->m32*m_sharedMatrix->m41)) / det, + -(m_sharedMatrix->m11*(m_sharedMatrix->m32*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m42) - m_sharedMatrix->m12*(m_sharedMatrix->m31*m_sharedMatrix->m44 - m_sharedMatrix->m34*m_sharedMatrix->m41) + m_sharedMatrix->m14*(m_sharedMatrix->m31*m_sharedMatrix->m42 - m_sharedMatrix->m32*m_sharedMatrix->m41)) / det, + (m_sharedMatrix->m11*(m_sharedMatrix->m22*m_sharedMatrix->m44 - m_sharedMatrix->m24*m_sharedMatrix->m42) - m_sharedMatrix->m12*(m_sharedMatrix->m21*m_sharedMatrix->m44 - m_sharedMatrix->m24*m_sharedMatrix->m41) + m_sharedMatrix->m14*(m_sharedMatrix->m21*m_sharedMatrix->m42 - m_sharedMatrix->m22*m_sharedMatrix->m41)) / det, + -(m_sharedMatrix->m11*(m_sharedMatrix->m22*m_sharedMatrix->m34 - m_sharedMatrix->m24*m_sharedMatrix->m32) - m_sharedMatrix->m12*(m_sharedMatrix->m21*m_sharedMatrix->m34 - m_sharedMatrix->m24*m_sharedMatrix->m31) + m_sharedMatrix->m14*(m_sharedMatrix->m21*m_sharedMatrix->m32 - m_sharedMatrix->m22*m_sharedMatrix->m31)) / det, - matrix(3, 0) = -(m_sharedMatrix->m21 * (m_sharedMatrix->m32 * m_sharedMatrix->m43 - m_sharedMatrix->m33 * m_sharedMatrix->m42) - m_sharedMatrix->m22 * (m_sharedMatrix->m31 * m_sharedMatrix->m43 - m_sharedMatrix->m33 * m_sharedMatrix->m41) + m_sharedMatrix->m23 * (m_sharedMatrix->m31 * m_sharedMatrix->m42 - m_sharedMatrix->m32 * m_sharedMatrix->m41)) / det; - matrix(3, 1) = (m_sharedMatrix->m11 * (m_sharedMatrix->m32 * m_sharedMatrix->m43 - m_sharedMatrix->m33 * m_sharedMatrix->m42) - m_sharedMatrix->m12 * (m_sharedMatrix->m31 * m_sharedMatrix->m43 - m_sharedMatrix->m33 * m_sharedMatrix->m41) + m_sharedMatrix->m13 * (m_sharedMatrix->m31 * m_sharedMatrix->m42 - m_sharedMatrix->m32 * m_sharedMatrix->m41)) / det; - matrix(3, 2) = -(m_sharedMatrix->m11 * (m_sharedMatrix->m22 * m_sharedMatrix->m43 - m_sharedMatrix->m23 * m_sharedMatrix->m42) - m_sharedMatrix->m12 * (m_sharedMatrix->m21 * m_sharedMatrix->m43 - m_sharedMatrix->m23 * m_sharedMatrix->m41) + m_sharedMatrix->m13 * (m_sharedMatrix->m21 * m_sharedMatrix->m42 - m_sharedMatrix->m22 * m_sharedMatrix->m41)) / det; - matrix(3, 3) = (m_sharedMatrix->m11 * (m_sharedMatrix->m22 * m_sharedMatrix->m33 - m_sharedMatrix->m23 * m_sharedMatrix->m32) - m_sharedMatrix->m12 * (m_sharedMatrix->m21 * m_sharedMatrix->m33 - m_sharedMatrix->m23 * m_sharedMatrix->m31) + m_sharedMatrix->m13 * (m_sharedMatrix->m21 * m_sharedMatrix->m32 - m_sharedMatrix->m22 * m_sharedMatrix->m31)) / det; + -(m_sharedMatrix->m21*(m_sharedMatrix->m32*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m42) - m_sharedMatrix->m22*(m_sharedMatrix->m31*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m41) + m_sharedMatrix->m23*(m_sharedMatrix->m31*m_sharedMatrix->m42 - m_sharedMatrix->m32*m_sharedMatrix->m41)) / det, + (m_sharedMatrix->m11*(m_sharedMatrix->m32*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m42) - m_sharedMatrix->m12*(m_sharedMatrix->m31*m_sharedMatrix->m43 - m_sharedMatrix->m33*m_sharedMatrix->m41) + m_sharedMatrix->m13*(m_sharedMatrix->m31*m_sharedMatrix->m42 - m_sharedMatrix->m32*m_sharedMatrix->m41)) / det, + -(m_sharedMatrix->m11*(m_sharedMatrix->m22*m_sharedMatrix->m43 - m_sharedMatrix->m23*m_sharedMatrix->m42) - m_sharedMatrix->m12*(m_sharedMatrix->m21*m_sharedMatrix->m43 - m_sharedMatrix->m23*m_sharedMatrix->m41) + m_sharedMatrix->m13*(m_sharedMatrix->m21*m_sharedMatrix->m42 - m_sharedMatrix->m22*m_sharedMatrix->m41)) / det, + (m_sharedMatrix->m11*(m_sharedMatrix->m22*m_sharedMatrix->m33 - m_sharedMatrix->m23*m_sharedMatrix->m32) - m_sharedMatrix->m12*(m_sharedMatrix->m21*m_sharedMatrix->m33 - m_sharedMatrix->m23*m_sharedMatrix->m31) + m_sharedMatrix->m13*(m_sharedMatrix->m21*m_sharedMatrix->m32 - m_sharedMatrix->m22*m_sharedMatrix->m31)) / det); } + else + { + NazaraError("Matrix has no inverse"); - return matrix; + return Identity(); + } } template NzVector3 NzMatrix4::GetScale() const { #if NAZARA_MATH_SAFE - if (!m_sharedMatrix) + if (!IsDefined()) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return NzVector3(); } #endif - return NzVector3(std::sqrt(m_sharedMatrix->m11 * m_sharedMatrix->m11 + m_sharedMatrix->m21 * m_sharedMatrix->m21 + m_sharedMatrix->m31 * m_sharedMatrix->m31), - std::sqrt(m_sharedMatrix->m12 * m_sharedMatrix->m12 + m_sharedMatrix->m22 * m_sharedMatrix->m22 + m_sharedMatrix->m32 * m_sharedMatrix->m32), - std::sqrt(m_sharedMatrix->m13 * m_sharedMatrix->m13 + m_sharedMatrix->m23 * m_sharedMatrix->m23 + m_sharedMatrix->m33 * m_sharedMatrix->m33)); + return NzVector3(std::sqrt(m_sharedMatrix->m11*m_sharedMatrix->m11 + m_sharedMatrix->m21*m_sharedMatrix->m21 + m_sharedMatrix->m31*m_sharedMatrix->m31), + std::sqrt(m_sharedMatrix->m12*m_sharedMatrix->m12 + m_sharedMatrix->m22*m_sharedMatrix->m22 + m_sharedMatrix->m32*m_sharedMatrix->m32), + std::sqrt(m_sharedMatrix->m13*m_sharedMatrix->m13 + m_sharedMatrix->m23*m_sharedMatrix->m23 + m_sharedMatrix->m33*m_sharedMatrix->m33)); } template NzVector3 NzMatrix4::GetTranslation() const { #if NAZARA_MATH_SAFE - if (!m_sharedMatrix) + if (!IsDefined()) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return NzVector3(); } #endif @@ -168,51 +173,209 @@ template NzMatrix4 NzMatrix4::GetTransposed() const { #if NAZARA_MATH_SAFE - if (!m_sharedMatrix) + if (!IsDefined()) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return NzMatrix4(); } #endif return NzMatrix4(m_sharedMatrix->m11, m_sharedMatrix->m21, m_sharedMatrix->m31, m_sharedMatrix->m41, - m_sharedMatrix->m12, m_sharedMatrix->m22, m_sharedMatrix->m32, m_sharedMatrix->m42, - m_sharedMatrix->m13, m_sharedMatrix->m23, m_sharedMatrix->m33, m_sharedMatrix->m43, - m_sharedMatrix->m14, m_sharedMatrix->m24, m_sharedMatrix->m34, m_sharedMatrix->m44); + m_sharedMatrix->m12, m_sharedMatrix->m22, m_sharedMatrix->m32, m_sharedMatrix->m42, + m_sharedMatrix->m13, m_sharedMatrix->m23, m_sharedMatrix->m33, m_sharedMatrix->m43, + m_sharedMatrix->m14, m_sharedMatrix->m24, m_sharedMatrix->m34, m_sharedMatrix->m44); } template bool NzMatrix4::HasNegativeScale() const { - return GetDeterminant() < 0.f; + return GetDeterminant() < F(0.0); } template bool NzMatrix4::HasScale() const { #if NAZARA_MATH_SAFE - if (!m_sharedMatrix) + if (!IsDefined()) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return false; } #endif - T t = m_sharedMatrix->m11 * m_sharedMatrix->m11 + m_sharedMatrix->m21 * m_sharedMatrix->m21 + m_sharedMatrix->m31 * m_sharedMatrix->m31; - if (1.0 - t > std::numeric_limits::epsilon()) + T t = m_sharedMatrix->m11*m_sharedMatrix->m11 + m_sharedMatrix->m21*m_sharedMatrix->m21 + m_sharedMatrix->m31*m_sharedMatrix->m31; + if (!NzNumberEquals(t, F(1.0))) return true; - t = m_sharedMatrix->m12 * m_sharedMatrix->m12 + m_sharedMatrix->m22 * m_sharedMatrix->m22 + m_sharedMatrix->m32 * m_sharedMatrix->m32; - if (1.0 - t > std::numeric_limits::epsilon()) + t = m_sharedMatrix->m12*m_sharedMatrix->m12 + m_sharedMatrix->m22*m_sharedMatrix->m22 + m_sharedMatrix->m32*m_sharedMatrix->m32; + if (!NzNumberEquals(t, F(1.0))) return true; - t = m_sharedMatrix->m13 * m_sharedMatrix->m13 + m_sharedMatrix->m23 * m_sharedMatrix->m23 + m_sharedMatrix->m33 * m_sharedMatrix->m33; - if (1.0 - t > std::numeric_limits::epsilon()) + t = m_sharedMatrix->m13*m_sharedMatrix->m13 + m_sharedMatrix->m23*m_sharedMatrix->m23 + m_sharedMatrix->m33*m_sharedMatrix->m33; + if (!NzNumberEquals(t, F(1.0))) return true; return false; } +template +bool NzMatrix4::IsAffine() const +{ + #if NAZARA_MATH_SAFE + if (!IsDefined()) + { + NazaraError("Matrix not defined"); + return false; + } + #endif + + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + return NzNumberEquals(m_sharedMatrix->m14, F(0.0)) && + NzNumberEquals(m_sharedMatrix->m24, F(0.0)) && + NzNumberEquals(m_sharedMatrix->m34, F(0.0)) && + NzNumberEquals(m_sharedMatrix->m44, F(1.0)); + #else + return NzNumberEquals(m_sharedMatrix->m41, F(0.0)) && + NzNumberEquals(m_sharedMatrix->m42, F(0.0)) && + NzNumberEquals(m_sharedMatrix->m43, F(0.0)) && + NzNumberEquals(m_sharedMatrix->m44, F(1.0)); + #endif +} + +template +bool NzMatrix4::IsDefined() const +{ + return m_sharedMatrix != nullptr; +} + +template +void NzMatrix4::MakeIdentity() +{ + Set(F(1.0), F(0.0), F(0.0), F(0.0), + F(0.0), F(1.0), F(0.0), F(0.0), + F(0.0), F(0.0), F(1.0), F(0.0), + F(0.0), F(0.0), F(0.0), F(1.0)); +} + +template +void NzMatrix4::MakeOrtho(T left, T top, T width, T height, T zNear, T zFar) +{ + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + Set(F(2.0)/(width-left), F(0.0), F(0.0), -(width+left)/(width-left), + F(0.0), F(2.0)/(top-height), F(0.0), -(top+height)/(top-height), + F(0.0), F(0.0), F(-2.0)/(zFar-zNear), -(zFar+zNear)/(zFar-zNear), + F(0.0), F(0.0), F(0.0), F(1.0)); + #else + Set(F(2.0)/(width-left), F(0.0), F(0.0), F(0.0), + F(0.0), F(2.0)/(top-height), F(0.0), F(0.0), + F(0.0), F(0.0), F(-2.0)/(zFar-zNear), F(0.0), + -(width+left)/(width-left), -(top+height)/(top-height), -(zFar+zNear)/(zFar-zNear), F(1.0)); + #endif +} + +template +void NzMatrix4::MakeLookAt(const NzVector3& eye, const NzVector3& center, const NzVector3& up) +{ + // http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml + NzVector3 f = center - eye; + f.Normalize(); + + NzVector3 u = up; + u.Normalize(); + + NzVector3 s = f.CrossProduct(u); + u = s.CrossProduct(f); + + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + Set(s.x, s.y, s.z, F(0.0), + u.x, u.y, u.z, F(0.0), + -f.x, -f.y, -f.z, F(0.0), + F(0.0), F(0.0), F(0.0), F(1.0)); + #else + Set(s.x, u.x, -f.x, F(0.0), + s.y, u.y, -f.y, F(0.0), + s.z, u.z, -f.z, F(0.0), + F(0.0), F(0.0), F(0.0), F(1.0)); + #endif + + Concatenate(Translate(-eye)); +} + +template +void NzMatrix4::MakePerspective(T angle, T ratio, T zNear, T zFar) +{ + #if NAZARA_MATH_ANGLE_RADIAN + angle /= F(2.0); + #else + angle = NzDegreeToRadian(angle/2); + #endif + + T f = F(1.0) / std::tan(angle); + + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + Set(f / ratio, F(0.0), F(0.0), F(0.0), + F(0.0), f, F(0.0), F(0.0), + F(0.0), F(0.0), (zNear+zFar) / (zNear-zFar), F(-1.0), + F(0.0), F(0.0), (F(2.0)*zNear*zFar) / (zNear-zFar), F(1.0)); + #else + Set(f / ratio, F(0.0), F(0.0), F(0.0), + F(0.0), f, F(0.0), F(0.0), + F(0.0), F(0.0), (zNear+zFar) / (zNear-zFar), (F(2.0)*zNear*zFar) / (zNear-zFar), + F(0.0), F(0.0), F(-1.0), F(1.0)); + #endif +} + +template +void NzMatrix4::MakeRotation(const NzQuaternion& rotation) +{ + // http://stackoverflow.com/questions/1556260/convert-quaternion-rotation-to-rotation-matrix + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + Set(F(1.0) - F(2.0)*rotation.y*rotation.y - F(2.0)*rotation.z*rotation.z, F(2.0)*rotation.x*rotation.y - F(2.0)*rotation.z*rotation.w, F(2.0)*rotation.x*rotation.z + F(2.0)*rotation.y*rotation.w, F(0.0), + F(2.0)*rotation.x*rotation.y + F(2.0)*rotation.z*rotation.w, F(1.0) - F(2.0)*rotation.x*rotation.x - F(2.0)*rotation.z*rotation.z, F(2.0)*rotation.y*rotation.z - F(2.0)*rotation.x*rotation.w, F(0.0), + F(2.0)*rotation.x*rotation.z - F(2.0)*rotation.y*rotation.w, F(2.0)*rotation.y*rotation.z + F(2.0)*rotation.x*rotation.w, F(1.0) - F(2.0)*rotation.x*rotation.x - F(2.0)*rotation.y*rotation.y, F(0.0), + F(0.0), F(0.0), F(0.0), F(1.0)); + #else + Set(F(1.0) - F(2.0)*rotation.y*rotation.y - F(2.0)*rotation.z*rotation.z, F(2.0)*rotation.x*rotation.y + F(2.0)*rotation.z*rotation.w, F(2.0)*rotation.x*rotation.z - F(2.0)*rotation.y*rotation.w, F(0.0), + F(2.0)*rotation.x*rotation.y - F(2.0)*rotation.z*rotation.w, F(1.0) - F(2.0)*rotation.x*rotation.x - F(2.0)*rotation.z*rotation.z, F(2.0)*rotation.y*rotation.z + F(2.0)*rotation.x*rotation.w, F(0.0), + F(2.0)*rotation.x*rotation.z + F(2.0)*rotation.y*rotation.w, F(2.0)*rotation.y*rotation.z - F(2.0)*rotation.x*rotation.w, F(1.0) - F(2.0)*rotation.x*rotation.x - F(2.0)*rotation.y*rotation.y, F(0.0), + F(0.0), F(0.0), F(0.0), F(1.0)); + #endif +} + +template +void NzMatrix4::MakeScale(const NzVector3& scale) +{ + Set(scale.x, F(0.0), F(0.0), F(0.0), + F(0.0), scale.y, F(0.0), F(0.0), + F(0.0), F(0.0), scale.z, F(0.0), + F(0.0), F(0.0), F(0.0), F(1.0)); +} + +template +void NzMatrix4::MakeTranslation(const NzVector3& translation) +{ + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + Set(F(1.0), F(0.0), F(0.0), F(0.0), + F(0.0), F(1.0), F(0.0), F(0.0), + F(0.0), F(0.0), F(1.0), F(0.0), + translation.x, translation.y, translation.z, F(1.0)); + #else + Set(F(1.0), F(0.0), F(0.0), translation.x, + F(0.0), F(1.0), F(0.0), translation.y, + F(0.0), F(0.0), F(1.0), translation.z, + F(0.0), F(0.0), F(0.0), F(1.0)); + #endif +} + +template +void NzMatrix4::MakeZero() +{ + Set(F(0.0), F(0.0), F(0.0), F(0.0), + F(0.0), F(0.0), F(0.0), F(0.0), + F(0.0), F(0.0), F(0.0), F(0.0), + F(0.0), F(0.0), F(0.0), F(0.0)); +} + template void NzMatrix4::Set(T r11, T r12, T r13, T r14, T r21, T r22, T r23, T r24, @@ -272,143 +435,65 @@ template template void NzMatrix4::Set(const NzMatrix4& matrix) { - Set(static_cast(matrix.m11), static_cast(matrix.m12), static_cast(matrix.m13), static_cast(matrix.m14), - static_cast(matrix.m21), static_cast(matrix.m22), static_cast(matrix.m23), static_cast(matrix.m24), - static_cast(matrix.m31), static_cast(matrix.m32), static_cast(matrix.m33), static_cast(matrix.m34), - static_cast(matrix.m41), static_cast(matrix.m42), static_cast(matrix.m43), static_cast(matrix.m44)); -} - -template -void NzMatrix4::SetIdentity() -{ - Set(1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0); -} - -template -void NzMatrix4::SetOrtho(T left, T top, T width, T height, T zNear, T zFar) -{ - #if NAZARA_MATH_MATRIX_COLUMN_MAJOR - Set(2.0/(width-left), 0.0, 0.0, -(width+left)/(width-left), - 0.0, 2.0/(top-height), 0.0, -(top+height)/(top-height), - 0.0, 0.0, -2.0/(zFar-zNear), -(zFar+zNear)/(zFar-zNear), - 0.0, 0.0, 0.0, 1.0); - #else - Set(2.0/(width-left), 0.0, 0.0, 0.0, - 0.0, 2.0/(top-height), 0.0, 0.0, - 0.0, 0.0, -2.0/(zFar-zNear), 0.0, - -(width+left)/(width-left), -(top+height)/(top-height), -(zFar+zNear)/(zFar-zNear), 1.0); - #endif -} - -template -void NzMatrix4::SetLookAt(const NzVector3& eye, const NzVector3& center, const NzVector3& up) -{ - // http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml - NzVector3 f = center - eye; - f.Normalize(); - - NzVector3 u = up; - u.Normalize(); - - NzVector3 s = f.CrossProduct(u); - u = s.CrossProduct(f); - - #if NAZARA_MATH_MATRIX_COLUMN_MAJOR - Set(s.x, s.y, s.z, 0.0, - u.x, u.y, u.z, 0.0, - -f.x, -f.y, -f.z, 0.0, - 0.0, 0.0, 0.0, 1.0); - #else - Set(s.x, u.x, -f.x, 0.0, - s.y, u.y, -f.y, 0.0, - s.z, u.z, -f.z, 0.0, - 0.0, 0.0, 0.0, 1.0); - #endif - - operator*=(Translate(-eye)); -} - -template -void NzMatrix4::SetPerspective(T angle, T ratio, T zNear, T zFar) -{ - #if NAZARA_MATH_ANGLE_RADIAN - angle /= 2; - #else - angle = NzDegreeToRadian(angle/2); - #endif - - auto f = 1 / std::tan(angle); - - #if NAZARA_MATH_MATRIX_COLUMN_MAJOR - Set(f / ratio, 0.0, 0.0, 0.0, - 0.0, f, 0.0, 0.0, - 0.0, 0.0, (zNear + zFar) / (zNear - zFar), -1.0, - 0.0, 0.0, (2 * zNear * zFar) / (zNear - zFar), 1.0); - #else - Set(f / ratio, 0.0, 0.0, 0.0, - 0.0, f, 0.0, 0.0, - 0.0, 0.0, (zNear + zFar) / (zNear - zFar), (2 * zNear * zFar) / (zNear - zFar), - 0.0, 0.0, -1.0, 1.0); - #endif + Set(F(matrix.m_sharedMatrix->m11), F(matrix.m_sharedMatrix->m12), F(matrix.m_sharedMatrix->m13), F(matrix.m_sharedMatrix->m14), + F(matrix.m_sharedMatrix->m21), F(matrix.m_sharedMatrix->m22), F(matrix.m_sharedMatrix->m23), F(matrix.m_sharedMatrix->m24), + F(matrix.m_sharedMatrix->m31), F(matrix.m_sharedMatrix->m32), F(matrix.m_sharedMatrix->m33), F(matrix.m_sharedMatrix->m34), + F(matrix.m_sharedMatrix->m41), F(matrix.m_sharedMatrix->m42), F(matrix.m_sharedMatrix->m43), F(matrix.m_sharedMatrix->m44)); } template void NzMatrix4::SetRotation(const NzQuaternion& rotation) { // http://www.flipcode.com/documents/matrfaq.html#Q54 - T xx = rotation.x * rotation.x; - T xy = rotation.x * rotation.y; - T xz = rotation.x * rotation.z; - T xw = rotation.x * rotation.w; + EnsureOwnership(); - T yy = rotation.y * rotation.y; - T yz = rotation.y * rotation.z; - T yw = rotation.y * rotation.w; + m_sharedMatrix->m11 = F(1.0) - F(2.0)*rotation.y*rotation.y - F(2.0)*rotation.z*rotation.z; + m_sharedMatrix->m22 = F(1.0) - F(2.0)*rotation.x*rotation.x - F(2.0)*rotation.z*rotation.z; + m_sharedMatrix->m33 = F(1.0) - F(2.0)*rotation.x*rotation.x - F(2.0)*rotation.y*rotation.y; - T zz = rotation.z * rotation.z; - T zw = rotation.z * rotation.w; - - Set(1.0 - 2.0*(yy+zz), 2.0*(xy-zw), 2.0*(xz+yw), 0.0, - 2.0*(xz+zw), 1.0 - 2.0*(xx+zz), 2.0*(yz-xw), 0.0, - 2.0*(xz-yw), 2.0*(yz+xw), 1.0 - 2.0*(xx+yy), 0.0, - 0.0, 0.0, 0.0, 1.0); + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + m_sharedMatrix->m12 = F(2.0)*rotation.x*rotation.y - F(2.0)*rotation.z*rotation.w; + m_sharedMatrix->m13 = F(2.0)*rotation.x*rotation.z + F(2.0)*rotation.y*rotation.w; + m_sharedMatrix->m21 = F(2.0)*rotation.x*rotation.y + F(2.0)*rotation.z*rotation.w; + m_sharedMatrix->m23 = F(2.0)*rotation.y*rotation.z - F(2.0)*rotation.x*rotation.w; + m_sharedMatrix->m31 = F(2.0)*rotation.x*rotation.z - F(2.0)*rotation.y*rotation.w; + m_sharedMatrix->m32 = F(2.0)*rotation.y*rotation.z + F(2.0)*rotation.x*rotation.w; + #else + m_sharedMatrix->m12 = F(2.0)*rotation.x*rotation.y + F(2.0)*rotation.z*rotation.w; + m_sharedMatrix->m13 = F(2.0)*rotation.x*rotation.z - F(2.0)*rotation.y*rotation.w; + m_sharedMatrix->m21 = F(2.0)*rotation.x*rotation.y - F(2.0)*rotation.z*rotation.w; + m_sharedMatrix->m23 = F(2.0)*rotation.y*rotation.z + F(2.0)*rotation.x*rotation.w; + m_sharedMatrix->m31 = F(2.0)*rotation.x*rotation.z + F(2.0)*rotation.y*rotation.w; + m_sharedMatrix->m32 = F(2.0)*rotation.y*rotation.z - F(2.0)*rotation.x*rotation.w; + #endif } template -void NzMatrix4::SetScale(const NzVector3& vector) +void NzMatrix4::SetScale(const NzVector3& scale) { - Set(vector.x, 0.0, 0.0, 0.0, - 0.0, vector.y, 0.0, 0.0, - 0.0, 0.0, vector.z, 0.0, - 0.0, 0.0, 0.0, 1.0); + EnsureOwnership(); + + m_sharedMatrix->m11 = scale.x; + m_sharedMatrix->m22 = scale.y; + m_sharedMatrix->m33 = scale.z; } template void NzMatrix4::SetTranslation(const NzVector3& translation) { - #if NAZARA_MATH_MATRIX_COLUMN_MAJOR - Set(1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - translation.x, translation.y, translation.z, 1.0); - #else - Set(1.0, 0.0, 0.0, translation.x, - 0.0, 1.0, 0.0, translation.y, - 0.0, 0.0, 1.0, translation.z, - 0.0, 0.0, 0.0, 1.0); - #endif -} + EnsureOwnership(); -template -void NzMatrix4::SetZero() -{ - Set(0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0); + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + m_sharedMatrix->m41 = translation.x; + m_sharedMatrix->m42 = translation.y; + m_sharedMatrix->m43 = translation.z; + m_sharedMatrix->m44 = F(1.0); + #else + m_sharedMatrix->m14 = translation.x; + m_sharedMatrix->m24 = translation.y; + m_sharedMatrix->m34 = translation.z; + m_sharedMatrix->m44 = F(1.0); + #endif } template @@ -419,9 +504,9 @@ NzString NzMatrix4::ToString() const NzStringStream ss; return ss << "Matrix4(" << m_sharedMatrix->m11 << ", " << m_sharedMatrix->m12 << ", " << m_sharedMatrix->m13 << ", " << m_sharedMatrix->m14 << ",\n" - << " " << m_sharedMatrix->m21 << ", " << m_sharedMatrix->m22 << ", " << m_sharedMatrix->m23 << ", " << m_sharedMatrix->m24 << ",\n" - << " " << m_sharedMatrix->m31 << ", " << m_sharedMatrix->m32 << ", " << m_sharedMatrix->m33 << ", " << m_sharedMatrix->m34 << ",\n" - << " " << m_sharedMatrix->m41 << ", " << m_sharedMatrix->m42 << ", " << m_sharedMatrix->m43 << ", " << m_sharedMatrix->m44 << ')'; + << " " << m_sharedMatrix->m21 << ", " << m_sharedMatrix->m22 << ", " << m_sharedMatrix->m23 << ", " << m_sharedMatrix->m24 << ",\n" + << " " << m_sharedMatrix->m31 << ", " << m_sharedMatrix->m32 << ", " << m_sharedMatrix->m33 << ", " << m_sharedMatrix->m34 << ",\n" + << " " << m_sharedMatrix->m41 << ", " << m_sharedMatrix->m42 << ", " << m_sharedMatrix->m43 << ", " << m_sharedMatrix->m44 << ')'; } template @@ -430,13 +515,13 @@ NzVector2 NzMatrix4::Transform(const NzVector2& vector, T z, T w) const #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return vector; } #endif - return NzVector2(m_sharedMatrix->m11 * vector.x + m_sharedMatrix->m12 * vector.y + m_sharedMatrix->m13 * z + m_sharedMatrix->m14 * w, - m_sharedMatrix->m21 * vector.x + m_sharedMatrix->m22 * vector.y + m_sharedMatrix->m23 * z + m_sharedMatrix->m24 * w); + return NzVector2(m_sharedMatrix->m11*vector.x + m_sharedMatrix->m12*vector.y + m_sharedMatrix->m13*z + m_sharedMatrix->m14*w, + m_sharedMatrix->m21*vector.x + m_sharedMatrix->m22*vector.y + m_sharedMatrix->m23*z + m_sharedMatrix->m24*w); } template @@ -445,14 +530,14 @@ NzVector3 NzMatrix4::Transform(const NzVector3& vector, T w) const #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return vector; } #endif - return NzVector3(m_sharedMatrix->m11 * vector.x + m_sharedMatrix->m12 * vector.y + m_sharedMatrix->m13 * vector.z + m_sharedMatrix->m14 * w, - m_sharedMatrix->m21 * vector.x + m_sharedMatrix->m22 * vector.y + m_sharedMatrix->m23 * vector.z + m_sharedMatrix->m24 * w, - m_sharedMatrix->m31 * vector.x + m_sharedMatrix->m32 * vector.y + m_sharedMatrix->m33 * vector.z + m_sharedMatrix->m34 * w); + return NzVector3(m_sharedMatrix->m11*vector.x + m_sharedMatrix->m12*vector.y + m_sharedMatrix->m13*vector.z + m_sharedMatrix->m14*w, + m_sharedMatrix->m21*vector.x + m_sharedMatrix->m22*vector.y + m_sharedMatrix->m23*vector.z + m_sharedMatrix->m24*w, + m_sharedMatrix->m31*vector.x + m_sharedMatrix->m32*vector.y + m_sharedMatrix->m33*vector.z + m_sharedMatrix->m34*w); } template @@ -461,15 +546,15 @@ NzVector4 NzMatrix4::Transform(const NzVector4& vector) const #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return vector; } #endif - return NzVector4(m_sharedMatrix->m11 * vector.x + m_sharedMatrix->m12 * vector.y + m_sharedMatrix->m13 * vector.z + m_sharedMatrix->m14 * vector.w, - m_sharedMatrix->m21 * vector.x + m_sharedMatrix->m22 * vector.y + m_sharedMatrix->m23 * vector.z + m_sharedMatrix->m24 * vector.w, - m_sharedMatrix->m31 * vector.x + m_sharedMatrix->m32 * vector.y + m_sharedMatrix->m33 * vector.z + m_sharedMatrix->m34 * vector.w, - m_sharedMatrix->m41 * vector.x + m_sharedMatrix->m42 * vector.y + m_sharedMatrix->m43 * vector.z + m_sharedMatrix->m44 * vector.w); + return NzVector4(m_sharedMatrix->m11*vector.x + m_sharedMatrix->m12*vector.y + m_sharedMatrix->m13*vector.z + m_sharedMatrix->m14*vector.w, + m_sharedMatrix->m21*vector.x + m_sharedMatrix->m22*vector.y + m_sharedMatrix->m23*vector.z + m_sharedMatrix->m24*vector.w, + m_sharedMatrix->m31*vector.x + m_sharedMatrix->m32*vector.y + m_sharedMatrix->m33*vector.z + m_sharedMatrix->m34*vector.w, + m_sharedMatrix->m41*vector.x + m_sharedMatrix->m42*vector.y + m_sharedMatrix->m43*vector.z + m_sharedMatrix->m44*vector.w); } template @@ -478,7 +563,7 @@ NzMatrix4& NzMatrix4::Transpose() #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return *this; } #endif @@ -493,13 +578,19 @@ NzMatrix4& NzMatrix4::Transpose() return *this; } +template +NzMatrix4::operator NzString() const +{ + return ToString(); +} + template NzMatrix4::operator T*() { #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return nullptr; } #endif @@ -515,7 +606,7 @@ NzMatrix4::operator const T*() const #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return nullptr; } #endif @@ -538,7 +629,7 @@ T& NzMatrix4::operator()(unsigned int x, unsigned int y) EnsureOwnership(); - return (&m_sharedMatrix->m11)[x*4+y]; + return (&m_sharedMatrix->m11)[y*4+x]; } template @@ -547,8 +638,8 @@ const T& NzMatrix4::operator()(unsigned int x, unsigned int y) const #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); - throw std::runtime_error("Tried to access element of undefined matrix"); + NazaraError("Matrix not defined"); + throw std::runtime_error("Tried to access element of Matrix not defined"); } if (x > 3 || y > 3) @@ -560,7 +651,7 @@ const T& NzMatrix4::operator()(unsigned int x, unsigned int y) const } #endif - return (&m_sharedMatrix->m11)[x*4+y]; + return (&m_sharedMatrix->m11)[y*4+x]; } template @@ -572,7 +663,7 @@ NzMatrix4& NzMatrix4::operator=(const NzMatrix4& matrix) } template -NzMatrix4& NzMatrix4::operator=(NzMatrix4&& matrix) +NzMatrix4& NzMatrix4::operator=(NzMatrix4&& matrix) noexcept { Set(matrix); @@ -582,30 +673,7 @@ NzMatrix4& NzMatrix4::operator=(NzMatrix4&& matrix) template NzMatrix4 NzMatrix4::operator*(const NzMatrix4& matrix) const { - #if NAZARA_MATH_SAFE - if (!m_sharedMatrix) - { - NazaraError("Undefined matrix"); - return matrix; - } - #endif - - return NzMatrix4(m_sharedMatrix->m11 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m14, - m_sharedMatrix->m12 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m14, - m_sharedMatrix->m13 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m14, - m_sharedMatrix->m14 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m14, - m_sharedMatrix->m11 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m24, - m_sharedMatrix->m12 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m24, - m_sharedMatrix->m13 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m24, - m_sharedMatrix->m14 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m24, - m_sharedMatrix->m11 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m34, - m_sharedMatrix->m12 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m34, - m_sharedMatrix->m13 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m34, - m_sharedMatrix->m14 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m34, - m_sharedMatrix->m11 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m44, - m_sharedMatrix->m12 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m44, - m_sharedMatrix->m13 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m44, - m_sharedMatrix->m14 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m44); + return Concatenate(matrix); } template @@ -632,15 +700,15 @@ NzMatrix4 NzMatrix4::operator*(T scalar) const #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return *this; } #endif return NzMatrix4(m_sharedMatrix->m11 * scalar, m_sharedMatrix->m12 * scalar, m_sharedMatrix->m13 * scalar, m_sharedMatrix->m14 * scalar, - m_sharedMatrix->m21 * scalar, m_sharedMatrix->m22 * scalar, m_sharedMatrix->m23 * scalar, m_sharedMatrix->m24 * scalar, - m_sharedMatrix->m31 * scalar, m_sharedMatrix->m32 * scalar, m_sharedMatrix->m33 * scalar, m_sharedMatrix->m34 * scalar, - m_sharedMatrix->m41 * scalar, m_sharedMatrix->m42 * scalar, m_sharedMatrix->m43 * scalar, m_sharedMatrix->m44 * scalar); + m_sharedMatrix->m21 * scalar, m_sharedMatrix->m22 * scalar, m_sharedMatrix->m23 * scalar, m_sharedMatrix->m24 * scalar, + m_sharedMatrix->m31 * scalar, m_sharedMatrix->m32 * scalar, m_sharedMatrix->m33 * scalar, m_sharedMatrix->m34 * scalar, + m_sharedMatrix->m41 * scalar, m_sharedMatrix->m42 * scalar, m_sharedMatrix->m43 * scalar, m_sharedMatrix->m44 * scalar); } template @@ -649,34 +717,12 @@ NzMatrix4& NzMatrix4::operator*=(const NzMatrix4& matrix) #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return *this; } #endif - // On calcule dans des variables temporaires - T r11 = m_sharedMatrix->m11 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m14; - T r12 = m_sharedMatrix->m12 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m14; - T r13 = m_sharedMatrix->m13 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m14; - T r14 = m_sharedMatrix->m14 * matrix.m_sharedMatrix->m11 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m12 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m13 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m14; - T r21 = m_sharedMatrix->m11 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m24; - T r22 = m_sharedMatrix->m12 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m24; - T r23 = m_sharedMatrix->m13 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m24; - T r24 = m_sharedMatrix->m14 * matrix.m_sharedMatrix->m21 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m22 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m23 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m24; - T r31 = m_sharedMatrix->m11 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m34; - T r32 = m_sharedMatrix->m12 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m34; - T r33 = m_sharedMatrix->m13 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m34; - T r34 = m_sharedMatrix->m14 * matrix.m_sharedMatrix->m31 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m32 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m33 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m34; - T r41 = m_sharedMatrix->m11 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m21 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m31 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m41 * matrix.m_sharedMatrix->m44; - T r42 = m_sharedMatrix->m12 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m22 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m32 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m42 * matrix.m_sharedMatrix->m44; - T r43 = m_sharedMatrix->m13 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m23 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m33 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m43 * matrix.m_sharedMatrix->m44; - T r44 = m_sharedMatrix->m14 * matrix.m_sharedMatrix->m41 + m_sharedMatrix->m24 * matrix.m_sharedMatrix->m42 + m_sharedMatrix->m34 * matrix.m_sharedMatrix->m43 + m_sharedMatrix->m44 * matrix.m_sharedMatrix->m44; - - // Et puis on affecte - Set(r11, r12, r13, r14, - r21, r22, r23, r24, - r31, r32, r33, r34, - r41, r42, r43, r44); + Set(Concatenate(*this, matrix)); return *this; } @@ -687,7 +733,7 @@ NzMatrix4& NzMatrix4::operator*=(T scalar) #if NAZARA_MATH_SAFE if (!m_sharedMatrix) { - NazaraError("Undefined matrix"); + NazaraError("Matrix not defined"); return *this; } #endif @@ -712,11 +758,137 @@ NzMatrix4& NzMatrix4::operator*=(T scalar) return *this; } +template +NzMatrix4 NzMatrix4::Concatenate(const NzMatrix4& m1, const NzMatrix4& m2) +{ + #if NAZARA_MATH_SAFE + if (!m1.IsDefined()) + { + NazaraError("First matrix not defined"); + return NzMatrix4(); + } + + if (!m2.IsDefined()) + { + NazaraError("Second matrix not defined"); + return NzMatrix4(); + } + #endif + + #if NAZARA_MATH_MATRIX4_CHECK_AFFINE + if (m1.IsAffine() && m2.IsAffine()) + return ConcatenateAffine(m1, m2); + #endif + + return NzMatrix4(m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m31 + m1.m_sharedMatrix->m14*m2.m_sharedMatrix->m41, + m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m32 + m1.m_sharedMatrix->m14*m2.m_sharedMatrix->m42, + m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m33 + m1.m_sharedMatrix->m14*m2.m_sharedMatrix->m43, + m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m14 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m24 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m34 + m1.m_sharedMatrix->m14*m2.m_sharedMatrix->m44, + + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m31 + m1.m_sharedMatrix->m24*m2.m_sharedMatrix->m41, + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m32 + m1.m_sharedMatrix->m24*m2.m_sharedMatrix->m42, + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m33 + m1.m_sharedMatrix->m24*m2.m_sharedMatrix->m43, + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m14 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m24 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m34 + m1.m_sharedMatrix->m24*m2.m_sharedMatrix->m44, + + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m31 + m1.m_sharedMatrix->m34*m2.m_sharedMatrix->m41, + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m32 + m1.m_sharedMatrix->m34*m2.m_sharedMatrix->m42, + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m33 + m1.m_sharedMatrix->m34*m2.m_sharedMatrix->m43, + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m14 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m24 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m34 + m1.m_sharedMatrix->m34*m2.m_sharedMatrix->m44, + + m1.m_sharedMatrix->m41*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m42*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m43*m2.m_sharedMatrix->m31 + m1.m_sharedMatrix->m44*m2.m_sharedMatrix->m41, + m1.m_sharedMatrix->m41*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m42*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m43*m2.m_sharedMatrix->m32 + m1.m_sharedMatrix->m44*m2.m_sharedMatrix->m42, + m1.m_sharedMatrix->m41*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m42*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m43*m2.m_sharedMatrix->m33 + m1.m_sharedMatrix->m44*m2.m_sharedMatrix->m43, + m1.m_sharedMatrix->m41*m2.m_sharedMatrix->m14 + m1.m_sharedMatrix->m42*m2.m_sharedMatrix->m24 + m1.m_sharedMatrix->m43*m2.m_sharedMatrix->m34 + m1.m_sharedMatrix->m44*m2.m_sharedMatrix->m44); +} + +template +NzMatrix4 NzMatrix4::ConcatenateAffine(const NzMatrix4& m1, const NzMatrix4& m2) +{ + #if NAZARA_MATH_SAFE + if (!m1.IsDefined()) + { + NazaraError("First matrix not defined"); + return NzMatrix4(); + } + + if (!m2.IsDefined()) + { + NazaraError("Second matrix not defined"); + return NzMatrix4(); + } + #endif + + #ifdef NAZARA_DEBUG + if (!m1.IsAffine()) + { + NazaraError("First matrix not affine"); + return NzMatrix4(); + } + + if (!m2.IsAffine()) + { + NazaraError("Second matrix not affine"); + return NzMatrix4(); + } + #endif + + #if NAZARA_MATH_MATRIX_COLUMN_MAJOR + return NzMatrix4(m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m31, + m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m32, + m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m33, + F(0.0), + + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m31, + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m32, + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m33, + F(0.0), + + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m31, + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m32, + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m33, + F(0.0), + + m1.m_sharedMatrix->m41*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m42*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m43*m2.m_sharedMatrix->m31 + m2.m_sharedMatrix->m41, + m1.m_sharedMatrix->m41*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m42*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m43*m2.m_sharedMatrix->m32 + m2.m_sharedMatrix->m42, + m1.m_sharedMatrix->m41*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m42*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m43*m2.m_sharedMatrix->m33 + m2.m_sharedMatrix->m43, + F(1.0)); + #else + return NzMatrix4(m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m31, + m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m32, + m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m33, + m1.m_sharedMatrix->m11*m2.m_sharedMatrix->m14 + m1.m_sharedMatrix->m12*m2.m_sharedMatrix->m24 + m1.m_sharedMatrix->m13*m2.m_sharedMatrix->m34 + m1.m_sharedMatrix->m14, + + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m31, + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m32, + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m33, + m1.m_sharedMatrix->m21*m2.m_sharedMatrix->m14 + m1.m_sharedMatrix->m22*m2.m_sharedMatrix->m24 + m1.m_sharedMatrix->m23*m2.m_sharedMatrix->m34 + m1.m_sharedMatrix->m24, + + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m11 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m21 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m31, + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m12 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m22 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m32, + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m13 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m23 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m33, + m1.m_sharedMatrix->m31*m2.m_sharedMatrix->m14 + m1.m_sharedMatrix->m32*m2.m_sharedMatrix->m24 + m1.m_sharedMatrix->m33*m2.m_sharedMatrix->m34 + m1.m_sharedMatrix->m34, + + F(0.0), + F(0.0), + F(0.0), + F(1.0)); + #endif +} + +template +NzMatrix4 NzMatrix4::Identity() +{ + NzMatrix4 matrix; + matrix.MakeIdentity(); + + return matrix; +} + template NzMatrix4 NzMatrix4::LookAt(const NzVector3& eye, const NzVector3& center, const NzVector3& up) { NzMatrix4 matrix; - matrix.SetLookAt(eye, center, up); + matrix.MakeLookAt(eye, center, up); return matrix; } @@ -725,7 +897,7 @@ template NzMatrix4 NzMatrix4::Ortho(T left, T top, T width, T height, T zNear, T zFar) { NzMatrix4 matrix; - matrix.SetOrtho(left, top, width, height, zNear, zFar); + matrix.MakeOrtho(left, top, width, height, zNear, zFar); return matrix; } @@ -734,7 +906,7 @@ template NzMatrix4 NzMatrix4::Perspective(T angle, T ratio, T zNear, T zFar) { NzMatrix4 matrix; - matrix.SetPerspective(angle, ratio, zNear, zFar); + matrix.MakePerspective(angle, ratio, zNear, zFar); return matrix; } @@ -743,7 +915,7 @@ template NzMatrix4 NzMatrix4::Rotate(const NzQuaternion& rotation) { NzMatrix4 matrix; - matrix.SetRotation(rotation); + matrix.MakeRotation(rotation); return matrix; } @@ -752,7 +924,7 @@ template NzMatrix4 NzMatrix4::Scale(const NzVector3& scale) { NzMatrix4 matrix; - matrix.SetScale(scale); + matrix.MakeScale(scale); return matrix; } @@ -761,17 +933,32 @@ template NzMatrix4 NzMatrix4::Translate(const NzVector3& translation) { NzMatrix4 mat; - mat.SetTranslation(translation); + mat.MakeTranslation(translation); return mat; } +template +NzMatrix4 NzMatrix4::Zero() +{ + NzMatrix4 matrix; + matrix.MakeZero(); + + return matrix; +} + template std::ostream& operator<<(std::ostream& out, const NzMatrix4& matrix) { return out << matrix.ToString(); } +template +NzMatrix4 operator*(T scale, const NzMatrix4& matrix) +{ + return matrix * scale; +} + template void NzMatrix4::EnsureOwnership() { @@ -806,6 +993,6 @@ void NzMatrix4::ReleaseMatrix() m_sharedMatrix = nullptr; } -#undef NAZARA_MATRIX4_INL +#undef F #include diff --git a/include/Nazara/Math/Quaternion.hpp b/include/Nazara/Math/Quaternion.hpp index a5e892f2a..b09518b52 100644 --- a/include/Nazara/Math/Quaternion.hpp +++ b/include/Nazara/Math/Quaternion.hpp @@ -31,9 +31,12 @@ template class NzQuaternion NzQuaternion GetConjugate() const; NzQuaternion GetNormalized() const; + void MakeIdentity(); + void MakeZero(); + T Magnitude() const; + T Normalize(); - T SquaredMagnitude() const; void Set(T W, T X, T Y, T Z); void Set(T quat[4]); @@ -42,13 +45,17 @@ template class NzQuaternion //void Set(const NzMatrix3& mat); void Set(const NzQuaternion& quat); template void Set(const NzQuaternion& quat); - void SetIdentity(); - void SetZero(); + + T SquaredMagnitude() const; NzEulerAngles ToEulerAngles() const; //NzMatrix3 ToRotationMatrix() const; NzString ToString() const; + operator NzString() const; + + NzQuaternion& operator=(const NzQuaternion& quat); + NzQuaternion operator+(const NzQuaternion& quat) const; NzQuaternion operator*(const NzQuaternion& quat) const; NzVector3 operator*(const NzVector3& vec) const; @@ -67,7 +74,9 @@ template class NzQuaternion bool operator>(const NzQuaternion& quat) const; bool operator>=(const NzQuaternion& quat) const; + static NzQuaternion Identity(); static NzQuaternion Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp); + static NzQuaternion Zero(); T w, x, y, z; }; diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index b4a459d3d..b03c588f2 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -8,8 +8,11 @@ #include #include #include +#include #include +#define F(a) static_cast(a) + template NzQuaternion::NzQuaternion() { @@ -53,9 +56,9 @@ NzQuaternion::NzQuaternion(const NzQuaternion& quat) } template -T NzQuaternion::DotProduct(const NzQuaternion& vec) const +T NzQuaternion::DotProduct(const NzQuaternion& quat) const { - return w*vec.w + x*vec.x + y*vec.y + z.vec.z; + return w*quat.w + x*quat.x + y*quat.y + z*quat.z; } template @@ -73,6 +76,18 @@ NzQuaternion NzQuaternion::GetNormalized() const return quat; } +template +void NzQuaternion::MakeIdentity() +{ + Set(1.0, 0.0, 0.0, 0.0); +} + +template +void NzQuaternion::MakeZero() +{ + Set(0.0, 0.0, 0.0, 0.0); +} + template T NzQuaternion::Magnitude() const { @@ -82,27 +97,21 @@ T NzQuaternion::Magnitude() const template T NzQuaternion::Normalize() { - T squaredLength = SquaredMagnitude(); + T squaredMagnitude = SquaredMagnitude(); - if (std::fabs(squaredLength) > 0.00001 && std::fabs(squaredLength - 1.0) > 0.00001) + if (squaredMagnitude-F(1.0) > std::numeric_limits::epsilon()) { - T length = std::sqrt(squaredLength); + T magnitude = std::sqrt(squaredMagnitude); - w /= length; - x /= length; - y /= length; - z /= length; + w /= magnitude; + x /= magnitude; + y /= magnitude; + z /= magnitude; - return length; + return magnitude; } else - return 1.0; // Le quaternion est déjà normalisé -} - -template -T NzQuaternion::SquaredMagnitude() const -{ - return w * w + x * x + y * y + z * z; + return F(1.0); // Le quaternion est déjà normalisé } template @@ -166,81 +175,29 @@ void NzQuaternion::Set(const NzQuaternion& quat) } template -void NzQuaternion::SetIdentity() +T NzQuaternion::SquaredMagnitude() const { - Set(1.0, 0.0, 0.0, 0.0); -} - -template -void NzQuaternion::SetZero() -{ - Set(0.0, 0.0, 0.0, 0.0); -} - -template -NzQuaternion NzQuaternion::Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp) -{ - if (interp <= 0.0) - return quatA; - - if (interp >= 1.0) - return quatB; - - NzQuaternion q; - - T cosOmega = quatA.DotProduct(quatB); - if (cosOmega < 0.0) - { - // On inverse tout - q.Set(-quatB.w, -quatB.x, -quatB.y, -quatB.z); - cosOmega = -cosOmega; - } - else - q.Set(quatB); - - T k0, k1; - if (cosOmega > 0.9999) - { - // Interpolation linéaire pour éviter une division par zéro - k0 = 1.0 - interp; - k1 = interp; - } - else - { - T sinOmega = std::sqrt(1.0f - (cosOmega * cosOmega)); - T omega = std::atan2(sinOmega, cosOmega); - - // Pour éviter deux divisions - sinOmega = 1/sinOmega; - - k0 = std::sin((1.0 - interp) * omega) * sinOmega; - k1 = std::sin(interp * omega) * sinOmega; - } - - NzQuaternion result(k0 * quatA.w, k0 * quatA.x, k0 * quatA.y, k0 * quatA.z); - return result += q; + return w*w + x*x + y*y + z*z; } template NzEulerAngles NzQuaternion::ToEulerAngles() const { - Normalize(); - T test = x*y + z*w; - if (test > 0.499) + if (test > F(0.499)) // singularity at north pole - return NzEulerAngles(NzDegrees(90.0), NzRadians(2.0 * std::atan2(x, w)), 0.0); + return NzEulerAngles(NzDegrees(F(90.0)), NzRadians(F(2.0) * std::atan2(x, w)), F(0.0)); - if (test < -0.499) - return NzEulerAngles(NzDegrees(-90.0), NzRadians(-2.0 * std::atan2(x, w)), 0.0); + if (test < F(-0.499)) + return NzEulerAngles(NzDegrees(F(-90.0)), NzRadians(F(-2.0) * std::atan2(x, w)), F(0.0)); T xx = x*x; T yy = y*y; T zz = z*z; - return NzEulerAngles(NzRadians(std::atan2(2.0*x*w - 2.0*y*z, 1.0 - 2.0*xx - 2.0*zz)), - NzRadians(std::atan2(2.0*y*w - 2.0*x*z, 1.f - 2.0*yy - 2.0*zz)), - NzRadians(std::asin(2.0*test))); + return NzEulerAngles(NzRadians(std::atan2(F(2.0)*x*w - F(2.0)*y*z, F(1.0) - F(2.0)*xx - F(2.0)*zz)), + NzRadians(std::atan2(F(2.0)*y*w - F(2.0)*x*z, F(1.0) - F(2.0)*yy - F(2.0)*zz)), + NzRadians(std::asin(F(2.0)*test))); } template @@ -251,6 +208,20 @@ NzString NzQuaternion::ToString() const return ss << "Quaternion(" << w << " | " << x << ", " << y << ", " << z << ')'; } +template +NzQuaternion::operator NzString() const +{ + return ToString(); +} + +template +NzQuaternion& NzQuaternion::operator=(const NzQuaternion& quat) +{ + Set(quat); + + return *this; +} + template NzQuaternion NzQuaternion::operator+(const NzQuaternion& quat) const { @@ -263,10 +234,10 @@ NzQuaternion NzQuaternion::operator+(const NzQuaternion& quat) const template NzQuaternion NzQuaternion::operator*(const NzQuaternion& quat) const { - return NzQuaternion(w * quat.w - x * quat.x - y * quat.y - z * quat.z, - w * quat.x + x * quat.w + y * quat.z - z * quat.y, - w * quat.y + y * quat.w + z * quat.x - x * quat.z, - w * quat.z + z * quat.w + x * quat.y - y * quat.x); + return NzQuaternion(w*quat.w - x*quat.x - y*quat.y - z*quat.z, + w*quat.x + x*quat.w + y*quat.z - z*quat.y, + w*quat.y + y*quat.w + z*quat.x - x*quat.z, + w*quat.z + z*quat.w + x*quat.y - y*quat.x); } template @@ -276,7 +247,7 @@ NzVector3 NzQuaternion::operator*(const NzVector3& vec) const normal.Normalize(); NzQuaternion qvec(0.0, normal.x, normal.y, normal.z); - NzQuaternion result = operator*(qvec * GetConjugate()); + NzQuaternion result(operator*(qvec * GetConjugate())); return NzVector3(result.x, result.y, result.z); @@ -360,10 +331,74 @@ bool NzQuaternion::operator>=(const NzQuaternion& quat) const return !operator<(quat); } +template +NzQuaternion NzQuaternion::Identity() +{ + NzQuaternion quaternion; + quaternion.MakeIdentity(); + + return quaternion; +} + +template +NzQuaternion NzQuaternion::Slerp(const NzQuaternion& quatA, const NzQuaternion& quatB, T interp) +{ + if (interp <= F(0.0)) + return quatA; + + if (interp >= F(1.0)) + return quatB; + + NzQuaternion q; + + T cosOmega = quatA.DotProduct(quatB); + if (cosOmega < F(0.0)) + { + // On inverse tout + q.Set(-quatB.w, -quatB.x, -quatB.y, -quatB.z); + cosOmega = -cosOmega; + } + else + q.Set(quatB); + + T k0, k1; + if (cosOmega > F(0.9999)) + { + // Interpolation linéaire pour éviter une division par zéro + k0 = F(1.0) - interp; + k1 = interp; + } + else + { + T sinOmega = std::sqrt(F(1.0) - cosOmega*cosOmega); + T omega = std::atan2(sinOmega, cosOmega); + + // Pour éviter deux divisions + sinOmega = F(1.0)/sinOmega; + + k0 = std::sin((F(1.0) - interp) * omega) * sinOmega; + k1 = std::sin(interp*omega) * sinOmega; + } + + NzQuaternion result(k0 * quatA.w, k0 * quatA.x, k0 * quatA.y, k0 * quatA.z); + return result += q*k1; +} + +template +NzQuaternion NzQuaternion::Zero() +{ + NzQuaternion quaternion; + quaternion.MakeZero(); + + return quaternion; +} + template std::ostream& operator<<(std::ostream& out, const NzQuaternion& quat) { return out << quat.ToString(); } +#undef F + #include diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index 4669c801d..5c06e9140 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -16,7 +16,8 @@ class NzRect public: NzRect(); NzRect(T X, T Y, T Width, T Height); - NzRect(T rect[4]); + NzRect(const T rect[4]); + NzRect(const NzVector2& vec1, const NzVector2& vec2); template explicit NzRect(const NzRect& rect); NzRect(const NzRect& rect) = default; ~NzRect() = default; @@ -30,11 +31,15 @@ class NzRect NzVector2 GetCenter() const; - bool Intersect(const NzRect& rect) const; - bool Intersect(const NzRect& rect, NzRect& intersection) const; + bool Intersect(const NzRect& rect, NzRect* intersection = nullptr) const; bool IsValid() const; + void Set(T X, T Y, T Width, T Height); + void Set(const T rect[4]); + void Set(const NzVector2& vec1, const NzVector2& vec2); + template void Set(const NzRect& rect); + NzString ToString() const; operator NzString() const; diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 97dab6292..97d1a6a69 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -6,37 +6,36 @@ #include #include +#define F(a) static_cast(a) + template NzRect::NzRect() { } template -NzRect::NzRect(T X, T Y, T Width, T Height) : -x(X), -y(Y), -width(Width), -height(Height) +NzRect::NzRect(T X, T Y, T Width, T Height) { + Set(X, Y, Width, Height); } template -NzRect::NzRect(T vec[4]) : -x(vec[0]), -y(vec[1]), -width(vec[2]), -height(vec[3]) +NzRect::NzRect(const T vec[4]) { + Set(vec); +} + +template +NzRect::NzRect(const NzVector2& vec1, const NzVector2& vec2) +{ + Set(vec1, vec2); } template template -NzRect::NzRect(const NzRect& rect) : -x(static_cast(rect.x)), -y(static_cast(rect.y)), -width(static_cast(rect.width)), -height(static_cast(rect.height)) +NzRect::NzRect(const NzRect& rect) { + Set(rect); } template @@ -80,18 +79,11 @@ void NzRect::ExtendTo(const NzRect& rect) template NzVector2 NzRect::GetCenter() const { - return NzVector2((x+width)/2, (y+height)/2); + return NzVector2((x+width)/F(2.0), (y+height)/F(2.0)); } template -bool NzRect::Intersect(const NzRect& rect) const -{ - NzRect intersection; // Optimisé par le compilateur - return Intersect(rect, intersection); -} - -template -bool NzRect::Intersect(const NzRect& rect, NzRect& intersection) const +bool NzRect::Intersect(const NzRect& rect, NzRect* intersection) const { T left = std::max(x, rect.x); T right = std::min(x+width, rect.x+rect.width); @@ -100,10 +92,13 @@ bool NzRect::Intersect(const NzRect& rect, NzRect& intersection) const if (left < right && top < bottom) { - intersection.x = left; - intersection.y = top; - intersection.width = right-left; - intersection.height = bottom-top; + if (intersection) + { + intersection->x = left; + intersection->y = top; + intersection->width = right-left; + intersection->height = bottom-top; + } return true; } @@ -114,7 +109,44 @@ bool NzRect::Intersect(const NzRect& rect, NzRect& intersection) const template bool NzRect::IsValid() const { - return width > 0 && height > 0; + return width > F(0.0) && height > F(0.0); +} + +template +void NzRect::Set(T X, T Y, T Width, T Height) +{ + x = X; + y = Y; + width = Width; + height = Height; +} + +template +void NzRect::Set(const T rect[4]) +{ + x = rect[0]; + y = rect[1]; + width = rect[2]; + height = rect[3]; +} + +template +void NzRect::Set(const NzVector2& vec1, const NzVector2& vec2) +{ + x = std::min(vec1.x, vec2.x); + y = std::min(vec1.y, vec2.y); + width = (vec2.x > vec1.x) ? vec2.x-vec1.x : vec1.x-vec2.x; + height = (vec2.y > vec1.y) ? vec2.y-vec1.y : vec1.y-vec2.y; +} + +template +template +void NzRect::Set(const NzRect& rect) +{ + x = F(rect.x); + y = F(rect.y); + width = F(rect.width); + height = F(rect.height); } template @@ -134,6 +166,7 @@ NzRect::operator NzString() const template T& NzRect::operator[](unsigned int i) { + #if NAZARA_MATH_SAFE if (i >= 4) { NzStringStream ss; @@ -141,6 +174,7 @@ T& NzRect::operator[](unsigned int i) throw std::domain_error(ss.ToString()); } + #endif return *(&x+i); } @@ -148,6 +182,7 @@ T& NzRect::operator[](unsigned int i) template T NzRect::operator[](unsigned int i) const { + #if NAZARA_MATH_SAFE if (i >= 4) { NzStringStream ss; @@ -155,6 +190,7 @@ T NzRect::operator[](unsigned int i) const throw std::domain_error(ss.ToString()); } + #endif return *(&x+i); } @@ -165,4 +201,6 @@ std::ostream& operator<<(std::ostream& out, const NzRect& rect) return out << rect.ToString(); } +#undef F + #include diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index 6473d7206..b7fc3eff1 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -21,20 +21,37 @@ template class NzVector2 ~NzVector2() = default; T AbsDotProduct(const NzVector2& vec) const; + T Distance(const NzVector2& vec) const; float Distancef(const NzVector2& vec) const; + T DotProduct(const NzVector2& vec) const; + NzVector2 GetNormal() const; + void MakeCeil(const NzVector2& vec); void MakeFloor(const NzVector2& vec); + void MakeUnitX(); + void MakeUnitY(); + void MakeZero(); + T Length() const; float Lengthf() const; + void Normalize(); + + void Set(T X, T Y); + void Set(T scale); + void Set(T vec[2]); + template void Set(const NzVector2& vec); + T SquaredDistance(const NzVector2& vec) const; T SquaredLength() const; NzString ToString() const; + operator NzString() const; + operator T*(); operator const T*() const; @@ -65,8 +82,11 @@ template class NzVector2 bool operator>(const NzVector2& vec) const; bool operator>=(const NzVector2& vec) const; - T x; - T y; + static NzVector2 UnitX(); + static NzVector2 UnitY(); + static NzVector2 Zero(); + + T x, y; }; template std::ostream& operator<<(std::ostream& out, const NzVector2& vec); diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index 3889aaa78..3ee71da3f 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -6,41 +6,40 @@ #include #include #include +#include #include #include +#define F(a) static_cast(a) + template NzVector2::NzVector2() { } template -NzVector2::NzVector2(T X, T Y) : -x(X), -y(Y) +NzVector2::NzVector2(T X, T Y) { + Set(X, Y); } template -NzVector2::NzVector2(T scale) : -x(scale), -y(scale) +NzVector2::NzVector2(T scale) { + Set(scale); } template -NzVector2::NzVector2(T vec[2]) : -x(vec[0]), -y(vec[1]) +NzVector2::NzVector2(T vec[2]) { + Set(vec); } template template -NzVector2::NzVector2(const NzVector2& vec) : -x(static_cast(vec.x)), -y(static_cast(vec.y)) +NzVector2::NzVector2(const NzVector2& vec) { + Set(vec); } template @@ -76,7 +75,7 @@ float NzVector2::Distancef(const NzVector2& vec) const template T NzVector2::DotProduct(const NzVector2& vec) const { - return x * vec.x + y * vec.y; + return x*vec.x + y*vec.y; } template @@ -88,6 +87,18 @@ NzVector2 NzVector2::GetNormal() const return vec; } +template +T NzVector2::Length() const +{ + return std::sqrt(SquaredLength()); +} + +template +float NzVector2::Lengthf() const +{ + return std::sqrt(static_cast(SquaredLength())); +} + template void NzVector2::MakeCeil(const NzVector2& vec) { @@ -109,29 +120,65 @@ void NzVector2::MakeFloor(const NzVector2& vec) } template -T NzVector2::Length() const +void NzVector2::MakeUnitX() { - return std::sqrt(SquaredLength()); + Set(F(1.0), F(0.0)); } template -float NzVector2::Lengthf() const +void NzVector2::MakeUnitY() { - return std::sqrt(static_cast(SquaredLength())); + Set(F(0.0), F(1.0)); +} + +template +void NzVector2::MakeZero() +{ + Set(F(0.0), F(0.0)); } template void NzVector2::Normalize() { - auto length = Length(); + T squaredLength = SquaredLength(); - if (!NzNumberEquals(length, static_cast(0.0))) + if (squaredLength-F(1.0) > std::numeric_limits::epsilon()) { + T length = std::sqrt(squaredLength); + x /= length; y /= length; } } +template +void NzVector2::Set(T X, T Y) +{ + x = X; + y = Y; +} + +template +void NzVector2::Set(T scale) +{ + x = scale; + y = scale; +} + +template +void NzVector2::Set(T vec[2]) +{ + std::memcpy(&x, vec, 2*sizeof(T)); +} + +template +template +void NzVector2::Set(const NzVector2& vec) +{ + x = F(vec.x); + y = F(vec.y); +} + template T NzVector2::SquaredDistance(const NzVector2& vec) const { @@ -141,7 +188,7 @@ T NzVector2::SquaredDistance(const NzVector2& vec) const template T NzVector2::SquaredLength() const { - return x * x + y * y; + return x*x + y*y; } template @@ -152,6 +199,12 @@ NzString NzVector2::ToString() const return ss << "Vector2(" << x << ", " << y << ')'; } +template +NzVector2::operator NzString() const +{ + return ToString(); +} + template NzVector2::operator T*() { @@ -167,6 +220,7 @@ NzVector2::operator const T*() const template T& NzVector2::operator[](unsigned int i) { + #if NAZARA_MATH_SAFE if (i >= 2) { NzStringStream ss; @@ -174,6 +228,7 @@ T& NzVector2::operator[](unsigned int i) throw std::domain_error(ss.ToString()); } + #endif return *(&x+i); } @@ -181,6 +236,7 @@ T& NzVector2::operator[](unsigned int i) template T NzVector2::operator[](unsigned int i) const { + #if NAZARA_MATH_SAFE if (i >= 2) { NzStringStream ss; @@ -188,6 +244,7 @@ T NzVector2::operator[](unsigned int i) const throw std::domain_error(ss.ToString()); } + #endif return *(&x+i); } @@ -231,13 +288,15 @@ NzVector2 NzVector2::operator*(T scale) const template NzVector2 NzVector2::operator/(const NzVector2& vec) const { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector2(x / vec.x, y / vec.y); } @@ -245,13 +304,15 @@ NzVector2 NzVector2::operator/(const NzVector2& vec) const template NzVector2 NzVector2::operator/(T scale) const { - if (NzNumberEquals(scale, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(scale, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector2(x / scale, y / scale); } @@ -295,13 +356,15 @@ NzVector2& NzVector2::operator*=(T scale) template NzVector2& NzVector2::operator/=(const NzVector2& vec) { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0)) || NzNumberEquals(vec.z, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif x /= vec.x; y /= vec.y; @@ -312,13 +375,15 @@ NzVector2& NzVector2::operator/=(const NzVector2& vec) template NzVector2& NzVector2::operator/=(T scale) { - if (NzNumberEquals(scale, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(scale, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif x /= scale; y /= scale; @@ -363,6 +428,33 @@ bool NzVector2::operator>=(const NzVector2& vec) const return !operator<(vec); } +template +NzVector2 NzVector2::UnitX() +{ + NzVector2 vector; + vector.MakeUnitX(); + + return vector; +} + +template +NzVector2 NzVector2::UnitY() +{ + NzVector2 vector; + vector.MakeUnitY(); + + return vector; +} + +template +NzVector2 NzVector2::Zero() +{ + NzVector2 vector; + vector.MakeZero(); + + return vector; +} + template std::ostream& operator<<(std::ostream& out, const NzVector2& vec) { @@ -378,15 +470,19 @@ NzVector2 operator*(T scale, const NzVector2& vec) template NzVector2 operator/(T scale, const NzVector2& vec) { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0)) || NzNumberEquals(vec.z, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector2(scale/vec.x, scale/vec.y); } +#undef F + #include diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index af4a2b934..c8320b9f0 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -23,21 +23,41 @@ template class NzVector3 ~NzVector3() = default; T AbsDotProduct(const NzVector3& vec) const; + NzVector3 CrossProduct(const NzVector3& vec) const; + T Distance(const NzVector3& vec) const; float Distancef(const NzVector3& vec) const; + T DotProduct(const NzVector3& vec) const; + NzVector3 GetNormal() const; - void MakeCeil(const NzVector3& vec); - void MakeFloor(const NzVector3& vec); + T Length() const; float Lengthf() const; + + void MakeCeil(const NzVector3& vec); + void MakeFloor(const NzVector3& vec); + void MakeUnitX(); + void MakeUnitY(); + void MakeUnitZ(); + void MakeZero(); + void Normalize(); + + void Set(T X, T Y, T Z); + void Set(T scale); + void Set(T vec[3]); + void Set(const NzVector2& vec, T Z = 0.0); + template void Set(const NzVector3& vec); + T SquaredDistance(const NzVector3& vec) const; T SquaredLength() const; NzString ToString() const; + operator NzString() const; + operator T*(); operator const T*() const; @@ -68,9 +88,12 @@ template class NzVector3 bool operator>(const NzVector3& vec) const; bool operator>=(const NzVector3& vec) const; - T x; - T y; - T z; + static NzVector3 UnitX(); + static NzVector3 UnitY(); + static NzVector3 UnitZ(); + static NzVector3 Zero(); + + T x, y, z; }; template std::ostream& operator<<(std::ostream& out, const NzVector3& vec); diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index aec284b9b..136fce90b 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -6,53 +6,46 @@ #include #include #include +#include #include #include +#define F(a) static_cast(a) + template NzVector3::NzVector3() { } template -NzVector3::NzVector3(T X, T Y, T Z) : -x(X), -y(Y), -z(Z) +NzVector3::NzVector3(T X, T Y, T Z) { + Set(X, Y, Z); } template -NzVector3::NzVector3(T scale) : -x(scale), -y(scale), -z(scale) +NzVector3::NzVector3(T scale) { + Set(scale); } template -NzVector3::NzVector3(T vec[3]) : -x(vec[0]), -y(vec[1]), -z(vec[2]) +NzVector3::NzVector3(T vec[3]) { + Set(vec); } template -NzVector3::NzVector3(const NzVector2& vec, T Z) : -x(vec.x), -y(vec.y), -z(Z) +NzVector3::NzVector3(const NzVector2& vec, T Z) { + Set(vec, Z); } template template -NzVector3::NzVector3(const NzVector3& vec) : -x(static_cast(vec.x)), -y(static_cast(vec.y)), -z(static_cast(vec.z)) +NzVector3::NzVector3(const NzVector3& vec) { + Set(vec); } template @@ -94,7 +87,7 @@ float NzVector3::Distancef(const NzVector3& vec) const template T NzVector3::DotProduct(const NzVector3& vec) const { - return x * vec.x + y * vec.y + z * vec.z; + return x*vec.x + y*vec.y + z*vec.z; } template @@ -132,6 +125,30 @@ void NzVector3::MakeFloor(const NzVector3& vec) z = vec.z; } +template +void NzVector3::MakeUnitX() +{ + Set(F(1.0), F(0.0), F(0.0)); +} + +template +void NzVector3::MakeUnitY() +{ + Set(F(0.0), F(1.0), F(0.0)); +} + +template +void NzVector3::MakeUnitZ() +{ + Set(F(0.0), F(0.0), F(1.0)); +} + +template +void NzVector3::MakeZero() +{ + Set(F(0.0), F(0.0), F(0.0)); +} + template T NzVector3::Length() const { @@ -147,16 +164,57 @@ float NzVector3::Lengthf() const template void NzVector3::Normalize() { - T length = Length(); + T squaredLength = SquaredLength(); - if (!NzNumberEquals(length, static_cast(0.0))) + if (squaredLength-F(1.0) > std::numeric_limits::epsilon()) { + T length = std::sqrt(squaredLength); + x /= length; y /= length; z /= length; } } +template +void NzVector3::Set(T X, T Y, T Z) +{ + x = X; + y = Y; + z = Z; +} + +template +void NzVector3::Set(T scale) +{ + x = scale; + y = scale; + z = scale; +} + +template +void NzVector3::Set(T vec[3]) +{ + std::memcpy(&x, vec, 3*sizeof(T)); +} + +template +void NzVector3::Set(const NzVector2& vec, T Z) +{ + x = vec.x; + y = vec.y; + z = Z; +} + +template +template +void NzVector3::Set(const NzVector3& vec) +{ + x = F(vec.x); + y = F(vec.y); + z = F(vec.z); +} + template T NzVector3::SquaredDistance(const NzVector3& vec) const { @@ -166,7 +224,7 @@ T NzVector3::SquaredDistance(const NzVector3& vec) const template T NzVector3::SquaredLength() const { - return x * x + y * y + z * z; + return x*x + y*y + z*z; } template @@ -177,6 +235,12 @@ NzString NzVector3::ToString() const return ss << "Vector3(" << x << ", " << y << ", " << z <<')'; } +template +NzVector3::operator NzString() const +{ + return ToString(); +} + template NzVector3::operator T*() { @@ -192,13 +256,15 @@ NzVector3::operator const T*() const template T& NzVector3::operator[](unsigned int i) { + #if NAZARA_MATH_SAFE if (i >= 3) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 3)"; - throw std::domain_error(ss.ToString()); + throw std::out_of_range(ss.ToString()); } + #endif return *(&x+i); } @@ -206,13 +272,15 @@ T& NzVector3::operator[](unsigned int i) template T NzVector3::operator[](unsigned int i) const { + #if NAZARA_MATH_SAFE if (i >= 3) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Index out of range (" << i << " >= 3)"; - throw std::domain_error(ss.ToString()); + throw std::out_of_range(ss.ToString()); } + #endif return *(&x+i); } @@ -256,13 +324,15 @@ NzVector3 NzVector3::operator*(T scale) const template NzVector3 NzVector3::operator/(const NzVector3& vec) const { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0)) || NzNumberEquals(vec.z, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector3(x / vec.x, y / vec.y, z / vec.z); } @@ -270,13 +340,15 @@ NzVector3 NzVector3::operator/(const NzVector3& vec) const template NzVector3 NzVector3::operator/(T scale) const { - if (NzNumberEquals(scale, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(scale, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector3(x / scale, y / scale, z / scale); } @@ -324,7 +396,7 @@ NzVector3& NzVector3::operator*=(T scale) template NzVector3& NzVector3::operator/=(const NzVector3& vec) { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0)) || NzNumberEquals(vec.z, static_cast(0.0))) + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; @@ -342,7 +414,7 @@ NzVector3& NzVector3::operator/=(const NzVector3& vec) template NzVector3& NzVector3::operator/=(T scale) { - if (NzNumberEquals(scale, static_cast(0.0))) + if (NzNumberEquals(scale, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; @@ -395,6 +467,42 @@ bool NzVector3::operator>=(const NzVector3& vec) const return !operator<(vec); } +template +NzVector3 NzVector3::UnitX() +{ + NzVector3 vector; + vector.MakeUnitX(); + + return vector; +} + +template +NzVector3 NzVector3::UnitY() +{ + NzVector3 vector; + vector.MakeUnitY(); + + return vector; +} + +template +NzVector3 NzVector3::UnitZ() +{ + NzVector3 vector; + vector.MakeUnitZ(); + + return vector; +} + +template +NzVector3 NzVector3::Zero() +{ + NzVector3 vector; + vector.MakeZero(); + + return vector; +} + template std::ostream& operator<<(std::ostream& out, const NzVector3& vec) { @@ -410,15 +518,19 @@ NzVector3 operator*(T scale, const NzVector3& vec) template NzVector3 operator/(T scale, const NzVector3& vec) { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0)) || NzNumberEquals(vec.z, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector3(scale / vec.x, scale / vec.y, scale / vec.z); } +#undef F + #include diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index 872ac16c0..8faa3b94c 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -17,19 +17,34 @@ template class NzVector4 NzVector4(T X, T Y, T Z, T W = 1.0); explicit NzVector4(T scale); NzVector4(T vec[4]); - template explicit NzVector4(const NzVector4& vec); NzVector4(const NzVector3& vec, T W = 1.0); + template explicit NzVector4(const NzVector4& vec); NzVector4(const NzVector4& vec) = default; ~NzVector4() = default; T AbsDotProduct(const NzVector4& vec) const; + T DotProduct(const NzVector4& vec) const; + void MakeCeil(const NzVector4& vec); void MakeFloor(const NzVector4& vec); + void MakeUnitX(); + void MakeUnitY(); + void MakeUnitZ(); + void MakeZero(); + void Normalize(); + void Set(T X, T Y, T Z, T W = 1.0); + void Set(T scale); + void Set(T vec[4]); + void Set(const NzVector3& vec, T W = 1.0); + template void Set(const NzVector4& vec); + NzString ToString() const; + operator NzString() const; + operator T*(); operator const T*() const; @@ -60,10 +75,12 @@ template class NzVector4 bool operator>(const NzVector4& vec) const; bool operator>=(const NzVector4& vec) const; - T x; - T y; - T z; - T w; + static NzVector4 UnitX(); + static NzVector4 UnitY(); + static NzVector4 UnitZ(); + static NzVector4 Zero(); + + T x, y, z, w; }; template std::ostream& operator<<(std::ostream& out, const NzVector4& vec); diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index e5ec906fd..99e868cf6 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -9,55 +9,44 @@ #include #include +///FIXME: Les calculs effectués ici sont probablements tous faux, la composante W étant spéciale dans le monde de la 3D + +#define F(a) static_cast(a) + template NzVector4::NzVector4() { } template -NzVector4::NzVector4(T X, T Y, T Z, T W) : -x(X), -y(Y), -z(Z), -w(W) +NzVector4::NzVector4(T X, T Y, T Z, T W) { + Set(X, Y, Z, W); } template -NzVector4::NzVector4(T scale) : -x(scale), -y(scale), -z(scale), -w(scale) +NzVector4::NzVector4(T scale) { + Set(scale); } template -NzVector4::NzVector4(T vec[4]) : -x(vec[0]), -y(vec[1]), -z(vec[2]), -w(vec[3]) +NzVector4::NzVector4(T vec[4]) { + Set(vec); +} + +template +NzVector4::NzVector4(const NzVector3& vec, T W) +{ + Set(vec, W); } template template -NzVector4::NzVector4(const NzVector4& vec) : -x(static_cast(vec.x)), -y(static_cast(vec.y)), -z(static_cast(vec.z)), -w(static_cast(vec.w)) -{ -} - -template -NzVector4::NzVector4(const NzVector3& vec, T W) : -x(vec.x), -y(vec.y), -z(vec.z), -w(W) +NzVector4::NzVector4(const NzVector4& vec) { + Set(vec); } template @@ -81,7 +70,7 @@ inline unsigned int NzVector4::AbsDotProduct(const NzVector4 T NzVector4::DotProduct(const NzVector4& vec) const { - return x * vec.x + y * vec.y + z * vec.z + w * vec.w; + return x*vec.x + y*vec.y + z*vec.z + w*vec.w; } template @@ -116,10 +105,34 @@ void NzVector4::MakeFloor(const NzVector4& vec) w = vec.w; } +template +void NzVector4::MakeUnitX() +{ + Set(F(1.0), F(0.0), F(0.0), F(1.0)); +} + +template +void NzVector4::MakeUnitY() +{ + Set(F(0.0), F(1.0), F(0.0), F(1.0)); +} + +template +void NzVector4::MakeUnitZ() +{ + Set(F(0.0), F(0.0), F(1.0), F(1.0)); +} + +template +void NzVector4::MakeZero() +{ + Set(F(0.0), F(0.0), F(0.0), F(0.0)); +} + template void NzVector4::Normalize() { - if (!NzNumberEquals(w, static_cast(0.0))) + if (!NzNumberEquals(w, F(0.0))) { x /= w; y /= w; @@ -127,6 +140,49 @@ void NzVector4::Normalize() } } +template +void NzVector4::Set(T X, T Y, T Z, T W) +{ + w = W; + x = X; + y = Y; + z = Z; +} + +template +void NzVector4::Set(T scale) +{ + w = scale; + x = scale; + y = scale; + z = scale; +} + +template +void NzVector4::Set(T vec[4]) +{ + std::memcpy(&x, vec, 4*sizeof(T)); +} + +template +void NzVector4::Set(const NzVector3& vec, T W) +{ + w = W; + x = vec.x; + y = vec.y; + z = vec.z; +} + +template +template +void NzVector4::Set(const NzVector4& vec) +{ + w = F(vec.w); + x = F(vec.x); + y = F(vec.y); + z = F(vec.z); +} + template NzString NzVector4::ToString() const { @@ -135,6 +191,12 @@ NzString NzVector4::ToString() const return ss << "Vector4(" << x << ", " << y << ", " << z << ", " << w << ')'; } +template +NzVector4::operator NzString() const +{ + return ToString(); +} + template NzVector4::operator T*() { @@ -150,6 +212,7 @@ NzVector4::operator const T*() const template T& NzVector4::operator[](unsigned int i) { + #if NAZARA_MATH_SAFE if (i >= 4) { NzStringStream ss; @@ -157,6 +220,7 @@ T& NzVector4::operator[](unsigned int i) throw std::domain_error(ss.ToString()); } + #endif return *(&x+i); } @@ -164,6 +228,7 @@ T& NzVector4::operator[](unsigned int i) template T NzVector4::operator[](unsigned int i) const { + #if NAZARA_MATH_SAFE if (i >= 4) { NzStringStream ss; @@ -171,6 +236,7 @@ T NzVector4::operator[](unsigned int i) const throw std::domain_error(ss.ToString()); } + #endif return *(&x+i); } @@ -214,13 +280,15 @@ NzVector4 NzVector4::operator*(T scale) const template NzVector4 NzVector4::operator/(const NzVector4& vec) const { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0)) || NzNumberEquals(vec.z, static_cast(0.0)) || NzNumberEquals(vec.w, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)) || NzNumberEquals(vec.w, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector4(x / vec.x, y / vec.y, z / vec.z, w / vec.w); } @@ -228,13 +296,15 @@ NzVector4 NzVector4::operator/(const NzVector4& vec) const template NzVector4 NzVector4::operator/(T scale) const { - if (NzNumberEquals(scale, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(scale, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector4(x / scale, y / scale, z / scale, w / scale); } @@ -286,13 +356,15 @@ NzVector4& NzVector4::operator*=(T scale) template NzVector4& NzVector4::operator/=(const NzVector4& vec) { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0)) || NzNumberEquals(vec.z, static_cast(0.0)) || NzNumberEquals(vec.w, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)) || NzNumberEquals(vec.w, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif x /= vec.x; y /= vec.y; @@ -305,13 +377,15 @@ NzVector4& NzVector4::operator/=(const NzVector4& vec) template NzVector4& NzVector4::operator/=(T scale) { - if (NzNumberEquals(scale, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(scale, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif x /= scale; y /= scale; @@ -360,6 +434,42 @@ bool NzVector4::operator>=(const NzVector4& vec) const return !operator<(vec); } +template +NzVector4 NzVector4::UnitX() +{ + NzVector4 vector; + vector.MakeUnitX(); + + return vector; +} + +template +NzVector4 NzVector4::UnitY() +{ + NzVector4 vector; + vector.MakeUnitY(); + + return vector; +} + +template +NzVector4 NzVector4::UnitZ() +{ + NzVector4 vector; + vector.MakeUnitZ(); + + return vector; +} + +template +NzVector4 NzVector4::Zero() +{ + NzVector4 vector; + vector.MakeZero(); + + return vector; +} + template std::ostream& operator<<(std::ostream& out, const NzVector4& vec) { @@ -375,15 +485,19 @@ NzVector4 operator*(T scale, const NzVector4& vec) template NzVector4 operator/(T scale, const NzVector4& vec) { - if (NzNumberEquals(vec.x, static_cast(0.0)) || NzNumberEquals(vec.y, static_cast(0.0)) || NzNumberEquals(vec.z, static_cast(0.0)) || NzNumberEquals(vec.w, static_cast(0.0))) + #if NAZARA_MATH_SAFE + if (NzNumberEquals(vec.x, F(0.0)) || NzNumberEquals(vec.y, F(0.0)) || NzNumberEquals(vec.z, F(0.0)) || NzNumberEquals(vec.w, F(0.0))) { NzStringStream ss; ss << __FILE__ << ':' << __LINE__ << ": Division by zero"; throw std::domain_error(ss.ToString()); } + #endif return NzVector4(scale / vec.x, scale / vec.y, scale / vec.z, scale / vec.w); } +#undef F + #include diff --git a/include/Nazara/Network/Debug.hpp b/include/Nazara/Network/Debug.hpp deleted file mode 100644 index 21b4efd1c..000000000 --- a/include/Nazara/Network/Debug.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// 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 -#if NAZARA_NETWORK_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG) - #include - - #define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete - #define new new(__FILE__, __LINE__) -#endif diff --git a/include/Nazara/Noise.hpp b/include/Nazara/Noise.hpp new file mode 100644 index 000000000..6603cf442 --- /dev/null +++ b/include/Nazara/Noise.hpp @@ -0,0 +1,39 @@ +// This file was automatically generated by Nazara + +/* + Nazara Engine - NzNoise Module + + Copyright (C) 2012 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/include/Nazara/Noise/Config.hpp b/include/Nazara/Noise/Config.hpp index 77cb9d990..dff3349d1 100644 --- a/include/Nazara/Noise/Config.hpp +++ b/include/Nazara/Noise/Config.hpp @@ -1,8 +1,4 @@ /* - Nazara Engine - - Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) - Nazara Engine - NzNoise Module Copyright (C) 2012 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) diff --git a/include/Nazara/Noise/Noise.hpp b/include/Nazara/Noise/Noise.hpp index a42cad927..1b6206c84 100644 --- a/include/Nazara/Noise/Noise.hpp +++ b/include/Nazara/Noise/Noise.hpp @@ -8,20 +8,22 @@ #define NAZARA_NOISE_HPP #include +#include class NAZARA_API NzNoise { public: - NzNoise(); - ~NzNoise(); + NzNoise() = delete; + ~NzNoise() = delete; - bool Initialize(); - void Uninitialize(); + static bool Initialize(); static bool IsInitialized(); + static void Uninitialize(); + private: - static bool s_initialized; + static unsigned int s_moduleReferenceCouter; }; -#endif // NOISE_HPP +#endif // NAZARA_NOISE_HPP diff --git a/include/Nazara/Prerequesites.hpp b/include/Nazara/Prerequesites.hpp index 0691fc975..4593dce62 100644 --- a/include/Nazara/Prerequesites.hpp +++ b/include/Nazara/Prerequesites.hpp @@ -6,7 +6,7 @@ #define NAZARA_PREREQUESITES_HPP #if __cplusplus < 201103L -#error Nazara requires a C++11 compliant compiler + #error Nazara requires a C++11 compliant compiler #endif // Version du moteur @@ -42,7 +42,7 @@ #define NazaraUnused(a) (void) a -#if defined(_WIN32) || defined(__WIN32__) || defined(NAZARA_PLATFORM_WINDOWSVISTA) +#if defined(_WIN32) || defined(__WIN32__) #if !defined(NAZARA_STATIC) #ifdef NAZARA_BUILD #define NAZARA_API __declspec(dllexport) @@ -71,6 +71,7 @@ #define NAZARA_WINNT 0x0501 #endif + // Pour ne pas casser le define déjà en place s'il est applicable #if defined(_WIN32_WINNT) #if _WIN32_WINNT < NAZARA_WINNT #undef _WIN32_WINNT @@ -110,6 +111,16 @@ #include +static_assert(sizeof(int8_t) == 1, "int8_t is not of the correct size" ); +static_assert(sizeof(int16_t) == 2, "int16_t is not of the correct size"); +static_assert(sizeof(int32_t) == 4, "int32_t is not of the correct size"); +static_assert(sizeof(int64_t) == 8, "int64_t is not of the correct size"); + +static_assert(sizeof(uint8_t) == 1, "uint8_t is not of the correct size" ); +static_assert(sizeof(uint16_t) == 2, "uint16_t is not of the correct size"); +static_assert(sizeof(uint32_t) == 4, "uint32_t is not of the correct size"); +static_assert(sizeof(uint64_t) == 8, "uint64_t is not of the correct size"); + typedef int8_t nzInt8; typedef uint8_t nzUInt8; diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp new file mode 100644 index 000000000..98d61077e --- /dev/null +++ b/include/Nazara/Renderer.hpp @@ -0,0 +1,40 @@ +// This file was automatically generated by Nazara + +/* + Nazara Engine + + Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/include/Nazara/Renderer/Config.hpp b/include/Nazara/Renderer/Config.hpp index 9d5cbe613..ae970da77 100644 --- a/include/Nazara/Renderer/Config.hpp +++ b/include/Nazara/Renderer/Config.hpp @@ -32,9 +32,6 @@ // Active une fenêtre de rendu (NzRenderWindow) lors de sa création #define NAZARA_RENDERER_ACTIVATE_RENDERWINDOW_ON_CREATION 1 -// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes/plus de consommation mémoire) -#define NAZARA_RENDERER_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 0 - // Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution) #define NAZARA_RENDERER_MEMORYLEAKTRACKER 0 diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 2497b0df8..47678946e 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -35,6 +35,15 @@ enum nzFaceFilling nzFaceFilling_Fill }; +enum nzMatrixType +{ + nzMatrixType_Projection, + nzMatrixType_View, + nzMatrixType_World, + + nzMatrixType_Max = nzMatrixType_World +}; + enum nzPixelBufferType { nzPixelBufferType_Pack, diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index adb36a520..ea844a904 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #ifdef NAZARA_RENDERER_COMMON -#error This file is not part of the common renderer interface, you must undefine NAZARA_RENDERER_COMMON to use it + #error This file is not part of the common renderer interface, you must undefine NAZARA_RENDERER_COMMON to use it #endif #pragma once @@ -12,18 +12,16 @@ #define NAZARA_OPENGL_HPP // gl3.h définit WIN32_LEAN_AND_MEAN qui entre en conflit avec la définition de Nazara et doit donc être inclut en premier -#include +#include #include #include -// Il semblerait qu'il ne soit pas conseillé d'inclure gl3.h t glext.h en même temps, mais je ne vois pas oomment gérer les extensions autrement... +// Inclusion des extensions #include #if defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_LINUX) #include -#else - #error OS not handled #endif typedef void (*NzOpenGLFunc)(); @@ -40,11 +38,12 @@ class NAZARA_API NzOpenGL PixelBufferObject, SeparateShaderObjects, Texture3D, + TextureArray, TextureCompression_s3tc, TextureStorage, VertexArrayObject, - Count + Max = VertexArrayObject }; static NzOpenGLFunc GetEntry(const NzString& entryPoint); diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index 8772a8c9e..391314c31 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -10,6 +10,7 @@ #define NAZARA_RENDERWINDOW_HPP #include +#include #include #include #include @@ -23,7 +24,7 @@ struct NzContextParameters; class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow { public: - NzRenderWindow(); + NzRenderWindow() = default; NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters()); NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters()); virtual ~NzRenderWindow(); @@ -52,15 +53,19 @@ class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow bool IsValid() const; + void SetFramerateLimit(unsigned int limit); + protected: - bool Activate(); + virtual bool Activate() override; private: - void OnClose(); - bool OnCreate(); + virtual void OnWindowDestroying() override; + virtual bool OnWindowCreated() override; - NzContext* m_context; + NzClock m_clock; NzContextParameters m_parameters; + NzContext* m_context = nullptr; + unsigned int m_framerateLimit = 0; }; #endif // NAZARA_RENDERWINDOW_HPP diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index 74484ff36..b73fb07a5 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -8,99 +8,76 @@ #define NAZARA_RENDERER_HPP #include +#include +#include #include #include #include #include -#include - -#define NazaraRenderer NzRenderer::Instance() class NzColor; class NzContext; class NzIndexBuffer; class NzRenderTarget; class NzShader; -class NzUtility; class NzVertexBuffer; class NzVertexDeclaration; class NAZARA_API NzRenderer { public: - NzRenderer(); - ~NzRenderer(); + NzRenderer() = delete; + ~NzRenderer() = delete; - void Clear(unsigned long flags = nzRendererClear_Color | nzRendererClear_Depth); + static void Clear(unsigned long flags = nzRendererClear_Color | nzRendererClear_Depth); - void DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount); - void DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount); + static void DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount); + static void DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount); - void Enable(nzRendererParameter parameter, bool enable); + static void Enable(nzRendererParameter parameter, bool enable); - unsigned int GetMaxAnisotropyLevel() const; - unsigned int GetMaxRenderTargets() const; - unsigned int GetMaxTextureUnits() const; - NzShader* GetShader() const; - NzRenderTarget* GetTarget() const; - NzRectui GetViewport() const; + //static NzMatrix4f GetMatrix(nzMatrixCombination combination); + static NzMatrix4f GetMatrix(nzMatrixType type); + static unsigned int GetMaxAnisotropyLevel(); + static unsigned int GetMaxRenderTargets(); + static unsigned int GetMaxTextureUnits(); + static NzShader* GetShader(); + static NzRenderTarget* GetTarget(); + static NzRectui GetViewport(); - bool HasCapability(nzRendererCap capability) const; - bool Initialize(); + static bool HasCapability(nzRendererCap capability); - void SetBlendFunc(nzBlendFunc src, nzBlendFunc dest); - void SetClearColor(const NzColor& color); - void SetClearColor(nzUInt8 r, nzUInt8 g, nzUInt8 b, nzUInt8 a = 255); - void SetClearDepth(double depth); - void SetClearStencil(unsigned int value); - void SetFaceCulling(nzFaceCulling cullingMode); - void SetFaceFilling(nzFaceFilling fillingMode); - bool SetIndexBuffer(const NzIndexBuffer* indexBuffer); - bool SetShader(NzShader* shader); - void SetStencilCompareFunction(nzRendererComparison compareFunc); - void SetStencilFailOperation(nzStencilOperation failOperation); - void SetStencilMask(nzUInt32 mask); - void SetStencilPassOperation(nzStencilOperation passOperation); - void SetStencilReferenceValue(unsigned int refValue); - void SetStencilZFailOperation(nzStencilOperation zfailOperation); - bool SetTarget(NzRenderTarget* target); - bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer); - bool SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration); - void SetViewport(const NzRectui& viewport); + static bool Initialize(); - void Uninitialize(); - - static NzRenderer* Instance(); static bool IsInitialized(); + static void SetBlendFunc(nzBlendFunc src, nzBlendFunc dest); + static void SetClearColor(const NzColor& color); + static void SetClearColor(nzUInt8 r, nzUInt8 g, nzUInt8 b, nzUInt8 a = 255); + static void SetClearDepth(double depth); + static void SetClearStencil(unsigned int value); + static void SetFaceCulling(nzFaceCulling cullingMode); + static void SetFaceFilling(nzFaceFilling fillingMode); + static bool SetIndexBuffer(const NzIndexBuffer* indexBuffer); + static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix); + static bool SetShader(NzShader* shader); + static void SetStencilCompareFunction(nzRendererComparison compareFunc); + static void SetStencilFailOperation(nzStencilOperation failOperation); + static void SetStencilMask(nzUInt32 mask); + static void SetStencilPassOperation(nzStencilOperation passOperation); + static void SetStencilReferenceValue(unsigned int refValue); + static void SetStencilZFailOperation(nzStencilOperation zfailOperation); + static bool SetTarget(NzRenderTarget* target); + static bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer); + static bool SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration); + static void SetViewport(const NzRectui& viewport); + + static void Uninitialize(); + private: - bool EnsureStateUpdate(); + static bool EnsureStateUpdate(); - typedef std::tuple VAO_Key; - - std::map m_vaos; - nzRendererComparison m_stencilCompare; - nzStencilOperation m_stencilFail; - nzStencilOperation m_stencilPass; - nzStencilOperation m_stencilZFail; - nzUInt32 m_stencilMask; - const NzIndexBuffer* m_indexBuffer; - NzRenderTarget* m_target; - NzShader* m_shader; - NzUtility* m_utilityModule; - const NzVertexBuffer* m_vertexBuffer; - const NzVertexDeclaration* m_vertexDeclaration; - bool m_vaoUpdated; - bool m_capabilities[nzRendererCap_Max+1]; - bool m_stencilFuncUpdated; - bool m_stencilOpUpdated; - unsigned int m_maxAnisotropyLevel; - unsigned int m_maxRenderTarget; - unsigned int m_maxTextureUnit; - unsigned int m_stencilReference; - - static NzRenderer* s_instance; - static bool s_initialized; + static unsigned int s_moduleReferenceCouter; }; #endif // NAZARA_RENDERER_HPP diff --git a/include/Nazara/Renderer/Shader.hpp b/include/Nazara/Renderer/Shader.hpp index c100cef13..f1ebb9ed2 100644 --- a/include/Nazara/Renderer/Shader.hpp +++ b/include/Nazara/Renderer/Shader.hpp @@ -9,13 +9,13 @@ #include #include +#include #include #include #include #include #include #include -#include class NzRenderer; class NzShaderImpl; @@ -38,6 +38,9 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable NzString GetLog() const; nzShaderLanguage GetLanguage() const; NzString GetSourceCode(nzShaderType type) const; + int GetUniformLocation(const NzString& name) const; + + bool HasUniform(const NzString& name) const; bool IsCompiled() const; bool IsLoaded(nzShaderType type) const; @@ -47,19 +50,19 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable bool Lock(); - bool SendBoolean(const NzString& name, bool value); - bool SendDouble(const NzString& name, double value); - bool SendFloat(const NzString& name, float value); - bool SendInteger(const NzString& name, int value); - bool SendMatrix(const NzString& name, const NzMatrix4d& matrix); - bool SendMatrix(const NzString& name, const NzMatrix4f& matrix); - bool SendVector(const NzString& name, const NzVector2d& vector); - bool SendVector(const NzString& name, const NzVector2f& vector); - bool SendVector(const NzString& name, const NzVector3d& vector); - bool SendVector(const NzString& name, const NzVector3f& vector); - bool SendVector(const NzString& name, const NzVector4d& vector); - bool SendVector(const NzString& name, const NzVector4f& vector); - bool SendTexture(const NzString& name, NzTexture* texture); + bool SendBoolean(int location, bool value); + bool SendDouble(int location, double value); + bool SendFloat(int location, float value); + bool SendInteger(int location, int value); + bool SendMatrix(int location, const NzMatrix4d& matrix); + bool SendMatrix(int location, const NzMatrix4f& matrix); + bool SendTexture(int location, const NzTexture* texture); + bool SendVector(int location, const NzVector2d& vector); + bool SendVector(int location, const NzVector2f& vector); + bool SendVector(int location, const NzVector3d& vector); + bool SendVector(int location, const NzVector3f& vector); + bool SendVector(int location, const NzVector4d& vector); + bool SendVector(int location, const NzVector4f& vector); void Unlock(); diff --git a/include/Nazara/Utility.hpp b/include/Nazara/Utility.hpp new file mode 100644 index 000000000..449b99967 --- /dev/null +++ b/include/Nazara/Utility.hpp @@ -0,0 +1,53 @@ +// This file was automatically generated by Nazara + +/* + Nazara Engine + + Copyright (C) 2012 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/include/Nazara/Utility/Animation.hpp b/include/Nazara/Utility/Animation.hpp index b8b8d251e..11b2c08bb 100644 --- a/include/Nazara/Utility/Animation.hpp +++ b/include/Nazara/Utility/Animation.hpp @@ -8,9 +8,9 @@ #define NAZARA_ANIMATION_HPP #include +#include #include #include -#include #include #include #include diff --git a/include/Nazara/Utility/AxisAlignedBox.hpp b/include/Nazara/Utility/AxisAlignedBox.hpp new file mode 100644 index 000000000..a12658c30 --- /dev/null +++ b/include/Nazara/Utility/AxisAlignedBox.hpp @@ -0,0 +1,50 @@ +// Copyright (C) 2011 Jérôme Leclercq +// This file is part of the "Ungine". +// For conditions of distribution and use, see copyright notice in Core.h + +#ifndef NAZARA_AXISALIGNEDBOX_HPP +#define NAZARA_AXISALIGNEDBOX_HPP + +#include +#include +#include +#include +#include + +class NAZARA_API NzAxisAlignedBox +{ + public: + NzAxisAlignedBox(); + NzAxisAlignedBox(const NzVector3f& vec1, const NzVector3f& vec2); + NzAxisAlignedBox(nzExtend extend); + + bool Contains(const NzAxisAlignedBox& box); + + void ExtendTo(const NzAxisAlignedBox& box); + void ExtendTo(const NzVector3f& vector); + + nzExtend GetExtend() const; + NzVector3f GetMaximum() const; + NzVector3f GetMinimum() const; + + bool IsFinite() const; + bool IsInfinite() const; + bool IsNull() const; + + void SetInfinite(); + void SetExtends(const NzVector3f& vec1, const NzVector3f& vec2); + void SetNull(); + + NzString ToString() const; + + static const NzAxisAlignedBox Infinite; + static const NzAxisAlignedBox Null; + + private: + nzExtend m_extend; + NzCubef m_cube; +}; + +NAZARA_API std::ostream& operator<<(std::ostream& out, const NzAxisAlignedBox& aabb); + +#endif // NAZARA_AXISALIGNEDBOX_HPP diff --git a/include/Nazara/Utility/Buffer.hpp b/include/Nazara/Utility/Buffer.hpp index 7fcad2221..5c728473a 100644 --- a/include/Nazara/Utility/Buffer.hpp +++ b/include/Nazara/Utility/Buffer.hpp @@ -9,8 +9,8 @@ #include #include +#include #include -#include class NzBufferImpl; class NzRenderer; diff --git a/include/Nazara/Utility/Config.hpp b/include/Nazara/Utility/Config.hpp index a9f059da4..f18cea996 100644 --- a/include/Nazara/Utility/Config.hpp +++ b/include/Nazara/Utility/Config.hpp @@ -29,6 +29,9 @@ /// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci +// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes/plus de consommation mémoire) +#define NAZARA_UTILITY_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 0 + // Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution) #define NAZARA_UTILITY_MEMORYLEAKTRACKER 0 @@ -38,12 +41,11 @@ // Fait tourner chaque fenêtre dans un thread séparé si le système le supporte #define NAZARA_UTILITY_THREADED_WINDOW 0 ///FIXME: Buggé depuis GCC 4.7 -// Protège le module des accès concurrentiels +// Protège les classes des accès concurrentiels #define NAZARA_UTILITY_THREADSAFE 1 -#if NAZARA_UTILITY_THREADSAFE - #define NAZARA_THREADSAFETY_IMAGE 1 // NzImage (COW) - #define NAZARA_THREADSAFETY_VERTEXDECLARATION 1 // NzVertexDeclaration (COW) -#endif +// Les classes à protéger des accès concurrentiels +#define NAZARA_THREADSAFETY_IMAGE 1 // NzImage (COW) +#define NAZARA_THREADSAFETY_VERTEXDECLARATION 1 // NzVertexDeclaration (COW) #endif // NAZARA_CONFIG_UTILITY_HPP diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index b2da366e7..5758f14ea 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -24,6 +24,7 @@ enum nzBufferAccess enum nzBufferStorage { + //nzBufferStorage_Both, nzBufferStorage_Hardware, nzBufferStorage_Software, @@ -44,8 +45,8 @@ enum nzBufferUsage enum nzCubemapFace { - // L'ordre est X, -X, Y, -Y, Z, -Z // Cette énumération est prévue pour remplacer l'argument "z" des méthodes de NzImage contenant un cubemap + // L'ordre est X, -X, Y, -Y, Z, -Z nzCubemapFace_PositiveX = 0, nzCubemapFace_PositiveY = 2, nzCubemapFace_PositiveZ = 4, @@ -86,10 +87,38 @@ enum nzElementUsage nzElementUsage_Max = nzElementUsage_TexCoord }; +enum nzEventType +{ + nzEventType_GainedFocus, + nzEventType_LostFocus, + nzEventType_KeyPressed, + nzEventType_KeyReleased, + nzEventType_MouseButtonDoubleClicked, + nzEventType_MouseButtonPressed, + nzEventType_MouseButtonReleased, + nzEventType_MouseEntered, + nzEventType_MouseLeft, + nzEventType_MouseMoved, + nzEventType_MouseWheelMoved, + nzEventType_Moved, + nzEventType_Quit, + nzEventType_Resized, + nzEventType_TextEntered +}; + +enum nzExtend +{ + nzExtend_Finite, + nzExtend_Infinite, + nzExtend_Null +}; + enum nzImageType { nzImageType_1D, + nzImageType_1D_Array, nzImageType_2D, + nzImageType_2D_Array, nzImageType_3D, nzImageType_Cubemap, diff --git a/include/Nazara/Utility/Event.hpp b/include/Nazara/Utility/Event.hpp index 5b2dbbd4c..6f8d28dee 100644 --- a/include/Nazara/Utility/Event.hpp +++ b/include/Nazara/Utility/Event.hpp @@ -14,15 +14,22 @@ struct NzEvent { + // Utilisé par: + // -nzEventType_KeyPressed + // -nzEventType_KeyReleased struct KeyEvent { NzKeyboard::Key code; bool alt; bool control; + bool repeated; bool shift; bool system; }; + // Utilisé par: + // -nzEventType_MouseButtonDoubleClicked + // -nzEventType_MouseButtonPressed struct MouseButtonEvent { NzMouse::Button button; @@ -30,63 +37,79 @@ struct NzEvent unsigned int y; }; + // Utilisé par: + // -nzEventType_MouseMoved struct MouseMoveEvent { - int x; - int y; + int deltaX; + int deltaY; + unsigned int x; + unsigned int y; }; + // Utilisé par: + // -nzEventType_MouseWheelMoved struct MouseWheelEvent { float delta; }; + // Utilisé par: + // -nzEventType_Moved struct PositionEvent { int x; int y; }; + // Utilisé par: + // -nzEventType_Resized struct SizeEvent { unsigned int height; unsigned int width; }; + // Utilisé par: + // -nzEventType_TextEntered struct TextEvent { + bool repeated; char32_t character; }; - enum Type - { - GainedFocus, - LostFocus, - KeyPressed, - KeyReleased, - MouseButtonDoubleClicked, - MouseButtonPressed, - MouseButtonReleased, - MouseEntered, - MouseLeft, - MouseMoved, - MouseWheelMoved, - Moved, - Quit, - Resized, - TextEntered - }; - - Type type; + nzEventType type; union { + // Utilisé par: + // -nzEventType_KeyPressed + // -nzEventType_KeyReleased KeyEvent key; + + // Utilisé par: + // -nzEventType_MouseButtonDoubleClicked + // -nzEventType_MouseButtonPressed MouseButtonEvent mouseButton; + + // Utilisé par: + // -nzEventType_MouseMoved MouseMoveEvent mouseMove; + + // Utilisé par: + // -nzEventType_MouseWheelMoved MouseWheelEvent mouseWheel; + + // Utilisé par: + // -nzEventType_Moved PositionEvent position; + + // Utilisé par: + // -nzEventType_Resized SizeEvent size; + + // Utilisé par: + // -nzEventType_TextEntered TextEvent text; }; }; diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index 8882aa73f..3a98656e1 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -10,17 +10,17 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include -#if NAZARA_THREADSAFETY_IMAGE +#if NAZARA_UTILITY_THREADSAFE && NAZARA_THREADSAFETY_IMAGE #include #else #include @@ -49,7 +49,7 @@ class NAZARA_API NzImage : public NzResource NzImage(); NzImage(const NzImage& image); - NzImage(NzImage&& image); + NzImage(NzImage&& image) noexcept; NzImage(SharedImage* sharedImage); ~NzImage(); @@ -68,14 +68,14 @@ class NAZARA_API NzImage : public NzResource bool FlipVertically(); nzUInt8 GetBPP() const; - const nzUInt8* GetConstPixels(nzUInt8 level = 0, unsigned int x = 0, unsigned int y = 0, unsigned int z = 0) const; + const nzUInt8* GetConstPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, nzUInt8 level = 0) const; unsigned int GetDepth(nzUInt8 level = 0) const; nzPixelFormat GetFormat() const; unsigned int GetHeight(nzUInt8 level = 0) const; nzUInt8 GetLevelCount() const; nzUInt8 GetMaxLevel() const; NzColor GetPixelColor(unsigned int x, unsigned int y = 0, unsigned int z = 0) const; - nzUInt8* GetPixels(nzUInt8 level = 0, unsigned int x = 0, unsigned int y = 0, unsigned int z = 0); + nzUInt8* GetPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, nzUInt8 level = 0); unsigned int GetSize() const; unsigned int GetSize(nzUInt8 level) const; nzImageType GetType() const; @@ -97,7 +97,7 @@ class NAZARA_API NzImage : public NzResource bool Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 level = 0); NzImage& operator=(const NzImage& image); - NzImage& operator=(NzImage&& image); + NzImage& operator=(NzImage&& image) noexcept; static nzUInt8 GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth = 1); diff --git a/include/Nazara/Utility/IndexBuffer.hpp b/include/Nazara/Utility/IndexBuffer.hpp index 22c22104b..dd6f99fd0 100644 --- a/include/Nazara/Utility/IndexBuffer.hpp +++ b/include/Nazara/Utility/IndexBuffer.hpp @@ -8,8 +8,8 @@ #define NAZARA_INDEXBUFFER_HPP #include +#include #include -#include class NAZARA_API NzIndexBuffer : public NzResource { diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index b7dbc71f1..7b4072035 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -9,21 +9,22 @@ #include #include +#include #include #include +#include #include -#include +#include #include #include -class NzSubMesh; class NzVertexDeclaration; struct NzMeshParams { NzAnimationParams animation; //const NzVertexDeclaration* declaration = nullptr; - bool forceSoftware = false; + nzBufferStorage storage = nzBufferStorage_Hardware; bool loadAnimations = true; bool IsValid() const; @@ -52,6 +53,7 @@ class NAZARA_API NzMesh : public NzResource bool Create(nzAnimationType type); void Destroy(); + const NzAxisAlignedBox& GetAABB() const; const NzAnimation* GetAnimation() const; nzAnimationType GetAnimationType() const; unsigned int GetFrameCount() const; @@ -69,6 +71,8 @@ class NAZARA_API NzMesh : public NzResource bool HasSubMesh(const NzString& identifier) const; bool HasSubMesh(nzUInt8 index = 0) const; + void InvalidateAABB() const; + bool IsAnimable() const; bool IsValid() const; diff --git a/include/Nazara/Utility/Mouse.hpp b/include/Nazara/Utility/Mouse.hpp index 4139efce3..37befe3ca 100644 --- a/include/Nazara/Utility/Mouse.hpp +++ b/include/Nazara/Utility/Mouse.hpp @@ -25,7 +25,7 @@ class NAZARA_API NzMouse XButton1, XButton2, - Count + Max = XButton2 }; static NzVector2i GetPosition(); diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index 917450700..bac3ff377 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -361,7 +361,7 @@ inline NzString NzPixelFormat::ToString(nzPixelFormat format) return "RGBA8"; case nzPixelFormat_Undefined: - break; + return "Undefined"; } NazaraError("Invalid pixel format"); diff --git a/include/Nazara/Utility/StaticMesh.hpp b/include/Nazara/Utility/StaticMesh.hpp index 2e1c5684a..dbdbf2cc1 100644 --- a/include/Nazara/Utility/StaticMesh.hpp +++ b/include/Nazara/Utility/StaticMesh.hpp @@ -14,12 +14,15 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh { public: NzStaticMesh(const NzMesh* parent); - NzStaticMesh(const NzMesh* parent, const NzVertexBuffer* vertexBuffer, const NzVertexDeclaration* vertexDeclaration, const NzIndexBuffer* indexBuffer = nullptr); + NzStaticMesh(const NzMesh* parent, const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr); virtual ~NzStaticMesh(); - bool Create(const NzVertexBuffer* vertexBuffer, const NzVertexDeclaration* vertexDeclaration, const NzIndexBuffer* indexBuffer = nullptr); + bool Create(const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer = nullptr); void Destroy(); + bool GenerateAABB(); + + const NzAxisAlignedBox& GetAABB() const; nzAnimationType GetAnimationType() const; unsigned int GetFrameCount() const; const NzIndexBuffer* GetIndexBuffer() const; @@ -30,14 +33,16 @@ class NAZARA_API NzStaticMesh final : public NzSubMesh bool IsAnimated() const; bool IsValid() const; + void SetAABB(const NzAxisAlignedBox& aabb); void SetPrimitiveType(nzPrimitiveType primitiveType); private: void AnimateImpl(unsigned int frameA, unsigned int frameB, float interpolation); nzPrimitiveType m_primitiveType = nzPrimitiveType_TriangleList; - const NzIndexBuffer* m_indexBuffer = nullptr; - const NzVertexBuffer* m_vertexBuffer = nullptr; + NzAxisAlignedBox m_aabb; + NzIndexBuffer* m_indexBuffer = nullptr; + NzVertexBuffer* m_vertexBuffer = nullptr; const NzVertexDeclaration* m_vertexDeclaration = nullptr; }; diff --git a/include/Nazara/Utility/SubMesh.hpp b/include/Nazara/Utility/SubMesh.hpp index 070563218..ee4c6bd5a 100644 --- a/include/Nazara/Utility/SubMesh.hpp +++ b/include/Nazara/Utility/SubMesh.hpp @@ -8,9 +8,10 @@ #define NAZARA_SUBMESH_HPP #include +#include +#include #include #include -#include #include #include @@ -26,6 +27,7 @@ class NAZARA_API NzSubMesh : public NzResource void Animate(unsigned int frameA, unsigned int frameB, float interpolation); + virtual const NzAxisAlignedBox& GetAABB() const = 0; virtual const NzIndexBuffer* GetIndexBuffer() const = 0; const NzMesh* GetParent() const; virtual nzPrimitiveType GetPrimitiveType() const = 0; diff --git a/include/Nazara/Utility/Utility.hpp b/include/Nazara/Utility/Utility.hpp index 5d70c6ba6..1133f0210 100644 --- a/include/Nazara/Utility/Utility.hpp +++ b/include/Nazara/Utility/Utility.hpp @@ -8,20 +8,22 @@ #define NAZARA_UTILITY_HPP #include +#include class NAZARA_API NzUtility { public: - NzUtility(); - ~NzUtility(); + NzUtility() = delete; + ~NzUtility() = delete; - bool Initialize(); - void Uninitialize(); + static bool Initialize(); static bool IsInitialized(); + static void Uninitialize(); + private: - static bool s_initialized; + static unsigned int s_moduleReferenceCouter; }; #endif // NAZARA_UTILITY_HPP diff --git a/include/Nazara/Utility/VertexBuffer.hpp b/include/Nazara/Utility/VertexBuffer.hpp index 49cee5012..51c5f154d 100644 --- a/include/Nazara/Utility/VertexBuffer.hpp +++ b/include/Nazara/Utility/VertexBuffer.hpp @@ -8,8 +8,8 @@ #define NAZARA_VERTEXBUFFER_HPP #include +#include #include -#include class NAZARA_API NzVertexBuffer : public NzResource { diff --git a/include/Nazara/Utility/VertexDeclaration.hpp b/include/Nazara/Utility/VertexDeclaration.hpp index 78e284b97..049fb43f7 100644 --- a/include/Nazara/Utility/VertexDeclaration.hpp +++ b/include/Nazara/Utility/VertexDeclaration.hpp @@ -6,8 +6,8 @@ #define NAZARA_VERTEXDECLARATION_HPP #include +#include #include -#include struct NzVertexElement { @@ -26,7 +26,7 @@ class NAZARA_API NzVertexDeclaration : public NzResource NzVertexDeclaration() = default; NzVertexDeclaration(const NzVertexElement* elements, unsigned int elementCount); NzVertexDeclaration(const NzVertexDeclaration& declaration); - NzVertexDeclaration(NzVertexDeclaration&& declaration); + NzVertexDeclaration(NzVertexDeclaration&& declaration) noexcept; ~NzVertexDeclaration(); bool Create(const NzVertexElement* elements, unsigned int elementCount); @@ -44,7 +44,7 @@ class NAZARA_API NzVertexDeclaration : public NzResource bool IsValid() const; NzVertexDeclaration& operator=(const NzVertexDeclaration& declaration); - NzVertexDeclaration& operator=(NzVertexDeclaration&& declaration); + NzVertexDeclaration& operator=(NzVertexDeclaration&& declaration) noexcept; private: NzVertexDeclarationImpl* m_sharedImpl = nullptr; diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index be45ed6b9..ab803d30b 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -28,11 +28,13 @@ class NzCursor; class NzImage; class NzIcon; +class NzMouse; class NzUtility; class NzWindowImpl; class NAZARA_API NzWindow : NzNonCopyable { + friend class NzMouse; friend class NzUtility; friend class NzWindowImpl; @@ -42,11 +44,11 @@ class NAZARA_API NzWindow : NzNonCopyable NzWindow(NzWindowHandle handle); virtual ~NzWindow(); - void Close(); - bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default); bool Create(NzWindowHandle handle); + void Destroy(); + void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); @@ -78,20 +80,20 @@ class NAZARA_API NzWindow : NzNonCopyable void SetPosition(int x, int y); void SetSize(const NzVector2i& size); void SetSize(unsigned int width, unsigned int height); + void SetStayOnTop(bool stayOnTop); void SetTitle(const NzString& title); void SetVisible(bool visible); - void StayOnTop(bool stayOnTop); - bool WaitEvent(NzEvent* event); protected: - virtual void OnClose(); - virtual bool OnCreate(); + virtual void OnWindowDestroying(); + virtual bool OnWindowCreated(); NzWindowImpl* m_impl; private: + void IgnoreNextMouseEvent(int mouseX, int mouseY) const; void PushEvent(const NzEvent& event); static bool Initialize(); @@ -99,9 +101,9 @@ class NAZARA_API NzWindow : NzNonCopyable std::queue m_events; #if NAZARA_UTILITY_THREADED_WINDOW + NzConditionVariable m_eventCondition; NzMutex m_eventMutex; NzMutex m_eventConditionMutex; - NzThreadCondition m_eventCondition; bool m_eventListener; bool m_waitForEvent; #endif diff --git a/src/Nazara/Audio/Debug/Leaks.cpp b/src/Nazara/Audio/Debug/Leaks.cpp deleted file mode 100644 index e28e0794e..000000000 --- a/src/Nazara/Audio/Debug/Leaks.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// 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 -#if NAZARA_AUDIO_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG) -#include -#include - -void* operator new(std::size_t size) -{ - return NzMemoryManager::Allocate(size, false); -} - -void* operator new[](std::size_t size) -{ - return NzMemoryManager::Allocate(size, true); -} - -void operator delete(void* pointer) noexcept -{ - NzMemoryManager::Free(pointer, false); -} - -void operator delete[](void* pointer) noexcept -{ - NzMemoryManager::Free(pointer, true); -} -#endif diff --git a/src/Nazara/Core/Clock.cpp b/src/Nazara/Core/Clock.cpp index 0963cf4af..5f685b3dc 100644 --- a/src/Nazara/Core/Clock.cpp +++ b/src/Nazara/Core/Clock.cpp @@ -15,6 +15,24 @@ #include +namespace +{ + nzUInt64 NzGetMicrosecondsLowPrecision() + { + return NzClockImplGetMilliseconds()*1000ULL; + } + + nzUInt64 NzGetMicrosecondsFirstRun() + { + if (NzClockImplInitializeHighPrecision()) + NzGetMicroseconds = NzClockImplGetMicroseconds; + else + NzGetMicroseconds = NzGetMicrosecondsLowPrecision; + + return NzGetMicroseconds(); + } +} + NzClock::NzClock() : m_elapsedTime(0), m_refTime(NzGetMicroseconds()), @@ -81,20 +99,5 @@ void NzClock::Unpause() NazaraWarning("Clock is not paused, ignoring..."); } -nzUInt64 NzGetMicrosecondsLowPrecision() -{ - return NzClockImplGetMilliseconds()*1000ULL; -} - -nzUInt64 NzGetMicrosecondsFirstRun() -{ - if (NzClockImplInitializeHighPrecision()) - NzGetMicroseconds = NzClockImplGetMicroseconds; - else - NzGetMicroseconds = NzGetMicrosecondsLowPrecision; - - return NzGetMicroseconds(); -} - NzClockFunction NzGetMicroseconds = NzGetMicrosecondsFirstRun; NzClockFunction NzGetMilliseconds = NzClockImplGetMilliseconds; diff --git a/src/Nazara/Core/ThreadCondition.cpp b/src/Nazara/Core/ConditionVariable.cpp similarity index 52% rename from src/Nazara/Core/ThreadCondition.cpp rename to src/Nazara/Core/ConditionVariable.cpp index fb8c3b7e8..88337bb64 100644 --- a/src/Nazara/Core/ThreadCondition.cpp +++ b/src/Nazara/Core/ConditionVariable.cpp @@ -2,45 +2,45 @@ // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #if defined(NAZARA_PLATFORM_WINDOWS) - #include + #include #elif defined(NAZARA_PLATFORM_POSIX) - #include + #include #else #error Thread condition has no implementation #endif #include -NzThreadCondition::NzThreadCondition() +NzConditionVariable::NzConditionVariable() { - m_impl = new NzThreadConditionImpl; + m_impl = new NzConditionVariableImpl; } -NzThreadCondition::~NzThreadCondition() +NzConditionVariable::~NzConditionVariable() { delete m_impl; } -void NzThreadCondition::Signal() +void NzConditionVariable::Signal() { m_impl->Signal(); } -void NzThreadCondition::SignalAll() +void NzConditionVariable::SignalAll() { m_impl->SignalAll(); } -void NzThreadCondition::Wait(NzMutex* mutex) +void NzConditionVariable::Wait(NzMutex* mutex) { m_impl->Wait(mutex->m_impl); } -bool NzThreadCondition::Wait(NzMutex* mutex, nzUInt32 timeout) +bool NzConditionVariable::Wait(NzMutex* mutex, nzUInt32 timeout) { return m_impl->Wait(mutex->m_impl, timeout); } diff --git a/src/Nazara/Core/Core.cpp b/src/Nazara/Core/Core.cpp new file mode 100644 index 000000000..0bd2ff041 --- /dev/null +++ b/src/Nazara/Core/Core.cpp @@ -0,0 +1,39 @@ +// Copyright (C) 2012 AUTHORS +// This file is part of the "Nazara Engine". +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +bool NzCore::Initialize() +{ + if (s_moduleReferenceCouter++ != 0) + return true; // Déjà initialisé + + // Initialisation du module + // Le noyau de Nazara n'a pour l'instant aucun besoin d'initialisation, mais dans le futur il est très probable que ce soit le cas. + // Donc en prévision, tous les modules initialisent le noyau + + NazaraNotice("Initialized: Core"); + + return true; +} + +bool NzCore::IsInitialized() +{ + return s_moduleReferenceCouter != 0; +} + +void NzCore::Uninitialize() +{ + if (--s_moduleReferenceCouter != 0) + return; // Encore utilisé + + // Libération du module + NazaraNotice("Uninitialized: Core"); +} + +unsigned int NzCore::s_moduleReferenceCouter = 0; diff --git a/src/Nazara/Core/Debug/MemoryLeakTracker.cpp b/src/Nazara/Core/Debug/MemoryLeakTracker.cpp index 08fce3532..35e96a967 100644 --- a/src/Nazara/Core/Debug/MemoryLeakTracker.cpp +++ b/src/Nazara/Core/Debug/MemoryLeakTracker.cpp @@ -119,19 +119,16 @@ void NzMemoryManager::Free(void* pointer, bool multi) if (nextFreeFile) { if (multi) - std::fprintf(log, "%s Warning: delete[] on new at %s:%d\n", time, nextFreeFile, nextFreeLine); + std::fprintf(log, "%s Warning: delete[] after new at %s:%d\n", time, nextFreeFile, nextFreeLine); else - std::fprintf(log, "%s Warning: delete on new[] at %s:%d\n", time, nextFreeFile, nextFreeLine); - - nextFreeFile = nullptr; - nextFreeLine = 0; + std::fprintf(log, "%s Warning: delete after new[] at %s:%d\n", time, nextFreeFile, nextFreeLine); } else { if (multi) - std::fprintf(log, "%s Warning: delete[] on new at unknown position\n", time); + std::fprintf(log, "%s Warning: delete[] after new at unknown position\n", time); else - std::fprintf(log, "%s Warning: delete on new[] at unknown position\n", time); + std::fprintf(log, "%s Warning: delete after new[] at unknown position\n", time); } std::fclose(log); @@ -145,6 +142,9 @@ void NzMemoryManager::Free(void* pointer, bool multi) std::free(ptr); + nextFreeFile = nullptr; + nextFreeLine = 0; + #if defined(NAZARA_PLATFORM_WINDOWS) LeaveCriticalSection(&mutex); #elif defined(NAZARA_PLATFORM_POSIX) diff --git a/src/Nazara/Core/Directory.cpp b/src/Nazara/Core/Directory.cpp index c5aa37c51..a614ba695 100644 --- a/src/Nazara/Core/Directory.cpp +++ b/src/Nazara/Core/Directory.cpp @@ -25,14 +25,14 @@ namespace } NzDirectory::NzDirectory() : -m_impl(nullptr) +m_pattern('*') { } NzDirectory::NzDirectory(const NzString& dirPath) : -m_impl(nullptr) +m_dirPath(dirPath), +m_pattern('*') { - SetDirectory(dirPath); } NzDirectory::~NzDirectory() @@ -42,18 +42,27 @@ NzDirectory::~NzDirectory() void NzDirectory::Close() { + NazaraLock(m_mutex); + if (m_impl) { m_impl->Close(); delete m_impl; m_impl = nullptr; - - NazaraMutexUnlock(m_mutex); } } +NzString NzDirectory::GetPattern() const +{ + NazaraLock(m_mutex); + + return m_pattern; +} + NzString NzDirectory::GetResultName() const { + NazaraLock(m_mutex); + #if NAZARA_CORE_SAFE if (!m_impl) { @@ -67,6 +76,8 @@ NzString NzDirectory::GetResultName() const NzString NzDirectory::GetResultPath() const { + NazaraLock(m_mutex); + #if NAZARA_CORE_SAFE if (!m_impl) { @@ -80,6 +91,8 @@ NzString NzDirectory::GetResultPath() const nzUInt64 NzDirectory::GetResultSize() const { + NazaraLock(m_mutex); + #if NAZARA_CORE_SAFE if (!m_impl) { @@ -91,8 +104,17 @@ nzUInt64 NzDirectory::GetResultSize() const return m_impl->GetResultSize(); } +bool NzDirectory::IsOpen() const +{ + NazaraLock(m_mutex); + + return m_impl != nullptr; +} + bool NzDirectory::IsResultDirectory() const { + NazaraLock(m_mutex); + #if NAZARA_CORE_SAFE if (!m_impl) { @@ -106,6 +128,8 @@ bool NzDirectory::IsResultDirectory() const bool NzDirectory::NextResult(bool skipDots) { + NazaraLock(m_mutex); + #if NAZARA_CORE_SAFE if (!m_impl) { @@ -114,41 +138,40 @@ bool NzDirectory::NextResult(bool skipDots) } #endif - if (skipDots) + NzString name; + do { - NzString name; - do - { - if (!m_impl->NextResult()) - return false; + if (!m_impl->NextResult()) + return false; - name = m_impl->GetResultName(); - } - while (name == '.' || name == ".."); + name = m_impl->GetResultName(); - return true; + if (skipDots && (name == '.' || name == "..")) + continue; + + if (name.Match(m_pattern)) + break; } - else - return m_impl->NextResult(); + while (true); + + return true; } bool NzDirectory::Open() { + NazaraLock(m_mutex); + Close(); if (!Exists(m_dirPath)) return false; - NazaraMutexLock(m_mutex); - m_impl = new NzDirectoryImpl(this); if (!m_impl->Open(m_dirPath)) { delete m_impl; m_impl = nullptr; - NazaraMutexUnlock(m_mutex); - return false; } @@ -157,11 +180,20 @@ bool NzDirectory::Open() void NzDirectory::SetDirectory(const NzString& dirPath) { + NazaraLock(m_mutex); + Close(); m_dirPath = NzFile::AbsolutePath(dirPath); } +void NzDirectory::SetPattern(const NzString& pattern) +{ + NazaraLock(m_mutex); + + m_pattern = pattern; +} + bool NzDirectory::Copy(const NzString& sourcePath, const NzString& destPath) { if (sourcePath.IsEmpty() || destPath.IsEmpty()) @@ -187,12 +219,12 @@ bool NzDirectory::Copy(const NzString& sourcePath, const NzString& destPath) { if (dir.IsResultDirectory()) { - if (!Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName())) + if (!Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName())) return false; } else if (!NzFile::Copy(dir.GetResultPath(), dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName())) { - NazaraError("Unable to copy \"" + dir.GetResultPath() + "\" to \"" + dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName() + '"'); + NazaraError("Failed to copy \"" + dir.GetResultPath() + "\" to \"" + dest + NAZARA_DIRECTORY_SEPARATOR + dir.GetResultName() + '"'); return false; } } diff --git a/src/Nazara/Core/Error.cpp b/src/Nazara/Core/Error.cpp index ad5c87091..a81012b2e 100644 --- a/src/Nazara/Core/Error.cpp +++ b/src/Nazara/Core/Error.cpp @@ -42,7 +42,7 @@ NzString NzGetLastSystemError(unsigned int code) wchar_t* buffer = nullptr; FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, - 0, + nullptr, code, 0, reinterpret_cast(&buffer), diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 4b88e957f..6a4d8ae20 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -45,7 +45,7 @@ m_openMode(0) Open(openMode); } -NzFile::NzFile(NzFile&& file) : +NzFile::NzFile(NzFile&& file) noexcept : m_endianness(file.m_endianness), m_filePath(std::move(file.m_filePath)), m_impl(file.m_impl), @@ -525,7 +525,7 @@ NzFile& NzFile::operator=(const NzString& filePath) return *this; } -NzFile& NzFile::operator=(NzFile&& file) +NzFile& NzFile::operator=(NzFile&& file) noexcept { NazaraLock(m_mutex) @@ -570,7 +570,7 @@ NzString NzFile::AbsolutePath(const NzString& filePath) NazaraError("Path unrecognized"); return path; } - #elif NAZARA_PLATEFORM_LINUX + #elif defined(NAZARA_PLATEFORM_LINUX) base = '/'; start = 0; #else @@ -718,7 +718,7 @@ bool NzFile::IsAbsolute(const NzString& path) return true; else return false; - #elif NAZARA_PLATEFORM_LINUX + #elif defined(NAZARA_PLATEFORM_LINUX) return wpath.StartsWith('/'); #else #error OS case not implemented @@ -752,7 +752,7 @@ NzString NzFile::NormalizeSeparators(const NzString& filePath) #elif defined(NAZARA_PLATFORM_LINUX) path.Replace('\\', '/'); #else - #error OS not handled + #error OS case not implemented #endif return path; @@ -793,4 +793,4 @@ bool NzFile::FillHash(NzHashImpl* hash) const } return true; -} // Fermeture auttomatique du fichier +} // Fermeture automatique du fichier diff --git a/src/Nazara/Core/Hash/MD5.cpp b/src/Nazara/Core/Hash/MD5.cpp index 6570fc8cc..3095746e0 100644 --- a/src/Nazara/Core/Hash/MD5.cpp +++ b/src/Nazara/Core/Hash/MD5.cpp @@ -136,7 +136,7 @@ namespace * On little-endian machines, we can process properly aligned * data without copying it. */ - if (!((data - reinterpret_cast(0)) & 3)) + if (!(data - static_cast(nullptr)) & 3) { /* data are properly aligned */ X = reinterpret_cast(data); diff --git a/src/Nazara/Core/Hash/SHA/Internal.cpp b/src/Nazara/Core/Hash/SHA/Internal.cpp index 734de4ede..40f9fcd68 100644 --- a/src/Nazara/Core/Hash/SHA/Internal.cpp +++ b/src/Nazara/Core/Hash/SHA/Internal.cpp @@ -315,119 +315,122 @@ void SHA1_Init(SHA_CTX* context) (b) = ROTL32(30, b); \ j++; -void SHA1_Internal_Transform(SHA_CTX* context, const nzUInt32* data) +namespace { - nzUInt32 a, b, c, d, e; - nzUInt32 T1, *W1; - int j; + void SHA1_Internal_Transform(SHA_CTX* context, const nzUInt32* data) + { + nzUInt32 a, b, c, d, e; + nzUInt32 T1, *W1; + int j; - W1 = reinterpret_cast(context->s1.buffer); + W1 = reinterpret_cast(context->s1.buffer); - /* Initialize registers with the prev. intermediate value */ - a = context->s1.state[0]; - b = context->s1.state[1]; - c = context->s1.state[2]; - d = context->s1.state[3]; - e = context->s1.state[4]; + /* Initialize registers with the prev. intermediate value */ + a = context->s1.state[0]; + b = context->s1.state[1]; + c = context->s1.state[2]; + d = context->s1.state[3]; + e = context->s1.state[4]; - j = 0; + j = 0; - /* Rounds 0 to 15 unrolled: */ - ROUND1_0_TO_15(a,b,c,d,e); - ROUND1_0_TO_15(e,a,b,c,d); - ROUND1_0_TO_15(d,e,a,b,c); - ROUND1_0_TO_15(c,d,e,a,b); - ROUND1_0_TO_15(b,c,d,e,a); - ROUND1_0_TO_15(a,b,c,d,e); - ROUND1_0_TO_15(e,a,b,c,d); - ROUND1_0_TO_15(d,e,a,b,c); - ROUND1_0_TO_15(c,d,e,a,b); - ROUND1_0_TO_15(b,c,d,e,a); - ROUND1_0_TO_15(a,b,c,d,e); - ROUND1_0_TO_15(e,a,b,c,d); - ROUND1_0_TO_15(d,e,a,b,c); - ROUND1_0_TO_15(c,d,e,a,b); - ROUND1_0_TO_15(b,c,d,e,a); - ROUND1_0_TO_15(a,b,c,d,e); + /* Rounds 0 to 15 unrolled: */ + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); - /* Rounds 16 to 19 unrolled: */ - ROUND1_16_TO_19(e,a,b,c,d); - ROUND1_16_TO_19(d,e,a,b,c); - ROUND1_16_TO_19(c,d,e,a,b); - ROUND1_16_TO_19(b,c,d,e,a); + /* Rounds 16 to 19 unrolled: */ + ROUND1_16_TO_19(e,a,b,c,d); + ROUND1_16_TO_19(d,e,a,b,c); + ROUND1_16_TO_19(c,d,e,a,b); + ROUND1_16_TO_19(b,c,d,e,a); - /* Rounds 20 to 39 unrolled: */ - ROUND1_20_TO_39(a,b,c,d,e); - ROUND1_20_TO_39(e,a,b,c,d); - ROUND1_20_TO_39(d,e,a,b,c); - ROUND1_20_TO_39(c,d,e,a,b); - ROUND1_20_TO_39(b,c,d,e,a); - ROUND1_20_TO_39(a,b,c,d,e); - ROUND1_20_TO_39(e,a,b,c,d); - ROUND1_20_TO_39(d,e,a,b,c); - ROUND1_20_TO_39(c,d,e,a,b); - ROUND1_20_TO_39(b,c,d,e,a); - ROUND1_20_TO_39(a,b,c,d,e); - ROUND1_20_TO_39(e,a,b,c,d); - ROUND1_20_TO_39(d,e,a,b,c); - ROUND1_20_TO_39(c,d,e,a,b); - ROUND1_20_TO_39(b,c,d,e,a); - ROUND1_20_TO_39(a,b,c,d,e); - ROUND1_20_TO_39(e,a,b,c,d); - ROUND1_20_TO_39(d,e,a,b,c); - ROUND1_20_TO_39(c,d,e,a,b); - ROUND1_20_TO_39(b,c,d,e,a); + /* Rounds 20 to 39 unrolled: */ + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); - /* Rounds 40 to 59 unrolled: */ - ROUND1_40_TO_59(a,b,c,d,e); - ROUND1_40_TO_59(e,a,b,c,d); - ROUND1_40_TO_59(d,e,a,b,c); - ROUND1_40_TO_59(c,d,e,a,b); - ROUND1_40_TO_59(b,c,d,e,a); - ROUND1_40_TO_59(a,b,c,d,e); - ROUND1_40_TO_59(e,a,b,c,d); - ROUND1_40_TO_59(d,e,a,b,c); - ROUND1_40_TO_59(c,d,e,a,b); - ROUND1_40_TO_59(b,c,d,e,a); - ROUND1_40_TO_59(a,b,c,d,e); - ROUND1_40_TO_59(e,a,b,c,d); - ROUND1_40_TO_59(d,e,a,b,c); - ROUND1_40_TO_59(c,d,e,a,b); - ROUND1_40_TO_59(b,c,d,e,a); - ROUND1_40_TO_59(a,b,c,d,e); - ROUND1_40_TO_59(e,a,b,c,d); - ROUND1_40_TO_59(d,e,a,b,c); - ROUND1_40_TO_59(c,d,e,a,b); - ROUND1_40_TO_59(b,c,d,e,a); + /* Rounds 40 to 59 unrolled: */ + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); - /* Rounds 60 to 79 unrolled: */ - ROUND1_60_TO_79(a,b,c,d,e); - ROUND1_60_TO_79(e,a,b,c,d); - ROUND1_60_TO_79(d,e,a,b,c); - ROUND1_60_TO_79(c,d,e,a,b); - ROUND1_60_TO_79(b,c,d,e,a); - ROUND1_60_TO_79(a,b,c,d,e); - ROUND1_60_TO_79(e,a,b,c,d); - ROUND1_60_TO_79(d,e,a,b,c); - ROUND1_60_TO_79(c,d,e,a,b); - ROUND1_60_TO_79(b,c,d,e,a); - ROUND1_60_TO_79(a,b,c,d,e); - ROUND1_60_TO_79(e,a,b,c,d); - ROUND1_60_TO_79(d,e,a,b,c); - ROUND1_60_TO_79(c,d,e,a,b); - ROUND1_60_TO_79(b,c,d,e,a); - ROUND1_60_TO_79(a,b,c,d,e); - ROUND1_60_TO_79(e,a,b,c,d); - ROUND1_60_TO_79(d,e,a,b,c); - ROUND1_60_TO_79(c,d,e,a,b); - ROUND1_60_TO_79(b,c,d,e,a); + /* Rounds 60 to 79 unrolled: */ + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); - /* Compute the current intermediate hash value */ - context->s1.state[0] += a; - context->s1.state[1] += b; - context->s1.state[2] += c; - context->s1.state[3] += d; - context->s1.state[4] += e; + /* Compute the current intermediate hash value */ + context->s1.state[0] += a; + context->s1.state[1] += b; + context->s1.state[2] += c; + context->s1.state[3] += d; + context->s1.state[4] += e; + } } void SHA1_Update(SHA_CTX* context, const nzUInt8* data, std::size_t len) @@ -766,9 +769,12 @@ void SHA224_Init(SHA_CTX* context) SHA256_Internal_Init(context, sha224_initial_hash_value); } -void SHA224_Internal_Transform(SHA_CTX* context, const nzUInt32* data) +namespace { - SHA256_Internal_Transform(context, data); + void SHA224_Internal_Transform(SHA_CTX* context, const nzUInt32* data) + { + SHA256_Internal_Transform(context, data); + } } void SHA224_Update(SHA_CTX* context, const nzUInt8 *data, std::size_t len) diff --git a/src/Nazara/Core/HashDigest.cpp b/src/Nazara/Core/HashDigest.cpp index e41666b55..d86a0e53f 100644 --- a/src/Nazara/Core/HashDigest.cpp +++ b/src/Nazara/Core/HashDigest.cpp @@ -42,7 +42,7 @@ m_digestLength(rhs.m_digestLength) m_digest = nullptr; } -NzHashDigest::NzHashDigest(NzHashDigest&& rhs) : +NzHashDigest::NzHashDigest(NzHashDigest&& rhs) noexcept : m_hashName(std::move(rhs.m_hashName)), m_digest(rhs.m_digest), m_digestLength(rhs.m_digestLength) @@ -118,7 +118,7 @@ NzHashDigest& NzHashDigest::operator=(const NzHashDigest& rhs) return *this; } -NzHashDigest& NzHashDigest::operator=(NzHashDigest&& rhs) +NzHashDigest& NzHashDigest::operator=(NzHashDigest&& rhs) noexcept { std::swap(m_hashName, rhs.m_hashName); std::swap(m_digest, rhs.m_digest); diff --git a/src/Nazara/Core/Log.cpp b/src/Nazara/Core/Log.cpp index 6c7ea1cf8..946182d62 100644 --- a/src/Nazara/Core/Log.cpp +++ b/src/Nazara/Core/Log.cpp @@ -8,8 +8,9 @@ #include #include #include +#include -#if NAZARA_CORE_REDIRECT_TO_CERR_ON_LOG_FAILURE +#if NAZARA_CORE_DUPLICATE_TO_COUT #include #endif @@ -17,7 +18,7 @@ namespace { - NzString errorType[] = { + const char* errorType[] = { "Assert failed: ", // nzErrorType_AssertFailed "Internal error: ", // nzErrorType_Internal "Error: ", // nzErrorType_Normal @@ -124,12 +125,11 @@ void NzLog::Write(const NzString& string) line += string; line += '\n'; - #if NAZARA_CORE_REDIRECT_TO_CERR_ON_LOG_FAILURE - if (!m_file->IsOpen() || !m_file->Write(line)) - std::fputs(line.GetBuffer(), stderr); - #else if (m_file->IsOpen()) m_file->Write(line); + + #if NAZARA_CORE_DUPLICATE_TO_COUT + std::fputs(line.GetConstBuffer(), stderr); #endif } } @@ -137,7 +137,7 @@ void NzLog::Write(const NzString& string) void NzLog::WriteError(nzErrorType type, const NzString& error, unsigned int line, const NzString& file, const NzString& func) { NzString stream; - stream.Reserve(errorType[type].GetSize() + error.GetSize() + 2 + file.GetSize() + 1 + NzGetNumberLength(line) +2 + func.GetSize() + 1); + stream.Reserve(std::strlen(errorType[type]) + error.GetSize() + 2 + file.GetSize() + 1 + NzGetNumberLength(line) +2 + func.GetSize() + 1); stream += errorType[type]; stream += error; stream += " ("; diff --git a/src/Nazara/Utility/Resource.cpp b/src/Nazara/Core/Resource.cpp similarity index 88% rename from src/Nazara/Utility/Resource.cpp rename to src/Nazara/Core/Resource.cpp index 7e7a06c1a..810d02e0a 100644 --- a/src/Nazara/Utility/Resource.cpp +++ b/src/Nazara/Core/Resource.cpp @@ -2,10 +2,10 @@ // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include +#include #include -#include -#include +#include NzResource::NzResource(bool persistent) : m_resourcePersistent(persistent), @@ -33,7 +33,7 @@ bool NzResource::IsPersistent() const void NzResource::RemoveResourceReference() const { - #if NAZARA_UTILITY_SAFE + #if NAZARA_CORE_SAFE if (m_resourceReferenceCount == 0) { NazaraError("Impossible to remove reference (Ref. counter is already 0)"); diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index b983ed9e7..40642cb4e 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -142,7 +142,7 @@ m_sharedString(string.m_sharedString) } } -NzString::NzString(NzString&& string) : +NzString::NzString(NzString&& string) noexcept : m_sharedString(string.m_sharedString) { string.m_sharedString = &emptyString; @@ -307,7 +307,6 @@ unsigned int NzString::Count(char character, int start, nzUInt32 flags) const { char character_lower = nzToLower(character); char character_upper = nzToUpper(character); - unsigned int count = 0; do { if (*str == character_lower || *str == character_upper) @@ -807,14 +806,14 @@ unsigned int NzString::Find(const char* string, int start, nzUInt32 flags) const { if (NzUnicode::GetLowercase(*it) == c) { - const char* pos = it.base(); + const char* ptrPos = it.base(); ++it; utf8::unchecked::iterator it2(t); while (true) { if (*it2 == '\0') - return static_cast(pos - m_sharedString->string); + return static_cast(ptrPos - m_sharedString->string); if (*it == '\0') return npos; @@ -836,14 +835,14 @@ unsigned int NzString::Find(const char* string, int start, nzUInt32 flags) const { if (nzToLower(*str) == c) { - char* pos = str; + char* ptrPos = str; str++; const char* ptr = &string[1]; while (true) { if (*ptr == '\0') - return static_cast(pos - m_sharedString->string); + return static_cast(ptrPos - m_sharedString->string); if (*str == '\0') return npos; @@ -897,14 +896,14 @@ unsigned int NzString::Find(const NzString& string, int start, nzUInt32 flags) c { if (NzUnicode::GetLowercase(*it) == c) { - const char* pos = it.base(); + const char* ptrPos = it.base(); ++it; utf8::unchecked::iterator it2(t); while (true) { if (*it2 == '\0') - return static_cast(pos - m_sharedString->string); + return static_cast(ptrPos - m_sharedString->string); if (*it == '\0') return npos; @@ -926,14 +925,14 @@ unsigned int NzString::Find(const NzString& string, int start, nzUInt32 flags) c { if (nzToLower(*str) == c) { - char* pos = str; + char* ptrPos = str; str++; const char* ptr = &string.m_sharedString->string[1]; while (true) { if (*ptr == '\0') - return static_cast(pos - m_sharedString->string); + return static_cast(ptrPos - m_sharedString->string); if (*str == '\0') return npos; @@ -2296,7 +2295,7 @@ char16_t* NzString::GetUtf16Buffer(unsigned int* size) const catch (const utf8::exception& exception) { NazaraError("UTF-8 error : " + NzString(exception.what())); - return 0; + return nullptr; } #endif @@ -2340,7 +2339,7 @@ char32_t* NzString::GetUtf32Buffer(unsigned int* size) const catch (const utf8::exception& exception) { NazaraError("UTF-8 error : " + NzString(exception.what())); - return 0; + return nullptr; } #endif } @@ -2387,7 +2386,7 @@ wchar_t* NzString::GetWideBuffer(unsigned int* size) const catch (const utf8::exception& exception) { NazaraError("UTF-8 error : " + NzString(exception.what())); - return 0; + return nullptr; } #endif } @@ -2621,7 +2620,7 @@ bool NzString::IsNull() const bool NzString::IsNumber(nzUInt8 base, nzUInt32 flags) const { - #if !NAZARA_UNSAFE + #if NAZARA_CORE_SAFE if (base < 2 || base > 36) { NazaraError("Base must be between 2 and 36"); @@ -2770,11 +2769,11 @@ unsigned int NzString::Replace(char oldCharacter, char newCharacter, int start, { if (!found) { - unsigned int pos = ptr-m_sharedString->string; + unsigned int offset = ptr-m_sharedString->string; EnsureOwnership(); - ptr = &m_sharedString->string[pos]; + ptr = &m_sharedString->string[offset]; found = true; } @@ -2790,11 +2789,11 @@ unsigned int NzString::Replace(char oldCharacter, char newCharacter, int start, { if (!found) { - unsigned int pos = ptr-m_sharedString->string; + unsigned int offset = ptr-m_sharedString->string; EnsureOwnership(); - ptr = &m_sharedString->string[pos]; + ptr = &m_sharedString->string[offset]; found = true; } @@ -2954,6 +2953,7 @@ unsigned int NzString::Replace(const NzString& oldString, const NzString& replac unsigned int NzString::ReplaceAny(const char* oldCharacters, char replaceCharacter, int start, nzUInt32 flags) { + ///FIXME: Ne gère pas l'UTF-8 if (!oldCharacters || !oldCharacters[0]) return 0; @@ -2982,11 +2982,11 @@ unsigned int NzString::ReplaceAny(const char* oldCharacters, char replaceCharact { if (!found) { - unsigned int pos = ptr-m_sharedString->string; + unsigned int offset = ptr-m_sharedString->string; EnsureOwnership(); - ptr = &m_sharedString->string[pos]; + ptr = &m_sharedString->string[offset]; found = true; } @@ -3006,11 +3006,11 @@ unsigned int NzString::ReplaceAny(const char* oldCharacters, char replaceCharact { if (!found) { - unsigned int pos = ptr-m_sharedString->string; + unsigned int offset = ptr-m_sharedString->string; EnsureOwnership(); - ptr = &m_sharedString->string[pos]; + ptr = &m_sharedString->string[offset]; found = true; } @@ -3203,7 +3203,10 @@ void NzString::Reserve(unsigned int bufferSize) NzString& NzString::Resize(int size, char character) { if (size == 0) + { Clear(true); + return *this; + } if (size < 0) size = std::max(static_cast(m_sharedString->size + size), 0); @@ -3249,9 +3252,6 @@ NzString& NzString::Resize(int size, char character) NzString NzString::Resized(int size, char character) const { - if (size == 0) - return NzString(); - if (size < 0) size = m_sharedString->size + size; @@ -3692,12 +3692,12 @@ NzString NzString::Substr(int startPos, int endPos) const return NzString(); } - unsigned int end = std::min(static_cast(endPos), m_sharedString->size-1); + unsigned int minEnd = std::min(static_cast(endPos), m_sharedString->size-1); - if (start > end || start >= m_sharedString->size) + if (start > minEnd || start >= m_sharedString->size) return NzString(); - unsigned int size = end-start+1; + unsigned int size = minEnd-start+1; char* str = new char[size+1]; std::memcpy(str, &m_sharedString->string[start], size*sizeof(char)); str[size] = '\0'; @@ -4232,7 +4232,7 @@ NzString& NzString::operator=(const NzString& string) return *this; } -NzString& NzString::operator=(NzString&& string) +NzString& NzString::operator=(NzString&& string) noexcept { std::swap(m_sharedString, string.m_sharedString); @@ -5107,7 +5107,6 @@ void NzString::ReleaseString() if (freeSharedString) { - NazaraMutexUnlock(m_sharedString->mutex); delete[] m_sharedString->string; delete m_sharedString; } diff --git a/src/Nazara/Core/Win32/ThreadConditionImpl.cpp b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp similarity index 80% rename from src/Nazara/Core/Win32/ThreadConditionImpl.cpp rename to src/Nazara/Core/Win32/ConditionVariableImpl.cpp index 53d8a07d2..76cdf8cd9 100644 --- a/src/Nazara/Core/Win32/ThreadConditionImpl.cpp +++ b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp @@ -4,13 +4,13 @@ // Source: http://www.cs.wustl.edu/~schmidt/win32-cv-1.html -#include +#include #include #include -NzThreadConditionImpl::NzThreadConditionImpl() +NzConditionVariableImpl::NzConditionVariableImpl() { - #ifdef NAZARA_PLATFORM_WINDOWSVISTA + #if NAZARA_CORE_WINDOWS_VISTA InitializeConditionVariable(&m_cv); #else m_count = 0; @@ -20,16 +20,16 @@ NzThreadConditionImpl::NzThreadConditionImpl() #endif } -#ifndef NAZARA_PLATFORM_WINDOWSVISTA -NzThreadConditionImpl::~NzThreadConditionImpl() +#if !NAZARA_CORE_WINDOWS_VISTA +NzConditionVariableImpl::~NzConditionVariableImpl() { DeleteCriticalSection(&m_countLock); } #endif -void NzThreadConditionImpl::Signal() +void NzConditionVariableImpl::Signal() { - #ifdef NAZARA_PLATFORM_WINDOWSVISTA + #if NAZARA_CORE_WINDOWS_VISTA WakeConditionVariable(&m_cv); #else // Avoid race conditions. @@ -42,9 +42,9 @@ void NzThreadConditionImpl::Signal() #endif } -void NzThreadConditionImpl::SignalAll() +void NzConditionVariableImpl::SignalAll() { - #ifdef NAZARA_PLATFORM_WINDOWSVISTA + #if NAZARA_CORE_WINDOWS_VISTA WakeAllConditionVariable(&m_cv); #else // Avoid race conditions. @@ -57,14 +57,14 @@ void NzThreadConditionImpl::SignalAll() #endif } -void NzThreadConditionImpl::Wait(NzMutexImpl* mutex) +void NzConditionVariableImpl::Wait(NzMutexImpl* mutex) { Wait(mutex, INFINITE); } -bool NzThreadConditionImpl::Wait(NzMutexImpl* mutex, nzUInt32 timeout) +bool NzConditionVariableImpl::Wait(NzMutexImpl* mutex, nzUInt32 timeout) { - #ifdef NAZARA_PLATFORM_WINDOWSVISTA + #if NAZARA_CORE_WINDOWS_VISTA return SleepConditionVariableCS(&m_cv, mutex->m_criticalSection, timeout); #else // Avoid race conditions. diff --git a/src/Nazara/Core/Win32/ThreadConditionImpl.hpp b/src/Nazara/Core/Win32/ConditionVariableImpl.hpp similarity index 67% rename from src/Nazara/Core/Win32/ThreadConditionImpl.hpp rename to src/Nazara/Core/Win32/ConditionVariableImpl.hpp index cf2fb3b8f..f4afa4545 100644 --- a/src/Nazara/Core/Win32/ThreadConditionImpl.hpp +++ b/src/Nazara/Core/Win32/ConditionVariableImpl.hpp @@ -6,22 +6,22 @@ #pragma once -#ifndef NAZARA_THREADCONDITIONIMPL_HPP -#define NAZARA_THREADCONDITIONIMPL_HPP +#ifndef NAZARA_CONDITIONVARIABLEIMPL_HPP +#define NAZARA_CONDITIONVARIABLEIMPL_HPP #include #include class NzMutexImpl; -class NzThreadConditionImpl +class NzConditionVariableImpl { public: - NzThreadConditionImpl(); - #ifdef NAZARA_PLATFORM_WINDOWSVISTA - ~NzThreadConditionImpl() = default; + NzConditionVariableImpl(); + #if NAZARA_CORE_WINDOWS_VISTA + ~NzConditionVariableImpl() = default; #else - ~NzThreadConditionImpl(); + ~NzConditionVariableImpl(); #endif void Signal(); @@ -31,7 +31,7 @@ class NzThreadConditionImpl bool Wait(NzMutexImpl* mutex, nzUInt32 timeout); private: - #ifdef NAZARA_PLATFORM_WINDOWSVISTA + #if NAZARA_CORE_WINDOWS_VISTA CONDITION_VARIABLE m_cv; #else enum @@ -48,4 +48,4 @@ class NzThreadConditionImpl }; -#endif // NAZARA_THREADCONDITIONIMPL_HPP +#endif // NAZARA_CONDITIONVARIABLEIMPL_HPP diff --git a/src/Nazara/Core/Win32/FileImpl.cpp b/src/Nazara/Core/Win32/FileImpl.cpp index b93ca618e..6154b1b65 100644 --- a/src/Nazara/Core/Win32/FileImpl.cpp +++ b/src/Nazara/Core/Win32/FileImpl.cpp @@ -117,7 +117,7 @@ std::size_t NzFileImpl::Read(void* buffer, std::size_t size) /// D'après les tests, ce n'est pas le cas, la taille lue est inférieure à la taille en argument, mais pas nulle /// Peut-être ais-je mal compris la documentation /// Le correctif (dans le cas où la doc serait vraie) est commenté en début de fonction et après ce commentaire - /// Il est cependant plus lourd, et ne fonctionne pas selon les tests... + /// Il est cependant plus lourd, et ne fonctionne pas avec le comportement observé de la fonction /* if (read == 0) { @@ -254,7 +254,7 @@ time_t NzFileImpl::GetCreationTime(const NzString& filePath) CloseHandle(handle); - return FileTimeToTime(&creationTime); + return NzFileTimeToTime(&creationTime); } time_t NzFileImpl::GetLastAccessTime(const NzString& filePath) @@ -277,7 +277,7 @@ time_t NzFileImpl::GetLastAccessTime(const NzString& filePath) CloseHandle(handle); - return FileTimeToTime(&accessTime); + return NzFileTimeToTime(&accessTime); } time_t NzFileImpl::GetLastWriteTime(const NzString& filePath) @@ -300,7 +300,7 @@ time_t NzFileImpl::GetLastWriteTime(const NzString& filePath) CloseHandle(handle); - return FileTimeToTime(&writeTime); + return NzFileTimeToTime(&writeTime); } nzUInt64 NzFileImpl::GetSize(const NzString& filePath) diff --git a/src/Nazara/Core/Win32/MutexImpl.cpp b/src/Nazara/Core/Win32/MutexImpl.cpp index d37568955..9bebb187c 100644 --- a/src/Nazara/Core/Win32/MutexImpl.cpp +++ b/src/Nazara/Core/Win32/MutexImpl.cpp @@ -7,7 +7,11 @@ NzMutexImpl::NzMutexImpl() { + #if NAZARA_CORE_WINDOWS_CS_SPINLOCKS > 0 + InitializeCriticalSectionAndSpinCount(&m_criticalSection, NAZARA_CORE_WINDOWS_CS_SPINLOCKS); + #else InitializeCriticalSection(&m_criticalSection); + #endif } NzMutexImpl::~NzMutexImpl() diff --git a/src/Nazara/Core/Win32/MutexImpl.hpp b/src/Nazara/Core/Win32/MutexImpl.hpp index 5b01e7864..6356f9e9e 100644 --- a/src/Nazara/Core/Win32/MutexImpl.hpp +++ b/src/Nazara/Core/Win32/MutexImpl.hpp @@ -9,11 +9,11 @@ #include -class NzThreadConditionImpl; +class NzConditionVariableImpl; class NzMutexImpl { - friend class NzThreadConditionImpl; + friend class NzConditionVariableImpl; public: NzMutexImpl(); diff --git a/src/Nazara/Core/Win32/Time.cpp b/src/Nazara/Core/Win32/Time.cpp new file mode 100644 index 000000000..23643d39e --- /dev/null +++ b/src/Nazara/Core/Win32/Time.cpp @@ -0,0 +1,24 @@ +// 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 + +time_t NzFileTimeToTime(FILETIME* time) +{ + SYSTEMTIME stUTC, stLocal; + + FileTimeToSystemTime(time, &stUTC); + SystemTimeToTzSpecificLocalTime(nullptr, &stUTC, &stLocal); + + std::tm timeinfo; + timeinfo.tm_sec = stLocal.wSecond; + timeinfo.tm_min = stLocal.wMinute; + timeinfo.tm_hour = stLocal.wHour; + timeinfo.tm_mday = stLocal.wDay; + timeinfo.tm_mon = stLocal.wMonth-1; + timeinfo.tm_year = stLocal.wYear-1900; + timeinfo.tm_isdst = -1; + + return std::mktime(&timeinfo); +} diff --git a/src/Nazara/Core/Win32/Time.hpp b/src/Nazara/Core/Win32/Time.hpp index 63d2aca26..952c2f240 100644 --- a/src/Nazara/Core/Win32/Time.hpp +++ b/src/Nazara/Core/Win32/Time.hpp @@ -10,23 +10,6 @@ #include #include -time_t FileTimeToTime(FILETIME* time) -{ - SYSTEMTIME stUTC, stLocal; - - FileTimeToSystemTime(time, &stUTC); - SystemTimeToTzSpecificLocalTime(nullptr, &stUTC, &stLocal); - - std::tm timeinfo; - timeinfo.tm_sec = stLocal.wSecond; - timeinfo.tm_min = stLocal.wMinute; - timeinfo.tm_hour = stLocal.wHour; - timeinfo.tm_mday = stLocal.wDay; - timeinfo.tm_mon = stLocal.wMonth-1; - timeinfo.tm_year = stLocal.wYear-1900; - timeinfo.tm_isdst = -1; - - return std::mktime(&timeinfo); -} +time_t NzFileTimeToTime(FILETIME* time); #endif // NAZARA_WINDOWS_TIME_HPP diff --git a/src/Nazara/Network/Debug/Leaks.cpp b/src/Nazara/Network/Debug/Leaks.cpp deleted file mode 100644 index 403a969d7..000000000 --- a/src/Nazara/Network/Debug/Leaks.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// 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 -#if NAZARA_NETWORK_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG) -#include -#include - -void* operator new(std::size_t size) -{ - return NzMemoryManager::Allocate(size, false); -} - -void* operator new[](std::size_t size) -{ - return NzMemoryManager::Allocate(size, true); -} - -void operator delete(void* pointer) noexcept -{ - NzMemoryManager::Free(pointer, false); -} - -void operator delete[](void* pointer) noexcept -{ - NzMemoryManager::Free(pointer, true); -} -#endif diff --git a/src/Nazara/Noise/Noise.cpp b/src/Nazara/Noise/Noise.cpp index 8d5dd92f5..a5d1b00ed 100644 --- a/src/Nazara/Noise/Noise.cpp +++ b/src/Nazara/Noise/Noise.cpp @@ -3,57 +3,47 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include +#include #include #include -NzNoise::NzNoise() -{ -} - -NzNoise::~NzNoise() -{ - if (s_initialized) - Uninitialize(); -} - bool NzNoise::Initialize() { - #if NAZARA_NOISE_SAFE - if (s_initialized) + if (s_moduleReferenceCouter++ != 0) + return true; // Déjà initialisé + + // Initialisation des dépendances + if (!NzCore::Initialize()) { - NazaraError("NzNoise already initialized"); - return true; + NazaraError("Failed to initialize core module"); + return false; } - #endif // Initialisation du module - s_initialized = true; + NazaraNotice("Initialized: Noise module"); return true; } +bool NzNoise::IsInitialized() +{ + return s_moduleReferenceCouter != 0; +} + void NzNoise::Uninitialize() { - #if NAZARA_NOISE_SAFE - if (!s_initialized) - { - NazaraError("NzNoise not initialized"); - return; - } - #endif + if (--s_moduleReferenceCouter != 0) + return; // Encore utilisé // Libération du module - s_initialized = false; + // Libération des dépendances + NzCore::Uninitialize(); + + NazaraNotice("Uninitialized: Noise module"); } -bool NzNoise::IsInitialized() -{ - return s_initialized; -} - -bool NzNoise::s_initialized = false; - -//#include //A INCLURE ? +unsigned int NzNoise::s_moduleReferenceCouter = 0; diff --git a/src/Nazara/Renderer/GLSLShader.cpp b/src/Nazara/Renderer/GLSLShader.cpp index b5d37d905..aa17c7ede 100644 --- a/src/Nazara/Renderer/GLSLShader.cpp +++ b/src/Nazara/Renderer/GLSLShader.cpp @@ -63,11 +63,22 @@ bool NzGLSLShader::Bind() glUseProgram(m_program); + return true; +} + +bool NzGLSLShader::BindTextures() +{ for (auto it = m_textures.begin(); it != m_textures.end(); ++it) { - glActiveTexture(GL_TEXTURE0 + it->second.unit); - if (!it->second.texture->Bind()) - NazaraWarning("Failed to bind texture"); + TextureSlot& slot = it->second; + if (!slot.updated) + { + glActiveTexture(GL_TEXTURE0 + slot.unit); + if (!slot.texture->Bind()) + NazaraWarning("Failed to bind texture"); + + slot.updated = true; + } } return true; @@ -78,6 +89,7 @@ bool NzGLSLShader::Compile() NzContext::EnsureContext(); m_idCache.clear(); + m_textures.clear(); glLinkProgram(m_program); @@ -86,8 +98,8 @@ bool NzGLSLShader::Compile() if (success == GL_TRUE) { - static NzString success("Linkage successful"); - m_log = success; + static NzString successStr("Linkage successful"); + m_log = successStr; return true; } @@ -131,7 +143,7 @@ bool NzGLSLShader::Create() glBindAttribLocation(m_program, attribIndex[nzElementUsage_Tangent], "Tangent"); NzString uniform = "TexCoord"; - unsigned int maxTexCoords = NazaraRenderer->GetMaxTextureUnits(); + unsigned int maxTexCoords = NzRenderer::GetMaxTextureUnits(); for (unsigned int i = 0; i < maxTexCoords; ++i) { NzString uniformName = uniform + NzString::Number(i); @@ -148,6 +160,9 @@ void NzGLSLShader::Destroy() { NzContext::EnsureContext(); + for (auto it = m_textures.begin(); it != m_textures.end(); ++it) + it->second.texture->RemoveResourceReference(); + for (GLuint shader : m_shaders) if (shader) glDeleteShader(shader); @@ -183,7 +198,7 @@ NzString NzGLSLShader::GetSourceCode(nzShaderType type) const return source; } -GLint NzGLSLShader::GetUniformLocation(const NzString& name) const +int NzGLSLShader::GetUniformLocation(const NzString& name) const { std::map::const_iterator it = m_idCache.find(name); GLint id; @@ -232,8 +247,8 @@ bool NzGLSLShader::Load(nzShaderType type, const NzString& source) glAttachShader(m_program, shader); m_shaders[type] = shader; - static NzString success("Compilation successful"); - m_log = success; + static NzString successStr("Compilation successful"); + m_log = successStr; return true; } @@ -280,226 +295,247 @@ bool NzGLSLShader::Lock() return true; } -bool NzGLSLShader::SendBoolean(const NzString& name, bool value) +bool NzGLSLShader::SendBoolean(int location, bool value) { if (glProgramUniform1i) - glProgramUniform1i(m_program, GetUniformLocation(name), value); + glProgramUniform1i(m_program, location, value); else { Lock(); - glUniform1i(GetUniformLocation(name), value); + glUniform1i(location, value); Unlock(); } return true; } -bool NzGLSLShader::SendDouble(const NzString& name, double value) +bool NzGLSLShader::SendDouble(int location, double value) { if (glProgramUniform1d) - glProgramUniform1d(m_program, GetUniformLocation(name), value); + glProgramUniform1d(m_program, location, value); else { Lock(); - glUniform1d(GetUniformLocation(name), value); + glUniform1d(location, value); Unlock(); } return true; } -bool NzGLSLShader::SendFloat(const NzString& name, float value) +bool NzGLSLShader::SendFloat(int location, float value) { if (glProgramUniform1f) - glProgramUniform1f(m_program, GetUniformLocation(name), value); + glProgramUniform1f(m_program, location, value); else { Lock(); - glUniform1f(GetUniformLocation(name), value); + glUniform1f(location, value); Unlock(); } return true; } -bool NzGLSLShader::SendInteger(const NzString& name, int value) +bool NzGLSLShader::SendInteger(int location, int value) { if (glProgramUniform1i) - glProgramUniform1i(m_program, GetUniformLocation(name), value); + glProgramUniform1i(m_program, location, value); else { Lock(); - glUniform1i(GetUniformLocation(name), value); + glUniform1i(location, value); Unlock(); } return true; } -bool NzGLSLShader::SendMatrix(const NzString& name, const NzMatrix4d& matrix) +bool NzGLSLShader::SendMatrix(int location, const NzMatrix4d& matrix) { if (glProgramUniformMatrix4dv) - glProgramUniformMatrix4dv(m_program, GetUniformLocation(name), 1, GL_FALSE, matrix); + glProgramUniformMatrix4dv(m_program, location, 1, GL_FALSE, matrix); else { Lock(); - glUniformMatrix4dv(GetUniformLocation(name), 1, GL_FALSE, matrix); + glUniformMatrix4dv(location, 1, GL_FALSE, matrix); Unlock(); } return true; } -bool NzGLSLShader::SendMatrix(const NzString& name, const NzMatrix4f& matrix) +bool NzGLSLShader::SendMatrix(int location, const NzMatrix4f& matrix) { if (glProgramUniformMatrix4fv) - glProgramUniformMatrix4fv(m_program, GetUniformLocation(name), 1, GL_FALSE, matrix); + glProgramUniformMatrix4fv(m_program, location, 1, GL_FALSE, matrix); else { Lock(); - glUniformMatrix4fv(GetUniformLocation(name), 1, GL_FALSE, matrix); + glUniformMatrix4fv(location, 1, GL_FALSE, matrix); Unlock(); } return true; } -bool NzGLSLShader::SendVector(const NzString& name, const NzVector2d& vector) +bool NzGLSLShader::SendTexture(int location, const NzTexture* texture) { - if (glProgramUniform2dv) - glProgramUniform2dv(m_program, GetUniformLocation(name), 1, vector); - else + auto it = m_textures.find(location); + if (it != m_textures.end()) { - Lock(); - glUniform2dv(GetUniformLocation(name), 1, vector); - Unlock(); - } - - return true; -} - -bool NzGLSLShader::SendVector(const NzString& name, const NzVector2f& vector) -{ - if (glProgramUniform2fv) - glProgramUniform2fv(m_program, GetUniformLocation(name), 1, vector); - else - { - Lock(); - glUniform2fv(GetUniformLocation(name), 1, vector); - Unlock(); - } - - return true; -} - -bool NzGLSLShader::SendVector(const NzString& name, const NzVector3d& vector) -{ - if (glProgramUniform3dv) - glProgramUniform3dv(m_program, GetUniformLocation(name), 1, vector); - else - { - Lock(); - glUniform3dv(GetUniformLocation(name), 1, vector); - Unlock(); - } - - return true; -} - -bool NzGLSLShader::SendVector(const NzString& name, const NzVector3f& vector) -{ - if (glProgramUniform3fv) - glProgramUniform3fv(m_program, GetUniformLocation(name), 1, vector); - else - { - Lock(); - glUniform3fv(GetUniformLocation(name), 1, vector); - Unlock(); - } - - return true; -} - -bool NzGLSLShader::SendVector(const NzString& name, const NzVector4d& vector) -{ - if (glProgramUniform4dv) - glProgramUniform4dv(m_program, GetUniformLocation(name), 1, vector); - else - { - Lock(); - glUniform4dv(GetUniformLocation(name), 1, vector); - Unlock(); - } - - return true; -} - -bool NzGLSLShader::SendVector(const NzString& name, const NzVector4f& vector) -{ - if (glProgramUniform4fv) - glProgramUniform4fv(m_program, GetUniformLocation(name), 1, vector); - else - { - Lock(); - glUniform4fv(GetUniformLocation(name), 1, vector); - Unlock(); - } - - return true; -} - -bool NzGLSLShader::SendTexture(const NzString& name, NzTexture* texture) -{ - static const unsigned int maxUnits = NazaraRenderer->GetMaxTextureUnits(); - - unsigned int unitUsed = m_textures.size(); - if (unitUsed >= maxUnits) - { - NazaraError("Unable to use texture \"" + name + "\" for shader: all available texture units are used"); - return false; - } - - // À partir d'ici nous savons qu'il y a au moins un identifiant de texture libre - GLint location = GetUniformLocation(name); - if (location == -1) - { - NazaraError("Parameter name \"" + name + "\" not found in shader"); - return false; - } - - nzUInt8 unit; - if (unitUsed == 0) - // Pas d'unité utilisée, la tâche est simple - unit = 0; - else - { - auto it = m_textures.rbegin(); // Itérateur vers la fin de la map - unit = it->second.unit; - if (unit == maxUnits-1) + // Slot déjà utilisé + TextureSlot& slot = it->second; + if (slot.texture != texture) { - // Il y a une place libre, mais pas à la fin - for (; it != m_textures.rend(); ++it) + slot.texture->RemoveResourceReference(); + + if (texture) { - if (unit - it->second.unit > 1) // Si l'espace entre les indices est supérieur à 1, alors il y a une place libre + slot.texture = texture; + slot.texture->AddResourceReference(); + + slot.updated = false; + } + else + m_textures.erase(it); // On supprime le slot + } + } + else + { + static const unsigned int maxUnits = NzRenderer::GetMaxTextureUnits(); + + unsigned int unitUsed = m_textures.size(); + if (unitUsed >= maxUnits) + { + NazaraError("Unable to use texture for shader: all available texture units are used"); + return false; + } + + // À partir d'ici nous savons qu'il y a au moins un identifiant de texture libre + nzUInt8 unit; + if (unitUsed == 0) + // Pas d'unité utilisée, la tâche est simple + unit = 0; + else + { + auto it2 = m_textures.rbegin(); // Itérateur vers la fin de la map + unit = it2->second.unit; + if (unit == maxUnits-1) + { + // Il y a une place libre, mais pas à la fin + for (; it2 != m_textures.rend(); ++it2) { - unit--; - break; + if (unit - it2->second.unit > 1) // Si l'espace entre les indices est supérieur à 1, alors il y a une place libre + { + unit--; + break; + } } } + else + // Il y a une place libre à la fin + unit++; } + + TextureSlot slot; + slot.unit = unit; + slot.texture = texture; + texture->AddResourceReference(); + + m_textures[location] = slot; + + if (glProgramUniform1i) + glProgramUniform1i(m_program, location, unit); else - // Il y a une place libre à la fin - unit++; + { + Lock(); + glUniform1i(location, unit); + Unlock(); + } } - m_textures[location] = TextureSlot{unit, texture}; + return true; +} - if (glProgramUniform1i) - glProgramUniform1i(m_program, location, unit); +bool NzGLSLShader::SendVector(int location, const NzVector2d& vector) +{ + if (glProgramUniform2dv) + glProgramUniform2dv(m_program, location, 1, vector); else { Lock(); - glUniform1i(location, unit); + glUniform2dv(location, 1, vector); + Unlock(); + } + + return true; +} + +bool NzGLSLShader::SendVector(int location, const NzVector2f& vector) +{ + if (glProgramUniform2fv) + glProgramUniform2fv(m_program, location, 1, vector); + else + { + Lock(); + glUniform2fv(location, 1, vector); + Unlock(); + } + + return true; +} + +bool NzGLSLShader::SendVector(int location, const NzVector3d& vector) +{ + if (glProgramUniform3dv) + glProgramUniform3dv(m_program, location, 1, vector); + else + { + Lock(); + glUniform3dv(location, 1, vector); + Unlock(); + } + + return true; +} + +bool NzGLSLShader::SendVector(int location, const NzVector3f& vector) +{ + if (glProgramUniform3fv) + glProgramUniform3fv(m_program, location, 1, vector); + else + { + Lock(); + glUniform3fv(location, 1, vector); + Unlock(); + } + + return true; +} + +bool NzGLSLShader::SendVector(int location, const NzVector4d& vector) +{ + if (glProgramUniform4dv) + glProgramUniform4dv(m_program, location, 1, vector); + else + { + Lock(); + glUniform4dv(location, 1, vector); + Unlock(); + } + + return true; +} + +bool NzGLSLShader::SendVector(int location, const NzVector4f& vector) +{ + if (glProgramUniform4fv) + glProgramUniform4fv(m_program, location, 1, vector); + else + { + Lock(); + glUniform4fv(location, 1, vector); Unlock(); } diff --git a/src/Nazara/Renderer/GLSLShader.hpp b/src/Nazara/Renderer/GLSLShader.hpp index f32d783ec..b429daced 100644 --- a/src/Nazara/Renderer/GLSLShader.hpp +++ b/src/Nazara/Renderer/GLSLShader.hpp @@ -20,35 +20,36 @@ class NzGLSLShader : public NzShaderImpl ~NzGLSLShader(); bool Bind(); + bool BindTextures(); bool Compile(); - bool Create(); + bool Create(); void Destroy(); NzString GetLog() const; nzShaderLanguage GetLanguage() const; NzString GetSourceCode(nzShaderType type) const; - GLint GetUniformLocation(const NzString& name) const; + int GetUniformLocation(const NzString& name) const; bool IsLoaded(nzShaderType type) const; bool Load(nzShaderType type, const NzString& source); bool Lock(); - bool SendBoolean(const NzString& name, bool value); - bool SendDouble(const NzString& name, double value); - bool SendFloat(const NzString& name, float value); - bool SendInteger(const NzString& name, int value); - bool SendMatrix(const NzString& name, const NzMatrix4d& matrix); - bool SendMatrix(const NzString& name, const NzMatrix4f& matrix); - bool SendVector(const NzString& name, const NzVector2d& vector); - bool SendVector(const NzString& name, const NzVector2f& vector); - bool SendVector(const NzString& name, const NzVector3d& vector); - bool SendVector(const NzString& name, const NzVector3f& vector); - bool SendVector(const NzString& name, const NzVector4d& vector); - bool SendVector(const NzString& name, const NzVector4f& vector); - bool SendTexture(const NzString& name, NzTexture* texture); + bool SendBoolean(int location, bool value); + bool SendDouble(int location, double value); + bool SendFloat(int location, float value); + bool SendInteger(int location, int value); + bool SendMatrix(int location, const NzMatrix4d& matrix); + bool SendMatrix(int location, const NzMatrix4f& matrix); + bool SendTexture(int location, const NzTexture* texture); + bool SendVector(int location, const NzVector2d& vector); + bool SendVector(int location, const NzVector2f& vector); + bool SendVector(int location, const NzVector3d& vector); + bool SendVector(int location, const NzVector3f& vector); + bool SendVector(int location, const NzVector4d& vector); + bool SendVector(int location, const NzVector4f& vector); void Unbind(); void Unlock(); @@ -56,8 +57,9 @@ class NzGLSLShader : public NzShaderImpl private: struct TextureSlot { + bool updated = false; nzUInt8 unit; - NzTexture* texture; + const NzTexture* texture; }; mutable std::map m_idCache; diff --git a/src/Nazara/Renderer/HardwareBuffer.cpp b/src/Nazara/Renderer/HardwareBuffer.cpp index af6401074..a56223103 100644 --- a/src/Nazara/Renderer/HardwareBuffer.cpp +++ b/src/Nazara/Renderer/HardwareBuffer.cpp @@ -52,14 +52,14 @@ namespace if (access == nzBufferAccess_DiscardAndWrite) { - GLint bufferSize; - glGetBufferParameteriv(bufferTargetBinding[type], GL_BUFFER_SIZE, &bufferSize); + GLint bufSize; + glGetBufferParameteriv(bufferTargetBinding[type], GL_BUFFER_SIZE, &bufSize); - GLint bufferUsage; - glGetBufferParameteriv(bufferTargetBinding[type], GL_BUFFER_USAGE, &bufferUsage); + GLint bufUsage; + glGetBufferParameteriv(bufferTargetBinding[type], GL_BUFFER_USAGE, &bufUsage); // On discard le buffer - glBufferData(bufferTargetBinding[type], bufferSize, nullptr, bufferUsage); + glBufferData(bufferTargetBinding[type], bufSize, nullptr, bufUsage); } void* ptr = glMapBuffer(bufferTarget[type], bufferLock[access]); diff --git a/src/Nazara/Renderer/OcclusionQuery.cpp b/src/Nazara/Renderer/OcclusionQuery.cpp index 50901e190..2b2d062cd 100644 --- a/src/Nazara/Renderer/OcclusionQuery.cpp +++ b/src/Nazara/Renderer/OcclusionQuery.cpp @@ -98,5 +98,5 @@ bool NzOcclusionQuery::IsResultAvailable() const bool NzOcclusionQuery::IsSupported() { - return NazaraRenderer->HasCapability(nzRendererCap_OcclusionQuery); + return NzRenderer::HasCapability(nzRendererCap_OcclusionQuery); } diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 0c775fef5..89545800d 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -1,3 +1,7 @@ +// 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 #include #include @@ -54,7 +58,7 @@ namespace } std::set openGLextensionSet; - bool openGLextensions[NzOpenGL::Count] = {false}; + bool openGLextensions[NzOpenGL::Max+1] = {false}; unsigned int openGLversion = 0; bool LoadExtensionsString(const NzString& extensionString) @@ -129,7 +133,7 @@ bool NzOpenGL::Initialize() /* Note: Même le contexte de chargement nécessite quelques fonctions de base pour correctement s'initialiser Pour cette raison, deux contextes sont créés, le premier sert à récupérer les fonctions permetttant - de créer le second avec les bons paramètres.s + de créer le second avec les bons paramètres. Non sérieusement si quelqu'un a une meilleure idée qu'il me le dise */ @@ -157,7 +161,7 @@ bool NzOpenGL::Initialize() // Récupération de la version d'OpenGL // Ce code se base sur le fait que la carte graphique renverra un contexte de compatibilité avec la plus haute version supportée // Ce qui semble vrai au moins chez ATI/AMD et NVidia, mais si quelqu'un à une meilleure idée ... - glGetString = reinterpret_cast(LoadEntry("glGetString")); + glGetString = reinterpret_cast(LoadEntry("glGetString", false)); if (!glGetString) { NazaraError("Unable to load OpenGL: failed to load glGetString"); @@ -191,10 +195,17 @@ bool NzOpenGL::Initialize() } openGLversion = major*100 + minor*10; + if (openGLversion < 200) + { + NazaraError("OpenGL version is too low, please upgrade your drivers or your graphics card"); + Uninitialize(); + + return false; + } parameters.debugMode = true; // Certaines extensions n'apparaissent qu'avec un contexte de debug (e.g. ARB_debug_output) - parameters.majorVersion = NzContextParameters::defaultMajorVersion = openGLversion/100; - parameters.minorVersion = NzContextParameters::defaultMinorVersion = (openGLversion%100)/10; + parameters.majorVersion = NzContextParameters::defaultMajorVersion = major; + parameters.minorVersion = NzContextParameters::defaultMinorVersion = minor; // Destruction implicite du premier contexte if (!loadContext.Create(parameters)) @@ -331,7 +342,7 @@ bool NzOpenGL::Initialize() loaded = false; if (!loaded) - NazaraWarning("Failed to load windows' extension string"); + NazaraWarning("Failed to load wgl extension string"); } #endif @@ -403,7 +414,7 @@ bool NzOpenGL::Initialize() openGLextensions[NzOpenGL::PixelBufferObject] = (openGLversion >= 210 || IsSupported("GL_ARB_pixel_buffer_object")); // SeparateShaderObjects - if (openGLversion >= 400 || IsSupported("GL_ARB_gpu_shader_fp64")) + if (openGLversion >= 400 || IsSupported("GL_ARB_separate_shader_objects")) { glProgramUniform1f = reinterpret_cast(LoadEntry("glProgramUniform1f")); glProgramUniform1i = reinterpret_cast(LoadEntry("glProgramUniform1i")); @@ -412,6 +423,7 @@ bool NzOpenGL::Initialize() glProgramUniform4fv = reinterpret_cast(LoadEntry("glProgramUniform4fv")); glProgramUniformMatrix4fv = reinterpret_cast(LoadEntry("glProgramUniformMatrix4fv")); + // Si ARB_gpu_shader_fp64 est supporté, alors cette extension donne également accès aux fonctions utilisant des double if (openGLextensions[NzOpenGL::FP64]) { glProgramUniform1d = reinterpret_cast(LoadEntry("glProgramUniform1d")); @@ -434,8 +446,7 @@ bool NzOpenGL::Initialize() } catch (const std::exception& e) { - if (openGLversion >= 120) - NazaraWarning("Failed to load core texture 3D (" + NzString(e.what()) + ")"); + NazaraWarning("Failed to load core texture 3D (" + NzString(e.what()) + ")"); if (IsSupported("GL_EXT_texture3D")) { @@ -449,13 +460,16 @@ bool NzOpenGL::Initialize() openGLextensions[NzOpenGL::Texture3D] = true; } - catch (const std::exception& e) + catch (const std::exception& e2) { - NazaraWarning("Failed to load EXT_texture3D: " + NzString(e.what())); + NazaraWarning("Failed to load EXT_texture3D: " + NzString(e2.what())); } } } + // TextureArray + openGLextensions[NzOpenGL::TextureArray] = (openGLversion >= 300 || IsSupported("GL_EXT_texture_array")); + // TextureCompression_s3tc openGLextensions[NzOpenGL::TextureCompression_s3tc] = IsSupported("GL_EXT_texture_compression_s3tc"); diff --git a/src/Nazara/Renderer/RenderTarget.cpp b/src/Nazara/Renderer/RenderTarget.cpp index 2954e61ca..9a9be298d 100644 --- a/src/Nazara/Renderer/RenderTarget.cpp +++ b/src/Nazara/Renderer/RenderTarget.cpp @@ -10,15 +10,15 @@ NzRenderTarget::~NzRenderTarget() = default; bool NzRenderTarget::IsActive() const { - return NazaraRenderer->GetTarget() == this; + return NzRenderer::GetTarget() == this; } bool NzRenderTarget::SetActive(bool active) { if (active) - return NazaraRenderer->SetTarget(this); - else if (NazaraRenderer->GetTarget() == this) - return NazaraRenderer->SetTarget(nullptr); + return NzRenderer::SetTarget(this); + else if (NzRenderer::GetTarget() == this) + return NzRenderer::SetTarget(nullptr); return true; } diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index 1af1c2174..46861f4eb 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -5,18 +5,13 @@ #include #include #include +#include #include #include #include #include -NzRenderWindow::NzRenderWindow() : -m_context(nullptr) -{ -} - -NzRenderWindow::NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style, const NzContextParameters& parameters) : -m_context(nullptr) +NzRenderWindow::NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style, const NzContextParameters& parameters) { Create(mode, title, style, parameters); @@ -29,8 +24,7 @@ m_context(nullptr) #endif } -NzRenderWindow::NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters) : -m_context(nullptr) +NzRenderWindow::NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters) { Create(handle, parameters); @@ -45,6 +39,8 @@ m_context(nullptr) NzRenderWindow::~NzRenderWindow() { + // Nécessaire si NzWindow::Destroy est appelé par son destructeur + OnWindowDestroying(); } bool NzRenderWindow::CopyToImage(NzImage* image) @@ -136,6 +132,15 @@ bool NzRenderWindow::Create(NzWindowHandle handle, const NzContextParameters& pa void NzRenderWindow::Display() { + if (m_framerateLimit > 0) + { + int remainingTime = 1000/m_framerateLimit - m_clock.GetMilliseconds(); + if (remainingTime > 0) + NzThread::Sleep(remainingTime); + + m_clock.Restart(); + } + if (m_context && m_parameters.doubleBuffered) m_context->SwapBuffers(); } @@ -218,6 +223,11 @@ bool NzRenderWindow::IsValid() const return m_impl != nullptr && m_context != nullptr; } +void NzRenderWindow::SetFramerateLimit(unsigned int limit) +{ + m_framerateLimit = limit; +} + bool NzRenderWindow::Activate() { if (m_context->SetActive(true)) @@ -232,12 +242,16 @@ bool NzRenderWindow::Activate() } } -void NzRenderWindow::OnClose() +void NzRenderWindow::OnWindowDestroying() { - delete m_context; + if (m_context) + { + delete m_context; + m_context = nullptr; + } } -bool NzRenderWindow::OnCreate() +bool NzRenderWindow::OnWindowCreated() { m_parameters.doubleBuffered = true; m_parameters.window = GetHandle(); @@ -258,5 +272,7 @@ bool NzRenderWindow::OnCreate() NazaraWarning("Failed to activate window"); #endif + m_clock.Restart(); + return true; } diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index d5865277f..65e1aceee 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include namespace @@ -61,7 +63,6 @@ namespace GL_FILL // nzFaceFilling_Fill }; - const GLenum openglPrimitive[] = { GL_LINES, // nzPrimitiveType_LineList, @@ -131,28 +132,47 @@ namespace GL_ZERO // nzStencilOperation_Zero }; + ///FIXME: Solution temporaire pour plus de facilité + enum nzMatrixCombination + { + nzMatrixCombination_ViewProj = nzMatrixType_Max+1, + nzMatrixCombination_WorldView, + nzMatrixCombination_WorldViewProj, + + nzMatrixCombination_Max = nzMatrixCombination_WorldViewProj + }; + NzBufferImpl* HardwareBufferFunction(NzBuffer* parent, nzBufferType type) { return new NzHardwareBuffer(parent, type); } -} -NzRenderer::NzRenderer() -{ - #if NAZARA_RENDERER_SAFE - if (s_instance) - throw std::runtime_error("Renderer already instanced"); - #endif + typedef std::tuple VAO_Key; - s_instance = this; -} + constexpr unsigned int totalMatrixCount = nzMatrixCombination_Max+1; -NzRenderer::~NzRenderer() -{ - if (s_initialized) - Uninitialize(); - - s_instance = nullptr; + std::map s_vaos; + NzMatrix4f s_matrix[totalMatrixCount]; + int s_matrixLocation[totalMatrixCount]; + bool s_matrixUpdated[totalMatrixCount]; + nzRendererComparison s_stencilCompare; + nzStencilOperation s_stencilFail; + nzStencilOperation s_stencilPass; + nzStencilOperation s_stencilZFail; + nzUInt32 s_stencilMask; + const NzIndexBuffer* s_indexBuffer; + NzRenderTarget* s_target; + NzShader* s_shader; + const NzVertexBuffer* s_vertexBuffer; + const NzVertexDeclaration* s_vertexDeclaration; + bool s_vaoUpdated; + bool s_capabilities[nzRendererCap_Max+1]; + bool s_stencilFuncUpdated; + bool s_stencilOpUpdated; + unsigned int s_maxAnisotropyLevel; + unsigned int s_maxRenderTarget; + unsigned int s_maxTextureUnit; + unsigned int s_stencilReference; } void NzRenderer::Clear(unsigned long flags) @@ -190,8 +210,10 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f NazaraError("No active context"); return; } + #endif - if (!m_indexBuffer) + #if NAZARA_RENDERER_SAFE + if (!s_indexBuffer) { NazaraError("No index buffer"); return; @@ -204,11 +226,11 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f return; } - if (m_indexBuffer->IsSequential()) - glDrawArrays(openglPrimitive[primitive], m_indexBuffer->GetStartIndex(), m_indexBuffer->GetIndexCount()); + if (s_indexBuffer->IsSequential()) + glDrawArrays(openglPrimitive[primitive], s_indexBuffer->GetStartIndex(), s_indexBuffer->GetIndexCount()); else { - nzUInt8 indexSize = m_indexBuffer->GetIndexSize(); + nzUInt8 indexSize = s_indexBuffer->GetIndexSize(); GLenum type; switch (indexSize) @@ -230,7 +252,7 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f return; } - glDrawElements(openglPrimitive[primitive], indexCount, type, reinterpret_cast(m_indexBuffer->GetPointer()) + firstIndex*indexSize); + glDrawElements(openglPrimitive[primitive], indexCount, type, reinterpret_cast(s_indexBuffer->GetPointer()) + firstIndex*indexSize); } } @@ -282,33 +304,70 @@ void NzRenderer::Enable(nzRendererParameter parameter, bool enable) break; } } - -unsigned int NzRenderer::GetMaxAnisotropyLevel() const +/* +NzMatrix4f NzRenderer::GetMatrix(nzMatrixCombination combination) { - return m_maxAnisotropyLevel; + switch (combination) + { + case nzMatrixCombination_ViewProj: + if (!s_matrixUpdated[nzMatrixCombination_ViewProj]) + { + s_matrix[nzMatrixCombination_ViewProj] = s_matrix[nzMatrixType_View] * s_matrix[nzMatrixType_Projection]; + s_matrixUpdated[nzMatrixCombination_ViewProj] = true; + } + break; + + case nzMatrixCombination_WorldView: + if (!s_matrixUpdated[nzMatrixCombination_WorldView]) + { + s_matrix[nzMatrixCombination_WorldView] = NzMatrix4f::ConcatenateAffine(s_matrix[nzMatrixType_World], s_matrix[nzMatrixType_View]); + s_matrixUpdated[nzMatrixCombination_WorldView] = true; + } + break; + + case nzMatrixCombination_WorldViewProj: + if (!s_matrixUpdated[nzMatrixCombination_WorldViewProj]) + { + s_matrix[nzMatrixCombination_WorldViewProj] = s_matrix[nzMatrixCombination_WorldView] * s_matrix[nzMatrixType_Projection]; + s_matrixUpdated[nzMatrixCombination_WorldViewProj] = true; + } + break; + } + + return m_matrix[combination]; +} +*/ +NzMatrix4f NzRenderer::GetMatrix(nzMatrixType type) +{ + return s_matrix[type]; } -unsigned int NzRenderer::GetMaxRenderTargets() const +unsigned int NzRenderer::GetMaxAnisotropyLevel() { - return m_maxRenderTarget; + return s_maxAnisotropyLevel; } -unsigned int NzRenderer::GetMaxTextureUnits() const +unsigned int NzRenderer::GetMaxRenderTargets() { - return m_maxTextureUnit; + return s_maxRenderTarget; } -NzShader* NzRenderer::GetShader() const +unsigned int NzRenderer::GetMaxTextureUnits() { - return m_shader; + return s_maxTextureUnit; } -NzRenderTarget* NzRenderer::GetTarget() const +NzShader* NzRenderer::GetShader() { - return m_target; + return s_shader; } -NzRectui NzRenderer::GetViewport() const +NzRenderTarget* NzRenderer::GetTarget() +{ + return s_target; +} + +NzRectui NzRenderer::GetViewport() { #ifdef NAZARA_DEBUG if (NzContext::GetCurrent() == nullptr) @@ -324,103 +383,110 @@ NzRectui NzRenderer::GetViewport() const return NzRectui(params[0], params[1], params[2], params[3]); } -bool NzRenderer::HasCapability(nzRendererCap capability) const +bool NzRenderer::HasCapability(nzRendererCap capability) { - return m_capabilities[capability]; + return s_capabilities[capability]; } bool NzRenderer::Initialize() { - #if NAZARA_RENDERER_SAFE - if (s_initialized) + if (s_moduleReferenceCouter++ != 0) + return true; // Déjà initialisé + + // Initialisation des dépendances + if (!NzUtility::Initialize()) { - NazaraError("Renderer already initialized"); - return true; - } - #endif - - // Initialisation du module Utility - if (!NzUtility::IsInitialized()) - { - m_utilityModule = new NzUtility; - m_utilityModule->Initialize(); - } - else - m_utilityModule = nullptr; - - if (NzOpenGL::Initialize()) - { - NzContext::EnsureContext(); - - m_indexBuffer = nullptr; - m_shader = nullptr; - m_stencilCompare = nzRendererComparison_Always; - m_stencilFail = nzStencilOperation_Keep; - m_stencilFuncUpdated = true; - m_stencilMask = 0xFFFFFFFF; - m_stencilOpUpdated = true; - m_stencilPass = nzStencilOperation_Keep; - m_stencilReference = 0; - m_stencilZFail = nzStencilOperation_Keep; - m_target = nullptr; - m_vaoUpdated = false; - m_vertexBuffer = nullptr; - m_vertexDeclaration = nullptr; - - // Récupération des capacités - m_capabilities[nzRendererCap_AnisotropicFilter] = NzOpenGL::IsSupported(NzOpenGL::AnisotropicFilter); - m_capabilities[nzRendererCap_FP64] = NzOpenGL::IsSupported(NzOpenGL::FP64); - m_capabilities[nzRendererCap_HardwareBuffer] = true; // Natif depuis OpenGL 1.5 - m_capabilities[nzRendererCap_MultipleRenderTargets] = true; // Natif depuis OpenGL 2.0 - m_capabilities[nzRendererCap_OcclusionQuery] = true; // Natif depuis OpenGL 1.5 - m_capabilities[nzRendererCap_PixelBufferObject] = NzOpenGL::IsSupported(NzOpenGL::PixelBufferObject); - m_capabilities[nzRendererCap_Texture3D] = NzOpenGL::IsSupported(NzOpenGL::Texture3D); - m_capabilities[nzRendererCap_TextureCubemap] = true; // Natif depuis OpenGL 1.3 - m_capabilities[nzRendererCap_TextureMulti] = true; // Natif depuis OpenGL 1.3 - m_capabilities[nzRendererCap_TextureNPOT] = true; // Natif depuis OpenGL 2.0 - - if (m_capabilities[nzRendererCap_AnisotropicFilter]) - { - GLint maxAnisotropy; - glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy); - - m_maxAnisotropyLevel = static_cast(maxAnisotropy); - } - else - m_maxAnisotropyLevel = 1; - - if (m_capabilities[nzRendererCap_MultipleRenderTargets]) - { - GLint maxDrawBuffers; - glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); - - m_maxRenderTarget = static_cast(maxDrawBuffers); - } - else - m_maxRenderTarget = 1; - - if (m_capabilities[nzRendererCap_TextureMulti]) - { - GLint maxTextureUnits; - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); - - GLint maxVertexAttribs; - glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); - - // Impossible de binder plus de texcoords que d'attributes (en sachant qu'un certain nombre est déjà pris par les autres attributs) - m_maxTextureUnit = static_cast(std::min(maxTextureUnits, maxVertexAttribs-attribIndex[nzElementUsage_TexCoord])); - } - else - m_maxTextureUnit = 1; - - NzBuffer::SetBufferFunction(nzBufferStorage_Hardware, HardwareBufferFunction); - - s_initialized = true; - - return true; - } - else + NazaraError("Failed to initialize utility module"); return false; + } + + // Initialisation du module + if (!NzOpenGL::Initialize()) + { + NazaraError("Failed to initialize OpenGL"); + return false; + } + + NzContext::EnsureContext(); + + for (unsigned int i = 0; i < totalMatrixCount; ++i) + { + s_matrix[i].MakeIdentity(); + s_matrixLocation[i] = -1; + s_matrixUpdated[i] = false; + } + + s_indexBuffer = nullptr; + s_shader = nullptr; + s_stencilCompare = nzRendererComparison_Always; + s_stencilFail = nzStencilOperation_Keep; + s_stencilFuncUpdated = true; + s_stencilMask = 0xFFFFFFFF; + s_stencilOpUpdated = true; + s_stencilPass = nzStencilOperation_Keep; + s_stencilReference = 0; + s_stencilZFail = nzStencilOperation_Keep; + s_target = nullptr; + s_vaoUpdated = false; + s_vertexBuffer = nullptr; + s_vertexDeclaration = nullptr; + + // Récupération des capacités + s_capabilities[nzRendererCap_AnisotropicFilter] = NzOpenGL::IsSupported(NzOpenGL::AnisotropicFilter); + s_capabilities[nzRendererCap_FP64] = NzOpenGL::IsSupported(NzOpenGL::FP64); + s_capabilities[nzRendererCap_HardwareBuffer] = true; // Natif depuis OpenGL 1.5 + s_capabilities[nzRendererCap_MultipleRenderTargets] = true; // Natif depuis OpenGL 2.0 + s_capabilities[nzRendererCap_OcclusionQuery] = true; // Natif depuis OpenGL 1.5 + s_capabilities[nzRendererCap_PixelBufferObject] = NzOpenGL::IsSupported(NzOpenGL::PixelBufferObject); + s_capabilities[nzRendererCap_Texture3D] = NzOpenGL::IsSupported(NzOpenGL::Texture3D); + s_capabilities[nzRendererCap_TextureCubemap] = true; // Natif depuis OpenGL 1.3 + s_capabilities[nzRendererCap_TextureMulti] = true; // Natif depuis OpenGL 1.3 + s_capabilities[nzRendererCap_TextureNPOT] = true; // Natif depuis OpenGL 2.0 + + if (s_capabilities[nzRendererCap_AnisotropicFilter]) + { + GLint maxAnisotropy; + glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy); + + s_maxAnisotropyLevel = static_cast(maxAnisotropy); + } + else + s_maxAnisotropyLevel = 1; + + if (s_capabilities[nzRendererCap_MultipleRenderTargets]) + { + GLint maxDrawBuffers; + glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); + + s_maxRenderTarget = static_cast(maxDrawBuffers); + } + else + s_maxRenderTarget = 1; + + if (s_capabilities[nzRendererCap_TextureMulti]) + { + GLint maxTextureUnits; + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); + + GLint maxVertexAttribs; + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); + + // Impossible de binder plus de texcoords que d'attributes (en sachant qu'un certain nombre est déjà pris par les autres attributs) + s_maxTextureUnit = static_cast(std::min(maxTextureUnits, maxVertexAttribs-attribIndex[nzElementUsage_TexCoord])); + } + else + s_maxTextureUnit = 1; + + NzBuffer::SetBufferFunction(nzBufferStorage_Hardware, HardwareBufferFunction); + + NazaraNotice("Initialized: Renderer module"); + + return true; +} + +bool NzRenderer::IsInitialized() +{ + return s_moduleReferenceCouter != 0; } void NzRenderer::SetBlendFunc(nzBlendFunc src, nzBlendFunc dest) @@ -524,22 +590,43 @@ bool NzRenderer::SetIndexBuffer(const NzIndexBuffer* indexBuffer) } #endif - if (indexBuffer != m_indexBuffer) + if (s_indexBuffer != indexBuffer) { - m_indexBuffer = indexBuffer; - m_vaoUpdated = false; + s_indexBuffer = indexBuffer; + s_vaoUpdated = false; } return true; } +void NzRenderer::SetMatrix(nzMatrixType type, const NzMatrix4f& matrix) +{ + s_matrix[type] = matrix; + + // Cas particulier, la matrice projection doit être inversée sur l'axe Y à cause des conventions d'OpenGL + if (type == nzMatrixType_Projection) + s_matrix[type] *= NzMatrix4f::Scale(NzVector3f(1.f, -1.f, 1.f)); + + // Invalidation des combinaisons + switch (type) + { + case nzMatrixType_View: + case nzMatrixType_World: + s_matrixUpdated[nzMatrixCombination_WorldView] = false; + case nzMatrixType_Projection: + s_matrixUpdated[nzMatrixCombination_WorldViewProj] = false; + s_matrixUpdated[nzMatrixCombination_ViewProj] = false; + break; + } +} + bool NzRenderer::SetShader(NzShader* shader) { - if (shader == m_shader) + if (s_shader == shader) return true; - if (m_shader) - m_shader->m_impl->Unbind(); + if (s_shader) + s_shader->m_impl->Unbind(); if (shader) { @@ -547,7 +634,7 @@ bool NzRenderer::SetShader(NzShader* shader) if (!shader->IsCompiled()) { NazaraError("Shader is not compiled"); - m_shader = nullptr; + shader = nullptr; return false; } @@ -556,78 +643,87 @@ bool NzRenderer::SetShader(NzShader* shader) if (!shader->m_impl->Bind()) { NazaraError("Failed to bind shader"); - m_shader = nullptr; + shader = nullptr; return false; } + + // Récupération des indices des variables uniformes (-1 si la variable n'existe pas) + s_matrixLocation[nzMatrixType_Projection] = shader->GetUniformLocation("ProjMatrix"); + s_matrixLocation[nzMatrixType_View] = shader->GetUniformLocation("ViewMatrix"); + s_matrixLocation[nzMatrixType_World] = shader->GetUniformLocation("WorldMatrix"); + + s_matrixLocation[nzMatrixCombination_ViewProj] = shader->GetUniformLocation("ViewProjMatrix"); + s_matrixLocation[nzMatrixCombination_WorldView] = shader->GetUniformLocation("WorldViewMatrix"); + s_matrixLocation[nzMatrixCombination_WorldViewProj] = shader->GetUniformLocation("WorldViewProjMatrix"); } - m_shader = shader; + s_shader = shader; return true; } void NzRenderer::SetStencilCompareFunction(nzRendererComparison compareFunc) { - if (compareFunc != m_stencilCompare) + if (compareFunc != s_stencilCompare) { - m_stencilCompare = compareFunc; - m_stencilFuncUpdated = false; + s_stencilCompare = compareFunc; + s_stencilFuncUpdated = false; } } void NzRenderer::SetStencilFailOperation(nzStencilOperation failOperation) { - if (failOperation != m_stencilFail) + if (failOperation != s_stencilFail) { - m_stencilFail = failOperation; - m_stencilOpUpdated = false; + s_stencilFail = failOperation; + s_stencilOpUpdated = false; } } void NzRenderer::SetStencilMask(nzUInt32 mask) { - if (mask != m_stencilMask) + if (mask != s_stencilMask) { - m_stencilMask = mask; - m_stencilFuncUpdated = false; + s_stencilMask = mask; + s_stencilFuncUpdated = false; } } void NzRenderer::SetStencilPassOperation(nzStencilOperation passOperation) { - if (passOperation != m_stencilPass) + if (passOperation != s_stencilPass) { - m_stencilPass = passOperation; - m_stencilOpUpdated = false; + s_stencilPass = passOperation; + s_stencilOpUpdated = false; } } void NzRenderer::SetStencilReferenceValue(unsigned int refValue) { - if (refValue != m_stencilReference) + if (refValue != s_stencilReference) { - m_stencilReference = refValue; - m_stencilFuncUpdated = false; + s_stencilReference = refValue; + s_stencilFuncUpdated = false; } } void NzRenderer::SetStencilZFailOperation(nzStencilOperation zfailOperation) { - if (zfailOperation != m_stencilZFail) + if (zfailOperation != s_stencilZFail) { - m_stencilZFail = zfailOperation; - m_stencilOpUpdated = false; + s_stencilZFail = zfailOperation; + s_stencilOpUpdated = false; } } bool NzRenderer::SetTarget(NzRenderTarget* target) { - if (target == m_target) + if (s_target == target) return true; - if (m_target && !m_target->HasContext()) - m_target->Desactivate(); + if (s_target && !target->HasContext()) + s_target->Desactivate(); if (target) { @@ -640,17 +736,17 @@ bool NzRenderer::SetTarget(NzRenderTarget* target) #endif if (target->Activate()) - m_target = target; + s_target = target; else { NazaraError("Failed to activate target"); - m_target = nullptr; + s_target = nullptr; return false; } } else - m_target = nullptr; + s_target = nullptr; return true; } @@ -665,10 +761,10 @@ bool NzRenderer::SetVertexBuffer(const NzVertexBuffer* vertexBuffer) } #endif - if (m_vertexBuffer != vertexBuffer) + if (s_vertexBuffer != vertexBuffer) { - m_vertexBuffer = vertexBuffer; - m_vaoUpdated = false; + s_vertexBuffer = vertexBuffer; + s_vaoUpdated = false; } return true; @@ -676,10 +772,10 @@ bool NzRenderer::SetVertexBuffer(const NzVertexBuffer* vertexBuffer) bool NzRenderer::SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration) { - if (m_vertexDeclaration != vertexDeclaration) + if (s_vertexDeclaration != vertexDeclaration) { - m_vertexDeclaration = vertexDeclaration; - m_vaoUpdated = false; + s_vertexDeclaration = vertexDeclaration; + s_vaoUpdated = false; } return true; @@ -695,16 +791,16 @@ void NzRenderer::SetViewport(const NzRectui& viewport) } #endif - unsigned int height = m_target->GetHeight(); + unsigned int height = s_target->GetHeight(); #if NAZARA_RENDERER_SAFE - if (!m_target) + if (!s_target) { NazaraError("Renderer has no target"); return; } - unsigned int width = m_target->GetWidth(); + unsigned int width = s_target->GetWidth(); if (viewport.x+viewport.width > width || viewport.y+viewport.height > height) { NazaraError("Rectangle dimensions are out of bounds"); @@ -718,20 +814,14 @@ void NzRenderer::SetViewport(const NzRectui& viewport) void NzRenderer::Uninitialize() { - #if NAZARA_RENDERER_SAFE - if (!s_initialized) - { - NazaraError("Renderer not initialized"); - return; - } - #endif + if (--s_moduleReferenceCouter != 0) + return; // Encore utilisé + // Libération du module NzContext::EnsureContext(); - s_initialized = false; - // Libération des VAOs - for (auto it = m_vaos.begin(); it != m_vaos.end(); ++it) + for (auto it = s_vaos.begin(); it != s_vaos.end(); ++it) { GLuint vao = static_cast(it->second); glDeleteVertexArrays(1, &vao); @@ -739,26 +829,10 @@ void NzRenderer::Uninitialize() NzOpenGL::Uninitialize(); - if (m_utilityModule) - { - delete m_utilityModule; - m_utilityModule = nullptr; - } -} + NazaraNotice("Uninitialized: Renderer module"); -NzRenderer* NzRenderer::Instance() -{ - #if defined(NAZARA_DEBUG) - if (!s_instance) - NazaraError("Renderer not instanced"); - #endif - - return s_instance; -} - -bool NzRenderer::IsInitialized() -{ - return s_initialized; + // Libération des dépendances + NzUtility::Uninitialize(); } bool NzRenderer::EnsureStateUpdate() @@ -771,28 +845,76 @@ bool NzRenderer::EnsureStateUpdate() } #endif - if (!m_stencilFuncUpdated) + #if NAZARA_RENDERER_SAFE + if (!s_shader) { - glStencilFunc(rendererComparison[m_stencilCompare], m_stencilReference, m_stencilMask); - m_stencilFuncUpdated = true; + NazaraError("No shader"); + return false; + } + #endif + + // Il est plus rapide d'opérer sur l'implémentation du shader directement + NzShaderImpl* shaderImpl = s_shader->m_impl; + + if (!shaderImpl->BindTextures()) + NazaraWarning("Failed to bind textures"); + + for (unsigned int i = 0; i <= nzMatrixType_Max; ++i) + { + if (!s_matrixUpdated[i]) + { + shaderImpl->SendMatrix(s_matrixLocation[i], s_matrix[i]); + s_matrixUpdated[i] = true; + } } - if (!m_stencilOpUpdated) + // Cas spéciaux car il faut recalculer la matrice + if (!s_matrixUpdated[nzMatrixCombination_ViewProj]) { - glStencilOp(stencilOperation[m_stencilFail], stencilOperation[m_stencilZFail], stencilOperation[m_stencilPass]); - m_stencilOpUpdated = true; + s_matrix[nzMatrixCombination_ViewProj] = s_matrix[nzMatrixType_View] * s_matrix[nzMatrixType_Projection]; + + shaderImpl->SendMatrix(s_matrixLocation[nzMatrixCombination_ViewProj], s_matrix[nzMatrixCombination_ViewProj]); + s_matrixUpdated[nzMatrixCombination_ViewProj] = true; } - if (!m_vaoUpdated) + if (!s_matrixUpdated[nzMatrixCombination_WorldView]) + { + s_matrix[nzMatrixCombination_WorldView] = NzMatrix4f::ConcatenateAffine(s_matrix[nzMatrixType_World], s_matrix[nzMatrixType_View]); + + shaderImpl->SendMatrix(s_matrixLocation[nzMatrixCombination_WorldView], s_matrix[nzMatrixCombination_WorldView]); + s_matrixUpdated[nzMatrixCombination_WorldView] = true; + } + + if (!s_matrixUpdated[nzMatrixCombination_WorldViewProj]) + { + s_matrix[nzMatrixCombination_WorldViewProj] = s_matrix[nzMatrixCombination_WorldView] * s_matrix[nzMatrixType_Projection]; + + shaderImpl->SendMatrix(s_matrixLocation[nzMatrixCombination_WorldViewProj], s_matrix[nzMatrixCombination_WorldViewProj]); + s_matrixUpdated[nzMatrixCombination_WorldViewProj] = true; + } + + if (!s_stencilFuncUpdated) + { + glStencilFunc(rendererComparison[s_stencilCompare], s_stencilReference, s_stencilMask); + s_stencilFuncUpdated = true; + } + + if (!s_stencilOpUpdated) + { + glStencilOp(stencilOperation[s_stencilFail], stencilOperation[s_stencilZFail], stencilOperation[s_stencilPass]); + s_stencilOpUpdated = true; + } + + if (!s_vaoUpdated) { #if NAZARA_RENDERER_SAFE - if (!m_vertexBuffer) + if (!s_vertexBuffer) { NazaraError("No vertex buffer"); return false; } - if (!m_vertexDeclaration) + if (!s_vertexDeclaration) { NazaraError("No vertex declaration"); return false; @@ -809,16 +931,16 @@ bool NzRenderer::EnsureStateUpdate() // On recherche si un VAO existe déjà avec notre configuration // Note: Les VAOs ne sont pas partagés entre les contextes, ces derniers font donc partie de notre configuration - auto key = std::make_tuple(NzContext::GetCurrent(), m_indexBuffer, m_vertexBuffer, m_vertexDeclaration); - auto it = m_vaos.find(key); - if (it == m_vaos.end()) + auto key = std::make_tuple(NzContext::GetCurrent(), s_indexBuffer, s_vertexBuffer, s_vertexDeclaration); + auto it = s_vaos.find(key); + if (it == s_vaos.end()) { // On créé notre VAO glGenVertexArrays(1, &vao); glBindVertexArray(vao); // On l'ajoute à notre liste - m_vaos.insert(std::make_pair(key, static_cast(vao))); + s_vaos.insert(std::make_pair(key, static_cast(vao))); // Et on indique qu'on veut le programmer update = true; @@ -836,15 +958,15 @@ bool NzRenderer::EnsureStateUpdate() if (update) { - NzHardwareBuffer* vertexBuffer = static_cast(m_vertexBuffer->GetBuffer()->GetImpl()); - vertexBuffer->Bind(); + NzHardwareBuffer* vertexBufferImpl = static_cast(s_vertexBuffer->GetBuffer()->GetImpl()); + vertexBufferImpl->Bind(); - const nzUInt8* buffer = reinterpret_cast(m_vertexBuffer->GetPointer()); + const nzUInt8* buffer = reinterpret_cast(s_vertexBuffer->GetPointer()); - unsigned int stride = m_vertexDeclaration->GetStride(nzElementStream_VertexData); + unsigned int stride = s_vertexDeclaration->GetStride(nzElementStream_VertexData); for (unsigned int i = 0; i <= nzElementUsage_Max; ++i) { - const NzVertexElement* element = m_vertexDeclaration->GetElement(nzElementStream_VertexData, static_cast(i)); + const NzVertexElement* element = s_vertexDeclaration->GetElement(nzElementStream_VertexData, static_cast(i)); if (element) { @@ -860,10 +982,10 @@ bool NzRenderer::EnsureStateUpdate() glDisableVertexAttribArray(attribIndex[i]); } - if (m_indexBuffer) + if (s_indexBuffer) { - NzHardwareBuffer* indexBuffer = static_cast(m_indexBuffer->GetBuffer()->GetImpl()); - indexBuffer->Bind(); + NzHardwareBuffer* indexBufferImpl = static_cast(s_indexBuffer->GetBuffer()->GetImpl()); + indexBufferImpl->Bind(); } } @@ -877,11 +999,10 @@ bool NzRenderer::EnsureStateUpdate() glBindVertexArray(vao); } - m_vaoUpdated = true; + s_vaoUpdated = true; } return true; } -NzRenderer* NzRenderer::s_instance = nullptr; -bool NzRenderer::s_initialized = false; +unsigned int NzRenderer::s_moduleReferenceCouter = 0; diff --git a/src/Nazara/Renderer/Shader.cpp b/src/Nazara/Renderer/Shader.cpp index f3e635089..ec12ee1d1 100644 --- a/src/Nazara/Renderer/Shader.cpp +++ b/src/Nazara/Renderer/Shader.cpp @@ -161,6 +161,32 @@ NzString NzShader::GetSourceCode(nzShaderType type) const return m_impl->GetSourceCode(type); } +int NzShader::GetUniformLocation(const NzString& name) const +{ + #if NAZARA_RENDERER_SAFE + if (!m_impl) + { + NazaraError("Shader not created"); + return false; + } + #endif + + return m_impl->GetUniformLocation(name); +} + +bool NzShader::HasUniform(const NzString& name) const +{ + #if NAZARA_RENDERER_SAFE + if (!m_impl) + { + NazaraError("Shader not created"); + return false; + } + #endif + + return m_impl->GetUniformLocation(name) != -1; +} + bool NzShader::IsCompiled() const { #if NAZARA_RENDERER_SAFE @@ -282,7 +308,7 @@ bool NzShader::Lock() return m_impl->Lock(); } -bool NzShader::SendBoolean(const NzString& name, bool value) +bool NzShader::SendBoolean(int location, bool value) { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -290,57 +316,43 @@ bool NzShader::SendBoolean(const NzString& name, bool value) NazaraError("Shader not created"); return false; } + + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } #endif - return m_impl->SendBoolean(name, value); + return m_impl->SendBoolean(location, value); } -bool NzShader::SendDouble(const NzString& name, double value) +bool NzShader::SendDouble(int location, double value) { #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Shader not created"); - return false; - } - - if (!NazaraRenderer->HasCapability(nzRendererCap_FP64)) + if (!NzRenderer::HasCapability(nzRendererCap_FP64)) { NazaraError("FP64 is not supported"); return false; } - #endif - return m_impl->SendDouble(name, value); -} - -bool NzShader::SendFloat(const NzString& name, float value) -{ - #if NAZARA_RENDERER_SAFE if (!m_impl) { NazaraError("Shader not created"); return false; } - #endif - return m_impl->SendFloat(name, value); -} - -bool NzShader::SendInteger(const NzString& name, int value) -{ - #if NAZARA_RENDERER_SAFE - if (!m_impl) + if (location == -1) { - NazaraError("Shader not created"); + NazaraError("Invalid location"); return false; } #endif - return m_impl->SendInteger(name, value); + return m_impl->SendDouble(location, value); } -bool NzShader::SendMatrix(const NzString& name, const NzMatrix4d& matrix) +bool NzShader::SendFloat(int location, float value) { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -349,30 +361,61 @@ bool NzShader::SendMatrix(const NzString& name, const NzMatrix4d& matrix) return false; } - if (!NazaraRenderer->HasCapability(nzRendererCap_FP64)) + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } + #endif + + return m_impl->SendFloat(location, value); +} + +bool NzShader::SendInteger(int location, int value) +{ + #if NAZARA_RENDERER_SAFE + if (!m_impl) + { + NazaraError("Shader not created"); + return false; + } + + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } + #endif + + return m_impl->SendInteger(location, value); +} + +bool NzShader::SendMatrix(int location, const NzMatrix4d& matrix) +{ + #if NAZARA_RENDERER_SAFE + if (!NzRenderer::HasCapability(nzRendererCap_FP64)) { NazaraError("FP64 is not supported"); return false; } - #endif - return m_impl->SendMatrix(name, matrix); -} - -bool NzShader::SendMatrix(const NzString& name, const NzMatrix4f& matrix) -{ - #if NAZARA_RENDERER_SAFE if (!m_impl) { NazaraError("Shader not created"); return false; } + + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } #endif - return m_impl->SendMatrix(name, matrix); + return m_impl->SendMatrix(location, matrix); } -bool NzShader::SendVector(const NzString& name, const NzVector2d& vector) +bool NzShader::SendMatrix(int location, const NzMatrix4f& matrix) { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -381,30 +424,61 @@ bool NzShader::SendVector(const NzString& name, const NzVector2d& vector) return false; } - if (!NazaraRenderer->HasCapability(nzRendererCap_FP64)) + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } + #endif + + return m_impl->SendMatrix(location, matrix); +} + +bool NzShader::SendTexture(int location, const NzTexture* texture) +{ + #if NAZARA_RENDERER_SAFE + if (!m_impl) + { + NazaraError("Shader not created"); + return false; + } + + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } + #endif + + return m_impl->SendTexture(location, texture); +} + +bool NzShader::SendVector(int location, const NzVector2d& vector) +{ + #if NAZARA_RENDERER_SAFE + if (!NzRenderer::HasCapability(nzRendererCap_FP64)) { NazaraError("FP64 is not supported"); return false; } - #endif - return m_impl->SendVector(name, vector); -} - -bool NzShader::SendVector(const NzString& name, const NzVector2f& vector) -{ - #if NAZARA_RENDERER_SAFE if (!m_impl) { NazaraError("Shader not created"); return false; } + + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } #endif - return m_impl->SendVector(name, vector); + return m_impl->SendVector(location, vector); } -bool NzShader::SendVector(const NzString& name, const NzVector3d& vector) +bool NzShader::SendVector(int location, const NzVector2f& vector) { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -413,30 +487,42 @@ bool NzShader::SendVector(const NzString& name, const NzVector3d& vector) return false; } - if (!NazaraRenderer->HasCapability(nzRendererCap_FP64)) + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } + #endif + + return m_impl->SendVector(location, vector); +} + +bool NzShader::SendVector(int location, const NzVector3d& vector) +{ + #if NAZARA_RENDERER_SAFE + if (!NzRenderer::HasCapability(nzRendererCap_FP64)) { NazaraError("FP64 is not supported"); return false; } - #endif - return m_impl->SendVector(name, vector); -} - -bool NzShader::SendVector(const NzString& name, const NzVector3f& vector) -{ - #if NAZARA_RENDERER_SAFE if (!m_impl) { NazaraError("Shader not created"); return false; } + + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } #endif - return m_impl->SendVector(name, vector); + return m_impl->SendVector(location, vector); } -bool NzShader::SendVector(const NzString& name, const NzVector4d& vector) +bool NzShader::SendVector(int location, const NzVector3f& vector) { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -445,17 +531,42 @@ bool NzShader::SendVector(const NzString& name, const NzVector4d& vector) return false; } - if (!NazaraRenderer->HasCapability(nzRendererCap_FP64)) + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } + #endif + + return m_impl->SendVector(location, vector); +} + +bool NzShader::SendVector(int location, const NzVector4d& vector) +{ + #if NAZARA_RENDERER_SAFE + if (!NzRenderer::HasCapability(nzRendererCap_FP64)) { NazaraError("FP64 is not supported"); return false; } + + if (!m_impl) + { + NazaraError("Shader not created"); + return false; + } + + if (location == -1) + { + NazaraError("Invalid location"); + return false; + } #endif - return m_impl->SendVector(name, vector); + return m_impl->SendVector(location, vector); } -bool NzShader::SendVector(const NzString& name, const NzVector4f& vector) +bool NzShader::SendVector(int location, const NzVector4f& vector) { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -463,22 +574,15 @@ bool NzShader::SendVector(const NzString& name, const NzVector4f& vector) NazaraError("Shader not created"); return false; } - #endif - return m_impl->SendVector(name, vector); -} - -bool NzShader::SendTexture(const NzString& name, NzTexture* texture) -{ - #if NAZARA_RENDERER_SAFE - if (!m_impl) + if (location == -1) { - NazaraError("Shader not created"); + NazaraError("Invalid location"); return false; } #endif - return m_impl->SendTexture(name, texture); + return m_impl->SendVector(location, vector); } void NzShader::Unlock() diff --git a/src/Nazara/Renderer/ShaderImpl.hpp b/src/Nazara/Renderer/ShaderImpl.hpp index 504f59853..94916904f 100644 --- a/src/Nazara/Renderer/ShaderImpl.hpp +++ b/src/Nazara/Renderer/ShaderImpl.hpp @@ -23,6 +23,7 @@ class NzShaderImpl virtual ~NzShaderImpl(); virtual bool Bind() = 0; + virtual bool BindTextures() = 0; virtual bool Compile() = 0; virtual bool Create() = 0; @@ -32,6 +33,7 @@ class NzShaderImpl virtual NzString GetLog() const = 0; virtual nzShaderLanguage GetLanguage() const = 0; virtual NzString GetSourceCode(nzShaderType type) const = 0; + virtual int GetUniformLocation(const NzString& name) const = 0; virtual bool IsLoaded(nzShaderType type) const = 0; @@ -39,19 +41,19 @@ class NzShaderImpl virtual bool Lock() = 0; - virtual bool SendBoolean(const NzString& name, bool value) = 0; - virtual bool SendDouble(const NzString& name, double value) = 0; - virtual bool SendFloat(const NzString& name, float value) = 0; - virtual bool SendInteger(const NzString& name, int value) = 0; - virtual bool SendMatrix(const NzString& name, const NzMatrix4d& matrix) = 0; - virtual bool SendMatrix(const NzString& name, const NzMatrix4f& matrix) = 0; - virtual bool SendVector(const NzString& name, const NzVector2d& vector) = 0; - virtual bool SendVector(const NzString& name, const NzVector2f& vector) = 0; - virtual bool SendVector(const NzString& name, const NzVector3d& vector) = 0; - virtual bool SendVector(const NzString& name, const NzVector3f& vector) = 0; - virtual bool SendVector(const NzString& name, const NzVector4d& vector) = 0; - virtual bool SendVector(const NzString& name, const NzVector4f& vector) = 0; - virtual bool SendTexture(const NzString& name, NzTexture* texture) = 0; + virtual bool SendBoolean(int location, bool value) = 0; + virtual bool SendDouble(int location, double value) = 0; + virtual bool SendFloat(int location, float value) = 0; + virtual bool SendInteger(int location, int value) = 0; + virtual bool SendMatrix(int location, const NzMatrix4d& matrix) = 0; + virtual bool SendMatrix(int location, const NzMatrix4f& matrix) = 0; + virtual bool SendTexture(int location, const NzTexture* texture) = 0; + virtual bool SendVector(int location, const NzVector2d& vector) = 0; + virtual bool SendVector(int location, const NzVector2f& vector) = 0; + virtual bool SendVector(int location, const NzVector3d& vector) = 0; + virtual bool SendVector(int location, const NzVector3f& vector) = 0; + virtual bool SendVector(int location, const NzVector4d& vector) = 0; + virtual bool SendVector(int location, const NzVector4f& vector) = 0; virtual void Unbind() = 0; virtual void Unlock() = 0; diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index abd54b992..cfe154a33 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -39,18 +39,31 @@ namespace GLenum openglTarget[] = { - GL_TEXTURE_1D, // nzImageType_1D - GL_TEXTURE_2D, // nzImageType_2D - GL_TEXTURE_3D, // nzImageType_3D - GL_TEXTURE_CUBE_MAP // nzImageType_Cubemap + GL_TEXTURE_1D, // nzImageType_1D + GL_TEXTURE_1D_ARRAY, // nzImageType_1D_Array + GL_TEXTURE_2D, // nzImageType_2D + GL_TEXTURE_2D_ARRAY, // nzImageType_2D_Array + GL_TEXTURE_3D, // nzImageType_3D + GL_TEXTURE_CUBE_MAP // nzImageType_Cubemap }; GLenum openglTargetBinding[] = { - GL_TEXTURE_BINDING_1D, // nzImageType_1D - GL_TEXTURE_BINDING_2D, // nzImageType_2D - GL_TEXTURE_BINDING_3D, // nzImageType_3D - GL_TEXTURE_BINDING_CUBE_MAP // nzImageType_Cubemap + GL_TEXTURE_BINDING_1D, // nzImageType_1D + GL_TEXTURE_BINDING_1D_ARRAY, // nzImageType_1D + GL_TEXTURE_BINDING_2D, // nzImageType_2D + GL_TEXTURE_BINDING_3D, // nzImageType_3D + GL_TEXTURE_BINDING_CUBE_MAP // nzImageType_Cubemap + }; + + GLenum openglTargetProxy[] = + { + GL_PROXY_TEXTURE_1D, // nzImageType_1D + GL_PROXY_TEXTURE_1D_ARRAY, // nzImageType_1D_Array + GL_PROXY_TEXTURE_2D, // nzImageType_2D + GL_PROXY_TEXTURE_2D_ARRAY, // nzImageType_2D_Array + GL_PROXY_TEXTURE_3D, // nzImageType_3D + GL_PROXY_TEXTURE_CUBE_MAP // nzImageType_Cubemap }; struct OpenGLFormat @@ -142,16 +155,16 @@ namespace return false; } - GLenum target; + GLenum target = (proxy) ? openglTargetProxy[impl->type] : openglTarget[impl->type]; + GLint previous; + glGetIntegerv(openglTargetBinding[impl->type], &previous); switch (impl->type) { case nzImageType_1D: { - target = (proxy) ? GL_TEXTURE_1D : GL_PROXY_TEXTURE_1D; - - /*if (glTexStorage1D) + if (glTexStorage1D) glTexStorage1D(target, impl->levelCount, openGLFormat.internalFormat, impl->width); - else*/ + else { unsigned int w = impl->width; for (nzUInt8 level = 0; level < impl->levelCount; ++level) @@ -164,13 +177,12 @@ namespace break; } + case nzImageType_1D_Array: case nzImageType_2D: { - target = (proxy) ? GL_TEXTURE_2D : GL_PROXY_TEXTURE_2D; - - /*if (glTexStorage2D) + if (glTexStorage2D) glTexStorage2D(target, impl->levelCount, openGLFormat.internalFormat, impl->width, impl->height); - else*/ + else { unsigned int w = impl->width; unsigned int h = impl->height; @@ -187,13 +199,12 @@ namespace break; } + case nzImageType_2D_Array: case nzImageType_3D: { - target = (proxy) ? GL_TEXTURE_3D : GL_PROXY_TEXTURE_3D; - - /*if (glTexStorage3D) + if (glTexStorage3D) glTexStorage3D(target, impl->levelCount, openGLFormat.internalFormat, impl->width, impl->height, impl->depth); - else*/ + else { unsigned int w = impl->width; unsigned int h = impl->height; @@ -216,11 +227,9 @@ namespace case nzImageType_Cubemap: { - target = (proxy) ? GL_TEXTURE_CUBE_MAP : GL_PROXY_TEXTURE_CUBE_MAP; - - /*if (glTexStorage2D) + if (glTexStorage2D) glTexStorage2D(target, impl->levelCount, openGLFormat.internalFormat, impl->width, impl->height); - else*/ + else { unsigned int size = impl->width; // Les cubemaps ont une longueur et largeur identique for (nzUInt8 level = 0; level < impl->levelCount; ++level) @@ -234,15 +243,11 @@ namespace } break; } - - default: - NazaraInternalError("Image type not handled"); - return false; } if (proxy) { - GLint internalFormat; + GLint internalFormat = 0; glGetTexLevelParameteriv(target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internalFormat); if (internalFormat == 0) return false; @@ -400,6 +405,7 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt } break; + case nzImageType_1D_Array: case nzImageType_2D: if (depth > 1) { @@ -408,6 +414,7 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt } break; + case nzImageType_2D_Array: case nzImageType_3D: break; @@ -424,10 +431,6 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt return false; } break; - - default: - NazaraInternalError("Image type not handled"); - return false; } #endif @@ -454,7 +457,7 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt LockTexture(impl); // Vérification du support par la carte graphique - if (!CreateTexture(impl, true)) + /*if (!CreateTexture(impl, true)) { NazaraError("Texture's parameters not supported by driver"); UnlockTexture(impl); @@ -462,7 +465,7 @@ bool NzTexture::Create(nzImageType type, nzPixelFormat format, unsigned int widt delete impl; return false; - } + }*/ // Création de la texture if (!CreateTexture(impl, false)) @@ -603,16 +606,13 @@ unsigned int NzTexture::GetAnisotropyLevel() const if (!IsValid()) { NazaraError("Texture must be valid"); - return 1; - } - - if (!NzOpenGL::IsSupported(NzOpenGL::AnisotropicFilter)) - { - NazaraError("Anisotropic filter not supported"); - return 1; + return 0; } #endif + if (!NzOpenGL::IsSupported(NzOpenGL::AnisotropicFilter)) + return 1; + LockTexture(m_impl); GLint anisotropyLevel; @@ -937,7 +937,7 @@ bool NzTexture::SetAnisotropyLevel(unsigned int anistropyLevel) } #endif - if (!NzOpenGL::IsSupported(NzOpenGL::AnisotropicFilter)) + if (!NzOpenGL::IsSupported(NzOpenGL::AnisotropicFilter) && anistropyLevel > 1) { NazaraError("Anisotropic filter not supported"); return false; @@ -1070,9 +1070,11 @@ bool NzTexture::SetWrapMode(nzTextureWrap wrap) case nzImageType_3D: glTexParameteri(target, GL_TEXTURE_WRAP_R, wrapMode); case nzImageType_2D: + case nzImageType_2D_Array: case nzImageType_Cubemap: glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapMode); case nzImageType_1D: + case nzImageType_1D_Array: glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapMode); break; @@ -1180,7 +1182,7 @@ bool NzTexture::Update(const nzUInt8* pixels, nzUInt8 level) } #endif - if (m_impl->type == nzImageType_3D) + if (m_impl->type == nzImageType_3D || m_impl->type == nzImageType_2D_Array) return Update(pixels, NzCubeui(0, 0, 0, std::max(m_impl->width >> level, 1U), std::max(m_impl->height >> level, 1U), std::max(m_impl->depth >> level, 1U)), level); else return Update(pixels, NzRectui(0, 0, std::max(m_impl->width >> level, 1U), std::max(m_impl->height >> level, 1U)), 0, level); @@ -1268,16 +1270,19 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int glTexSubImage1D(GL_TEXTURE_1D, level, rect.x, rect.width, format.dataFormat, format.dataType, mirrored.GetConstPixels()); break; + case nzImageType_1D_Array: case nzImageType_2D: - glTexSubImage2D(GL_TEXTURE_2D, level, rect.x, height-rect.height-rect.y, rect.width, rect.height, format.dataFormat, format.dataType, mirrored.GetConstPixels()); + glTexSubImage2D(openglTarget[m_impl->type], level, rect.x, height-rect.height-rect.y, rect.width, rect.height, format.dataFormat, format.dataType, mirrored.GetConstPixels()); break; + case nzImageType_2D_Array: case nzImageType_3D: - glTexSubImage3D(GL_TEXTURE_3D, level, rect.x, height-rect.height-rect.y, z, rect.width, rect.height, 1, format.dataFormat, format.dataType, mirrored.GetConstPixels()); + glTexSubImage3D(openglTarget[m_impl->type], level, rect.x, height-rect.height-rect.y, z, rect.width, rect.height, 1, format.dataFormat, format.dataType, mirrored.GetConstPixels()); break; - default: - NazaraInternalError("Image type not handled (0x" + NzString::Number(m_impl->type, 16) + ')'); + case nzImageType_Cubemap: + NazaraError("Update used on a cubemap texture, please enable safe mode"); + break; } UnlockTexture(m_impl); @@ -1363,16 +1368,19 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzCubeui& cube, nzUInt8 leve glTexSubImage1D(GL_TEXTURE_1D, level, cube.x, cube.width, format.dataFormat, format.dataType, mirrored); break; + case nzImageType_1D_Array: case nzImageType_2D: - glTexSubImage2D(GL_TEXTURE_2D, level, cube.x, height-cube.height-cube.y, cube.width, cube.height, format.dataFormat, format.dataType, mirrored); + glTexSubImage2D(openglTarget[m_impl->type], level, cube.x, height-cube.height-cube.y, cube.width, cube.height, format.dataFormat, format.dataType, mirrored); break; + case nzImageType_2D_Array: case nzImageType_3D: - glTexSubImage3D(GL_TEXTURE_3D, level, cube.x, height-cube.height-cube.y, cube.z, cube.width, cube.height, cube.depth, format.dataFormat, format.dataType, mirrored); + glTexSubImage3D(openglTarget[m_impl->type], level, cube.x, height-cube.height-cube.y, cube.z, cube.width, cube.height, cube.depth, format.dataFormat, format.dataType, mirrored); break; - default: - NazaraInternalError("Image type not handled (0x" + NzString::Number(m_impl->type, 16) + ')'); + case nzImageType_Cubemap: + NazaraError("Update used on a cubemap texture, please enable safe mode"); + break; } UnlockTexture(m_impl); @@ -1531,7 +1539,7 @@ void NzTexture::Unlock() unsigned int NzTexture::GetValidSize(unsigned int size) { - if (NazaraRenderer->HasCapability(nzRendererCap_TextureNPOT)) + if (NzRenderer::HasCapability(nzRendererCap_TextureNPOT)) return size; else { @@ -1596,9 +1604,16 @@ bool NzTexture::IsTypeSupported(nzImageType type) case nzImageType_Cubemap: return true; // Tous supportés nativement dans OpenGL 2 - default: - return false; + case nzImageType_1D_Array: + case nzImageType_2D_Array: + { + static bool supported = NzOpenGL::IsSupported(NzOpenGL::TextureArray); + return supported; + } } + + NazaraError("Image type not handled (0x" + NzString::Number(type, 16) + ')'); + return false; } void NzTexture::SetTarget(bool isTarget) diff --git a/src/Nazara/Utility/AxisAlignedBox.cpp b/src/Nazara/Utility/AxisAlignedBox.cpp new file mode 100644 index 000000000..81b76cbb6 --- /dev/null +++ b/src/Nazara/Utility/AxisAlignedBox.cpp @@ -0,0 +1,162 @@ +// Copyright (C) 2011 Jérôme Leclercq +// This file is part of the "Ungine". +// For conditions of distribution and use, see copyright notice in Core.h + +#include +#include +#include + +NzAxisAlignedBox::NzAxisAlignedBox() : +m_extend(nzExtend_Null) +{ +} + +NzAxisAlignedBox::NzAxisAlignedBox(const NzVector3f& vec1, const NzVector3f& vec2) : +m_extend(nzExtend_Finite), +m_cube(vec1, vec2) +{ +} + +NzAxisAlignedBox::NzAxisAlignedBox(nzExtend extend) : +m_extend(extend) +{ +} + +bool NzAxisAlignedBox::Contains(const NzAxisAlignedBox& box) +{ + if (m_extend == nzExtend_Null || box.m_extend == nzExtend_Null) + return false; + else if (m_extend == nzExtend_Infinite || box.m_extend == nzExtend_Infinite) + return true; + + return m_cube.Contains(box.m_cube); +} + +void NzAxisAlignedBox::ExtendTo(const NzAxisAlignedBox& box) +{ + switch (m_extend) + { + case nzExtend_Finite: + { + switch (box.m_extend) + { + case nzExtend_Finite: + m_cube.ExtendTo(box.m_cube); + break; + + case nzExtend_Infinite: + SetInfinite(); + break; + + case nzExtend_Null: + break; + + break; + } + + case nzExtend_Infinite: + // Rien à faire + break; + + case nzExtend_Null: + operator=(box); + break; + } + } +} + +void NzAxisAlignedBox::ExtendTo(const NzVector3f& vector) +{ + switch (m_extend) + { + case nzExtend_Finite: + m_cube.ExtendTo(vector); + break; + + case nzExtend_Infinite: + // Rien à faire + break; + + case nzExtend_Null: + // Nous étendons l'AABB en la construisant de l'origine jusqu'au vecteur + m_cube.x = 0.f; + m_cube.y = 0.f; + m_cube.z = 0.f; + m_cube.width = std::fabs(vector.x); + m_cube.height = std::fabs(vector.y); + m_cube.depth = std::fabs(vector.z); + break; + } +} + +nzExtend NzAxisAlignedBox::GetExtend() const +{ + return m_extend; +} + +NzVector3f NzAxisAlignedBox::GetMaximum() const +{ + return NzVector3f(m_cube.x+m_cube.width, m_cube.y+m_cube.height, m_cube.z+m_cube.depth); +} + +NzVector3f NzAxisAlignedBox::GetMinimum() const +{ + return NzVector3f(m_cube.x, m_cube.y, m_cube.z); +} + +bool NzAxisAlignedBox::IsFinite() const +{ + return m_extend == nzExtend_Finite; +} + +bool NzAxisAlignedBox::IsInfinite() const +{ + return m_extend == nzExtend_Infinite; +} + +bool NzAxisAlignedBox::IsNull() const +{ + return m_extend == nzExtend_Null; +} + +void NzAxisAlignedBox::SetInfinite() +{ + m_extend = nzExtend_Infinite; +} + +void NzAxisAlignedBox::SetExtends(const NzVector3f& vec1, const NzVector3f& vec2) +{ + m_extend = nzExtend_Finite; + m_cube.Set(vec1, vec2); +} + +void NzAxisAlignedBox::SetNull() +{ + m_extend = nzExtend_Null; +} + +NzString NzAxisAlignedBox::ToString() const +{ + switch (m_extend) + { + case nzExtend_Finite: + return "NzAxisAlignedBox(min=" + GetMinimum().ToString() + ", max=" + GetMaximum().ToString() + ')'; + + case nzExtend_Infinite: + return "NzAxisAlignedBox(Infinite)"; + + case nzExtend_Null: + return "NzAxisAlignedBox(Null)"; + } + + return "NzAxisAlignedBox(ERROR)"; +} + +const NzAxisAlignedBox NzAxisAlignedBox::Infinite(nzExtend_Infinite); +const NzAxisAlignedBox NzAxisAlignedBox::Null(nzExtend_Null); + +std::ostream& operator<<(std::ostream& out, const NzAxisAlignedBox& aabb) +{ + out << aabb.ToString(); + return out; +} diff --git a/src/Nazara/Utility/Buffer.cpp b/src/Nazara/Utility/Buffer.cpp index 0f35946aa..c537aeb03 100644 --- a/src/Nazara/Utility/Buffer.cpp +++ b/src/Nazara/Utility/Buffer.cpp @@ -290,9 +290,10 @@ bool NzBuffer::SetStorage(nzBufferStorage storage) m_impl->Unmap(); m_impl->Destroy(); - delete m_impl; + delete m_impl; m_impl = impl; + m_storage = storage; return true; diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index 662d59238..79d4d16d9 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -17,7 +17,7 @@ namespace inline nzUInt8* GetPixelPtr(nzUInt8* base, nzUInt8 bpp, unsigned int x, unsigned int y, unsigned int z, unsigned int width, unsigned int height) { - return &base[(width*(height*z+y) + x) * bpp]; + return &base[(width*(height*z + y) + x)*bpp]; } } @@ -43,7 +43,7 @@ m_sharedImage(image.m_sharedImage) } } -NzImage::NzImage(NzImage&& image) : +NzImage::NzImage(NzImage&& image) noexcept : m_sharedImage(image.m_sharedImage) { image.m_sharedImage = &emptyImage; @@ -95,14 +95,15 @@ bool NzImage::Convert(nzPixelFormat format) unsigned int srcStride = pixelsPerFace * NzPixelFormat::GetBPP(m_sharedImage->format); unsigned int dstStride = pixelsPerFace * NzPixelFormat::GetBPP(format); - levels[i] = ptr; - for (unsigned int d = 0; d < depth; ++d) { if (!NzPixelFormat::Convert(m_sharedImage->format, format, pixels, &pixels[srcStride], ptr)) { NazaraError("Failed to convert image"); - for (unsigned int j = 0; j <= i; ++j) + + // Nettoyage de la mémoire + delete[] ptr; // Permet une optimisation de boucle (GCC) + for (unsigned int j = 0; j < i; ++j) delete[] levels[j]; delete[] levels; @@ -114,6 +115,8 @@ bool NzImage::Convert(nzPixelFormat format) ptr += dstStride; } + levels[i] = ptr; + if (width > 1) width >>= 1; @@ -223,6 +226,7 @@ bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width, } break; + case nzImageType_1D_Array: case nzImageType_2D: if (depth > 1) { @@ -231,6 +235,7 @@ bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width, } break; + case nzImageType_2D_Array: case nzImageType_3D: break; @@ -281,7 +286,10 @@ bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width, catch (const std::exception& e) { NazaraError("Failed to allocate image's level " + NzString::Number(i) + " (" + NzString(e.what()) + ')'); - for (unsigned int j = 0; j <= i; ++j) + + // Nettoyage + delete[] levels[i]; // Permet une optimisation de boucle (GCC) + for (unsigned int j = 0; j < i; ++j) delete[] levels[j]; delete[] levels; @@ -302,7 +310,7 @@ void NzImage::Destroy() bool NzImage::Fill(const NzColor& color) { - #if NAZARA_RENDERER_SAFE + #if NAZARA_UTILITY_SAFE if (!IsValid()) { NazaraError("Image must be valid"); @@ -399,6 +407,7 @@ bool NzImage::Fill(const NzColor& color, const NzRectui& rect, unsigned int z) return false; } + ///FIXME: L'algorithme a du mal avec un bpp non multiple de 2 nzUInt8* dstPixels = GetPixelPtr(m_sharedImage->pixels[0], bpp, rect.x, rect.y, z, m_sharedImage->width, m_sharedImage->height); unsigned int srcStride = rect.width * bpp; unsigned int dstStride = m_sharedImage->width * bpp; @@ -415,6 +424,8 @@ bool NzImage::Fill(const NzColor& color, const NzRectui& rect, unsigned int z) dstPixels += dstStride; } + delete[] pixels; + return true; } @@ -452,6 +463,7 @@ bool NzImage::Fill(const NzColor& color, const NzCubeui& cube) return false; } + ///FIXME: L'algorithme a du mal avec un bpp non multiple de 2 nzUInt8* dstPixels = GetPixelPtr(m_sharedImage->pixels[0], bpp, cube.x, cube.y, cube.z, m_sharedImage->width, m_sharedImage->height); unsigned int srcStride = cube.width * bpp; unsigned int dstStride = m_sharedImage->width * bpp; @@ -562,7 +574,7 @@ nzUInt8 NzImage::GetBPP() const return NzPixelFormat::GetBPP(m_sharedImage->format); } -const nzUInt8* NzImage::GetConstPixels(nzUInt8 level, unsigned int x, unsigned int y, unsigned int z) const +const nzUInt8* NzImage::GetConstPixels(unsigned int x, unsigned int y, unsigned int z, nzUInt8 level) const { #if NAZARA_UTILITY_SAFE if (!IsValid()) @@ -571,12 +583,6 @@ const nzUInt8* NzImage::GetConstPixels(nzUInt8 level, unsigned int x, unsigned i return nullptr; } - if (level >= m_sharedImage->levelCount) - { - NazaraError("Level out of bounds (" + NzString::Number(level) + " >= " + NzString::Number(m_sharedImage->levelCount) + ')'); - return nullptr; - } - if (x >= m_sharedImage->width) { NazaraError("X value exceeds width (" + NzString::Number(x) + " >= (" + NzString::Number(m_sharedImage->width) + ')'); @@ -595,6 +601,12 @@ const nzUInt8* NzImage::GetConstPixels(nzUInt8 level, unsigned int x, unsigned i NazaraError("Z value exceeds depth (" + NzString::Number(z) + " >= (" + NzString::Number(depth) + ')'); return nullptr; } + + if (level >= m_sharedImage->levelCount) + { + NazaraError("Level out of bounds (" + NzString::Number(level) + " >= " + NzString::Number(m_sharedImage->levelCount) + ')'); + return nullptr; + } #endif return GetPixelPtr(m_sharedImage->pixels[level], NzPixelFormat::GetBPP(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height); @@ -685,7 +697,7 @@ NzColor NzImage::GetPixelColor(unsigned int x, unsigned int y, unsigned int z) c return color; } -nzUInt8* NzImage::GetPixels(nzUInt8 level, unsigned int x, unsigned int y, unsigned int z) +nzUInt8* NzImage::GetPixels(unsigned int x, unsigned int y, unsigned int z, nzUInt8 level) { #if NAZARA_UTILITY_SAFE if (!IsValid()) @@ -694,12 +706,6 @@ nzUInt8* NzImage::GetPixels(nzUInt8 level, unsigned int x, unsigned int y, unsig return nullptr; } - if (level >= m_sharedImage->levelCount) - { - NazaraError("Level out of bounds (" + NzString::Number(level) + " >= " + NzString::Number(m_sharedImage->levelCount) + ')'); - return nullptr; - } - if (x >= m_sharedImage->width) { NazaraError("X value exceeds width (" + NzString::Number(x) + " >= (" + NzString::Number(m_sharedImage->width) + ')'); @@ -718,6 +724,13 @@ nzUInt8* NzImage::GetPixels(nzUInt8 level, unsigned int x, unsigned int y, unsig NazaraError("Z value exceeds depth (" + NzString::Number(z) + " >= (" + NzString::Number(depth) + ')'); return nullptr; } + + + if (level >= m_sharedImage->levelCount) + { + NazaraError("Level out of bounds (" + NzString::Number(level) + " >= " + NzString::Number(m_sharedImage->levelCount) + ')'); + return nullptr; + } #endif EnsureOwnership(); @@ -1077,7 +1090,7 @@ NzImage& NzImage::operator=(const NzImage& image) return *this; } -NzImage& NzImage::operator=(NzImage&& image) +NzImage& NzImage::operator=(NzImage&& image) noexcept { std::swap(m_sharedImage, image.m_sharedImage); @@ -1086,11 +1099,11 @@ NzImage& NzImage::operator=(NzImage&& image) nzUInt8 NzImage::GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth) { - static const float l2 = std::log(2); + static const float l2 = std::log(2.f); - unsigned int widthLevel = std::log(width)/l2; - unsigned int heightLevel = std::log(height)/l2; - unsigned int depthLevel = std::log(depth)/l2; + unsigned int widthLevel = std::log(static_cast(width))/l2; + unsigned int heightLevel = std::log(static_cast(height))/l2; + unsigned int depthLevel = std::log(static_cast(depth))/l2; return std::max(std::max(std::max(widthLevel, heightLevel), depthLevel), 1U); } diff --git a/src/Nazara/Utility/Loaders/MD2/Loader.cpp b/src/Nazara/Utility/Loaders/MD2/Loader.cpp index b625ede27..cd9fc862b 100644 --- a/src/Nazara/Utility/Loaders/MD2/Loader.cpp +++ b/src/Nazara/Utility/Loaders/MD2/Loader.cpp @@ -48,7 +48,7 @@ namespace } // Les fichiers MD2 sont en little endian - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) NzByteSwap(&header.ident, sizeof(nzUInt32)); #endif @@ -58,7 +58,7 @@ namespace return false; } - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) NzByteSwap(&header.version, sizeof(nzUInt32)); #endif @@ -68,7 +68,7 @@ namespace return false; } - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) NzByteSwap(&header.skinwidth, sizeof(nzUInt32)); NzByteSwap(&header.skinheight, sizeof(nzUInt32)); NzByteSwap(&header.framesize, sizeof(nzUInt32)); @@ -129,6 +129,7 @@ namespace NzAnimation* animation = new NzAnimation; if (animation->Create(nzAnimationType_Keyframe, endFrame-startFrame+1)) { + // Décodage des séquences NzString frameName; NzSequence sequence; @@ -154,7 +155,7 @@ namespace stream.SetCursorPos(header.offset_frames + i*header.framesize + offsetof(md2_frame, name)); stream.Read(name, 16*sizeof(char)); - int pos = std::strlen(name)-1; + pos = std::strlen(name)-1; for (unsigned int j = 0; j < 2; ++j) { if (!std::isdigit(name[pos])) @@ -217,7 +218,7 @@ namespace const md2_header* header = reinterpret_cast(data); - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) nzUInt32 ident = header->ident; nzUInt32 version = header->version; @@ -238,7 +239,7 @@ namespace if (stream.Read(&magic[0], 2*sizeof(nzUInt32)) != 2*sizeof(nzUInt32)) return false; - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) NzByteSwap(&magic[0], sizeof(nzUInt32)); NzByteSwap(&magic[1], sizeof(nzUInt32)); #endif diff --git a/src/Nazara/Utility/Loaders/MD2/Mesh.cpp b/src/Nazara/Utility/Loaders/MD2/Mesh.cpp index 184bb868f..1accab406 100644 --- a/src/Nazara/Utility/Loaders/MD2/Mesh.cpp +++ b/src/Nazara/Utility/Loaders/MD2/Mesh.cpp @@ -41,7 +41,7 @@ bool NzMD2Mesh::Create(const md2_header& header, NzInputStream& stream, const Nz stream.SetCursorPos(header.offset_st); stream.Read(&texCoords[0], header.num_st*sizeof(md2_texCoord)); - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) for (unsigned int i = 0; i < header.num_st; ++i) { NzByteSwap(&texCoords[i].u, sizeof(nzInt16)); @@ -52,7 +52,7 @@ bool NzMD2Mesh::Create(const md2_header& header, NzInputStream& stream, const Nz stream.SetCursorPos(header.offset_tris); stream.Read(&triangles[0], header.num_tris*sizeof(md2_triangle)); - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) for (unsigned int i = 0; i < header.num_tris; ++i) { NzByteSwap(&triangles[i].vertices[0], sizeof(nzUInt16)); @@ -72,9 +72,7 @@ bool NzMD2Mesh::Create(const md2_header& header, NzInputStream& stream, const Nz frame.vertices.resize(header.num_vertices); // Pour que le modèle soit correctement aligné, on génère une matrice de rotation que nous appliquerons à chacune des vertices - NzMatrix4f rotationMatrix = NzMatrix4f::Rotate(NzEulerAnglesf(-90.f, 0.f, -90.f)); - //NzMatrix4f rotationMatrix; - //rotationMatrix.SetIdentity(); + NzMatrix4f rotationMatrix = NzMatrix4f::Rotate(NzEulerAnglesf(90.f, -90.f, 0.f)); unsigned int stride = s_declaration.GetStride(nzElementStream_VertexData); @@ -86,7 +84,7 @@ bool NzMD2Mesh::Create(const md2_header& header, NzInputStream& stream, const Nz stream.Read(&frame.name, 16*sizeof(char)); stream.Read(&frame.vertices[0], header.num_vertices*sizeof(md2_vertex)); - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) NzByteSwap(&frame.scale.x, sizeof(float)); NzByteSwap(&frame.scale.y, sizeof(float)); NzByteSwap(&frame.scale.z, sizeof(float)); @@ -98,6 +96,8 @@ bool NzMD2Mesh::Create(const md2_header& header, NzInputStream& stream, const Nz m_frames[i].normal = new nzUInt8[m_vertexCount]; // Nous stockons l'indice de la normale plutôt que la normale (gain d'espace) m_frames[i].vertices = new NzVector3f[m_vertexCount]; + + NzVector3f max, min; for (unsigned int t = 0; t < header.num_tris; ++t) { for (unsigned int v = 0; v < 3; ++v) @@ -105,17 +105,19 @@ bool NzMD2Mesh::Create(const md2_header& header, NzInputStream& stream, const Nz const md2_vertex& vert = frame.vertices[triangles[t].vertices[v]]; NzVector3f vertex = rotationMatrix * NzVector3f(vert.x * frame.scale.x + frame.translate.x, vert.y * frame.scale.y + frame.translate.y, vert.z * frame.scale.z + frame.translate.z); + max.MakeCeil(vertex); + min.MakeFloor(vertex); m_frames[i].normal[t*3+v] = vert.n; m_frames[i].vertices[t*3+v] = vertex; } } + + m_frames[i].aabb.SetExtends(min, max); } - nzBufferStorage storage = (NzBuffer::IsSupported(nzBufferStorage_Hardware) && !parameters.forceSoftware) ? nzBufferStorage_Hardware : nzBufferStorage_Software; - m_indexBuffer = nullptr; // Pas d'indexbuffer pour l'instant - m_vertexBuffer = new NzVertexBuffer(m_vertexCount, (3+3+2)*sizeof(float), storage, nzBufferUsage_Dynamic); + m_vertexBuffer = new NzVertexBuffer(m_vertexCount, (3+3+2)*sizeof(float), parameters.storage, nzBufferUsage_Dynamic); nzUInt8* ptr = reinterpret_cast(m_vertexBuffer->Map(nzBufferAccess_WriteOnly)); if (!ptr) @@ -185,6 +187,11 @@ void NzMD2Mesh::Destroy() } } +const NzAxisAlignedBox& NzMD2Mesh::GetAABB() const +{ + return m_aabb; +} + nzAnimationType NzMD2Mesh::GetAnimationType() const { if (m_frameCount > 1) @@ -262,14 +269,19 @@ void NzMD2Mesh::AnimateImpl(unsigned int frameA, unsigned int frameB, float inte NzVector3f* position = reinterpret_cast(ptr + positionOffset); NzVector3f* normal = reinterpret_cast(ptr + normalOffset); - *position = fA->vertices[i] + interpolation * (fB->vertices[i] - fA->vertices[i]); - *normal = md2Normals[fA->normal[i]] + interpolation * (md2Normals[fB->normal[i]] - md2Normals[fA->normal[i]]); + *position = fA->vertices[i] + interpolation * (fB->vertices[i] - fA->vertices[i]); + *normal = md2Normals[fA->normal[i]] + interpolation * (md2Normals[fB->normal[i]] - md2Normals[fA->normal[i]]); ptr += stride; } if (!m_vertexBuffer->Unmap()) NazaraWarning("Failed to unmap vertex buffer, expect mesh corruption"); + + // Interpolation de l'AABB + NzVector3f max1 = fA->aabb.GetMaximum(); + NzVector3f min1 = fA->aabb.GetMinimum(); + m_aabb.SetExtends(min1 + interpolation * (fB->aabb.GetMinimum() - min1), max1 + interpolation * (fB->aabb.GetMaximum() - max1)); } NzVertexDeclaration NzMD2Mesh::s_declaration; diff --git a/src/Nazara/Utility/Loaders/MD2/Mesh.hpp b/src/Nazara/Utility/Loaders/MD2/Mesh.hpp index 5b0b47efd..baa5cc9a8 100644 --- a/src/Nazara/Utility/Loaders/MD2/Mesh.hpp +++ b/src/Nazara/Utility/Loaders/MD2/Mesh.hpp @@ -27,6 +27,7 @@ class NAZARA_API NzMD2Mesh : public NzKeyframeMesh bool Create(const md2_header& header, NzInputStream& stream, const NzMeshParams& parameters); void Destroy(); + const NzAxisAlignedBox& GetAABB() const; nzAnimationType GetAnimationType() const; unsigned int GetFrameCount() const; const NzIndexBuffer* GetIndexBuffer() const; @@ -44,14 +45,14 @@ class NAZARA_API NzMD2Mesh : public NzKeyframeMesh struct Frame { - //AxisAlignedBox aabb; + NzAxisAlignedBox aabb; nzUInt8* normal; NzVector3f* tangents; NzVector3f* vertices; char name[16]; }; - //AxisAlignedBox m_aabb; + NzAxisAlignedBox m_aabb; Frame* m_frames; NzIndexBuffer* m_indexBuffer; NzVertexBuffer* m_vertexBuffer; diff --git a/src/Nazara/Utility/Loaders/PCX/Loader.cpp b/src/Nazara/Utility/Loaders/PCX/Loader.cpp index fd30498cd..abf21a8a7 100644 --- a/src/Nazara/Utility/Loaders/PCX/Loader.cpp +++ b/src/Nazara/Utility/Loaders/PCX/Loader.cpp @@ -74,7 +74,7 @@ namespace return false; } - #if NAZARA_BIG_ENDIAN + #if defined(NAZARA_BIG_ENDIAN) // Les fichiers PCX sont en little endian NzByteSwap(&header.xmin, sizeof(nzUInt16)); NzByteSwap(&header.ymin, sizeof(nzUInt16)); diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 7214e8bd3..db61476ce 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -18,6 +19,12 @@ bool NzMeshParams::IsValid() const return false; } + if (!NzBuffer::IsSupported(storage)) + { + NazaraError("Storage not supported"); + return false; + } + return true; } @@ -27,6 +34,7 @@ struct NzMeshImpl std::deque skins; std::vector subMeshes; nzAnimationType animationType; + NzAxisAlignedBox aabb; const NzAnimation* animation = nullptr; }; @@ -76,6 +84,8 @@ nzUInt8 NzMesh::AddSubMesh(NzSubMesh* subMesh) #endif subMesh->AddResourceReference(); + + m_impl->aabb.SetNull(); // On invalide l'AABB m_impl->subMeshes.push_back(subMesh); return m_impl->subMeshes.size()-1; @@ -114,6 +124,7 @@ nzUInt8 NzMesh::AddSubMesh(const NzString& identifier, NzSubMesh* subMesh) subMesh->AddResourceReference(); + m_impl->aabb.SetNull(); // On invalide l'AABB m_impl->subMeshes.push_back(subMesh); m_impl->subMeshMap[identifier] = index; @@ -157,6 +168,8 @@ void NzMesh::Animate(unsigned int frameA, unsigned int frameB, float interpolati for (NzSubMesh* subMesh : m_impl->subMeshes) subMesh->AnimateImpl(frameA, frameB, interpolation); + + m_impl->aabb.SetNull(); // On invalide l'AABB } bool NzMesh::Create(nzAnimationType type) @@ -184,6 +197,25 @@ void NzMesh::Destroy() } } +const NzAxisAlignedBox& NzMesh::GetAABB() const +{ + #if NAZARA_UTILITY_SAFE + if (!m_impl) + { + NazaraError("Mesh not created"); + return NzAxisAlignedBox::Null; + } + #endif + + if (m_impl->aabb.IsNull()) + { + for (NzSubMesh* subMesh : m_impl->subMeshes) + m_impl->aabb.ExtendTo(subMesh->GetAABB()); + } + + return m_impl->aabb; +} + const NzAnimation* NzMesh::GetAnimation() const { #if NAZARA_UTILITY_SAFE @@ -373,6 +405,19 @@ unsigned int NzMesh::GetVertexCount() const return vertexCount; } +void NzMesh::InvalidateAABB() const +{ + #if NAZARA_UTILITY_SAFE + if (!m_impl) + { + NazaraError("Mesh not created"); + return; + } + #endif + + m_impl->aabb.SetNull(); +} + bool NzMesh::HasAnimation() const { #if NAZARA_UTILITY_SAFE @@ -505,6 +550,8 @@ void NzMesh::RemoveSubMesh(const NzString& identifier) std::advance(it2, index); m_impl->subMeshes.erase(it2); + + m_impl->aabb.SetNull(); // On invalide l'AABB } void NzMesh::RemoveSubMesh(nzUInt8 index) @@ -527,6 +574,8 @@ void NzMesh::RemoveSubMesh(nzUInt8 index) std::advance(it, index); m_impl->subMeshes.erase(it); + + m_impl->aabb.SetNull(); // On invalide l'AABB } bool NzMesh::SetAnimation(const NzAnimation* animation) diff --git a/src/Nazara/Utility/Mouse.cpp b/src/Nazara/Utility/Mouse.cpp index 0efd05663..206ea6c1d 100644 --- a/src/Nazara/Utility/Mouse.cpp +++ b/src/Nazara/Utility/Mouse.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #if defined(NAZARA_PLATFORM_WINDOWS) #include @@ -36,6 +37,9 @@ void NzMouse::SetPosition(const NzVector2i& position) void NzMouse::SetPosition(const NzVector2i& position, const NzWindow& relativeTo) { + if (position.x > 0 && position.y > 0) + relativeTo.IgnoreNextMouseEvent(position.x, position.y); + NzEventImpl::SetMousePosition(position.x, position.y, relativeTo); } @@ -46,5 +50,8 @@ void NzMouse::SetPosition(int x, int y) void NzMouse::SetPosition(int x, int y, const NzWindow& relativeTo) { + if (x > 0 && y > 0) + relativeTo.IgnoreNextMouseEvent(x, y); + NzEventImpl::SetMousePosition(x, y, relativeTo); } diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index c4178b4b4..ee440c489 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -1320,5 +1320,5 @@ void NzPixelFormat::Uninitialize() s_flipFunctions[i].clear(); } -NzPixelFormat::ConvertFunction NzPixelFormat::s_convertFunctions[nzPixelFormat_Max+1][nzPixelFormat_Max+1] = {{0}}; ///FIXME: Fonctionne correctement ? +NzPixelFormat::ConvertFunction NzPixelFormat::s_convertFunctions[nzPixelFormat_Max+1][nzPixelFormat_Max+1] = {{nullptr}}; ///FIXME: Fonctionne correctement ? std::map NzPixelFormat::s_flipFunctions[nzPixelFlipping_Max+1]; diff --git a/src/Nazara/Utility/StaticMesh.cpp b/src/Nazara/Utility/StaticMesh.cpp index 42171bb25..7d72e29c6 100644 --- a/src/Nazara/Utility/StaticMesh.cpp +++ b/src/Nazara/Utility/StaticMesh.cpp @@ -12,17 +12,17 @@ NzSubMesh(parent) { } -NzStaticMesh::NzStaticMesh(const NzMesh* parent, const NzVertexBuffer* vertexBuffer, const NzVertexDeclaration* vertexDeclaration, const NzIndexBuffer* indexBuffer) : +NzStaticMesh::NzStaticMesh(const NzMesh* parent, const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer) : NzSubMesh(parent) { #ifdef NAZARA_DEBUG - if (!Create(vertexBuffer, vertexDeclaration, indexBuffer)) + if (!Create(vertexDeclaration, vertexBuffer, indexBuffer)) { NazaraError("Failed to create mesh"); throw std::runtime_error("Constructor failed"); } #else - Create(vertexBuffer, vertexDeclaration, indexBuffer); + Create(vertexDeclaration, vertexBuffer, indexBuffer); #endif } @@ -31,22 +31,22 @@ NzStaticMesh::~NzStaticMesh() Destroy(); } -bool NzStaticMesh::Create(const NzVertexBuffer* vertexBuffer, const NzVertexDeclaration* vertexDeclaration, const NzIndexBuffer* indexBuffer) +bool NzStaticMesh::Create(const NzVertexDeclaration* vertexDeclaration, NzVertexBuffer* vertexBuffer, NzIndexBuffer* indexBuffer) { Destroy(); #if NAZARA_UTILITY_SAFE - if (!vertexBuffer) - { - NazaraError("Vertex buffer is null"); - return false; - } - if (!vertexDeclaration) { NazaraError("Vertex declaration is null"); return false; } + + if (!vertexBuffer) + { + NazaraError("Vertex buffer is null"); + return false; + } #endif if (indexBuffer) @@ -66,6 +66,8 @@ bool NzStaticMesh::Create(const NzVertexBuffer* vertexBuffer, const NzVertexDecl void NzStaticMesh::Destroy() { + m_aabb.SetNull(); + if (m_indexBuffer) { m_indexBuffer->RemoveResourceReference(); @@ -85,6 +87,44 @@ void NzStaticMesh::Destroy() } } +bool NzStaticMesh::GenerateAABB() +{ + if (!m_aabb.IsNull()) + return true; + + const NzVertexElement* position = m_vertexDeclaration->GetElement(nzElementStream_VertexData, nzElementUsage_Position); + if (position && position->type == nzElementType_Float3) // Si nous avons des positions du type Vec3 + { + // On lock le buffer pour itérer sur toutes les positions et composer notre AABB + nzUInt8* buffer = reinterpret_cast(m_vertexBuffer->Map(nzBufferAccess_ReadOnly)); + if (!buffer) + { + NazaraWarning("Failed to lock vertex buffer"); + return false; + } + + buffer += position->offset; + unsigned int stride = m_vertexDeclaration->GetStride(nzElementStream_VertexData); + unsigned int vertexCount = m_vertexBuffer->GetVertexCount(); + for (unsigned int i = 0; i < vertexCount; ++i) + { + m_aabb.ExtendTo(*reinterpret_cast(buffer)); + + buffer += stride; + } + + if (!m_vertexBuffer->Unmap()) + NazaraWarning("Failed to unmap vertex buffer"); + } + + return true; +} + +const NzAxisAlignedBox& NzStaticMesh::GetAABB() const +{ + return m_aabb; +} + nzAnimationType NzStaticMesh::GetAnimationType() const { return nzAnimationType_Static; @@ -125,6 +165,11 @@ bool NzStaticMesh::IsValid() const return m_vertexBuffer != nullptr && m_vertexDeclaration != nullptr; } +void NzStaticMesh::SetAABB(const NzAxisAlignedBox& aabb) +{ + m_aabb = aabb; +} + void NzStaticMesh::SetPrimitiveType(nzPrimitiveType primitiveType) { m_primitiveType = primitiveType; diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index 40a6bd661..d4a7e6ce3 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -14,7 +14,7 @@ NzSubMesh::NzSubMesh(const NzMesh* parent) : NzResource(false), // Un SubMesh n'est pas persistant par défaut m_parent(parent) { - #if NAZARA_DEBUG + #ifdef NAZARA_DEBUG if (!m_parent) { NazaraError("Parent mesh is null"); @@ -55,6 +55,8 @@ void NzSubMesh::Animate(unsigned int frameA, unsigned int frameB, float interpol #endif AnimateImpl(frameA, frameB, interpolation); + + m_parent->InvalidateAABB(); } const NzMesh* NzSubMesh::GetParent() const diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 0d5b541cb..755b05120 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -3,7 +3,9 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include +#include #include #include #include @@ -13,26 +15,19 @@ #include #include -NzUtility::NzUtility() -{ -} - -NzUtility::~NzUtility() -{ - if (s_initialized) - Uninitialize(); -} - bool NzUtility::Initialize() { - #if NAZARA_UTILITY_SAFE - if (s_initialized) - { - NazaraError("Renderer already initialized"); - return true; - } - #endif + if (s_moduleReferenceCouter++ != 0) + return true; // Déjà initialisé + // Initialisation des dépendances + if (!NzCore::Initialize()) + { + NazaraError("Failed to initialize core module"); + return false; + } + + // Initialisation du module if (!NzBuffer::Initialize()) { NazaraError("Failed to initialize buffers"); @@ -64,21 +59,22 @@ bool NzUtility::Initialize() // Image NzLoaders_STB_Register(); // Loader générique (STB) - s_initialized = true; + NazaraNotice("Initialized: Utility module"); return true; } +bool NzUtility::IsInitialized() +{ + return s_moduleReferenceCouter != 0; +} + void NzUtility::Uninitialize() { - #if NAZARA_UTILITY_SAFE - if (!s_initialized) - { - NazaraError("Utility not initialized"); - return; - } - #endif + if (--s_moduleReferenceCouter != 0) + return; // Encore utilisé + // Libération du module NzLoaders_MD2_Unregister(); NzLoaders_PCX_Unregister(); NzLoaders_STB_Unregister(); @@ -87,12 +83,11 @@ void NzUtility::Uninitialize() NzPixelFormat::Uninitialize(); NzBuffer::Uninitialize(); - s_initialized = false; + NazaraNotice("Uninitialized: Utility module"); + + // Libération des dépendances + NzCore::Uninitialize(); } -bool NzUtility::IsInitialized() -{ - return s_initialized; -} +unsigned int NzUtility::s_moduleReferenceCouter = 0; -bool NzUtility::s_initialized = false; diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 8db74ddd2..1d8f546f7 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -10,7 +10,7 @@ #include #include -#if NAZARA_THREADSAFETY_VERTEXDECLARATION +#if NAZARA_UTILITY_THREADSAFE && NAZARA_THREADSAFETY_VERTEXDECLARATION #include #else #include @@ -22,15 +22,15 @@ namespace { const unsigned int size[] = { - 4, // nzElementType_Color - 8, // nzElementType_Double1 - 16, // nzElementType_Double2 - 24, // nzElementType_Double3 - 32, // nzElementType_Double4 - 4, // nzElementType_Float1 - 8, // nzElementType_Float2 - 12, // nzElementType_Float3 - 16 // nzElementType_Float4 + sizeof(nzUInt32), // nzElementType_Color + 1*sizeof(double), // nzElementType_Double1 + 2*sizeof(double), // nzElementType_Double2 + 3*sizeof(double), // nzElementType_Double3 + 4*sizeof(double), // nzElementType_Double4 + 1*sizeof(float), // nzElementType_Float1 + 2*sizeof(float), // nzElementType_Float2 + 3*sizeof(float), // nzElementType_Float3 + 4*sizeof(float) // nzElementType_Float4 }; bool VertexElementCompare(const NzVertexElement& elementA, const NzVertexElement& elementB) @@ -57,7 +57,7 @@ struct NzVertexDeclarationImpl int streamPos[nzElementStream_Max+1]; unsigned int stride[nzElementStream_Max+1] = {0}; - unsigned short refCount; + unsigned short refCount = 1; NazaraMutex(mutex) }; @@ -86,7 +86,7 @@ m_sharedImpl(declaration.m_sharedImpl) } } -NzVertexDeclaration::NzVertexDeclaration(NzVertexDeclaration&& declaration) : +NzVertexDeclaration::NzVertexDeclaration(NzVertexDeclaration&& declaration) noexcept : m_sharedImpl(declaration.m_sharedImpl) { declaration.m_sharedImpl = nullptr; @@ -146,7 +146,7 @@ bool NzVertexDeclaration::Create(const NzVertexElement* elements, unsigned int e impl->stride[current.stream] += size[current.type]; } - #if NAZARA_RENDERER_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 + #if NAZARA_UTILITY_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 for (unsigned int& stride : impl->stride) stride = ((static_cast(stride)-1)/32+1)*32; #endif @@ -335,7 +335,7 @@ NzVertexDeclaration& NzVertexDeclaration::operator=(const NzVertexDeclaration& d return *this; } -NzVertexDeclaration& NzVertexDeclaration::operator=(NzVertexDeclaration&& declaration) +NzVertexDeclaration& NzVertexDeclaration::operator=(NzVertexDeclaration&& declaration) noexcept { Destroy(); diff --git a/src/Nazara/Utility/Win32/InputImpl.cpp b/src/Nazara/Utility/Win32/InputImpl.cpp index 4d44710db..a91c92cce 100644 --- a/src/Nazara/Utility/Win32/InputImpl.cpp +++ b/src/Nazara/Utility/Win32/InputImpl.cpp @@ -192,7 +192,7 @@ bool NzEventImpl::IsKeyPressed(NzKeyboard::Key key) bool NzEventImpl::IsMouseButtonPressed(NzMouse::Button button) { - static int vButtons[NzMouse::Count] = { + static int vButtons[NzMouse::Max+1] = { VK_LBUTTON, // Button::Left VK_MBUTTON, // Button::Middle VK_RBUTTON, // Button::Right diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index 5b525c959..ec8dd7b96 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -7,10 +7,10 @@ #define OEMRESOURCE #include +#include #include #include #include -#include #include #include #include @@ -53,28 +53,6 @@ m_scrolling(0) { } -void NzWindowImpl::Close() -{ - if (m_ownsWindow) - { - #if NAZARA_UTILITY_THREADED_WINDOW - if (m_thread) - { - m_threadActive = false; - PostMessageW(m_handle, WM_NULL, 0, 0); // Pour réveiller le thread - - m_thread->Join(); - delete m_thread; - } - #else - if (m_handle) - DestroyWindow(m_handle); - #endif - } - else - SetEventListener(false); -} - bool NzWindowImpl::Create(NzVideoMode mode, const NzString& title, nzUInt32 style) { bool fullscreen = (style & nzWindowStyle_Fullscreen) != 0; @@ -99,6 +77,7 @@ bool NzWindowImpl::Create(NzVideoMode mode, const NzString& title, nzUInt32 styl } } + // Testé une seconde fois car sa valeur peut changer if (fullscreen) { x = 0; @@ -143,7 +122,7 @@ bool NzWindowImpl::Create(NzVideoMode mode, const NzString& title, nzUInt32 styl #if NAZARA_UTILITY_THREADED_WINDOW NzMutex mutex; - NzThreadCondition condition; + NzConditionVariable condition; m_thread = new NzThread(WindowThread, &m_handle, win32StyleEx, wtitle, win32Style, x, y, width, height, this, &mutex, &condition); m_threadActive = true; @@ -166,6 +145,9 @@ bool NzWindowImpl::Create(NzVideoMode mode, const NzString& title, nzUInt32 styl m_eventListener = true; m_ownsWindow = true; + #if !NAZARA_UTILITY_THREADED_WINDOW + m_sizemove = false; + #endif return m_handle != nullptr; } @@ -181,10 +163,35 @@ bool NzWindowImpl::Create(NzWindowHandle handle) m_handle = reinterpret_cast(handle); m_eventListener = false; m_ownsWindow = false; + #if !NAZARA_UTILITY_THREADED_WINDOW + m_sizemove = false; + #endif return true; } +void NzWindowImpl::Destroy() +{ + if (m_ownsWindow) + { + #if NAZARA_UTILITY_THREADED_WINDOW + if (m_thread) + { + m_threadActive = false; + PostMessageW(m_handle, WM_NULL, 0, 0); // Pour réveiller le thread + + m_thread->Join(); + delete m_thread; + } + #else + if (m_handle) + DestroyWindow(m_handle); + #endif + } + else + SetEventListener(false); +} + void NzWindowImpl::EnableKeyRepeat(bool enable) { m_keyRepeat = enable; @@ -267,6 +274,13 @@ void NzWindowImpl::ProcessEvents(bool block) } } +void NzWindowImpl::IgnoreNextMouseEvent(int mouseX, int mouseY) +{ + // Petite astuce ... + m_mousePos.x = mouseX; + m_mousePos.y = mouseY; +} + bool NzWindowImpl::IsMinimized() const { return IsIconic(m_handle); @@ -317,12 +331,12 @@ void NzWindowImpl::SetCursor(nzWindowCursor cursor) case nzWindowCursor_ResizeNW: case nzWindowCursor_ResizeSE: - m_cursor = reinterpret_cast(LoadImage(nullptr, IDC_SIZENESW, IMAGE_CURSOR, 0, 0, LR_SHARED)); + m_cursor = reinterpret_cast(LoadImage(nullptr, IDC_SIZENWSE, IMAGE_CURSOR, 0, 0, LR_SHARED)); break; case nzWindowCursor_ResizeNE: case nzWindowCursor_ResizeSW: - m_cursor = reinterpret_cast(LoadImage(nullptr, IDC_SIZENWSE, IMAGE_CURSOR, 0, 0, LR_SHARED)); + m_cursor = reinterpret_cast(LoadImage(nullptr, IDC_SIZENESW, IMAGE_CURSOR, 0, 0, LR_SHARED)); break; case nzWindowCursor_ResizeE: @@ -418,7 +432,7 @@ void NzWindowImpl::SetMinimumSize(int width, int height) void NzWindowImpl::SetPosition(int x, int y) { - SetWindowPos(m_handle, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + SetWindowPos(m_handle, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } void NzWindowImpl::SetSize(unsigned int width, unsigned int height) @@ -427,7 +441,15 @@ void NzWindowImpl::SetSize(unsigned int width, unsigned int height) RECT rect = {0, 0, static_cast(width), static_cast(height)}; AdjustWindowRect(&rect, GetWindowLongPtr(m_handle, GWL_STYLE), false); - SetWindowPos(m_handle, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER); + SetWindowPos(m_handle, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER); +} + +void NzWindowImpl::SetStayOnTop(bool stayOnTop) +{ + if (stayOnTop) + SetWindowPos(m_handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + else + SetWindowPos(m_handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } void NzWindowImpl::SetTitle(const NzString& title) @@ -442,11 +464,6 @@ void NzWindowImpl::SetVisible(bool visible) ShowWindow(m_handle, (visible) ? SW_SHOW : SW_HIDE); } -void NzWindowImpl::StayOnTop(bool stayOnTop) -{ - SetWindowPos(m_handle, (stayOnTop) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); -} - bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARAM lParam) { // Inutile de récupérer des évènements ne venant pas de notre fenêtre @@ -495,11 +512,13 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_CHAR: { // http://msdn.microsoft.com/en-us/library/ms646267(VS.85).aspx - if (m_keyRepeat || (HIWORD(lParam) & KF_REPEAT) == 0) + bool repeated = ((HIWORD(lParam) & KF_REPEAT) != 0); + if (m_keyRepeat || !repeated) { NzEvent event; - event.type = NzEvent::TextEntered; - event.text.character = static_cast(wParam); + event.type = nzEventType_TextEntered; + event.text.character = static_cast(wParam); + event.text.repeated = repeated; m_parent->PushEvent(event); } @@ -509,65 +528,64 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_CLOSE: { NzEvent event; - event.type = NzEvent::Quit; + event.type = nzEventType_Quit; m_parent->PushEvent(event); return true; // Afin que Windows ne ferme pas la fenêtre automatiquement } - case WM_LBUTTONDBLCLK: + #if !NAZARA_UTILITY_THREADED_WINDOW + case WM_ENTERSIZEMOVE: { - // Cet évènement est généré à la place d'un WM_LBUTTONDOWN lors d'un double-clic. - // Comme nous désirons quand même notifier chaque clic, nous envoyons les deux évènements. - NzEvent event; - event.mouseButton.button = NzMouse::Left; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - - event.type = NzEvent::MouseButtonDoubleClicked; - m_parent->PushEvent(event); - - event.type = NzEvent::MouseButtonPressed; - m_parent->PushEvent(event); - + m_sizemove = true; break; } - case WM_LBUTTONDOWN: + case WM_EXITSIZEMOVE: { - NzEvent event; - event.type = NzEvent::MouseButtonPressed; - event.mouseButton.button = NzMouse::Left; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); + m_sizemove = false; - break; + // On vérifie ce qui a changé + NzVector2i position = GetPosition(); + if (m_position != position) + { + m_position = position; + + NzEvent event; + event.type = nzEventType_Moved; + event.position.x = position.x; + event.position.y = position.y; + m_parent->PushEvent(event); + } + + NzVector2ui size = GetSize(); + if (m_size != size) + { + m_size = size; + + NzEvent event; + event.type = nzEventType_Resized; + event.size.width = size.x; + event.size.height = size.y; + m_parent->PushEvent(event); + } } - case WM_LBUTTONUP: - { - NzEvent event; - event.type = NzEvent::MouseButtonReleased; - event.mouseButton.button = NzMouse::Left; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } + #endif case WM_KEYDOWN: case WM_SYSKEYDOWN: { // http://msdn.microsoft.com/en-us/library/ms646267(VS.85).aspx - if (m_keyRepeat || (HIWORD(lParam) & KF_REPEAT) == 0) + bool repeated = ((HIWORD(lParam) & KF_REPEAT) != 0); + if (m_keyRepeat || !repeated) { NzEvent event; - event.type = NzEvent::KeyPressed; + event.type = nzEventType_KeyPressed; event.key.code = ConvertVirtualKey(wParam, lParam); event.key.alt = ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0); event.key.control = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0); + event.key.repeated = repeated; event.key.shift = ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0); event.key.system = (((GetAsyncKeyState(VK_LWIN) & 0x8000) != 0) || ((GetAsyncKeyState(VK_RWIN) & 0x8000) != 0)); m_parent->PushEvent(event); @@ -581,7 +599,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA { // http://msdn.microsoft.com/en-us/library/ms646267(VS.85).aspx NzEvent event; - event.type = NzEvent::KeyReleased; + event.type = nzEventType_KeyReleased; event.key.code = ConvertVirtualKey(wParam, lParam); event.key.alt = ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0); event.key.control = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0); @@ -595,7 +613,49 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_KILLFOCUS: { NzEvent event; - event.type = NzEvent::LostFocus; + event.type = nzEventType_LostFocus; + m_parent->PushEvent(event); + + break; + } + + case WM_LBUTTONDBLCLK: + { + // Cet évènement est généré à la place d'un WM_LBUTTONDOWN lors d'un double-clic. + // Comme nous désirons quand même notifier chaque clic, nous envoyons les deux évènements. + NzEvent event; + event.mouseButton.button = NzMouse::Left; + event.mouseButton.x = GET_X_LPARAM(lParam); + event.mouseButton.y = GET_Y_LPARAM(lParam); + + event.type = nzEventType_MouseButtonDoubleClicked; + m_parent->PushEvent(event); + + event.type = nzEventType_MouseButtonPressed; + m_parent->PushEvent(event); + + break; + } + + case WM_LBUTTONDOWN: + { + NzEvent event; + event.type = nzEventType_MouseButtonPressed; + event.mouseButton.button = NzMouse::Left; + event.mouseButton.x = GET_X_LPARAM(lParam); + event.mouseButton.y = GET_Y_LPARAM(lParam); + m_parent->PushEvent(event); + + break; + } + + case WM_LBUTTONUP: + { + NzEvent event; + event.type = nzEventType_MouseButtonReleased; + event.mouseButton.button = NzMouse::Left; + event.mouseButton.x = GET_X_LPARAM(lParam); + event.mouseButton.y = GET_Y_LPARAM(lParam); m_parent->PushEvent(event); break; @@ -608,10 +668,10 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA event.mouseButton.x = GET_X_LPARAM(lParam); event.mouseButton.y = GET_Y_LPARAM(lParam); - event.type = NzEvent::MouseButtonDoubleClicked; + event.type = nzEventType_MouseButtonDoubleClicked; m_parent->PushEvent(event); - event.type = NzEvent::MouseButtonPressed; + event.type = nzEventType_MouseButtonPressed; m_parent->PushEvent(event); break; @@ -620,7 +680,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_MBUTTONDOWN: { NzEvent event; - event.type = NzEvent::MouseButtonPressed; + event.type = nzEventType_MouseButtonPressed; event.mouseButton.button = NzMouse::Middle; event.mouseButton.x = GET_X_LPARAM(lParam); event.mouseButton.y = GET_Y_LPARAM(lParam); @@ -632,7 +692,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_MBUTTONUP: { NzEvent event; - event.type = NzEvent::MouseButtonReleased; + event.type = nzEventType_MouseButtonReleased; event.mouseButton.button = NzMouse::Middle; event.mouseButton.x = GET_X_LPARAM(lParam); event.mouseButton.y = GET_Y_LPARAM(lParam); @@ -648,13 +708,16 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA m_mouseInside = false; NzEvent event; - event.type = NzEvent::MouseLeft; + event.type = nzEventType_MouseLeft; m_parent->PushEvent(event); break; } case WM_MOUSEMOVE: { + int currentX = GET_X_LPARAM(lParam); + int currentY = GET_Y_LPARAM(lParam); + if (!m_mouseInside) { m_mouseInside = true; @@ -667,14 +730,37 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA TrackMouseEvent(&mouseEvent); NzEvent event; - event.type = NzEvent::MouseEntered; + event.type = nzEventType_MouseEntered; m_parent->PushEvent(event); + + event.type = nzEventType_MouseMoved; + + // Le delta sera 0 + event.mouseMove.deltaX = 0; + event.mouseMove.deltaY = 0; + + event.mouseMove.x = currentX; + event.mouseMove.y = currentY; + + m_mousePos.x = currentX; + m_mousePos.y = currentY; + + m_parent->PushEvent(event); + break; } + else if (m_mousePos.x == currentX && m_mousePos.y == currentY) + break; NzEvent event; - event.type = NzEvent::MouseMoved; - event.mouseMove.x = GET_X_LPARAM(lParam); - event.mouseMove.y = GET_Y_LPARAM(lParam); + event.type = nzEventType_MouseMoved; + event.mouseMove.deltaX = currentX - m_mousePos.x; + event.mouseMove.deltaY = currentY - m_mousePos.y; + event.mouseMove.x = currentX; + event.mouseMove.y = currentY; + + m_mousePos.x = currentX; + m_mousePos.y = currentY; + m_parent->PushEvent(event); break; } @@ -684,7 +770,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA if (m_smoothScrolling) { NzEvent event; - event.type = NzEvent::MouseWheelMoved; + event.type = nzEventType_MouseWheelMoved; event.mouseWheel.delta = static_cast(GET_WHEEL_DELTA_WPARAM(wParam))/WHEEL_DELTA; m_parent->PushEvent(event); } @@ -694,7 +780,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA if (std::abs(m_scrolling) >= WHEEL_DELTA) { NzEvent event; - event.type = NzEvent::MouseWheelMoved; + event.type = nzEventType_MouseWheelMoved; event.mouseWheel.delta = m_scrolling/WHEEL_DELTA; m_parent->PushEvent(event); @@ -709,7 +795,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA NzVector2i position = GetPosition(); NzEvent event; - event.type = NzEvent::Moved; + event.type = nzEventType_Moved; event.position.x = position.x; event.position.y = position.y; m_parent->PushEvent(event); @@ -724,10 +810,10 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA event.mouseButton.x = GET_X_LPARAM(lParam); event.mouseButton.y = GET_Y_LPARAM(lParam); - event.type = NzEvent::MouseButtonDoubleClicked; + event.type = nzEventType_MouseButtonDoubleClicked; m_parent->PushEvent(event); - event.type = NzEvent::MouseButtonPressed; + event.type = nzEventType_MouseButtonPressed; m_parent->PushEvent(event); break; @@ -736,7 +822,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_RBUTTONDOWN: { NzEvent event; - event.type = NzEvent::MouseButtonPressed; + event.type = nzEventType_MouseButtonPressed; event.mouseButton.button = NzMouse::Right; event.mouseButton.x = GET_X_LPARAM(lParam); event.mouseButton.y = GET_Y_LPARAM(lParam); @@ -748,7 +834,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_RBUTTONUP: { NzEvent event; - event.type = NzEvent::MouseButtonReleased; + event.type = nzEventType_MouseButtonReleased; event.mouseButton.button = NzMouse::Right; event.mouseButton.x = GET_X_LPARAM(lParam); event.mouseButton.y = GET_Y_LPARAM(lParam); @@ -760,7 +846,7 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_SETFOCUS: { NzEvent event; - event.type = NzEvent::GainedFocus; + event.type = nzEventType_GainedFocus; m_parent->PushEvent(event); break; @@ -768,12 +854,22 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_SIZE: { + #if NAZARA_UTILITY_THREADED_WINDOW if (wParam != SIZE_MINIMIZED) + #else + if (!m_sizemove && wParam != SIZE_MINIMIZED) + #endif { NzVector2ui size = GetSize(); // On récupère uniquement la taille de la zone client + #if !NAZARA_UTILITY_THREADED_WINDOW + if (m_size == size) + break; + + m_size = size; + #endif NzEvent event; - event.type = NzEvent::Resized; + event.type = nzEventType_Resized; event.size.width = size.x; event.size.height = size.y; m_parent->PushEvent(event); @@ -792,10 +888,10 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA event.mouseButton.x = GET_X_LPARAM(lParam); event.mouseButton.y = GET_Y_LPARAM(lParam); - event.type = NzEvent::MouseButtonDoubleClicked; + event.type = nzEventType_MouseButtonDoubleClicked; m_parent->PushEvent(event); - event.type = NzEvent::MouseButtonPressed; + event.type = nzEventType_MouseButtonPressed; m_parent->PushEvent(event); break; @@ -804,6 +900,8 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_XBUTTONDOWN: { NzEvent event; + event.type = nzEventType_MouseButtonPressed; + if (HIWORD(wParam) == XBUTTON1) event.mouseButton.button = NzMouse::XButton1; else @@ -819,6 +917,8 @@ bool NzWindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARA case WM_XBUTTONUP: { NzEvent event; + event.type = nzEventType_MouseButtonReleased; + if (HIWORD(wParam) == XBUTTON1) event.mouseButton.button = NzMouse::XButton1; else @@ -1018,7 +1118,7 @@ NzKeyboard::Key NzWindowImpl::ConvertVirtualKey(WPARAM key, LPARAM flags) } #if NAZARA_UTILITY_THREADED_WINDOW -void NzWindowImpl::WindowThread(HWND* handle, DWORD styleEx, const wchar_t* title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, NzWindowImpl* window, NzMutex* mutex, NzThreadCondition* condition) +void NzWindowImpl::WindowThread(HWND* handle, DWORD styleEx, const wchar_t* title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, NzWindowImpl* window, NzMutex* mutex, NzConditionVariable* condition) { *handle = CreateWindowExW(styleEx, className, title, style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), window); diff --git a/src/Nazara/Utility/Win32/WindowImpl.hpp b/src/Nazara/Utility/Win32/WindowImpl.hpp index 16c28b70a..bb566ebda 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.hpp +++ b/src/Nazara/Utility/Win32/WindowImpl.hpp @@ -20,9 +20,9 @@ #include #if NAZARA_UTILITY_THREADED_WINDOW +class NzConditionVariable; class NzMutex; class NzThread; -class NzThreadCondition; #endif class NzWindow; @@ -34,11 +34,11 @@ class NzWindowImpl : NzNonCopyable NzWindowImpl(NzWindow* parent); ~NzWindowImpl() = default; - void Close(); - bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style); bool Create(NzWindowHandle handle); + void Destroy(); + void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); @@ -53,6 +53,8 @@ class NzWindowImpl : NzNonCopyable void ProcessEvents(bool block); + void IgnoreNextMouseEvent(int mouseX, int mouseY); + bool IsMinimized() const; bool IsVisible() const; @@ -65,11 +67,10 @@ class NzWindowImpl : NzNonCopyable void SetMinimumSize(int width, int height); void SetPosition(int x, int y); void SetSize(unsigned int width, unsigned int height); + void SetStayOnTop(bool stayOnTop); void SetTitle(const NzString& title); void SetVisible(bool visible); - void StayOnTop(bool stayOnTop); - static bool Initialize(); static void Uninitialize(); @@ -79,7 +80,7 @@ class NzWindowImpl : NzNonCopyable static LRESULT CALLBACK MessageHandler(HWND window, UINT message, WPARAM wParam, LPARAM lParam); static NzKeyboard::Key ConvertVirtualKey(WPARAM key, LPARAM flags); #if NAZARA_UTILITY_THREADED_WINDOW - static void WindowThread(HWND* handle, DWORD styleEx, const wchar_t* title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, NzWindowImpl* window, NzMutex* mutex, NzThreadCondition* condition); + static void WindowThread(HWND* handle, DWORD styleEx, const wchar_t* title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, NzWindowImpl* window, NzMutex* mutex, NzConditionVariable* condition); #endif HCURSOR m_cursor; @@ -87,7 +88,11 @@ class NzWindowImpl : NzNonCopyable LONG_PTR m_callback; NzVector2i m_maxSize; NzVector2i m_minSize; - #if NAZARA_UTILITY_THREADED_WINDOW + NzVector2i m_mousePos; + #if !NAZARA_UTILITY_THREADED_WINDOW + NzVector2i m_position; + NzVector2ui m_size; + #else NzThread* m_thread; #endif NzWindow* m_parent; @@ -95,6 +100,9 @@ class NzWindowImpl : NzNonCopyable bool m_keyRepeat; bool m_mouseInside; bool m_ownsWindow; + #if !NAZARA_UTILITY_THREADED_WINDOW + bool m_sizemove; + #endif bool m_smoothScrolling; #if NAZARA_UTILITY_THREADED_WINDOW bool m_threadActive; diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 2c02557db..5e476dbaf 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -82,32 +82,18 @@ m_impl(nullptr) NzWindow::~NzWindow() { - Close(); -} - -void NzWindow::Close() -{ - if (m_impl) - { - OnClose(); - - m_impl->Close(); - delete m_impl; - m_impl = nullptr; - - if (fullscreenWindow == this) - fullscreenWindow = nullptr; - } + Destroy(); } bool NzWindow::Create(NzVideoMode mode, const NzString& title, nzUInt32 style) { + // Si la fenêtre est déjà ouverte, nous conservons sa position bool opened = IsOpen(); NzVector2i position; if (opened) position = m_impl->GetPosition(); - Close(); + Destroy(); // Inspiré du code de la SFML par Laurent Gomila if (style & nzWindowStyle_Fullscreen) @@ -143,7 +129,7 @@ bool NzWindow::Create(NzVideoMode mode, const NzString& title, nzUInt32 style) m_ownsWindow = true; - if (!OnCreate()) + if (!OnWindowCreated()) { NazaraError("Failed to initialize window extension"); delete m_impl; @@ -152,6 +138,7 @@ bool NzWindow::Create(NzVideoMode mode, const NzString& title, nzUInt32 style) return false; } + // Paramètres par défaut m_impl->EnableKeyRepeat(true); m_impl->EnableSmoothScrolling(false); m_impl->SetCursor(nzWindowCursor_Default); @@ -167,7 +154,7 @@ bool NzWindow::Create(NzVideoMode mode, const NzString& title, nzUInt32 style) bool NzWindow::Create(NzWindowHandle handle) { - Close(); + Destroy(); m_impl = new NzWindowImpl(this); if (!m_impl->Create(handle)) @@ -181,7 +168,7 @@ bool NzWindow::Create(NzWindowHandle handle) m_ownsWindow = false; - if (!OnCreate()) + if (!OnWindowCreated()) { NazaraError("Failed to initialize window's derivate"); delete m_impl; @@ -193,6 +180,21 @@ bool NzWindow::Create(NzWindowHandle handle) return true; } +void NzWindow::Destroy() +{ + if (m_impl) + { + OnWindowDestroying(); + + m_impl->Destroy(); + delete m_impl; + m_impl = nullptr; + + if (fullscreenWindow == this) + fullscreenWindow = nullptr; + } +} + void NzWindow::EnableKeyRepeat(bool enable) { if (m_impl) @@ -210,7 +212,7 @@ NzWindowHandle NzWindow::GetHandle() const if (m_impl) return m_impl->GetHandle(); else - return 0; + return reinterpret_cast(0); } unsigned int NzWindow::GetHeight() const @@ -420,6 +422,12 @@ void NzWindow::SetSize(unsigned int width, unsigned int height) m_impl->SetSize(width, height); } +void NzWindow::SetStayOnTop(bool stayOnTop) +{ + if (m_impl) + m_impl->SetStayOnTop(stayOnTop); +} + void NzWindow::SetTitle(const NzString& title) { if (m_impl) @@ -432,12 +440,6 @@ void NzWindow::SetVisible(bool visible) m_impl->SetVisible(visible); } -void NzWindow::StayOnTop(bool stayOnTop) -{ - if (m_impl) - m_impl->StayOnTop(stayOnTop); -} - bool NzWindow::WaitEvent(NzEvent* event) { if (!m_impl) @@ -481,15 +483,21 @@ bool NzWindow::WaitEvent(NzEvent* event) #endif } -void NzWindow::OnClose() +void NzWindow::OnWindowDestroying() { } -bool NzWindow::OnCreate() +bool NzWindow::OnWindowCreated() { return true; } +void NzWindow::IgnoreNextMouseEvent(int mouseX, int mouseY) const +{ + if (m_impl) + m_impl->IgnoreNextMouseEvent(mouseX, mouseY); +} + void NzWindow::PushEvent(const NzEvent& event) { #if NAZARA_UTILITY_THREADED_WINDOW