Browse Source

Moving to Gitea, nuking history

master
Aramir 3 months ago
commit
c7fb061f5a
  1. 4
      .gitignore
  2. 37
      CMakeLists.txt
  3. 142
      Camera.cpp
  4. 60
      Camera.h
  5. 169
      Config.cpp
  6. 42
      Config.h
  7. 10
      ExternalLib/SOIL/CMakeLists.txt
  8. 18
      ExternalLib/SOIL/LICENSE.txt
  9. 59
      ExternalLib/SOIL/README.md
  10. 433
      ExternalLib/SOIL/inc/SOIL/SOIL.h
  11. 123
      ExternalLib/SOIL/inc/SOIL/image_DXT.h
  12. 115
      ExternalLib/SOIL/inc/SOIL/image_helper.h
  13. 354
      ExternalLib/SOIL/inc/SOIL/stb_image_aug.h
  14. 21
      ExternalLib/SOIL/inc/SOIL/stbi_DDS_aug.h
  15. 511
      ExternalLib/SOIL/inc/SOIL/stbi_DDS_aug_c.h
  16. 2024
      ExternalLib/SOIL/src/SOIL.c
  17. 632
      ExternalLib/SOIL/src/image_DXT.c
  18. 435
      ExternalLib/SOIL/src/image_helper.c
  19. 3632
      ExternalLib/SOIL/src/original/stb_image-1.09.c
  20. 3821
      ExternalLib/SOIL/src/original/stb_image-1.16.c
  21. 3631
      ExternalLib/SOIL/src/stb_image_aug.c
  22. 16829
      ExternalLib/glad.h
  23. 22
      ExternalLib/glfwSrc/.appveyor.yml
  24. 346
      ExternalLib/glfwSrc/.github/CONTRIBUTING.md
  25. 30
      ExternalLib/glfwSrc/.travis.yml
  26. 38
      ExternalLib/glfwSrc/CMake/MacOSXBundleInfo.plist.in
  27. 13
      ExternalLib/glfwSrc/CMake/amd64-mingw32msvc.cmake
  28. 13
      ExternalLib/glfwSrc/CMake/i586-mingw32msvc.cmake
  29. 13
      ExternalLib/glfwSrc/CMake/i686-pc-mingw32.cmake
  30. 13
      ExternalLib/glfwSrc/CMake/i686-w64-mingw32.cmake
  31. 18
      ExternalLib/glfwSrc/CMake/modules/FindMir.cmake
  32. 34
      ExternalLib/glfwSrc/CMake/modules/FindVulkan.cmake
  33. 26
      ExternalLib/glfwSrc/CMake/modules/FindWaylandProtocols.cmake
  34. 34
      ExternalLib/glfwSrc/CMake/modules/FindXKBCommon.cmake
  35. 13
      ExternalLib/glfwSrc/CMake/x86_64-w64-mingw32.cmake
  36. 419
      ExternalLib/glfwSrc/CMakeLists.txt
  37. 22
      ExternalLib/glfwSrc/COPYING.txt
  38. 274
      ExternalLib/glfwSrc/README.md
  39. 29
      ExternalLib/glfwSrc/cmake_uninstall.cmake
  40. 29
      ExternalLib/glfwSrc/cmake_uninstall.cmake.in
  41. 282
      ExternalLib/glfwSrc/deps/KHR/khrplatform.h
  42. 230
      ExternalLib/glfwSrc/deps/getopt.c
  43. 57
      ExternalLib/glfwSrc/deps/getopt.h
  44. 1555
      ExternalLib/glfwSrc/deps/glad.c
  45. 3520
      ExternalLib/glfwSrc/deps/glad/glad.h
  46. 574
      ExternalLib/glfwSrc/deps/linmath.h
  47. 117
      ExternalLib/glfwSrc/deps/mingw/_mingw_dxhelper.h
  48. 2467
      ExternalLib/glfwSrc/deps/mingw/dinput.h
  49. 239
      ExternalLib/glfwSrc/deps/mingw/xinput.h
  50. 594
      ExternalLib/glfwSrc/deps/tinycthread.c
  51. 441
      ExternalLib/glfwSrc/deps/tinycthread.h
  52. 120
      ExternalLib/glfwSrc/deps/vulkan/vk_platform.h
  53. 3835
      ExternalLib/glfwSrc/deps/vulkan/vulkan.h
  54. 32
      ExternalLib/glfwSrc/docs/CMakeLists.txt
  55. 1859
      ExternalLib/glfwSrc/docs/Doxyfile.in
  56. 188
      ExternalLib/glfwSrc/docs/DoxygenLayout.xml
  57. 347
      ExternalLib/glfwSrc/docs/build.dox
  58. 224
      ExternalLib/glfwSrc/docs/compat.dox
  59. 284
      ExternalLib/glfwSrc/docs/compile.dox
  60. 345
      ExternalLib/glfwSrc/docs/context.dox
  61. 1
      ExternalLib/glfwSrc/docs/extra.css
  62. 370
      ExternalLib/glfwSrc/docs/extra.less
  63. 7
      ExternalLib/glfwSrc/docs/footer.html
  64. 34
      ExternalLib/glfwSrc/docs/header.html
  65. 104
      ExternalLib/glfwSrc/docs/html/annotated.html
  66. BIN
      ExternalLib/glfwSrc/docs/html/arrowdown.png
  67. BIN
      ExternalLib/glfwSrc/docs/html/arrowright.png
  68. BIN
      ExternalLib/glfwSrc/docs/html/bc_s.png
  69. BIN
      ExternalLib/glfwSrc/docs/html/bdwn.png
  70. 94
      ExternalLib/glfwSrc/docs/html/bug.html
  71. 96
      ExternalLib/glfwSrc/docs/html/build_8dox.html
  72. 188
      ExternalLib/glfwSrc/docs/html/build_guide.html
  73. 106
      ExternalLib/glfwSrc/docs/html/classes.html
  74. BIN
      ExternalLib/glfwSrc/docs/html/closed.png
  75. 96
      ExternalLib/glfwSrc/docs/html/compat_8dox.html
  76. 150
      ExternalLib/glfwSrc/docs/html/compat_guide.html
  77. 96
      ExternalLib/glfwSrc/docs/html/compile_8dox.html
  78. 211
      ExternalLib/glfwSrc/docs/html/compile_guide.html
  79. 96
      ExternalLib/glfwSrc/docs/html/context_8dox.html
  80. 195
      ExternalLib/glfwSrc/docs/html/context_guide.html
  81. 106
      ExternalLib/glfwSrc/docs/html/dir_1f12d41534b9d9c99a183e145b58d6f3.html
  82. 106
      ExternalLib/glfwSrc/docs/html/dir_351f617146de9499414a6c099ebbe0ca.html
  83. 110
      ExternalLib/glfwSrc/docs/html/dir_4bcf8e981abe5adb811ce4f57d70c9af.html
  84. BIN
      ExternalLib/glfwSrc/docs/html/doc.png
  85. 1475
      ExternalLib/glfwSrc/docs/html/doxygen.css
  86. BIN
      ExternalLib/glfwSrc/docs/html/doxygen.png
  87. 97
      ExternalLib/glfwSrc/docs/html/dynsections.js
  88. 1
      ExternalLib/glfwSrc/docs/html/extra.css
  89. 102
      ExternalLib/glfwSrc/docs/html/files.html
  90. BIN
      ExternalLib/glfwSrc/docs/html/folderclosed.png
  91. BIN
      ExternalLib/glfwSrc/docs/html/folderopen.png
  92. 136
      ExternalLib/glfwSrc/docs/html/functions.html
  93. 136
      ExternalLib/glfwSrc/docs/html/functions_vars.html
  94. 1759
      ExternalLib/glfwSrc/docs/html/glfw3_8h.html
  95. 237
      ExternalLib/glfwSrc/docs/html/glfw3_8h_source.html
  96. 179
      ExternalLib/glfwSrc/docs/html/glfw3native_8h.html
  97. 124
      ExternalLib/glfwSrc/docs/html/glfw3native_8h_source.html
  98. 159
      ExternalLib/glfwSrc/docs/html/globals.html
  99. 132
      ExternalLib/glfwSrc/docs/html/globals_b.html
  100. 183
      ExternalLib/glfwSrc/docs/html/globals_c.html

4
.gitignore

@ -0,0 +1,4 @@
/[Bb]uild/
CMakeLists.txt.user
/[Tt]mp/
/TMP/

37
CMakeLists.txt

@ -0,0 +1,37 @@
project(Embryo)
cmake_minimum_required(VERSION 2.8)
# Compiler options
set(CMAKE_CXX_FLAGS "-std=c++17 -Lstdc++fs -Wall -Wextra -static")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules/")
set(GLFW_SRC_PATH "${CMAKE_SOURCE_DIR}/ExternalLib/glfwSrc/")
set(SOIL_SRC_PATH "${CMAKE_SOURCE_DIR}/ExternalLib/SOIL/")
#Listing Code Sources at root
aux_source_directory(. SRC_LIST)
#Listing Shaders Sources (so they show up in the IDE)
file(GLOB_RECURSE shaders_SRC
"shaders/*.frag"
"shaders/*.vert"
)
# Writing config.cfg file
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.cfg "# This file has been automatically generated, please only interact with it if you know what you're doing\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/config.cfg "shaders = ${CMAKE_SOURCE_DIR}/shaders/\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/config.cfg "models = ${CMAKE_SOURCE_DIR}/models/\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/config.cfg "resources = ${CMAKE_SOURCE_DIR}/resources/\n")
# TODO : detect whenever user is installing and if so, copy the shaders, models, resources files and write a config.cfg file with correct adresses
#Including SOIL
add_subdirectory(${SOIL_SRC_PATH})
include_directories("${SOIL_SRC_PATH}")
#Including glfw
add_subdirectory(${GLFW_SRC_PATH})
include_directories("${GLFW_SRC_PATH}/include")
find_package(OpenGL REQUIRED)
# Targets and executable
add_executable(${PROJECT_NAME} ${SRC_LIST} ${shaders_SRC})
target_link_libraries(${PROJECT_NAME} soil ${OPENGL_LIBRARIES} glfw ${GLFW_LIBRARIES})

142
Camera.cpp

@ -0,0 +1,142 @@
#include "Camera.h"
#include "ShaderProgram.h"
#include "ExternalLib/glm/gtc/matrix_transform.hpp"
#include "ExternalLib/glm/gtc/type_ptr.hpp"
#include "ExternalLib/glm/gtc/matrix_access.hpp"
/******************
* Constructors *
******************/
Camera::Camera(int* width_, int* height_, float minDistance_, float maxDistance_)
: width(width_), height(height_), minDistance(minDistance_), maxDistance(maxDistance_)
{
/**
* \brief Create a default camera at position(0;0;0) with its View and Projection Matrices
* \param width, height : resolution
* minDistance : defines frustrum's nearplan
* maxDistance : defines frustrum's farplan
*/
/***************************************************************
* DEFINING COMMON MATRICES : Projection and View *
****************************************************************/
/* View Matrix */
/* Allow conversion from world space to view space/camera view */
cameraPos = glm::vec3(0.0f, 0.0f, -2.0f); // initial position of the camera
cameraForward = glm::vec3(0.0f, 0.0f, -1.0f); // Z axis of the camera
cameraUp = glm::vec3(0.0f, 1.0f, 0.0f); // Y axis of the camera
// Default FOV
FOV = 80.0f; // Field Of View
FOVScrollStep = 5.0f; // For each mouseScroll input, modify FOV by FOVScrollStep
// Default look direction
cameraPitch = 2*glm::pi<float>(); // camera's pitch
cameraYaw = glm::pi<float>()/2; // camera's yaw
cameraRoll = 0; // camera's roll
cameraRollStep = glm::radians(45.0f); // Step used for roll
cameraStep = 5.0f; // Step used for planar movements
// Player's configuration // TODO : deserialize below informations from an option file
xAxisSensitivity = 0.1f; // x axis mouse sensitivity
yAxisSensitivity = 0.2f; // y axis mouse sensitivity
invertYAxis = false; // inverted x axis ?
invertXAxis = false; // inverted y axis ?
// Set Matrices
actualizeProjectionMatrix();
actualizeViewMatrix();
}
/*************
* Setters *
*************/
void Camera::setPosition(const glm::vec3& cameraPos_)
{ cameraPos = cameraPos_; actualizeViewMatrix();}
/*************
* Methods *
*************/
void Camera::actualizeViewMatrix()
{
/**
* \brief Actualize Camera's View Matrix
*/
// modulo those values to two pi in order to avoid overflow over time
float pi2 = 2.0f*glm::pi<float>();
cameraPitch = fmodf(cameraPitch, pi2);
cameraYaw = fmodf(cameraYaw, pi2);
cameraRoll = fmodf(cameraRoll, pi2);
// Apply pitch and Yaw
glm::vec3 newCameraForward = cameraPos;
newCameraForward.z += cosf(cameraPitch)*sinf(cameraYaw);
newCameraForward.y += cosf(cameraYaw);
newCameraForward.x += sinf(cameraPitch)*sinf(cameraYaw);
cameraForward = glm::vec3(0, 0, -1) * glm::mat3(view);
// Apply roll (will probably be easier to implement with quaternions)
// TODO : here are a few tries, probably not that far off...
// cameraUp = glm::rotate(cameraUp, cameraRoll, newCameraForward);
// float foo[16] = { cos(cameraRoll), -sin(cameraRoll), 0, 0,
// sin(cameraRoll), cos(cameraRoll), 0, 0,
// 0, 0, 1, 0,
// 0, 0, 0, 1
// };
// glm::mat4 rotationMatrix = glm::make_mat4(foo);
/* Setting View matrix, it allows conversion from world space to view space/camera view */
view = glm::lookAt(cameraPos, newCameraForward, cameraUp); // define view Matrix to suit our camera system
// view *= rotationMatrix;
// view = glm::rotate(view, cameraRoll, cameraForward);
// viewLoc = glGetUniformLocation(sp->getId(), "view");
// glProgramUniformMatrix4fv(sp->getId(), viewLoc, 1, GL_FALSE, glm::value_ptr(view));
}
void Camera::actualizeProjectionMatrix()
{
/**
* \brief Actualize Camera's Projection Matrix (for FOV changes)
*/
/* Convert current coordinates to Normalized Device Coordinates (-1.0;1.0) */
/* And defines frustrum and perspective of the camera */
projection = glm::perspective(static_cast<GLfloat>(glm::radians(FOV))
, static_cast<GLfloat>(*width) / static_cast<GLfloat>(*height)
, static_cast<GLfloat>(minDistance)
, static_cast<GLfloat>(maxDistance) );
}
void Camera::bindToShaderProgram(const ShaderProgram& sp)
{
/**
* \brief Bind Camera to a ShaderProgram
*/
viewLoc = glGetUniformLocation(sp.getId(), "view");
glProgramUniformMatrix4fv(sp.getId(), viewLoc, 1, GL_FALSE, glm::value_ptr(view));
projectionLoc = glGetUniformLocation(sp.getId(), "projection");
glProgramUniformMatrix4fv(sp.getId(), projectionLoc, 1, GL_FALSE, glm::value_ptr(projection));
}
Camera Camera::mirrorCamera(const glm::mat4& mirrorModelMatrix, const glm::vec4& /*mirror*/, const glm::vec4& /*pointOnMirror*/) const
{
/**
* \brief Create a Camera with mirrored view matrix behind the mirror given in parameter
* \param mirrorModelMatrix <=> mirror's matrix model
* mirror <=> mirror's forward vector
* pointOnMirror <=> point on mirror to locate it in worldspace
*/
Camera mirroredCamera = *this;
// Put camera behind the mirror
mirroredCamera.view = view * mirrorModelMatrix * glm::scale(glm::mat4() , glm::vec3(1, 1, -1)) * glm::inverse(mirrorModelMatrix);
// Overlap nearplan's view on mirror plan in order to cull objects behind the mirror (cf "Oblique View Frustum Depth Projection and Clipping" paper)
// BUGGY, doing things, not sure what probably moving camera somewhere else
// mirroredCamera.view[2] = ((-2*pointOnMirror.z)/(glm::dot(mirror, pointOnMirror)))*mirror + glm::vec4(0,0,-1,0);
// mirroredCamera.view[3] = glm::vec4(0,0,-1,0);
return mirroredCamera;
}

60
Camera.h

@ -0,0 +1,60 @@
#ifndef CAMERA_H
#define CAMERA_H
#include "ShaderProgram.h"
#include "ExternalLib/glm/glm.hpp"
#include "ExternalLib/glad.h"
#include "Mesh.h"
/**************************************************************
* Camera : Camera is sotring every information needed to *
* "create a camera", including its position, its *
* rotation, direction, view and projection matrices *
**************************************************************/
class Camera
{
public:
GLint viewLoc; // Location of view Matrix in sp
GLint projectionLoc; // Location of projection Matrix in sp
int* width; // width of the renderingWindow, pointer so we don't need to update it when resizing
int* height; // height of the renderingWindow, pointer so we don't need to update it when resizing
glm::vec3 cameraPos; // position of the camera in worldSpace coordinates
glm::vec3 cameraForward; // facing direction ...
glm::vec3 cameraUp; // up direction ...
GLfloat FOV = 80; // camera's FOV
float FOVScrollStep = 5.0f; // camera's FOV scroll step
glm::mat4 projection; // Projection Matrix for the Coordinate Conversion Pipeline
glm::mat4 view; // View Matrix for the Coordinate Conversion Pipeline
float cameraPitch; // camera's pitch
float cameraYaw; // camera's yaw
float cameraRoll; // camera's roll
float cameraRollStep; // Step used for roll
float cameraStep; // Step used for planar movements
// Player's configuration dependant // TODO serialize those informations
float minDistance = 0.1f; // camera's minimum rendering distance
float maxDistance = 10.0f; // camera's maximum rendering distance
float xAxisSensitivity = 0.1f; // mouse sensitivity for the X axis
float yAxisSensitivity = 0.2f; // mouse sensitivity for the X axis
bool invertXAxis = false; // invert X axis
bool invertYAxis = false; // invert Y axis for more "plane simulator"ish controls
/***** Constructors *****/
Camera(){} // TODO : just a glut to allow Cameras in RenderingWindow.h
Camera(int* width_, int* height_, float minDistance_, float maxDistance_);
/***** Methods *****/
void actualizeViewMatrix();
void actualizeProjectionMatrix();
void bindToShaderProgram(const ShaderProgram& sp);
void setPosition(const glm::vec3& cameraPosition_);
Camera mirrorCamera(const glm::mat4& mirrorModelMatrix, const glm::vec4& mirror, const glm::vec4& pointOnMirror) const;
};
#endif /* CAMERA_H */

169
Config.cpp

@ -0,0 +1,169 @@
#include "Config.h"
#include <fstream>
#include <iostream>
#include <any>
#include <algorithm>
#include <stdexcept>
/***************
* CONFIG *
***************/
namespace Config
{
namespace
{
std::map<std::string, ConfigValue> values; // < name, (int, float, double, string) value>
}
ConfigValue const& GetValue(std::string key)
{
return values[key];
}
template<class T>
void SaveValue(std::string /*key*/, T* /*val*/)
{
// TODO
}
void LoadConfigFile()
{
std::ifstream configFile(CONFIG_FILE_NAME);
if (!configFile.good())
{
std::cerr << "ERROR : Couldn't open config file : " << CONFIG_FILE_NAME << std::endl;
return;
}
int cptLine = 1;
for (std::string line; std::getline(configFile, line); ++cptLine)
{
// Get rid of commentaries
std::string::iterator lineIt = std::find (line.begin(), line.end(), '#');
if (lineIt == line.begin())
continue;
else if(lineIt != line.end())
line = std::string(line.begin(), lineIt);
// Removing white spaces
line.erase(std::remove_if(line.begin(), line.end(), isspace), line.end());
// Parsing line
std::string key, val;
std::string::iterator equalIt = std::find(line.begin(), line.end(), '=');
if (equalIt == line.end())
{
std::cout << "No = found on line : " << cptLine << std::endl;
continue;
}
if (equalIt == line.begin())
{
std::cout << "No key on line : " << cptLine << std::endl;
continue;
}
else
key = std::string(line.begin(), equalIt);
if (equalIt+1 == line.end())
{
std::cout << "No val on line : " << cptLine << std::endl;
continue;
}
else
val = std::string(equalIt+1, line.end());
// Registers std::map[key] = val
values[key] = ConfigValue(val);
}
}
}
/***************
* ConfigValue *
***************/
/*** Constructors ***/
ConfigValue::ConfigValue()
: pureValue("")
{ }
ConfigValue::ConfigValue(std::string s)
: pureValue(s)
{ }
ConfigValue::ConfigValue(char const* c)
: pureValue(c)
{ }
ConfigValue::ConfigValue(int i)
: pureValue(std::to_string(i))
{ }
ConfigValue::ConfigValue(double d)
: pureValue(std::to_string(d))
{ }
ConfigValue::ConfigValue(float f)
: pureValue(std::to_string(f))
{ }
/*** For conversion ***/
ConfigValue::operator float() const
{
float ret(0.0f);
try
{
std::string::size_type sz;
ret = std::stof(pureValue, &sz);
}
catch (const std::invalid_argument& ia)
{
std::cerr << "Invalid argument for ConfigValue ( " << pureValue << " ) Conversion : " << ia.what() << '\n';
}
return ret;
}
ConfigValue::operator double() const
{
double ret(0.0);
try
{
std::string::size_type sz;
ret = std::stod(pureValue, &sz);
}
catch (const std::invalid_argument& ia)
{
std::cerr << "Invalid argument for ConfigValue ( " << pureValue << " ) Conversion : " << ia.what() << '\n';
}
return ret;
}
ConfigValue::operator int() const
{
int ret(0.0);
try
{
std::string::size_type sz;
ret = std::stoi(pureValue, &sz);
}
catch (const std::invalid_argument& ia)
{
std::cerr << "Invalid argument for ConfigValue ( " << pureValue << " ) Conversion : " << ia.what() << '\n';
}
return ret;
}
ConfigValue::operator std::string() const
{
return pureValue;
}

42
Config.h

@ -0,0 +1,42 @@
#ifndef CONFIG_H
#define CONFIG_H
#include <string>
#include <map>
#define CONFIG_FILE_NAME "config.cfg"
class ConfigValue;
namespace Config
{
ConfigValue const& GetValue(std::string key); // Use with implicit conversion
// eg : int ls = GetValue("levelSize")
// float shaderDirectoryPath = GetValue("Shaders")
template<class T>
void SaveValue(std::string key, T* val); // TODO
void LoadConfigFile();
}
class ConfigValue
{
public :
// Constructors
ConfigValue();
ConfigValue(std::string s);
ConfigValue(char const* c);
ConfigValue(int i);
ConfigValue(double d);
ConfigValue(float f);
// For conversion
operator float() const;
operator double() const;
operator int() const;
operator std::string() const;
private :
std::string pureValue; // value taken directly from the config file before any conversion
};
#endif /* CONFIG_H */

10
ExternalLib/SOIL/CMakeLists.txt

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.6)
include_directories(inc)
ADD_LIBRARY( soil STATIC
src/image_helper.c
src/stb_image_aug.c
src/image_DXT.c
src/SOIL.c
)

18
ExternalLib/SOIL/LICENSE.txt

@ -0,0 +1,18 @@
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.

59
ExternalLib/SOIL/README.md

@ -0,0 +1,59 @@
**Simple OpenGL Image Library**
**Introduction:**
SOIL is a tiny C library used primarily for uploading textures into OpenGL. It is based on stb_image version 1.16, the public domain code from Sean Barrett (found here). It has been extended to load TGA and DDS files, and to perform common functions needed in loading OpenGL textures. SOIL can also be used to save and load images in a variety of formats.
**Features:**
* Readable Image Formats:
* BMP - non-1bpp, non-RLE (from stb_image documentation)
* PNG - non-interlaced (from stb_image documentation)
* JPG - JPEG baseline (from stb_image documentation)
* TGA - greyscale or RGB or RGBA or indexed, uncompressed or RLE
* DDS - DXT1/2/3/4/5, uncompressed, cubemaps (can't read 3D DDS files yet)
* PSD - (from stb_image documentation)
* HDR - converted to LDR, unless loaded with \*HDR\* functions (RGBE or RGBdivA or RGBdivA2)
Writeable Image Formats:
* TGA - Greyscale or RGB or RGBA, uncompressed
* BMP - RGB, uncompressed
* DDS - RGB as DXT1, or RGBA as DXT5
* Can load an image file directly into a 2D OpenGL texture, optionally performing the following functions:
* Can generate a new texture handle, or reuse one specified
* Can automatically rescale the image to the next largest power-of-two size
* Can automatically create MIPmaps
* Can scale (not simply clamp) the RGB values into the "safe range" for NTSC displays (16 to 235, as recommended [here][1])
* Can multiply alpha on load (for more correct blending / compositing)
* Can flip the image vertically
* Can compress and upload any image as DXT1 or DXT5 (if EXT\_texture\_compression_s3tc is available), using an internal (very fast!) compressor
* Can convert the RGB to YCoCg color space (useful with DXT5 compression: see [this link][2] from NVIDIA)
* Will automatically downsize a texture if it is larger than GL\_MAX\_TEXTURE_SIZE
* Can directly upload DDS files (DXT1/3/5/uncompressed/cubemap, with or without MIPmaps). Note: directly uploading the compressed DDS image will disable the other options (no flipping, no pre-multiplying alpha, no rescaling, no creation of MIPmaps, no auto-downsizing)
* Can load rectangluar textures for GUI elements or splash screens (requires GL\_ARB/EXT/NV\_texture_rectangle)
* Can decompress images from RAM (e.g. via [PhysicsFS][3] or similar) into an OpenGL texture (same features as regular 2D textures, above)
* Can load cube maps directly into an OpenGL texture (same features as regular 2D textures, above)
* Can take six image files directly into an OpenGL cube map texture
* Can take a single image file where width = 6*height (or vice versa), split it into an OpenGL cube map texture
* No external dependencies
* Tiny
* Cross platform (Windows, *nix, Mac OS X)
* Public Domain
**Usage:**
SOIL is meant to be used as a static library (as it's tiny and in the public domain).
Simply include SOIL.h in your C or C++ file, link in the static library, and then use any of SOIL's functions. The file SOIL.h contains simple doxygen style documentation. (If you use the static library, no other header files are needed besides SOIL.h)
You can compile it like any other CMAKE project, simply make a folder named "build" and run
```
cmake ..
make
```
[1]: http://msdn2.microsoft.com/en-us/library/bb174608.aspx#NTSC_Suggestions
[2]: http://developer.nvidia.com/object/real-time-ycocg-dxt-compression.html
[3]: http://icculus.org/physfs/

433
ExternalLib/SOIL/inc/SOIL/SOIL.h

@ -0,0 +1,433 @@
/**
@mainpage SOIL
Jonathan Dummer
2007-07-26-10.36
Simple OpenGL Image Library
A tiny c library for uploading images as
textures into OpenGL. Also saving and
loading of images is supported.
I'm using Sean's Tool Box image loader as a base:
http://www.nothings.org/
I'm upgrading it to load TGA and DDS files, and a direct
path for loading DDS files straight into OpenGL textures,
when applicable.
Image Formats:
- BMP load & save
- TGA load & save
- DDS load & save
- PNG load
- JPG load
OpenGL Texture Features:
- resample to power-of-two sizes
- MIPmap generation
- compressed texture S3TC formats (if supported)
- can pre-multiply alpha for you, for better compositing
- can flip image about the y-axis (except pre-compressed DDS files)
Thanks to:
* Sean Barret - for the awesome stb_image
* Dan Venkitachalam - for finding some non-compliant DDS files, and patching some explicit casts
* everybody at gamedev.net
**/
#ifndef HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
#define HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY
#ifdef __cplusplus
extern "C" {
#endif
/**
The format of images that may be loaded (force_channels).
SOIL_LOAD_AUTO leaves the image in whatever format it was found.
SOIL_LOAD_L forces the image to load as Luminous (greyscale)
SOIL_LOAD_LA forces the image to load as Luminous with Alpha
SOIL_LOAD_RGB forces the image to load as Red Green Blue
SOIL_LOAD_RGBA forces the image to load as Red Green Blue Alpha
**/
enum
{
SOIL_LOAD_AUTO = 0,
SOIL_LOAD_L = 1,
SOIL_LOAD_LA = 2,
SOIL_LOAD_RGB = 3,
SOIL_LOAD_RGBA = 4
};
/**
Passed in as reuse_texture_ID, will cause SOIL to
register a new texture ID using glGenTextures().
If the value passed into reuse_texture_ID > 0 then
SOIL will just re-use that texture ID (great for
reloading image assets in-game!)
**/
enum
{
SOIL_CREATE_NEW_ID = 0
};
/**
flags you can pass into SOIL_load_OGL_texture()
and SOIL_create_OGL_texture().
(note that if SOIL_FLAG_DDS_LOAD_DIRECT is used
the rest of the flags with the exception of
SOIL_FLAG_TEXTURE_REPEATS will be ignored while
loading already-compressed DDS files.)
SOIL_FLAG_POWER_OF_TWO: force the image to be POT
SOIL_FLAG_MIPMAPS: generate mipmaps for the texture
SOIL_FLAG_TEXTURE_REPEATS: otherwise will clamp
SOIL_FLAG_MULTIPLY_ALPHA: for using (GL_ONE,GL_ONE_MINUS_SRC_ALPHA) blending
SOIL_FLAG_INVERT_Y: flip the image vertically
SOIL_FLAG_COMPRESS_TO_DXT: if the card can display them, will convert RGB to DXT1, RGBA to DXT5
SOIL_FLAG_DDS_LOAD_DIRECT: will load DDS files directly without _ANY_ additional processing
SOIL_FLAG_NTSC_SAFE_RGB: clamps RGB components to the range [16,235]
SOIL_FLAG_CoCg_Y: Google YCoCg; RGB=>CoYCg, RGBA=>CoCgAY
SOIL_FLAG_TEXTURE_RECTANGE: uses ARB_texture_rectangle ; pixel indexed & no repeat or MIPmaps or cubemaps
**/
enum
{
SOIL_FLAG_POWER_OF_TWO = 1,
SOIL_FLAG_MIPMAPS = 2,
SOIL_FLAG_TEXTURE_REPEATS = 4,
SOIL_FLAG_MULTIPLY_ALPHA = 8,
SOIL_FLAG_INVERT_Y = 16,
SOIL_FLAG_COMPRESS_TO_DXT = 32,
SOIL_FLAG_DDS_LOAD_DIRECT = 64,
SOIL_FLAG_NTSC_SAFE_RGB = 128,
SOIL_FLAG_CoCg_Y = 256,
SOIL_FLAG_TEXTURE_RECTANGLE = 512
};
/**
The types of images that may be saved.
(TGA supports uncompressed RGB / RGBA)
(BMP supports uncompressed RGB)
(DDS supports DXT1 and DXT5)
**/
enum
{
SOIL_SAVE_TYPE_TGA = 0,
SOIL_SAVE_TYPE_BMP = 1,
SOIL_SAVE_TYPE_DDS = 2
};
/**
Defines the order of faces in a DDS cubemap.
I recommend that you use the same order in single
image cubemap files, so they will be interchangeable
with DDS cubemaps when using SOIL.
**/
#define SOIL_DDS_CUBEMAP_FACE_ORDER "EWUDNS"
/**
The types of internal fake HDR representations
SOIL_HDR_RGBE: RGB * pow( 2.0, A - 128.0 )
SOIL_HDR_RGBdivA: RGB / A
SOIL_HDR_RGBdivA2: RGB / (A*A)
**/
enum
{
SOIL_HDR_RGBE = 0,
SOIL_HDR_RGBdivA = 1,
SOIL_HDR_RGBdivA2 = 2
};
/**
Loads an image from disk into an OpenGL texture.
\param filename the name of the file to upload as a texture
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_texture
(
const char *filename,
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads 6 images from disk into an OpenGL cubemap texture.
\param x_pos_file the name of the file to upload as the +x cube face
\param x_neg_file the name of the file to upload as the -x cube face
\param y_pos_file the name of the file to upload as the +y cube face
\param y_neg_file the name of the file to upload as the -y cube face
\param z_pos_file the name of the file to upload as the +z cube face
\param z_neg_file the name of the file to upload as the -z cube face
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_cubemap
(
const char *x_pos_file,
const char *x_neg_file,
const char *y_pos_file,
const char *y_neg_file,
const char *z_pos_file,
const char *z_neg_file,
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads 1 image from disk and splits it into an OpenGL cubemap texture.
\param filename the name of the file to upload as a texture
\param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc.
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_single_cubemap
(
const char *filename,
const char face_order[6],
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads an HDR image from disk into an OpenGL texture.
\param filename the name of the file to upload as a texture
\param fake_HDR_format SOIL_HDR_RGBE, SOIL_HDR_RGBdivA, SOIL_HDR_RGBdivA2
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_HDR_texture
(
const char *filename,
int fake_HDR_format,
int rescale_to_max,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads an image from RAM into an OpenGL texture.
\param buffer the image data in RAM just as if it were still in a file
\param buffer_length the size of the buffer in bytes
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_texture_from_memory
(
const unsigned char *const buffer,
int buffer_length,
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads 6 images from memory into an OpenGL cubemap texture.
\param x_pos_buffer the image data in RAM to upload as the +x cube face
\param x_pos_buffer_length the size of the above buffer
\param x_neg_buffer the image data in RAM to upload as the +x cube face
\param x_neg_buffer_length the size of the above buffer
\param y_pos_buffer the image data in RAM to upload as the +x cube face
\param y_pos_buffer_length the size of the above buffer
\param y_neg_buffer the image data in RAM to upload as the +x cube face
\param y_neg_buffer_length the size of the above buffer
\param z_pos_buffer the image data in RAM to upload as the +x cube face
\param z_pos_buffer_length the size of the above buffer
\param z_neg_buffer the image data in RAM to upload as the +x cube face
\param z_neg_buffer_length the size of the above buffer
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_cubemap_from_memory
(
const unsigned char *const x_pos_buffer,
int x_pos_buffer_length,
const unsigned char *const x_neg_buffer,
int x_neg_buffer_length,
const unsigned char *const y_pos_buffer,
int y_pos_buffer_length,
const unsigned char *const y_neg_buffer,
int y_neg_buffer_length,
const unsigned char *const z_pos_buffer,
int z_pos_buffer_length,
const unsigned char *const z_neg_buffer,
int z_neg_buffer_length,
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Loads 1 image from RAM and splits it into an OpenGL cubemap texture.
\param buffer the image data in RAM just as if it were still in a file
\param buffer_length the size of the buffer in bytes
\param face_order the order of the faces in the file, any combination of NSWEUD, for North, South, Up, etc.
\param force_channels 0-image format, 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_load_OGL_single_cubemap_from_memory
(
const unsigned char *const buffer,
int buffer_length,
const char face_order[6],
int force_channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Creates a 2D OpenGL texture from raw image data. Note that the raw data is
_NOT_ freed after the upload (so the user can load various versions).
\param data the raw data to be uploaded as an OpenGL texture
\param width the width of the image in pixels
\param height the height of the image in pixels
\param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_create_OGL_texture
(
const unsigned char *const data,
int width, int height, int channels,
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Creates an OpenGL cubemap texture by splitting up 1 image into 6 parts.
\param data the raw data to be uploaded as an OpenGL texture
\param width the width of the image in pixels
\param height the height of the image in pixels
\param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
\param face_order the order of the faces in the file, and combination of NSWEUD, for North, South, Up, etc.
\param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
\param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT | SOIL_FLAG_DDS_LOAD_DIRECT
\return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
SOIL_create_OGL_single_cubemap
(
const unsigned char *const data,
int width, int height, int channels,
const char face_order[6],
unsigned int reuse_texture_ID,
unsigned int flags
);
/**
Captures the OpenGL window (RGB) and saves it to disk
\return 0 if it failed, otherwise returns 1
**/
int
SOIL_save_screenshot
(
const char *filename,
int image_type,
int x, int y,
int width, int height
);
/**
Loads an image from disk into an array of unsigned chars.
Note that *channels return the original channel count of the
image. If force_channels was other than SOIL_LOAD_AUTO,
the resulting image has force_channels, but *channels may be
different (if the original image had a different channel
count).
\return 0 if failed, otherwise returns 1
**/
unsigned char*
SOIL_load_image
(
const char *filename,
int *width, int *height, int *channels,
int force_channels
);
/**
Loads an image from memory into an array of unsigned chars.
Note that *channels return the original channel count of the
image. If force_channels was other than SOIL_LOAD_AUTO,
the resulting image has force_channels, but *channels may be
different (if the original image had a different channel
count).
\return 0 if failed, otherwise returns 1
**/
unsigned char*
SOIL_load_image_from_memory
(
const unsigned char *const buffer,
int buffer_length,
int *width, int *height, int *channels,
int force_channels
);
/**
Saves an image from an array of unsigned chars (RGBA) to disk
\return 0 if failed, otherwise returns 1
**/
int
SOIL_save_image
(
const char *filename,
int image_type,
int width, int height, int channels,
const unsigned char *const data
);
/**
Frees the image data (note, this is just C's "free()"...this function is
present mostly so C++ programmers don't forget to use "free()" and call
"delete []" instead [8^)
**/
void
SOIL_free_image_data
(
unsigned char *img_data
);
/**
This function resturn a pointer to a string describing the last thing
that happened inside SOIL. It can be used to determine why an image
failed to load.
**/
const char*
SOIL_last_result
(
void
);
#ifdef __cplusplus
}
#endif
#endif /* HEADER_SIMPLE_OPENGL_IMAGE_LIBRARY */

123
ExternalLib/SOIL/inc/SOIL/image_DXT.h

@ -0,0 +1,123 @@
/*
Jonathan Dummer
2007-07-31-10.32
simple DXT compression / decompression code
public domain
*/
#ifndef HEADER_IMAGE_DXT
#define HEADER_IMAGE_DXT
/**
Converts an image from an array of unsigned chars (RGB or RGBA) to
DXT1 or DXT5, then saves the converted image to disk.
\return 0 if failed, otherwise returns 1
**/
int
save_image_as_DDS
(
const char *filename,
int width, int height, int channels,
const unsigned char *const data
);
/**
take an image and convert it to DXT1 (no alpha)
**/
unsigned char*
convert_image_to_DXT1
(
const unsigned char *const uncompressed,
int width, int height, int channels,
int *out_size
);
/**
take an image and convert it to DXT5 (with alpha)
**/
unsigned char*
convert_image_to_DXT5
(
const unsigned char *const uncompressed,
int width, int height, int channels,
int *out_size
);
/** A bunch of DirectDraw Surface structures and flags **/
typedef struct
{
unsigned int dwMagic;
unsigned int dwSize;
unsigned int dwFlags;
unsigned int dwHeight;
unsigned int dwWidth;
unsigned int dwPitchOrLinearSize;
unsigned int dwDepth;
unsigned int dwMipMapCount;
unsigned int dwReserved1[ 11 ];
/* DDPIXELFORMAT */
struct
{
unsigned int dwSize;
unsigned int dwFlags;
unsigned int dwFourCC;
unsigned int dwRGBBitCount;
unsigned int dwRBitMask;
unsigned int dwGBitMask;
unsigned int dwBBitMask;
unsigned int dwAlphaBitMask;
}
sPixelFormat;
/* DDCAPS2 */
struct
{
unsigned int dwCaps1;
unsigned int dwCaps2;
unsigned int dwDDSX;
unsigned int dwReserved;
}
sCaps;
unsigned int dwReserved2;
}
DDS_header ;
/* the following constants were copied directly off the MSDN website */
/* The dwFlags member of the original DDSURFACEDESC2 structure
can be set to one or more of the following values. */
#define DDSD_CAPS 0x00000001
#define DDSD_HEIGHT 0x00000002
#define DDSD_WIDTH 0x00000004
#define DDSD_PITCH 0x00000008
#define DDSD_PIXELFORMAT 0x00001000
#define DDSD_MIPMAPCOUNT 0x00020000
#define DDSD_LINEARSIZE 0x00080000
#define DDSD_DEPTH 0x00800000
/* DirectDraw Pixel Format */
#define DDPF_ALPHAPIXELS 0x00000001
#define DDPF_FOURCC 0x00000004
#define DDPF_RGB 0x00000040
/* The dwCaps1 member of the DDSCAPS2 structure can be
set to one or more of the following values. */
#define DDSCAPS_COMPLEX 0x00000008
#define DDSCAPS_TEXTURE 0x00001000
#define DDSCAPS_MIPMAP 0x00400000
/* The dwCaps2 member of the DDSCAPS2 structure can be
set to one or more of the following values. */
#define DDSCAPS2_CUBEMAP 0x00000200
#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400
#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800
#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000
#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000
#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000
#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000
#define DDSCAPS2_VOLUME 0x00200000
#endif /* HEADER_IMAGE_DXT */

115
ExternalLib/SOIL/inc/SOIL/image_helper.h

@ -0,0 +1,115 @@
/*
Jonathan Dummer
Image helper functions
MIT license
*/
#ifndef HEADER_IMAGE_HELPER
#define HEADER_IMAGE_HELPER
#ifdef __cplusplus
extern "C" {
#endif
/**
This function upscales an image.
Not to be used to create MIPmaps,
but to make it square,
or to make it a power-of-two sized.
**/
int
up_scale_image
(
const unsigned char* const orig,
int width, int height, int channels,
unsigned char* resampled,
int resampled_width, int resampled_height
);
/**
This function downscales an image.
Used for creating MIPmaps,
the incoming image should be a
power-of-two sized.
**/
int
mipmap_image
(
const unsigned char* const orig,
int width, int height, int channels,
unsigned char* resampled,
int block_size_x, int block_size_y
);
/**
This function takes the RGB components of the image
and scales each channel from [0,255] to [16,235].
This makes the colors "Safe" for display on NTSC
displays. Note that this is _NOT_ a good idea for
loading images like normal- or height-maps!
**/
int
scale_image_RGB_to_NTSC_safe
(
unsigned char* orig,
int width, int height, int channels
);
/**
This function takes the RGB components of the image
and converts them into YCoCg. 3 components will be
re-ordered to CoYCg (for optimum DXT1 compression),
while 4 components will be ordered CoCgAY (for DXT5
compression).
**/
int
convert_RGB_to_YCoCg
(
unsigned char* orig,
int width, int height, int channels
);
/**
This function takes the YCoCg components of the image
and converts them into RGB. See above.
**/
int
convert_YCoCg_to_RGB
(
unsigned char* orig,
int width, int height, int channels
);
/**
Converts an HDR image from an array
of unsigned chars (RGBE) to RGBdivA
\return 0 if failed, otherwise returns 1
**/
int
RGBE_to_RGBdivA
(
unsigned char *image,
int width, int height,
int rescale_to_max
);
/**
Converts an HDR image from an array
of unsigned chars (RGBE) to RGBdivA2
\return 0 if failed, otherwise returns 1
**/
int
RGBE_to_RGBdivA2
(
unsigned char *image,
int width, int height,
int rescale_to_max
);
#ifdef __cplusplus
}
#endif
#endif /* HEADER_IMAGE_HELPER */

354
ExternalLib/SOIL/inc/SOIL/stb_image_aug.h

@ -0,0 +1,354 @@
/* stbi-1.16 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c
when you control the images you're loading
QUICK NOTES:
Primarily of interest to game developers and other people who can
avoid problematic images and only need the trivial interface
JPEG baseline (no JPEG progressive, no oddball channel decimations)
PNG non-interlaced
BMP non-1bpp, non-RLE
TGA (not sure what subset, if a subset)
PSD (composited view only, no extra channels)
HDR (radiance rgbE format)
writes BMP,TGA (define STBI_NO_WRITE to remove code)
decoded from memory or through stdio FILE (define STBI_NO_STDIO to remove code)
supports installable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD)
TODO:
stbi_info_*
history:
1.16 major bugfix - convert_format converted one too many pixels
1.15 initialize some fields for thread safety
1.14 fix threadsafe conversion bug; header-file-only version (#define STBI_HEADER_FILE_ONLY before including)
1.13 threadsafe
1.12 const qualifiers in the API
1.11 Support installable IDCT, colorspace conversion routines
1.10 Fixes for 64-bit (don't use "unsigned long")
optimized upsampling by Fabian "ryg" Giesen
1.09 Fix format-conversion for PSD code (bad global variables!)
1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz
1.07 attempt to fix C++ warning/errors again
1.06 attempt to fix C++ warning/errors again
1.05 fix TGA loading to return correct *comp and use good luminance calc
1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free
1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR
1.02 support for (subset of) HDR files, float interface for preferred access to them
1.01 fix bug: possible bug in handling right-side up bmps... not sure
fix bug: the stbi_bmp_load() and stbi_tga_load() functions didn't work at all
1.00 interface to zlib that skips zlib header
0.99 correct handling of alpha in palette
0.98 TGA loader by lonesock; dynamically add loaders (untested)
0.97 jpeg errors on too large a file; also catch another malloc failure
0.96 fix detection of invalid v value - particleman@mollyrocket forum
0.95 during header scan, seek to markers in case of padding
0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same
0.93 handle jpegtran output; verbose errors
0.92 read 4,8,16,24,32-bit BMP files of several formats
0.91 output 24-bit Windows 3.0 BMP files
0.90 fix a few more warnings; bump version number to approach 1.0
0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd
0.60 fix compiling as c++
0.59 fix warnings: merge Dave Moore's -Wall fixes
0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian
0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less
than 16 available
0.56 fix bug: zlib uncompressed mode len vs. nlen
0.55 fix bug: restart_interval not initialized to 0
0.54 allow NULL for 'int *comp'
0.53 fix bug in png 3->4; speedup png decoding
0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments
0.51 obey req_comp requests, 1-component jpegs return as 1-component,
on 'test' only check type, not whether we support this variant
*/
#ifndef HEADER_STB_IMAGE_AUGMENTED
#define HEADER_STB_IMAGE_AUGMENTED
//// begin header file ////////////////////////////////////////////////////
//
// Limitations:
// - no progressive/interlaced support (jpeg, png)
// - 8-bit samples only (jpeg, png)
// - not threadsafe
// - channel subsampling of at most 2 in each dimension (jpeg)
// - no delayed line count (jpeg) -- IJG doesn't support either
//
// Basic usage (see HDR discussion below):
// int x,y,n;
// unsigned char *data = stbi_load(filename, &x, &y, &n, 0);
// // ... process data if not NULL ...
// // ... x = width, y = height, n = # 8-bit components per pixel ...
// // ... replace '0' with '1'..'4' to force that many components per pixel
// stbi_image_free(data)
//
// Standard parameters:
// int *x -- outputs image width in pixels
// int *y -- outputs image height in pixels
// int *comp -- outputs # of image components in image file
// int req_comp -- if non-zero, # of image components requested in result
//
// The return value from an image loader is an 'unsigned char *' which points
// to the pixel data. The pixel data consists of *y scanlines of *x pixels,
// with each pixel consisting of N interleaved 8-bit components; the first
// pixel pointed to is top-left-most in the image. There is no padding between
// image scanlines or between pixels, regardless of format. The number of
// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise.
// If req_comp is non-zero, *comp has the number of components that _would_
// have been output otherwise. E.g. if you set req_comp to 4, you will always
// get RGBA output, but you can check *comp to easily see if it's opaque.
//
// An output image with N components has the following components interleaved
// in this order in each pixel:
//
// N=#comp components
// 1 grey
// 2 grey, alpha
// 3 red, green, blue
// 4 red, green, blue, alpha
//
// If image loading fails for any reason, the return value will be NULL,
// and *x, *y, *comp will be unchanged. The function stbi_failure_reason()
// can be queried for an extremely brief, end-user unfriendly explanation
// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid
// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly
// more user-friendly ones.
//
// Paletted PNG and BMP images are automatically depalettized.
//
//
// ===========================================================================
//
// HDR image support (disable by defining STBI_NO_HDR)
//
// stb_image now supports loading HDR images in general, and currently
// the Radiance .HDR file format, although the support is provided
// generically. You can still load any file through the existing interface;
// if you attempt to load an HDR file, it will be automatically remapped to
// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1;
// both of these constants can be reconfigured through this interface:
//
// stbi_hdr_to_ldr_gamma(2.2f);
// stbi_hdr_to_ldr_scale(1.0f);
//
// (note, do not use _inverse_ constants; stbi_image will invert them
// appropriately).
//
// Additionally, there is a new, parallel interface for loading files as
// (linear) floats to preserve the full dynamic range:
//
// float *data = stbi_loadf(filename, &x, &y, &n, 0);
//
// If you load LDR images through this interface, those images will
// be promoted to floating point values, run through the inverse of
// constants corresponding to the above:
//
// stbi_ldr_to_hdr_scale(1.0f);
// stbi_ldr_to_hdr_gamma(2.2f);
//
// Finally, given a filename (or an open file or memory block--see header
// file for details) containing image data, you can query for the "most
// appropriate" interface to use (that is, whether the image is HDR or
// not), using:
//
// stbi_is_hdr(char *filename);
#ifndef STBI_NO_STDIO
#include <stdio.h>
#endif
#define STBI_VERSION 1
enum
{
STBI_default = 0, // only used for req_comp
STBI_grey = 1,
STBI_grey_alpha = 2,
STBI_rgb = 3,
STBI_rgb_alpha = 4,
};
typedef unsigned char stbi_uc;
#ifdef __cplusplus
extern "C" {
#endif
// WRITING API
#if !defined(STBI_NO_WRITE) && !defined(STBI_NO_STDIO)
// write a BMP/TGA file given tightly packed 'comp' channels (no padding, nor bmp-stride-padding)
// (you must include the appropriate extension in the filename).
// returns TRUE on success, FALSE if couldn't open file, error writing file
extern int stbi_write_bmp (char const *filename, int x, int y, int comp, void *data);
extern int stbi_write_tga (char const *filename, int x, int y, int comp, void *data);
#endif
// PRIMARY API - works on images of any type
// load image by filename, open file, or memory buffer
#ifndef STBI_NO_STDIO
extern stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp);
#endif
extern stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
// for stbi_load_from_file, file pointer is left pointing immediately after image
#ifndef STBI_NO_HDR
#ifndef STBI_NO_STDIO
extern float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp);
extern float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
#endif
extern float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
extern void stbi_hdr_to_ldr_gamma(float gamma);
extern void stbi_hdr_to_ldr_scale(float scale);
extern void stbi_ldr_to_hdr_gamma(float gamma);
extern void stbi_ldr_to_hdr_scale(float scale);
#endif // STBI_NO_HDR
// get a VERY brief reason for failure
// NOT THREADSAFE
extern char *stbi_failure_reason (void);
// free the loaded image -- this is just free()
extern void stbi_image_free (void *retval_from_stbi_load);
// get image dimensions & components without fully decoding
extern int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
extern int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);
#ifndef STBI_NO_STDIO
extern int stbi_info (char const *filename, int *x, int *y, int *comp);
extern int stbi_is_hdr (char const *filename);
extern int stbi_is_hdr_from_file(FILE *f);
#endif
// ZLIB client - used by PNG, available for other purposes
extern char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
extern char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen);
extern int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
extern char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen);
extern int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
// TYPE-SPECIFIC ACCESS
// is it a jpeg?
extern int stbi_jpeg_test_memory (stbi_uc const *buffer, int len);
extern stbi_uc *stbi_jpeg_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
extern int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
#ifndef STBI_NO_STDIO
extern stbi_uc *stbi_jpeg_load (char const *filename, int *x, int *y, int *comp, int req_comp);
extern int stbi_jpeg_test_file (FILE *f);
extern stbi_uc *stbi_jpeg_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
extern int stbi_jpeg_info (char const *filename, int *x, int *y, int *comp);
extern int stbi_jpeg_info_from_file (FILE *f, int *x, int *y, int *comp);
#endif
// is it a png?
extern int stbi_png_test_memory (stbi_uc const *buffer, int len);
extern stbi_uc *stbi_png_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
extern int stbi_png_info_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp);
#ifndef STBI_NO_STDIO
extern stbi_uc *stbi_png_load (char const *filename, int *x, int *y, int *comp, int req_comp);
extern int stbi_png_info (char const *filename, int *x, int *y, int *comp);
extern int stbi_png_test_file (FILE *f);
extern stbi_uc *stbi_png_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp);
extern int stbi_png_info_from_file (FILE *f, int *x, int *y, int *comp);
#endif
// is it a bmp?
extern int stbi_bmp_test_memory (stbi_uc const *buffer, int len);
extern stbi_uc *stbi_bmp_load (char const *filename, int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_bmp_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
#ifndef STBI_NO_STDIO