- Added bswap for 64 bits.

- Improved and better unified OpenGL and OpenGL ES2 texture interface (support for compressed textures in OpenGL ES2).
- Added support for PVRTC and PVRTC2 compressed textures format.
- Minor improved in DDS loader.
- Initial support for PVR loader (currently with limited image formats support - PVRTC, PVRTC2, DXTn). This loader will improve soon.

IMPORTANT: This commit doesn't provide integration of PVR loader with iOS, MacOSX and some Windows IDEs project files.


git-svn-id: http://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4529 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
nadro 2013-05-20 21:38:55 +00:00
parent 24d2223820
commit c277059e51
33 changed files with 3226 additions and 685 deletions

View File

@ -121,6 +121,12 @@ namespace video
//! Support for DXTn compressed textures.
EVDF_TEXTURE_COMPRESSED_DXT,
//! Support for PVRTC compressed textures.
EVDF_TEXTURE_COMPRESSED_PVRTC,
//! Support for PVRTC2 compressed textures.
EVDF_TEXTURE_COMPRESSED_PVRTC2,
//! Only used for counting the elements of this enum
EVDF_COUNT
};

View File

@ -125,6 +125,16 @@ public:
case ECF_DXT4:
case ECF_DXT5:
return 32;
case ECF_PVRTC_R2G2B2:
return 6;
case ECF_PVRTC_A2R2G2B2:
case ECF_PVRTC2_A2R2G2B2:
return 8;
case ECF_PVRTC_R4G4B4:
return 12;
case ECF_PVRTC_A4R4G4B4:
case ECF_PVRTC2_A4R4G4B4:
return 16;
case ECF_R16F:
return 16;
case ECF_G16R16F:
@ -142,6 +152,46 @@ public:
}
}
//! calculate compressed image size for selected width and height.
static u32 getCompressedImageSize(ECOLOR_FORMAT format, u32 width, u32 height)
{
if (!isCompressedFormat(format))
return 0;
u32 compressedImageSize = 0;
switch (format)
{
case ECF_DXT1:
compressedImageSize = ((width + 3) / 4) * ((height + 3) / 4) * 8;
break;
case ECF_DXT2:
case ECF_DXT3:
case ECF_DXT4:
case ECF_DXT5:
compressedImageSize = ((width + 3) / 4) * ((height + 3) / 4) * 16;
break;
case ECF_PVRTC_R2G2B2:
case ECF_PVRTC_A2R2G2B2:
compressedImageSize = (core::max_<u32>(width, 16) * core::max_<u32>(height, 8) * 2 + 7) / 8;
break;
case ECF_PVRTC_R4G4B4:
case ECF_PVRTC_A4R4G4B4:
compressedImageSize = (core::max_<u32>(width, 8) * core::max_<u32>(height, 8) * 4 + 7) / 8;
break;
case ECF_PVRTC2_A2R2G2B2:
compressedImageSize = core::ceil32(width / 8.0f) * core::ceil32(height / 4.0f) * 8;
break;
case ECF_PVRTC2_A4R4G4B4:
compressedImageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 8;
break;
default:
break;
}
return compressedImageSize;
}
//! test if this is compressed color format
static bool isCompressedFormat(const ECOLOR_FORMAT format)
{
@ -152,6 +202,12 @@ public:
case ECF_DXT3:
case ECF_DXT4:
case ECF_DXT5:
case ECF_PVRTC_R2G2B2:
case ECF_PVRTC_A2R2G2B2:
case ECF_PVRTC2_A2R2G2B2:
case ECF_PVRTC_R4G4B4:
case ECF_PVRTC_A4R4G4B4:
case ECF_PVRTC2_A4R4G4B4:
return true;
default:
return false;

View File

@ -630,6 +630,11 @@ B3D, MS3D or X meshes */
#ifdef _IRR_COMPILE_WITH_DDS_DECODER_LOADER_
#undef _IRR_COMPILE_WITH_DDS_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_PVR_LOADER_ if you want to load .pvr files
#define _IRR_COMPILE_WITH_PVR_LOADER_
#ifdef NO_IRR_COMPILE_WITH_PVR_LOADER_
#undef _IRR_COMPILE_WITH_PVR_LOADER_
#endif
//! Define _IRR_COMPILE_WITH_TGA_LOADER_ if you want to load .tga files
#define _IRR_COMPILE_WITH_TGA_LOADER_
#ifdef NO_IRR_COMPILE_WITH_TGA_LOADER_

View File

@ -48,6 +48,24 @@ namespace video
//! DXT5 color format.
ECF_DXT5,
//! PVRTC RGB 2bpp
ECF_PVRTC_R2G2B2,
//! PVRTC ARGB 2bpp
ECF_PVRTC_A2R2G2B2,
//! PVRTC RGB 4bpp
ECF_PVRTC_R4G4B4,
//! PVRTC ARGB 4bpp
ECF_PVRTC_A4R4G4B4,
//! PVRTC2 ARGB 2bpp
ECF_PVRTC2_A2R2G2B2,
//! PVRTC2 ARGB 4bpp
ECF_PVRTC2_A4R4G4B4,
/** Floating Point formats. The following formats may only be used for render target textures. */
//! 16 bit floating point format using 16 bits for the red channel.

View File

@ -114,6 +114,7 @@ LOCAL_SRC_FILES := \
CImageWriterPPM.cpp \
CImageWriterPSD.cpp \
CImageWriterTGA.cpp \
CImageLoaderPVR.cpp \
CIrrDeviceConsole.cpp \
CIrrDeviceFB.cpp \
CIrrDeviceLinux.cpp \

View File

@ -612,6 +612,9 @@ bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
return true;
case EVDF_TEXTURE_COMPRESSED_DXT:
return false; // TO-DO
case EVDF_TEXTURE_COMPRESSED_PVRTC:
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
return false;
default:
return false;
};

View File

@ -67,14 +67,12 @@ HasMipMaps(false), IsRenderTarget(false)
if (image)
{
if(image->getColorFormat() == ECF_DXT1 || image->getColorFormat() == ECF_DXT2 || image->getColorFormat() == ECF_DXT3 || image->getColorFormat() == ECF_DXT4 || image->getColorFormat() == ECF_DXT5)
if (IImage::isCompressedFormat(image->getColorFormat()))
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_DXT))
{
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
os::Printer::log("This driver doesn't support compressed textures.", ELL_ERROR);
IsCompressed = true;
return;
}
}
if (createTexture(flags, image))
{

View File

@ -684,6 +684,9 @@ bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
return true;
case EVDF_TEXTURE_COMPRESSED_DXT:
return true;
case EVDF_TEXTURE_COMPRESSED_PVRTC:
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
return false;
default:
return false;
};

View File

@ -76,6 +76,24 @@ CD3D9Texture::CD3D9Texture(IImage* image, CD3D9Driver* driver,
}
}
if(image->getColorFormat() == ECF_PVRTC_R2G2B2 || image->getColorFormat() == ECF_PVRTC_A2R2G2B2 || image->getColorFormat() == ECF_PVRTC_R4G4B4 || image->getColorFormat() == ECF_PVRTC_A4R4G4B4)
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC))
{
os::Printer::log("PVRTC texture compression not available.", ELL_ERROR);
return;
}
}
if(image->getColorFormat() == ECF_PVRTC2_A2R2G2B2 || image->getColorFormat() == ECF_PVRTC2_A4R4G4B4)
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2))
{
os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR);
return;
}
}
if (createTexture(flags, image))
{
if (copyTexture(image))

View File

@ -809,78 +809,40 @@ IImage* CImageLoaderDDS::loadImage(io::IReadFile* file) const
switch(pixelFormat)
{
case DDS_PF_DXT1:
{
u32 curWidth = header.Width;
u32 curHeight = header.Height;
dataSize = ((curWidth + 3) / 4) * ((curHeight + 3) / 4) * 8;
do
{
if (curWidth > 1)
curWidth >>= 1;
if (curHeight > 1)
curHeight >>= 1;
dataSize += ((curWidth + 3) / 4) * ((curHeight + 3) / 4) * 8;
}
while (curWidth != 1 || curWidth != 1);
format = ECF_DXT1;
break;
}
case DDS_PF_DXT2:
case DDS_PF_DXT3:
{
u32 curWidth = header.Width;
u32 curHeight = header.Height;
dataSize = ((curWidth + 3) / 4) * ((curHeight + 3) / 4) * 16;
do
{
if (curWidth > 1)
curWidth >>= 1;
if (curHeight > 1)
curHeight >>= 1;
dataSize += ((curWidth + 3) / 4) * ((curHeight + 3) / 4) * 16;
}
while (curWidth != 1 || curWidth != 1);
format = ECF_DXT3;
break;
}
case DDS_PF_DXT4:
case DDS_PF_DXT5:
{
u32 curWidth = header.Width;
u32 curHeight = header.Height;
dataSize = ((curWidth + 3) / 4) * ((curHeight + 3) / 4) * 16;
do
{
if (curWidth > 1)
curWidth >>= 1;
if (curHeight > 1)
curHeight >>= 1;
dataSize += ((curWidth + 3) / 4) * ((curHeight + 3) / 4) * 16;
}
while (curWidth != 1 || curWidth != 1);
format = ECF_DXT5;
break;
}
}
if (format != ECF_UNKNOWN)
{
if (!is3D) // Currently 3D textures are unsupported.
// Calculate image data size.
u32 curWidth = header.Width;
u32 curHeight = header.Height;
dataSize = IImage::getCompressedImageSize(format, curWidth, curHeight);
do
{
if (curWidth > 1)
curWidth >>= 1;
if (curHeight > 1)
curHeight >>= 1;
dataSize += IImage::getCompressedImageSize(format, curWidth, curHeight);
}
while (curWidth != 1 || curWidth != 1);
// Currently 3D textures are unsupported.
if (!is3D)
{
u8* data = new u8[dataSize];
file->read(data, dataSize);

View File

@ -0,0 +1,176 @@
// Copyright (C) 2013 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CImageLoaderPVR.h"
#ifdef _IRR_COMPILE_WITH_PVR_LOADER_
#include "IReadFile.h"
#include "os.h"
#include "CImage.h"
#include "irrString.h"
namespace irr
{
namespace video
{
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".tga")
bool CImageLoaderPVR::isALoadableFileExtension(const io::path& filename) const
{
return core::hasFileExtension(filename, "pvr");
}
//! returns true if the file maybe is able to be loaded by this class
bool CImageLoaderPVR::isALoadableFileFormat(io::IReadFile* file) const
{
if (!file)
return false;
c8 fourCC[4];
file->seek(0);
file->read(&fourCC, 4);
/*if (header.Version == 0x03525650) // TO-DO - fix endiannes
{
printf("Bad endian2\n");
fourCC[0] = os::Byteswap::byteswap(fourCC[0]);
fourCC[1] = os::Byteswap::byteswap(fourCC[1]);
fourCC[2] = os::Byteswap::byteswap(fourCC[2]);
fourCC[3] = os::Byteswap::byteswap(fourCC[3]);
}*/
return (fourCC[0] == 'P' && fourCC[1] == 'V' && fourCC[2] == 'R');
}
//! creates a surface from the file
IImage* CImageLoaderPVR::loadImage(io::IReadFile* file) const
{
SPVRHeader header;
IImage* image = 0;
ECOLOR_FORMAT format = ECF_UNKNOWN;
u32 dataSize = 0;
file->seek(0);
file->read(&header, sizeof(SPVRHeader));
/*if (header.Version == 0x03525650) // TO-DO - fix endiannes
{
header.Flags = os::Byteswap::byteswap(header.Flags);
header.PixelFormat = os::Byteswap::byteswap(header.PixelFormat);
header.ColourSpace = os::Byteswap::byteswap(header.ColourSpace);
header.ChannelType = os::Byteswap::byteswap(header.ChannelType);
header.Height = os::Byteswap::byteswap(header.Height);
header.Width = os::Byteswap::byteswap(header.Width);
header.Depth = os::Byteswap::byteswap(header.Depth);
header.NumSurfaces = os::Byteswap::byteswap(header.NumSurfaces);
header.NumFaces = os::Byteswap::byteswap(header.NumFaces);
header.MipMapCount = os::Byteswap::byteswap(header.MipMapCount);
header.MetDataSize = os::Byteswap::byteswap(header.MetDataSize);
}*/
c8 fourCC[4];
u32 key;
u32 helperDataSize;
if (header.MetDataSize > 0)
{
file->read(&fourCC, 4);
file->read(&key, sizeof(u32));
file->read(&helperDataSize, sizeof(u32));
file->seek(helperDataSize, true);
}
if (header.PixelFormat & 0xFFFFFFFF00000000) // Uncompressed texture formats
{
// TO-DO add support for uncompressed images.
}
else // Compressed texture formats
{
switch(header.PixelFormat)
{
case 0: // PVRTC 2bpp RGB
format = ECF_PVRTC_R2G2B2;
break;
case 1: // PVRTC 2bpp RGBA
format = ECF_PVRTC_A2R2G2B2;
break;
case 2: // PVRTC 4bpp RGB
format = ECF_PVRTC_R4G4B4;
break;
case 3: // PVRTC 4bpp RGBA
format = ECF_PVRTC_A4R4G4B4;
break;
case 4: // PVRTC-II 2bpp
format = ECF_PVRTC2_A2R2G2B2;
break;
case 5: // PVRTC-II 4bpp
format = ECF_PVRTC2_A4R4G4B4;
break;
case 7: // DXT1 / BC1
format = ECF_DXT1;
break;
case 8: // DXT2
case 9: // DXT3 / BC2
format = ECF_DXT3;
break;
case 10: // DXT4
case 11: // DXT5 / BC3
format = ECF_DXT5;
break;
}
if (format != ECF_UNKNOWN)
{
// Calculate image data size.
u32 curWidth = header.Width;
u32 curHeight = header.Height;
dataSize = IImage::getCompressedImageSize(format, curWidth, curHeight);
do
{
if (curWidth > 1)
curWidth >>= 1;
if (curHeight > 1)
curHeight >>= 1;
dataSize += IImage::getCompressedImageSize(format, curWidth, curHeight);
}
while (curWidth != 1 || curWidth != 1);
// 3D textures, texture arrays, cube maps textures aren't currently supported
if (header.Depth < 2 && header.NumSurfaces < 2 && header.NumFaces < 2)
{
u8* data = new u8[dataSize];
file->read(data, dataSize);
bool hasMipMap = (header.MipMapCount > 0) ? true : false;
image = new CImage(format, core::dimension2d<u32>(header.Width, header.Height), data, true, true, true, hasMipMap);
}
}
}
return image;
}
//! creates a loader which is able to load pvr images
IImageLoader* createImageLoaderPVR()
{
return new CImageLoaderPVR();
}
} // end namespace video
} // end namespace irr
#endif

View File

@ -0,0 +1,64 @@
// Copyright (C) 2013 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_IMAGE_LOADER_PVR_H_INCLUDED__
#define __C_IMAGE_LOADER_PVR_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_PVR_LOADER_
#include "IImageLoader.h"
namespace irr
{
namespace video
{
// byte-align structures
#include "irrpack.h"
/* structures */
struct SPVRHeader
{
u32 Version;
u32 Flags;
u64 PixelFormat;
u32 ColourSpace;
u32 ChannelType;
u32 Height;
u32 Width;
u32 Depth;
u32 NumSurfaces;
u32 NumFaces;
u32 MipMapCount;
u32 MetDataSize;
} PACK_STRUCT;
// Default alignment
#include "irrunpack.h"
/*!
Surface Loader for PVR images
*/
class CImageLoaderPVR : public IImageLoader
{
public:
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".tga")
virtual bool isALoadableFileExtension(const io::path& filename) const;
//! returns true if the file maybe is able to be loaded by this class
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
//! creates a surface from the file
virtual IImage* loadImage(io::IReadFile* file) const;
};
} // end namespace video
} // end namespace irr
#endif // compiled with PVR loader
#endif

View File

@ -37,6 +37,9 @@ IImageLoader* createImageLoaderPSD();
//! creates a loader which is able to load dds images
IImageLoader* createImageLoaderDDS();
//! creates a loader which is able to load pvr images
IImageLoader* createImageLoaderPVR();
//! creates a loader which is able to load pcx images
IImageLoader* createImageLoaderPCX();
@ -142,6 +145,9 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
#if defined(_IRR_COMPILE_WITH_DDS_LOADER_) || defined(_IRR_COMPILE_WITH_DDS_DECODER_LOADER_)
SurfaceLoader.push_back(video::createImageLoaderDDS());
#endif
#ifdef _IRR_COMPILE_WITH_PVR_LOADER_
SurfaceLoader.push_back(video::createImageLoaderPVR());
#endif
#ifdef _IRR_COMPILE_WITH_PCX_LOADER_
SurfaceLoader.push_back(video::createImageLoaderPCX());
#endif

View File

@ -77,6 +77,7 @@ namespace video
"GL_IMG_read_format",
"GL_IMG_shader_binary",
"GL_IMG_texture_compression_pvrtc",
"GL_IMG_texture_compression_pvrtc2",
"GL_IMG_texture_env_enhanced_fixed_function",
"GL_IMG_texture_format_BGRA8888",
"GL_IMG_user_clip_plane",

View File

@ -92,6 +92,7 @@ namespace video
IRR_IMG_read_format, // 53
IRR_IMG_shader_binary, // 68
IRR_IMG_texture_compression_pvrtc, // 54
IRR_IMG_texture_compression_pvrtc2, // 140
IRR_IMG_texture_env_enhanced_fixed_function, // 58
IRR_IMG_texture_format_BGRA8888, // replaced by EXT version
IRR_IMG_user_clip_plane, // 57, was clip_planes
@ -222,6 +223,10 @@ namespace video
return false;
case EVDF_TEXTURE_COMPRESSED_DXT:
return false; // NV Tegra need improvements here
case EVDF_TEXTURE_COMPRESSED_PVRTC:
return FeatureAvailable[IRR_IMG_texture_compression_pvrtc];
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
return FeatureAvailable[IRR_IMG_texture_compression_pvrtc2];
case EVDF_STENCIL_BUFFER:
return StencilBuffer;
default:

View File

@ -42,19 +42,35 @@ COGLES2Texture::COGLES2Texture(IImage* origImage, const io::path& name, void* mi
: ITexture(name), ColorFormat(ECF_A8R8G8B8), Driver(driver), Image(0), MipImage(0),
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0),
IsRenderTarget(false), AutomaticMipmapUpdate(false),
IsRenderTarget(false), IsCompressed(false), AutomaticMipmapUpdate(false),
ReadOnlyLock(false), KeepImage(true)
{
#ifdef _DEBUG
setDebugName("COGLES2Texture");
#endif
#ifndef GL_BGRA
// whoa, pretty badly implemented extension...
if (Driver->FeatureAvailable[COGLES2ExtensionHandler::IRR_IMG_texture_format_BGRA8888] ||
Driver->FeatureAvailable[COGLES2ExtensionHandler::IRR_EXT_texture_format_BGRA8888] ||
Driver->FeatureAvailable[COGLES2ExtensionHandler::IRR_APPLE_texture_format_BGRA8888])
GL_BGRA = 0x80E1;
else
GL_BGRA = GL_RGBA;
#endif
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
getImageValues(origImage);
glGenTextures(1, &TextureName);
if (ImageSize==TextureSize)
if (checkFormatCompatibility())
{
if (IsCompressed)
{
Image = origImage;
Image->grab();
KeepImage = false;
}
else if (ImageSize==TextureSize)
{
Image = Driver->createImage(ColorFormat, ImageSize);
origImage->copyTo(Image);
@ -62,16 +78,19 @@ COGLES2Texture::COGLES2Texture(IImage* origImage, const io::path& name, void* mi
else
{
Image = Driver->createImage(ColorFormat, TextureSize);
// scale texture
origImage->copyToScaling(Image);
}
glGenTextures(1, &TextureName);
uploadTexture(true, mipmapData);
if (!KeepImage)
{
Image->drop();
Image=0;
}
}
}
//! constructor for basic setup (only for derived classes)
@ -79,7 +98,7 @@ COGLES2Texture::COGLES2Texture(const io::path& name, COGLES2Driver* driver)
: ITexture(name), ColorFormat(ECF_A8R8G8B8), Driver(driver), Image(0), MipImage(0),
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0), HasMipMaps(true),
IsRenderTarget(false), AutomaticMipmapUpdate(false),
IsRenderTarget(false), IsCompressed(false), AutomaticMipmapUpdate(false),
ReadOnlyLock(false), KeepImage(true)
{
#ifdef _DEBUG
@ -102,6 +121,9 @@ COGLES2Texture::~COGLES2Texture()
ECOLOR_FORMAT COGLES2Texture::getBestColorFormat(ECOLOR_FORMAT format)
{
ECOLOR_FORMAT destFormat = ECF_A8R8G8B8;
if (!IImage::isCompressedFormat(format))
{
switch (format)
{
case ECF_A1R5G5B5:
@ -121,9 +143,14 @@ ECOLOR_FORMAT COGLES2Texture::getBestColorFormat(ECOLOR_FORMAT format)
if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) ||
Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
destFormat = ECF_A1R5G5B5;
break;
default:
break;
}
}
else
destFormat = format;
if (Driver->getTextureCreationFlag(ETCF_NO_ALPHA_CHANNEL))
{
switch (destFormat)
@ -138,16 +165,147 @@ ECOLOR_FORMAT COGLES2Texture::getBestColorFormat(ECOLOR_FORMAT format)
break;
}
}
return destFormat;
}
//! Get the OpenGL color format parameters based on the given Irrlicht color format
void COGLES2Texture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLint& filtering,
GLenum& pixelFormat, GLenum& type, void(*&convert)(const void*, s32, void*))
{
switch(format)
{
case ECF_A1R5G5B5:
internalFormat = GL_RGBA;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = GL_UNSIGNED_SHORT_5_5_5_1;
convert = CColorConverter::convert_A1R5G5B5toR5G5B5A1;
break;
case ECF_R5G6B5:
internalFormat = GL_RGB;
filtering = GL_LINEAR;
pixelFormat = GL_RGB;
type = GL_UNSIGNED_SHORT_5_6_5;
break;
case ECF_R8G8B8:
internalFormat = GL_RGB;
filtering = GL_LINEAR;
pixelFormat = GL_RGB;
type = GL_UNSIGNED_BYTE;
convert = CColorConverter::convert_R8G8B8toB8G8R8;
break;
case ECF_A8R8G8B8:
filtering = GL_LINEAR;
type = GL_UNSIGNED_BYTE;
if (!Driver->queryOpenGLFeature(COGLES2ExtensionHandler::IRR_IMG_texture_format_BGRA8888) &&
!Driver->queryOpenGLFeature(COGLES2ExtensionHandler::IRR_EXT_texture_format_BGRA8888) &&
!Driver->queryOpenGLFeature(COGLES2ExtensionHandler::IRR_APPLE_texture_format_BGRA8888))
{
internalFormat = GL_RGBA;
pixelFormat = GL_RGBA;
convert = CColorConverter::convert_A8R8G8B8toA8B8G8R8;
}
else
{
internalFormat = GL_BGRA;
pixelFormat = GL_BGRA;
}
break;
#ifdef GL_EXT_texture_compression_s3tc
case ECF_DXT1:
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
filtering = GL_LINEAR;
pixelFormat = GL_BGRA;
type = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
break;
#endif
#ifdef GL_EXT_texture_compression_s3tc
case ECF_DXT2:
case ECF_DXT3:
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
filtering = GL_LINEAR;
pixelFormat = GL_BGRA;
type = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
break;
#endif
#ifdef GL_EXT_texture_compression_s3tc
case ECF_DXT4:
case ECF_DXT5:
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
filtering = GL_LINEAR;
pixelFormat = GL_BGRA;
type = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc
case ECF_PVRTC_R2G2B2:
internalFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGB;
type = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc
case ECF_PVRTC_A2R2G2B2:
internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc
case ECF_PVRTC_R4G4B4:
internalFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGB;
type = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc
case ECF_PVRTC_A4R4G4B4:
internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc2
case ECF_PVRTC2_A2R2G2B2:
internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc2
case ECF_PVRTC2_A4R4G4B4:
internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
break;
#endif
default:
os::Printer::log("Unsupported texture format", ELL_ERROR);
break;
}
// Hack for iPhone SDK, which requires a different InternalFormat
#ifdef _IRR_IPHONE_PLATFORM_
if (internalFormat == GL_BGRA)
internalFormat = GL_RGBA;
#endif
}
// prepare values ImageSize, TextureSize, and ColorFormat based on image
void COGLES2Texture::getImageValues(IImage* image)
{
if (!image)
{
os::Printer::log("No image for OpenGL texture.", ELL_ERROR);
os::Printer::log("No image for OpenGL ES2 texture.", ELL_ERROR);
return;
}
@ -155,7 +313,7 @@ void COGLES2Texture::getImageValues(IImage* image)
if ( !ImageSize.Width || !ImageSize.Height)
{
os::Printer::log("Invalid size of image for OpenGL Texture.", ELL_ERROR);
os::Printer::log("Invalid size of image for OpenGL ES2 Texture.", ELL_ERROR);
return;
}
@ -176,6 +334,77 @@ void COGLES2Texture::getImageValues(IImage* image)
}
//! check format compatibility.
bool COGLES2Texture::checkFormatCompatibility()
{
bool status = true;
switch (ColorFormat)
{
case ECF_DXT1:
case ECF_DXT2:
case ECF_DXT3:
case ECF_DXT4:
case ECF_DXT5:
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_DXT))
{
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
status = false;
}
else if(ImageSize != TextureSize)
{
os::Printer::log("Invalid size of image for DXTn compressed texture, size of image must be POT.", ELL_ERROR);
status = false;
}
else
IsCompressed = true;
}
break;
case ECF_PVRTC_R2G2B2:
case ECF_PVRTC_A2R2G2B2:
case ECF_PVRTC_R4G4B4:
case ECF_PVRTC_A4R4G4B4:
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC))
{
os::Printer::log("PVRTC texture compression not available.", ELL_ERROR);
status = false;
}
else if(ImageSize != TextureSize)
{
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be POT.", ELL_ERROR);
status = false;
}
else if(TextureSize.Height != TextureSize.Width)
{
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be squared.", ELL_ERROR);
status = false;
}
else
IsCompressed = true;
}
break;
case ECF_PVRTC2_A2R2G2B2:
case ECF_PVRTC2_A4R4G4B4:
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2))
{
os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR);
status = false;
}
else
IsCompressed = true;
}
break;
default:
break;
}
return status;
}
//! copies the the texture into an open gl texture.
void COGLES2Texture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
{
@ -183,65 +412,17 @@ void COGLES2Texture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
IImage* image = level?MipImage:Image;
if (!image)
{
os::Printer::log("No image for OGLES2 texture to upload", ELL_ERROR);
os::Printer::log("No image for OpenGL ES2 texture to upload", ELL_ERROR);
return;
}
#ifndef GL_BGRA
// whoa, pretty badly implemented extension...
if (Driver->FeatureAvailable[COGLES2ExtensionHandler::IRR_IMG_texture_format_BGRA8888] || Driver->FeatureAvailable[COGLES2ExtensionHandler::IRR_EXT_texture_format_BGRA8888])
GL_BGRA=0x80E1;
else
GL_BGRA=GL_RGBA;
#endif
GLenum oldInternalFormat = InternalFormat;
// get correct opengl color data values
GLint oldInternalFormat = InternalFormat;
GLint filtering = GL_LINEAR;
void(*convert)(const void*, s32, void*) = 0;
switch (Image->getColorFormat())
{
case ECF_A1R5G5B5:
InternalFormat=GL_RGBA;
PixelFormat=GL_RGBA;
PixelType=GL_UNSIGNED_SHORT_5_5_5_1;
convert=CColorConverter::convert_A1R5G5B5toR5G5B5A1;
break;
case ECF_R5G6B5:
InternalFormat=GL_RGB;
PixelFormat=GL_RGB;
PixelType=GL_UNSIGNED_SHORT_5_6_5;
break;
case ECF_R8G8B8:
InternalFormat=GL_RGB;
PixelFormat=GL_RGB;
PixelType=GL_UNSIGNED_BYTE;
convert=CColorConverter::convert_R8G8B8toB8G8R8;
break;
case ECF_A8R8G8B8:
PixelType=GL_UNSIGNED_BYTE;
if (!Driver->queryOpenGLFeature(COGLES2ExtensionHandler::IRR_IMG_texture_format_BGRA8888) &&
!Driver->queryOpenGLFeature(COGLES2ExtensionHandler::IRR_EXT_texture_format_BGRA8888) &&
!Driver->queryOpenGLFeature(COGLES2ExtensionHandler::IRR_APPLE_texture_format_BGRA8888))
{
convert=CColorConverter::convert_A8R8G8B8toA8B8G8R8;
InternalFormat=GL_RGBA;
PixelFormat=GL_RGBA;
}
else
{
InternalFormat=GL_BGRA;
PixelFormat=GL_BGRA;
}
break;
default:
os::Printer::log("Unsupported texture format", ELL_ERROR);
break;
}
// Hack for iPhone SDK, which requires a different InternalFormat
#ifdef _IRR_IPHONE_PLATFORM_
if (InternalFormat==GL_BGRA)
InternalFormat=GL_RGBA;
#endif
// make sure we don't change the internal format of existing matrices
getFormatParameters(ColorFormat, InternalFormat, filtering, PixelFormat, PixelType, convert);
// make sure we don't change the internal format of existing images
if (!newTexture)
InternalFormat = oldInternalFormat;
@ -254,9 +435,8 @@ void COGLES2Texture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
// mipmap handling for main texture
if (!level && newTexture)
{
#ifndef DISABLE_MIPMAPPING
// auto generate if possible and no mipmap data is given
if (HasMipMaps && !mipmapData)
if (!IsCompressed && HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
{
if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
@ -267,42 +447,26 @@ void COGLES2Texture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
AutomaticMipmapUpdate=true;
}
else
{
// Either generate manually due to missing capability
// or use predefined mipmap data
AutomaticMipmapUpdate=false;
regenerateMipMapLevels(mipmapData);
}
if (HasMipMaps) // might have changed in regenerateMipMapLevels
{
// enable bilinear mipmap filter
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
StatesCache.BilinearFilter = true;
StatesCache.TrilinearFilter = false;
StatesCache.MipMapStatus = true;
}
else
#else
HasMipMaps=false;
os::Printer::log("Did not create OpenGL texture mip maps.", ELL_INFORMATION);
#endif
{
// enable bilinear filter without mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (filtering == GL_LINEAR)
StatesCache.BilinearFilter = true;
else
StatesCache.BilinearFilter = false;
StatesCache.TrilinearFilter = false;
StatesCache.MipMapStatus = false;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
}
// now get image data and upload to GPU
u32 compressedImageSize = IImage::getCompressedImageSize(ColorFormat, image->getDimension().Width, image->getDimension().Height);
void* source = image->lock();
IImage* tmpImage = 0;
if (convert)
@ -315,11 +479,27 @@ void COGLES2Texture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
}
if (newTexture)
{
if (IsCompressed)
{
glCompressedTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, image->getDimension().Width,
image->getDimension().Height, 0, compressedImageSize, source);
}
else
glTexImage2D(GL_TEXTURE_2D, level, InternalFormat, image->getDimension().Width,
image->getDimension().Height, 0, PixelFormat, PixelType, source);
}
else
{
if (IsCompressed)
{
glCompressedTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
image->getDimension().Height, PixelFormat, compressedImageSize, source);
}
else
glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
image->getDimension().Height, PixelFormat, PixelType, source);
}
if (convert)
{
@ -329,8 +509,38 @@ void COGLES2Texture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
else
image->unlock();
if (AutomaticMipmapUpdate)
glGenerateMipmap(GL_TEXTURE_2D);
if (!level && newTexture)
{
if (IsCompressed && !mipmapData)
{
if (image->hasMipMaps())
mipmapData = static_cast<u8*>(image->lock())+compressedImageSize;
else
HasMipMaps = false;
}
regenerateMipMapLevels(mipmapData);
if (HasMipMaps) // might have changed in regenerateMipMapLevels
{
// enable bilinear mipmap filter
GLint filteringMipMaps = GL_LINEAR_MIPMAP_NEAREST;
if (filtering == GL_LINEAR)
StatesCache.BilinearFilter = true;
else
{
StatesCache.BilinearFilter = false;
filteringMipMaps = GL_NEAREST_MIPMAP_NEAREST;
}
StatesCache.TrilinearFilter = false;
StatesCache.MipMapStatus = false;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filteringMipMaps);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
}
}
if (Driver->testGLError())
os::Printer::log("Could not glTexImage2D", ELL_ERROR);
@ -435,12 +645,32 @@ bool COGLES2Texture::hasMipMaps() const
//! modifying the texture
void COGLES2Texture::regenerateMipMapLevels(void* mipmapData)
{
if (AutomaticMipmapUpdate || !HasMipMaps || !Image)
return;
if ((Image->getDimension().Width==1) && (Image->getDimension().Height==1))
// texture require mipmaps?
if (!HasMipMaps)
return;
// we don't use custom data for mipmaps.
if (!mipmapData)
{
// compressed textures require custom data for prepare mipmaps.
if (IsCompressed)
return;
// hardware doesn't support generate mipmaps for certain texture but image data doesn't exist or is wrong.
if (!AutomaticMipmapUpdate && (!Image || (Image && ((Image->getDimension().Width==1) && (Image->getDimension().Height==1)))))
return;
}
// hardware moethods for generate mipmaps.
if (!mipmapData && AutomaticMipmapUpdate)
{
glGenerateMipmap(GL_TEXTURE_2D);
return;
}
// Manually create mipmaps or use prepared version
u32 compressedImageSize = 0;
u32 width=Image->getDimension().Width;
u32 height=Image->getDimension().Height;
u32 i=0;
@ -451,18 +681,35 @@ void COGLES2Texture::regenerateMipMapLevels(void* mipmapData)
width>>=1;
if (height>1)
height>>=1;
++i;
if (!target)
target = new u8[width*height*Image->getBytesPerPixel()];
// create scaled version if no mipdata available
if (!mipmapData)
Image->copyToScaling(target, width, height, Image->getColorFormat());
if (IsCompressed)
{
compressedImageSize = IImage::getCompressedImageSize(ColorFormat, width, height);
glCompressedTexImage2D(GL_TEXTURE_2D, i, InternalFormat, width,
height, 0, compressedImageSize, target);
}
else
glTexImage2D(GL_TEXTURE_2D, i, InternalFormat, width, height,
0, PixelFormat, PixelType, target);
// get next prepared mipmap data if available
if (mipmapData)
{
if (IsCompressed)
mipmapData = static_cast<u8*>(mipmapData)+compressedImageSize;
else
mipmapData = static_cast<u8*>(mipmapData)+width*height*Image->getBytesPerPixel();
target = static_cast<u8*>(mipmapData);
}
}

View File

@ -117,9 +117,16 @@ protected:
//! get the desired color format based on texture creation flags and the input format.
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
//! Get the OpenGL color format parameters based on the given Irrlicht color format
void getFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLint& filtering,
GLenum& pixelFormat, GLenum& type, void(*&convert)(const void*, s32, void*));
//! get important numbers of the image and hw texture
void getImageValues(IImage* image);
//! check format compatibility.
bool checkFormatCompatibility();
//! copies the texture into an OpenGL texture.
/** \param newTexture True if method is called for a newly created texture for the first time. Otherwise call with false to improve memory handling.
\param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image.
@ -141,6 +148,7 @@ protected:
u8 MipLevelStored;
bool HasMipMaps;
bool IsRenderTarget;
bool IsCompressed;
bool AutomaticMipmapUpdate;
bool ReadOnlyLock;
bool KeepImage;

View File

@ -200,6 +200,11 @@ namespace video
return true; // non-square is always supported
case EVDF_TEXTURE_NPOT:
return FeatureAvailable[IRR_APPLE_texture_2D_limited_npot];
case EVDF_TEXTURE_COMPRESSED_DXT:
return false; // NV Tegra need improvements here
case EVDF_TEXTURE_COMPRESSED_PVRTC:
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
return false; // PowerVR need improvements here
default:
return false;
}

View File

@ -35,7 +35,7 @@ COGLES1Texture::COGLES1Texture(IImage* origImage, const io::path& name, COGLES1D
// TODO ogl-es
// PixelFormat(GL_BGRA),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0),
HasMipMaps(true), IsRenderTarget(false), AutomaticMipmapUpdate(false),
HasMipMaps(true), IsRenderTarget(false), IsCompressed(false), AutomaticMipmapUpdate(false),
UseStencil(false), ReadOnlyLock(false), KeepImage(true)
{
#ifdef _DEBUG
@ -45,6 +45,13 @@ COGLES1Texture::COGLES1Texture(IImage* origImage, const io::path& name, COGLES1D
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
getImageValues(origImage);
if (IImage::isCompressedFormat(origImage->getColorFormat())) // TO-DO add support for compressed textures
{
os::Printer::log("This driver doesn't support compressed textures.", ELL_ERROR);
IsCompressed = true;
return;
}
glGenTextures(1, &TextureName);
Image = new CImage(ColorFormat, TextureSize);
@ -68,7 +75,7 @@ COGLES1Texture::COGLES1Texture(const io::path& name, COGLES1Driver* driver)
: ITexture(name), Driver(driver), Image(0), MipImage(0),
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_RGBA),
PixelType(GL_UNSIGNED_BYTE), MipLevelStored(0),
HasMipMaps(true), IsRenderTarget(false), AutomaticMipmapUpdate(false),
HasMipMaps(true), IsRenderTarget(false), IsCompressed(false), AutomaticMipmapUpdate(false),
ReadOnlyLock(false), KeepImage(true)
{
#ifdef _DEBUG
@ -80,6 +87,7 @@ COGLES1Texture::COGLES1Texture(const io::path& name, COGLES1Driver* driver)
//! destructor
COGLES1Texture::~COGLES1Texture()
{
if (TextureName)
glDeleteTextures(1, &TextureName);
if (Image)
Image->drop();

View File

@ -112,6 +112,7 @@ protected:
bool HasMipMaps;
bool IsRenderTarget;
bool IsCompressed;
bool AutomaticMipmapUpdate;
bool UseStencil;
bool ReadOnlyLock;

View File

@ -791,6 +791,9 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
return true;
case EVDF_TEXTURE_COMPRESSED_DXT:
return FeatureAvailable[IRR_EXT_texture_compression_s3tc];
case EVDF_TEXTURE_COMPRESSED_PVRTC: // Currently disabled, but in future maybe special extension will be available.
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
return false;
default:
return false;
};

View File

@ -34,27 +34,14 @@ COpenGLTexture::COpenGLTexture(IImage* origImage, const io::path& name, void* mi
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
getImageValues(origImage);
if (ColorFormat == ECF_DXT1 || ColorFormat == ECF_DXT2 || ColorFormat == ECF_DXT3 || ColorFormat == ECF_DXT4 || ColorFormat == ECF_DXT5)
if (checkFormatCompatibility())
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_DXT))
if (IsCompressed)
{
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
return;
}
if(ImageSize != TextureSize)
{
os::Printer::log("Invalid size of image for compressed texture, size of image must be POT.", ELL_ERROR);
return;
}
else
{
IsCompressed = true;
Image = origImage;
Image->grab();
KeepImage = false;
}
}
else if (ImageSize==TextureSize)
{
Image = Driver->createImage(ColorFormat, ImageSize);
@ -63,17 +50,19 @@ COpenGLTexture::COpenGLTexture(IImage* origImage, const io::path& name, void* mi
else
{
Image = Driver->createImage(ColorFormat, TextureSize);
// scale texture
origImage->copyToScaling(Image);
}
glGenTextures(1, &TextureName);
uploadTexture(true, mipmapData);
if (!KeepImage)
{
Image->drop();
Image=0;
}
}
}
//! constructor for basic setup (only for derived classes)
@ -104,6 +93,9 @@ COpenGLTexture::~COpenGLTexture()
ECOLOR_FORMAT COpenGLTexture::getBestColorFormat(ECOLOR_FORMAT format)
{
ECOLOR_FORMAT destFormat = ECF_A8R8G8B8;
if (!IImage::isCompressedFormat(format))
{
switch (format)
{
case ECF_A1R5G5B5:
@ -123,9 +115,14 @@ ECOLOR_FORMAT COpenGLTexture::getBestColorFormat(ECOLOR_FORMAT format)
if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) ||
Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
destFormat = ECF_A1R5G5B5;
break;
default:
break;
}
}
else
destFormat = format;
if (Driver->getTextureCreationFlag(ETCF_NO_ALPHA_CHANNEL))
{
switch (destFormat)
@ -140,162 +137,172 @@ ECOLOR_FORMAT COpenGLTexture::getBestColorFormat(ECOLOR_FORMAT format)
break;
}
}
return destFormat;
}
//! Get opengl values for the GPU texture storage
GLint COpenGLTexture::getOpenGLFormatAndParametersFromColorFormat(ECOLOR_FORMAT format,
GLint& filtering,
GLenum& colorformat,
GLenum& type)
//! Get the OpenGL color format parameters based on the given Irrlicht color format
void COpenGLTexture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLint& filtering,
GLenum& pixelFormat, GLenum& type)
{
// default
filtering = GL_LINEAR;
colorformat = GL_RGBA;
type = GL_UNSIGNED_BYTE;
GLenum internalformat = GL_RGBA;
switch(format)
{
case ECF_A1R5G5B5:
colorformat=GL_BGRA_EXT;
internalFormat = GL_RGBA;
filtering = GL_LINEAR;
pixelFormat = GL_BGRA_EXT;
type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
internalformat = GL_RGBA;
break;
case ECF_R5G6B5:
colorformat=GL_RGB;
internalFormat = GL_RGB;
filtering = GL_LINEAR;
pixelFormat = GL_RGB;
type = GL_UNSIGNED_SHORT_5_6_5;
internalformat = GL_RGB;
break;
case ECF_R8G8B8:
colorformat=GL_BGR;
internalFormat = GL_RGB;
filtering = GL_LINEAR;
pixelFormat = GL_BGR;
type = GL_UNSIGNED_BYTE;
internalformat = GL_RGB;
break;
case ECF_A8R8G8B8:
colorformat=GL_BGRA_EXT;
internalFormat = GL_RGBA;
filtering = GL_LINEAR;
pixelFormat = GL_BGRA_EXT;
if (Driver->Version > 101)
type = GL_UNSIGNED_INT_8_8_8_8_REV;
internalformat = GL_RGBA;
else
type = GL_UNSIGNED_BYTE;
break;
#ifdef GL_EXT_texture_compression_s3tc
case ECF_DXT1:
colorformat = GL_BGRA_EXT;
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
filtering = GL_LINEAR;
pixelFormat = GL_BGRA_EXT;
type = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
internalformat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
break;
#endif
#ifdef GL_EXT_texture_compression_s3tc
case ECF_DXT2:
case ECF_DXT3:
colorformat = GL_BGRA_EXT;
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
filtering = GL_LINEAR;
pixelFormat = GL_BGRA_EXT;
type = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
internalformat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
break;
#endif
#ifdef GL_EXT_texture_compression_s3tc
case ECF_DXT4:
case ECF_DXT5:
colorformat = GL_BGRA_EXT;
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
filtering = GL_LINEAR;
pixelFormat = GL_BGRA_EXT;
type = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
internalformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
break;
case ECF_R16F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RED;
type = GL_FLOAT;
internalformat = GL_R16F;
#else
ColorFormat = ECF_A8R8G8B8;
internalformat = GL_RGB8;
#endif
}
#ifdef GL_IMG_texture_compression_pvrtc
case ECF_PVRTC_R2G2B2:
internalFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGB;
type = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc
case ECF_PVRTC_A2R2G2B2:
internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc
case ECF_PVRTC_R4G4B4:
internalFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGB;
type = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc
case ECF_PVRTC_A4R4G4B4:
internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc2
case ECF_PVRTC2_A2R2G2B2:
internalFormat = COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
break;
#endif
#ifdef GL_IMG_texture_compression_pvrtc2
case ECF_PVRTC2_A4R4G4B4:
internalFormat = COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
filtering = GL_LINEAR;
pixelFormat = GL_RGBA;
type = COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
break;
#endif
#ifdef GL_ARB_texture_rg
case ECF_R16F:
internalFormat = GL_R16F;
filtering = GL_NEAREST;
pixelFormat = GL_RED;
type = GL_FLOAT;
break;
case ECF_G16R16F:
{
#ifdef GL_ARB_texture_rg
internalFormat = GL_RG16F;
filtering = GL_NEAREST;
colorformat = GL_RG;
pixelFormat = GL_RG;
type = GL_FLOAT;
internalformat = GL_RG16F;
#else
ColorFormat = ECF_A8R8G8B8;
internalformat = GL_RGB8;
#endif
}
break;
case ECF_A16B16G16R16F:
{
#ifdef GL_ARB_texture_rg
filtering = GL_NEAREST;
colorformat = GL_RGBA;
type = GL_FLOAT;
internalformat = GL_RGBA16F_ARB;
#else
ColorFormat = ECF_A8R8G8B8;
internalformat = GL_RGBA8;
#endif
}
break;
case ECF_R32F:
{
#ifdef GL_ARB_texture_rg
internalFormat = GL_R32F;
filtering = GL_NEAREST;
colorformat = GL_RED;
pixelFormat = GL_RED;
type = GL_FLOAT;
internalformat = GL_R32F;
#else
ColorFormat = ECF_A8R8G8B8;
internalformat = GL_RGB8;
#endif
}
break;
case ECF_G32R32F:
{
#ifdef GL_ARB_texture_rg
internalFormat = GL_RG32F;
filtering = GL_NEAREST;
colorformat = GL_RG;
pixelFormat = GL_RG;
type = GL_FLOAT;
internalformat = GL_RG32F;
#else
ColorFormat = ECF_A8R8G8B8;
internalformat = GL_RGB8;
break;
#endif
}
#ifdef GL_ARB_texture_float
case ECF_A16B16G16R16F:
internalFormat = GL_RGBA16F_ARB;
filtering = GL_NEAREST;
pixelFormat = GL_RGBA;
type = GL_FLOAT;
break;
case ECF_A32B32G32R32F:
{
#ifdef GL_ARB_texture_float
internalFormat = GL_RGBA32F_ARB;
filtering = GL_NEAREST;
colorformat = GL_RGBA;
pixelFormat = GL_RGBA;
type = GL_FLOAT;
internalformat = GL_RGBA32F_ARB;
#else
ColorFormat = ECF_A8R8G8B8;
internalformat = GL_RGBA8;
#endif
}
break;
#endif
default:
{
os::Printer::log("Unsupported texture format", ELL_ERROR);
internalformat = GL_RGBA8;
}
break;
}
#if defined(GL_ARB_framebuffer_sRGB) || defined(GL_EXT_framebuffer_sRGB)
if (Driver->Params.HandleSRGB)
{
if (internalformat==GL_RGBA)
internalformat=GL_SRGB_ALPHA_EXT;
else if (internalformat==GL_RGB)
internalformat=GL_SRGB_EXT;
if (internalFormat == GL_RGBA)
internalFormat = GL_SRGB_ALPHA_EXT;
else if (internalFormat == GL_RGB)
internalFormat = GL_SRGB_EXT;
}
#endif
return internalformat;
}
@ -329,13 +336,81 @@ void COpenGLTexture::getImageValues(IImage* image)
}
TextureSize=ImageSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT));
if(image->getColorFormat() == ECF_DXT1 || image->getColorFormat() == ECF_DXT2 || image->getColorFormat() == ECF_DXT3 || image->getColorFormat() == ECF_DXT4 || image->getColorFormat() == ECF_DXT5)
ColorFormat = image->getColorFormat();
else
ColorFormat = getBestColorFormat(image->getColorFormat());
}
//! check format compatibility.
bool COpenGLTexture::checkFormatCompatibility()
{
bool status = true;
switch (ColorFormat)
{
case ECF_DXT1:
case ECF_DXT2:
case ECF_DXT3:
case ECF_DXT4:
case ECF_DXT5:
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_DXT))
{
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
status = false;
}
else if(ImageSize != TextureSize)
{
os::Printer::log("Invalid size of image for DXTn compressed texture, size of image must be POT.", ELL_ERROR);
status = false;
}
else
IsCompressed = true;
}
break;
case ECF_PVRTC_R2G2B2:
case ECF_PVRTC_A2R2G2B2:
case ECF_PVRTC_R4G4B4:
case ECF_PVRTC_A4R4G4B4:
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC))
{
os::Printer::log("PVRTC texture compression not available.", ELL_ERROR);
status = false;
}
else if(ImageSize != TextureSize)
{
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be POT.", ELL_ERROR);
status = false;
}
else if(TextureSize.Height != TextureSize.Width)
{
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be squared.", ELL_ERROR);
status = false;
}
else
IsCompressed = true;
}
break;
case ECF_PVRTC2_A2R2G2B2:
case ECF_PVRTC2_A4R4G4B4:
{
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2))
{
os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR);
status = false;
}
else
IsCompressed = true;
}
break;
default:
break;
}
return status;
}
//! copies the the texture into an open gl texture.
void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
{
@ -348,9 +423,10 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
}
// get correct opengl color data values
GLenum oldInternalFormat = InternalFormat;
GLint filtering;
InternalFormat = getOpenGLFormatAndParametersFromColorFormat(ColorFormat, filtering, PixelFormat, PixelType);
GLint oldInternalFormat = InternalFormat;
GLint filtering = GL_LINEAR;
getFormatParameters(ColorFormat, InternalFormat, filtering, PixelFormat, PixelType);
// make sure we don't change the internal format of existing images
if (!newTexture)
InternalFormat = oldInternalFormat;
@ -397,29 +473,29 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
}
// enable bilinear filter without mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (filtering == GL_LINEAR)
StatesCache.BilinearFilter = true;
else
StatesCache.BilinearFilter = false;
StatesCache.TrilinearFilter = false;
StatesCache.MipMapStatus = false;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
}
// now get image data and upload to GPU
u32 compressedDataSize = 0;
u32 compressedImageSize = IImage::getCompressedImageSize(ColorFormat, image->getDimension().Width, image->getDimension().Height);
void* source = image->lock();
if (newTexture)
{
if (IsCompressed)
{
if(ColorFormat == ECF_DXT1)
compressedDataSize = ((image->getDimension().Width + 3) / 4) * ((image->getDimension().Height + 3) / 4) * 8;
else if (ColorFormat == ECF_DXT2 || ColorFormat == ECF_DXT3 || ColorFormat == ECF_DXT4 || ColorFormat == ECF_DXT5)
compressedDataSize = ((image->getDimension().Width + 3) / 4) * ((image->getDimension().Height + 3) / 4) * 16;
Driver->extGlCompressedTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, image->getDimension().Width,
image->getDimension().Height, 0, compressedDataSize, source);
image->getDimension().Height, 0, compressedImageSize, source);
}
else
glTexImage2D(GL_TEXTURE_2D, level, InternalFormat, image->getDimension().Width,
@ -429,13 +505,8 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
{
if (IsCompressed)
{
if(ColorFormat == ECF_DXT1)
compressedDataSize = ((image->getDimension().Width + 3) / 4) * ((image->getDimension().Height + 3) / 4) * 8;
else if (ColorFormat == ECF_DXT2 || ColorFormat == ECF_DXT3 || ColorFormat == ECF_DXT4 || ColorFormat == ECF_DXT5)
compressedDataSize = ((image->getDimension().Width + 3) / 4) * ((image->getDimension().Height + 3) / 4) * 16;
Driver->extGlCompressedTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
image->getDimension().Height, PixelFormat, compressedDataSize, source);
image->getDimension().Height, PixelFormat, compressedImageSize, source);
}
else
glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
@ -448,7 +519,7 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
if (IsCompressed && !mipmapData)
{
if (image->hasMipMaps())
mipmapData = static_cast<u8*>(image->lock())+compressedDataSize;
mipmapData = static_cast<u8*>(image->lock())+compressedImageSize;
else
HasMipMaps = false;
}
@ -458,12 +529,21 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
if (HasMipMaps) // might have changed in regenerateMipMapLevels
{
// enable bilinear mipmap filter
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GLint filteringMipMaps = GL_LINEAR_MIPMAP_NEAREST;
if (filtering == GL_LINEAR)
StatesCache.BilinearFilter = true;
else
{
StatesCache.BilinearFilter = false;
filteringMipMaps = GL_NEAREST_MIPMAP_NEAREST;
}
StatesCache.TrilinearFilter = false;
StatesCache.MipMapStatus = true;
StatesCache.MipMapStatus = false;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filteringMipMaps);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
}
}
@ -701,7 +781,7 @@ void COpenGLTexture::regenerateMipMapLevels(void* mipmapData)
}
// Manually create mipmaps or use prepared version
u32 compressedDataSize = 0;
u32 compressedImageSize = 0;
u32 width=Image->getDimension().Width;
u32 height=Image->getDimension().Height;
u32 i=0;
@ -724,13 +804,10 @@ void COpenGLTexture::regenerateMipMapLevels(void* mipmapData)
if (IsCompressed)
{
if(ColorFormat == ECF_DXT1)
compressedDataSize = ((width + 3) / 4) * ((height + 3) / 4) * 8;
else if (ColorFormat == ECF_DXT2 || ColorFormat == ECF_DXT3 || ColorFormat == ECF_DXT4 || ColorFormat == ECF_DXT5)
compressedDataSize = ((width + 3) / 4) * ((height + 3) / 4) * 16;
compressedImageSize = IImage::getCompressedImageSize(ColorFormat, width, height);
Driver->extGlCompressedTexImage2D(GL_TEXTURE_2D, i, InternalFormat, width,
height, 0, compressedDataSize, target);
height, 0, compressedImageSize, target);
}
else
glTexImage2D(GL_TEXTURE_2D, i, InternalFormat, width, height,
@ -740,7 +817,7 @@ void COpenGLTexture::regenerateMipMapLevels(void* mipmapData)
if (mipmapData)
{
if (IsCompressed)
mipmapData = static_cast<u8*>(mipmapData)+compressedDataSize;
mipmapData = static_cast<u8*>(mipmapData)+compressedImageSize;
else
mipmapData = static_cast<u8*>(mipmapData)+width*height*Image->getBytesPerPixel();
@ -819,8 +896,8 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
ColorFormat = format;
GLint FilteringType;
InternalFormat = getOpenGLFormatAndParametersFromColorFormat(format, FilteringType, PixelFormat, PixelType);
GLint filtering = GL_LINEAR;
getFormatParameters(format, InternalFormat, filtering, PixelFormat, PixelType);
HasMipMaps = false;
IsRenderTarget = true;
@ -836,11 +913,11 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
Driver->setActiveTexture(0, this);
Driver->getBridgeCalls()->setTexture(0, true);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, FilteringType);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if(FilteringType == GL_NEAREST)
if(filtering == GL_NEAREST)
StatesCache.BilinearFilter = false;
else
StatesCache.BilinearFilter = true;

View File

@ -137,12 +137,15 @@ protected:
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
//! Get the OpenGL color format parameters based on the given Irrlicht color format
GLint getOpenGLFormatAndParametersFromColorFormat(
ECOLOR_FORMAT format, GLint& filtering, GLenum& colorformat, GLenum& type);
void getFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLint& filtering,
GLenum& pixelFormat, GLenum& type);
//! get important numbers of the image and hw texture
void getImageValues(IImage* image);
//! check format compatibility.
bool checkFormatCompatibility();
//! copies the texture into an OpenGL texture.
/** \param newTexture True if method is called for a newly created texture for the first time. Otherwise call with false to improve memory handling.
\param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image.

View File

@ -26,9 +26,9 @@ CSoftwareTexture::CSoftwareTexture(IImage* image, const io::path& name,
{
bool IsCompressed = false;
if(image->getColorFormat() == ECF_DXT1 || image->getColorFormat() == ECF_DXT2 || image->getColorFormat() == ECF_DXT3 || image->getColorFormat() == ECF_DXT4 || image->getColorFormat() == ECF_DXT5)
if (IImage::isCompressedFormat(image->getColorFormat()))
{
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
os::Printer::log("This driver doesn't support compressed textures.", ELL_ERROR);
IsCompressed = true;
}

View File

@ -34,9 +34,9 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name,
{
bool IsCompressed = false;
if(image->getColorFormat() == ECF_DXT1 || image->getColorFormat() == ECF_DXT2 || image->getColorFormat() == ECF_DXT3 || image->getColorFormat() == ECF_DXT4 || image->getColorFormat() == ECF_DXT5)
if (IImage::isCompressedFormat(image->getColorFormat()))
{
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
os::Printer::log("This driver doesn't support compressed textures.", ELL_ERROR);
IsCompressed = true;
}

View File

@ -1001,6 +1001,7 @@
<ClInclude Include="CDefaultSceneNodeAnimatorFactory.h" />
<ClInclude Include="CDefaultSceneNodeFactory.h" />
<ClInclude Include="CGeometryCreator.h" />
<ClInclude Include="CImageLoaderPVR.h" />
<ClInclude Include="CMeshCache.h" />
<ClInclude Include="CMeshManipulator.h" />
<ClInclude Include="COGLES2Driver.h" />
@ -1263,6 +1264,7 @@
<ClCompile Include="CDefaultSceneNodeAnimatorFactory.cpp" />
<ClCompile Include="CDefaultSceneNodeFactory.cpp" />
<ClCompile Include="CGeometryCreator.cpp" />
<ClCompile Include="CImageLoaderPVR.cpp" />
<ClCompile Include="CMeshCache.cpp" />
<ClCompile Include="CMeshManipulator.cpp" />
<ClCompile Include="COGLES2Driver.cpp" />

View File

@ -1351,6 +1351,9 @@
<ClInclude Include="COGLESTexture.h">
<Filter>Irrlicht\video\OpenGL-ES 1.x</Filter>
</ClInclude>
<ClInclude Include="CImageLoaderPVR.h">
<Filter>Irrlicht\video\Null\Loader</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\changes.txt">
@ -2321,6 +2324,9 @@
<ClCompile Include="COGLESTexture.cpp">
<Filter>Irrlicht\video\OpenGL-ES 1.x</Filter>
</ClCompile>
<ClCompile Include="CImageLoaderPVR.cpp">
<Filter>Irrlicht\video\Null\Loader</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Irrlicht.rc" />

View File

@ -39,7 +39,7 @@ IRROBJ = CBillboardSceneNode.o CCameraSceneNode.o CDummyTransformationSceneNode.
IRRPARTICLEOBJ = CParticleAnimatedMeshSceneNodeEmitter.o CParticleBoxEmitter.o CParticleCylinderEmitter.o CParticleMeshEmitter.o CParticlePointEmitter.o CParticleRingEmitter.o CParticleSphereEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticleSystemSceneNode.o CParticleScaleAffector.o
IRRANIMOBJ = CSceneNodeAnimatorCameraFPS.o CSceneNodeAnimatorCameraMaya.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o
IRRDRVROBJ = CNullDriver.o CCgMaterialRenderer.o COpenGLCgMaterialRenderer.o COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o COGLESDriver.o COGLESTexture.o COGLESExtensionHandler.o
IRRIMAGEOBJ = CColorConverter.o CImage.o CImageLoaderBMP.o CImageLoaderDDS.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderTGA.o CImageLoaderPPM.o CImageLoaderWAL.o CImageLoaderRGB.o \
IRRIMAGEOBJ = CColorConverter.o CImage.o CImageLoaderBMP.o CImageLoaderDDS.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderPVR.o CImageLoaderTGA.o CImageLoaderPPM.o CImageLoaderWAL.o CImageLoaderRGB.o \
CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o
IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ)
IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRNormalMap.o CTRStencilShadow.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o CBurningShader_Raster_Reference.o

View File

@ -1,7 +1,7 @@
#ifndef __glext_h_
#define __glext_h_
/* $Revision: 19260 $ on $Date:: 2012-09-20 11:30:36 -0700 #$ */
/* $Revision: 20798 $ on $Date:: 2013-03-07 01:19:34 -0800 #$ */
#ifdef __cplusplus
extern "C" {
@ -1055,10 +1055,10 @@ typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum
#ifndef GL_EXT_multi_draw_arrays
#define GL_EXT_multi_draw_arrays 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei);
GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
#endif

View File

@ -1,7 +1,7 @@
#ifndef __gl2ext_h_
#define __gl2ext_h_
/* $Revision: 19436 $ on $Date:: 2012-10-10 10:37:04 -0700 #$ */
/* $Revision: 21470 $ on $Date:: 2013-05-08 17:33:40 -0700 #$ */
#ifdef __cplusplus
extern "C" {
@ -16,6 +16,20 @@ extern "C" {
# define GL_APIENTRYP GL_APIENTRY*
#endif
/* New types shared by several extensions */
#ifndef __gl3_h_
/* These are defineed with respect to <inttypes.h> in the
* Apple extension spec, but they are also used by non-APPLE
* extensions, and in the Khronos header we use the Khronos
* portable types in khrplatform.h, which must be defined.
*/
typedef khronos_int64_t GLint64;
typedef khronos_uint64_t GLuint64;
typedef struct __GLsync *GLsync;
#endif
/*------------------------------------------------------------------------*
* OES extension tokens
*------------------------------------------------------------------------*/
@ -183,47 +197,47 @@ typedef void* GLeglImageOES;
*------------------------------------------------------------------------*/
#ifndef GL_KHR_debug
typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
#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
typedef void (GL_APIENTRYP GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242
#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243
#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244
#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245
#define GL_DEBUG_SOURCE_API_KHR 0x8246
#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247
#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248
#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249
#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A
#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B
#define GL_DEBUG_TYPE_ERROR_KHR 0x824C
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E
#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F
#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250
#define GL_DEBUG_TYPE_OTHER_KHR 0x8251
#define GL_DEBUG_TYPE_MARKER_KHR 0x8268
#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269
#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A
#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B
#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C
#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D
#define GL_BUFFER_KHR 0x82E0
#define GL_SHADER_KHR 0x82E1
#define GL_PROGRAM_KHR 0x82E2
#define GL_QUERY_KHR 0x82E3
/* PROGRAM_PIPELINE only in GL */
#define GL_SAMPLER 0x82E6
#define GL_SAMPLER_KHR 0x82E6
/* DISPLAY_LIST only in GL */
#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
#define GL_STACK_OVERFLOW 0x0503
#define GL_STACK_UNDERFLOW 0x0504
#define GL_MAX_LABEL_LENGTH_KHR 0x82E8
#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143
#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144
#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145
#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146
#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147
#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148
#define GL_DEBUG_OUTPUT_KHR 0x92E0
#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002
#define GL_STACK_OVERFLOW_KHR 0x0503
#define GL_STACK_UNDERFLOW_KHR 0x0504
#endif
#ifndef GL_KHR_texture_compression_astc_ldr
@ -294,6 +308,18 @@ typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLen
* ANGLE extension tokens
*------------------------------------------------------------------------*/
/* GL_ANGLE_depth_texture */
#ifndef GL_ANGLE_depth_texture
#define GL_DEPTH_COMPONENT 0x1902
#define GL_DEPTH_STENCIL_OES 0x84F9
#define GL_UNSIGNED_SHORT 0x1403
#define GL_UNSIGNED_INT 0x1405
#define GL_UNSIGNED_INT_24_8_OES 0x84FA
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_DEPTH_COMPONENT32_OES 0x81A7
#define GL_DEPTH24_STENCIL8_OES 0x88F0
#endif
/* GL_ANGLE_framebuffer_blit */
#ifndef GL_ANGLE_framebuffer_blit
#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8
@ -319,6 +345,11 @@ typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLen
#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
#endif
/* GL_ANGLE_program_binary */
#ifndef GL_ANGLE_program_binary
#define GL_PROGRAM_BINARY_ANGLE 0x93A6
#endif
/* GL_ANGLE_texture_compression_dxt3 */
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
@ -368,19 +399,6 @@ typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLen
/* GL_APPLE_sync */
#ifndef GL_APPLE_sync
#ifndef __gl3_h_
/* These types are defined with reference to <inttypes.h>
* in the Apple extension spec, but here we use the Khronos
* portable types in khrplatform.h, and assume those types
* are always defined.
* If any other extensions using these types are defined,
* the typedefs must move out of this block and be shared.
*/
typedef khronos_int64_t GLint64;
typedef khronos_uint64_t GLuint64;
typedef struct __GLsync *GLsync;
#endif
#define GL_SYNC_OBJECT_APPLE 0x8A53
#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
#define GL_OBJECT_TYPE_APPLE 0x9112
@ -466,6 +484,17 @@ typedef struct __GLsync *GLsync;
#define GL_STENCIL_EXT 0x1802
#endif
#ifndef GL_EXT_disjoint_timer_query
#define GL_EXT_disjoint_timer_query 1
#define GL_QUERY_COUNTER_BITS_EXT 0x8864
#define GL_CURRENT_QUERY_EXT 0x8865
#define GL_QUERY_RESULT_EXT 0x8866
#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
#define GL_TIME_ELAPSED_EXT 0x88BF
#define GL_TIMESTAMP_EXT 0x8E28
#define GL_GPU_DISJOINT_EXT 0x8FBB
#endif
/* GL_EXT_map_buffer_range */
#ifndef GL_EXT_map_buffer_range
#define GL_MAP_READ_BIT_EXT 0x0001
@ -618,9 +647,9 @@ typedef struct __GLsync *GLsync;
/* GL_EXT_unpack_subimage */
#ifndef GL_EXT_unpack_subimage
#define GL_UNPACK_ROW_LENGTH 0x0CF2
#define GL_UNPACK_SKIP_ROWS 0x0CF3
#define GL_UNPACK_SKIP_PIXELS 0x0CF4
#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3
#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
#endif
/*------------------------------------------------------------------------*
@ -638,7 +667,7 @@ typedef struct __GLsync *GLsync;
/* GL_FJ_shader_binary_GCCSO */
#ifndef GL_FJ_shader_binary_GCCSO
#define GCCSO_SHADER_BINARY_FJ 0x9260
#define GL_GCCSO_SHADER_BINARY_FJ 0x9260
#endif
/*------------------------------------------------------------------------*
@ -669,6 +698,12 @@ typedef struct __GLsync *GLsync;
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
#endif
/* GL_IMG_texture_compression_pvrtc2 */
#ifndef GL_IMG_texture_compression_pvrtc2
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
#endif
/* GL_IMG_multisampled_render_to_texture */
#ifndef GL_IMG_multisampled_render_to_texture
#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
@ -691,7 +726,7 @@ typedef struct __GLsync *GLsync;
#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5
#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6
#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7
#define GL_COVERAGE_BUFFER_BIT_NV 0x8000
#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000
#endif
/* GL_NV_depth_nonlinear */
@ -736,6 +771,9 @@ typedef struct __GLsync *GLsync;
#define GL_COLOR_ATTACHMENT15_NV 0x8CEF
#endif
/* GL_NV_draw_instanced */
/* No new tokens introduced by this extension. */
/* GL_NV_fbo_color_attachments */
#ifndef GL_NV_fbo_color_attachments
#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF
@ -749,6 +787,29 @@ typedef struct __GLsync *GLsync;
#define GL_FENCE_CONDITION_NV 0x84F4
#endif
/* GL_NV_framebuffer_blit */
#ifndef GL_NV_framebuffer_blit
#define GL_READ_FRAMEBUFFER_NV 0x8CA8
#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9
#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6
#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA
#endif
/* GL_NV_framebuffer_multisample */
#ifndef GL_NV_framebuffer_multisample
#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56
#define GL_MAX_SAMPLES_NV 0x8D57
#endif
/* GL_NV_generate_mipmap_sRGB */
/* No new tokens introduced by this extension. */
/* GL_NV_instanced_arrays */
#ifndef GL_NV_instanced_arrays
#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE
#endif
/* GL_NV_read_buffer */
#ifndef GL_NV_read_buffer
#define GL_READ_BUFFER_NV 0x0C02
@ -766,6 +827,36 @@ typedef struct __GLsync *GLsync;
/* GL_NV_read_stencil */
/* No new tokens introduced by this extension. */
/* GL_NV_shadow_samplers_array */
#ifndef GL_NV_shadow_samplers_array
#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4
#endif
/* GL_NV_shadow_samplers_cube */
#ifndef GL_NV_shadow_samplers_cube
#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5
#endif
/* GL_NV_sRGB_formats */
#ifndef GL_NV_sRGB_formats
#define GL_SLUMINANCE_NV 0x8C46
#define GL_SLUMINANCE_ALPHA_NV 0x8C44
#define GL_SRGB8_NV 0x8C41
#define GL_SLUMINANCE8_NV 0x8C47
#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45
#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F
#define GL_ETC1_SRGB8_NV 0x88EE
#endif
/* GL_NV_texture_border_clamp */
#ifndef GL_NV_texture_border_clamp
#define GL_TEXTURE_BORDER_COLOR_NV 0x1004
#define GL_CLAMP_TO_BORDER_NV 0x812D
#endif
/* GL_NV_texture_compression_s3tc_update */
/* No new tokens introduced by this extension. */
@ -1066,29 +1157,29 @@ typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
#ifndef GL_KHR_debug
#define GL_KHR_debug 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam);
GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message);
GL_APICALL void GL_APIENTRY glPopDebugGroup (void);
GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label);
GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params);
GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam);
GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message);
GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void);
GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label);
GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params);
#endif
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params);
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam);
typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void);
typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label);
typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params);
#endif
#ifndef GL_KHR_texture_compression_astc_ldr
@ -1148,6 +1239,11 @@ typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monito
* ANGLE extension functions
*------------------------------------------------------------------------*/
/* GL_ANGLE_depth_texture */
#ifndef GL_ANGLE_depth_texture
#define GL_ANGLE_depth_texture 1
#endif
/* GL_ANGLE_framebuffer_blit */
#ifndef GL_ANGLE_framebuffer_blit
#define GL_ANGLE_framebuffer_blit 1
@ -1167,14 +1263,15 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum
#endif
#ifndef GL_ANGLE_instanced_arrays
#define GL_ANGLE_instanced_arrays 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor);
#endif
typedef void (GL_APIENTRYP PFLGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
typedef void (GL_APIENTRYP PFLGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
#endif
/* GL_ANGLE_pack_reverse_row_order */
@ -1182,6 +1279,11 @@ typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLu
#define GL_ANGLE_pack_reverse_row_order 1
#endif
/* GL_ANGLE_program_binary */
#ifndef GL_ANGLE_program_binary
#define GL_ANGLE_program_binary 1
#endif
/* GL_ANGLE_texture_compression_dxt3 */
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_ANGLE_texture_compression_dxt3 1
@ -1202,7 +1304,7 @@ typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLu
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
#endif
typedef void (GL_APIENTRYP PFLGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
#endif
/*------------------------------------------------------------------------*
@ -1331,6 +1433,34 @@ GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numA
typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
#endif
#ifndef GL_EXT_disjoint_timer_query
#define GL_EXT_disjoint_timer_query 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids);
GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids);
GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id);
GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id);
GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target);
GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target);
GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params);
GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params);
GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params);
#endif
typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids);
typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids);
typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id);
typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id);
typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target);
typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target);
typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params);
typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params);
#endif /* GL_EXT_disjoint_timer_query */
/* GL_EXT_map_buffer_range */
#ifndef GL_EXT_map_buffer_range
#define GL_EXT_map_buffer_range 1
@ -1369,10 +1499,10 @@ typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint ind
#ifndef GL_EXT_multi_draw_arrays
#define GL_EXT_multi_draw_arrays 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei);
GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
#endif
@ -1595,6 +1725,11 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum
#define GL_IMG_texture_compression_pvrtc 1
#endif
/* GL_IMG_texture_compression_pvrtc2 */
#ifndef GL_IMG_texture_compression_pvrtc2
#define GL_IMG_texture_compression_pvrtc2 1
#endif
/* GL_IMG_multisampled_render_to_texture */
#ifndef GL_IMG_multisampled_render_to_texture
#define GL_IMG_multisampled_render_to_texture 1
@ -1635,6 +1770,17 @@ GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
#endif
/* GL_NV_draw_instanced */
#ifndef GL_NV_draw_instanced
#define GL_NV_draw_instanced 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
#endif
typedef void (GL_APIENTRYP PFNDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
typedef void (GL_APIENTRYP PFNDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
#endif
/* GL_NV_fbo_color_attachments */
#ifndef GL_NV_fbo_color_attachments
#define GL_NV_fbo_color_attachments 1
@ -1661,6 +1807,38 @@ typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
#endif
/* GL_NV_framebuffer_blit */
#ifndef GL_NV_framebuffer_blit
#define GL_NV_framebuffer_blit 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glBlitFramebufferNV (int srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
typedef void (GL_APIENTRYP PFNBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
/* GL_NV_framebuffer_multisample */
#ifndef GL_NV_framebuffer_multisample
#define GL_NV_framebuffer_multisample 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#endif
typedef void (GL_APIENTRYP PFNRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#endif
/* GL_NV_generate_mipmap_sRGB */
#ifndef GL_NV_generate_mipmap_sRGB
#define GL_NV_generate_mipmap_sRGB 1
#endif
/* GL_NV_instanced_arrays */
#ifndef GL_NV_instanced_arrays
#define GL_NV_instanced_arrays 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor);
#endif
typedef void (GL_APIENTRYP PFNVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor);
#endif
/* GL_NV_read_buffer */
#ifndef GL_NV_read_buffer
#define GL_NV_read_buffer 1
@ -1690,6 +1868,26 @@ typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
#define GL_NV_read_stencil 1
#endif
/* GL_NV_shadow_samplers_array */
#ifndef GL_NV_shadow_samplers_array
#define GL_NV_shadow_samplers_array 1
#endif
/* GL_NV_shadow_samplers_cube */
#ifndef GL_NV_shadow_samplers_cube
#define GL_NV_shadow_samplers_cube 1
#endif
/* GL_NV_sRGB_formats */
#ifndef GL_NV_sRGB_formats
#define GL_NV_sRGB_formats 1
#endif
/* GL_NV_texture_border_clamp */
#ifndef GL_NV_texture_border_clamp
#define GL_NV_texture_border_clamp 1
#endif
/* GL_NV_texture_compression_s3tc_update */
#ifndef GL_NV_texture_compression_s3tc_update
#define GL_NV_texture_compression_s3tc_update 1

File diff suppressed because it is too large Load Diff

View File

@ -11,10 +11,12 @@
#include <SDL/SDL_endian.h>
#define bswap_16(X) SDL_Swap16(X)
#define bswap_32(X) SDL_Swap32(X)
#define bswap_64(X) SDL_Swap64(X)
#elif defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER > 1298)
#include <stdlib.h>
#define bswap_16(X) _byteswap_ushort(X)
#define bswap_32(X) _byteswap_ulong(X)
#define bswap_64(X) _byteswap_uint64(X)
#if (_MSC_VER >= 1400)
#define localtime _localtime_s
#endif
@ -22,15 +24,18 @@
#include <libkern/OSByteOrder.h>
#define bswap_16(X) OSReadSwapInt16(&X,0)
#define bswap_32(X) OSReadSwapInt32(&X,0)
#define bswap_64(X) OSReadSwapInt64(&X,0)
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/endian.h>
#define bswap_16(X) bswap16(X)
#define bswap_32(X) bswap32(X)
#define bswap_64(X) bswap64(X)
#elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_)
#include <byteswap.h>
#else
#define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&0xFF00) >> 8))
#define bswap_32(X) ((((X)&0x000000FF) << 24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8))
#define bswap_64(X) ((((X)&0x00000000000000FF) << 56) | (((X)&0xFF00000000000000) >> 56) | (((X)&0x000000000000FF00) << 40) | (((X)&0x00FF000000000000) >> 40) | (((X)&0x0000000000FF0000) << 24) | (((X)&0x0000FF0000000000) >> 24) | (((X)&0x00000000FF000000) << 8) | (((X) &0x000000FF00000000) >> 8))
#endif
namespace irr
@ -41,6 +46,8 @@ namespace os
s16 Byteswap::byteswap(s16 num) {return bswap_16(num);}
u32 Byteswap::byteswap(u32 num) {return bswap_32(num);}
s32 Byteswap::byteswap(s32 num) {return bswap_32(num);}
u64 Byteswap::byteswap(u64 num) {return bswap_64(num);}
s64 Byteswap::byteswap(s64 num) {return bswap_64(num);}
f32 Byteswap::byteswap(f32 num) {u32 tmp=IR(num); tmp=bswap_32(tmp); return (FR(tmp));}
// prevent accidental byte swapping of chars
u8 Byteswap::byteswap(u8 num) {return num;}

View File

@ -24,6 +24,8 @@ namespace os
static s16 byteswap(s16 num);
static u32 byteswap(u32 num);
static s32 byteswap(s32 num);
static u64 byteswap(u64 num);
static s64 byteswap(s64 num);
static f32 byteswap(f32 num);
// prevent accidental swapping of chars
static u8 byteswap(u8 num);