2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2007-06-25 19:50:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2007-06-25 19:50:25 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-06-25 19:50:25 +00:00
|
|
|
*
|
2011-05-07 20:53:49 +00:00
|
|
|
* Contributors: Amorilia (amorilia@users.sourceforge.net)
|
2007-06-25 19:50:25 +00:00
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2007-06-25 19:50:25 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:23:21 +00:00
|
|
|
/** \file blender/imbuf/intern/dds/DirectDrawSurface.h
|
|
|
|
* \ingroup imbdds
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-06-25 19:50:25 +00:00
|
|
|
/*
|
|
|
|
* This file is based on a similar file from the NVIDIA texture tools
|
|
|
|
* (http://nvidia-texture-tools.googlecode.com/)
|
|
|
|
*
|
|
|
|
* Original license from NVIDIA follows.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person
|
|
|
|
// obtaining a copy of this software and associated documentation
|
|
|
|
// files (the "Software"), to deal in the Software without
|
|
|
|
// restriction, including without limitation the rights to use,
|
|
|
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following
|
|
|
|
// conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be
|
|
|
|
// included in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
// OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __DIRECTDRAWSURFACE_H__
|
|
|
|
#define __DIRECTDRAWSURFACE_H__
|
2007-06-25 19:50:25 +00:00
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
#include <Common.h>
|
2007-06-25 19:50:25 +00:00
|
|
|
#include <Stream.h>
|
|
|
|
#include <ColorBlock.h>
|
|
|
|
#include <Image.h>
|
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
struct DDSPixelFormat
|
|
|
|
{
|
|
|
|
uint size;
|
|
|
|
uint flags;
|
|
|
|
uint fourcc;
|
|
|
|
uint bitcount;
|
|
|
|
uint rmask;
|
|
|
|
uint gmask;
|
|
|
|
uint bmask;
|
|
|
|
uint amask;
|
2007-06-25 19:50:25 +00:00
|
|
|
};
|
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
struct DDSCaps
|
|
|
|
{
|
|
|
|
uint caps1;
|
|
|
|
uint caps2;
|
|
|
|
uint caps3;
|
|
|
|
uint caps4;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// DDS file header for DX10.
|
|
|
|
struct DDSHeader10
|
|
|
|
{
|
2010-03-22 09:30:00 +00:00
|
|
|
uint dxgiFormat;
|
|
|
|
uint resourceDimension;
|
|
|
|
uint miscFlag;
|
|
|
|
uint arraySize;
|
|
|
|
uint reserved;
|
2007-06-25 19:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// DDS file header.
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
struct DDSHeader
|
|
|
|
{
|
|
|
|
uint fourcc;
|
|
|
|
uint size;
|
|
|
|
uint flags;
|
|
|
|
uint height;
|
|
|
|
uint width;
|
|
|
|
uint pitch;
|
|
|
|
uint depth;
|
|
|
|
uint mipmapcount;
|
|
|
|
uint reserved[11];
|
2007-06-25 19:50:25 +00:00
|
|
|
DDSPixelFormat pf;
|
|
|
|
DDSCaps caps;
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
uint notused;
|
|
|
|
DDSHeader10 header10;
|
|
|
|
|
|
|
|
|
2007-06-25 19:50:25 +00:00
|
|
|
// Helper methods.
|
|
|
|
DDSHeader();
|
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
void setWidth(uint w);
|
|
|
|
void setHeight(uint h);
|
|
|
|
void setDepth(uint d);
|
|
|
|
void setMipmapCount(uint count);
|
2007-06-25 19:50:25 +00:00
|
|
|
void setTexture2D();
|
|
|
|
void setTexture3D();
|
|
|
|
void setTextureCube();
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
void setLinearSize(uint size);
|
|
|
|
void setPitch(uint pitch);
|
|
|
|
void setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3);
|
2011-05-08 09:05:52 +00:00
|
|
|
void setFormatCode(uint code);
|
|
|
|
void setSwizzleCode(uint8 c0, uint8 c1, uint8 c2, uint8 c3);
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
void setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask);
|
|
|
|
void setDX10Format(uint format);
|
2007-06-25 19:50:25 +00:00
|
|
|
void setNormalFlag(bool b);
|
2012-05-01 17:51:03 +00:00
|
|
|
void setSrgbFlag(bool b);
|
2011-05-08 09:05:52 +00:00
|
|
|
void setHasAlphaFlag(bool b);
|
2012-05-01 17:51:03 +00:00
|
|
|
void setUserVersion(int version);
|
2011-05-08 09:05:52 +00:00
|
|
|
|
|
|
|
/*void swapBytes();*/
|
2007-06-25 19:50:25 +00:00
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
bool hasDX10Header() const;
|
2012-05-01 17:51:03 +00:00
|
|
|
uint signature() const;
|
|
|
|
uint toolVersion() const;
|
|
|
|
uint userVersion() const;
|
|
|
|
bool isNormalMap() const;
|
|
|
|
bool isSrgb() const;
|
|
|
|
bool hasAlpha() const;
|
|
|
|
uint d3d9Format() const;
|
2007-06-25 19:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// DirectDraw Surface. (DDS)
|
|
|
|
class DirectDrawSurface
|
|
|
|
{
|
|
|
|
public:
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
DirectDrawSurface(unsigned char *mem, uint size);
|
2007-06-25 19:50:25 +00:00
|
|
|
~DirectDrawSurface();
|
|
|
|
|
|
|
|
bool isValid() const;
|
|
|
|
bool isSupported() const;
|
2011-05-08 09:05:52 +00:00
|
|
|
|
|
|
|
bool hasAlpha() const;
|
2007-06-25 19:50:25 +00:00
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
uint mipmapCount() const;
|
2012-06-30 04:34:34 +00:00
|
|
|
uint fourCC() const;
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
uint width() const;
|
|
|
|
uint height() const;
|
|
|
|
uint depth() const;
|
2008-09-10 15:07:20 +00:00
|
|
|
bool isTexture1D() const;
|
2007-06-25 19:50:25 +00:00
|
|
|
bool isTexture2D() const;
|
|
|
|
bool isTexture3D() const;
|
|
|
|
bool isTextureCube() const;
|
2008-09-10 15:07:20 +00:00
|
|
|
|
|
|
|
void setNormalFlag(bool b);
|
2011-05-08 09:05:52 +00:00
|
|
|
void setHasAlphaFlag(bool b);
|
|
|
|
void setUserVersion(int version);
|
2007-06-25 19:50:25 +00:00
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
void mipmap(Image * img, uint f, uint m);
|
2012-06-30 04:34:34 +00:00
|
|
|
void* readData(uint &size);
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
// void mipmap(FloatImage * img, uint f, uint m);
|
2007-06-25 19:50:25 +00:00
|
|
|
|
|
|
|
void printInfo() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
uint blockSize() const;
|
|
|
|
uint faceSize() const;
|
|
|
|
uint mipmapSize(uint m) const;
|
2007-06-25 19:50:25 +00:00
|
|
|
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
uint offset(uint f, uint m);
|
2007-06-25 19:50:25 +00:00
|
|
|
|
|
|
|
void readLinearImage(Image * img);
|
|
|
|
void readBlockImage(Image * img);
|
|
|
|
void readBlock(ColorBlock * rgba);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
Stream stream; // memory where DDS file resides
|
|
|
|
DDSHeader header;
|
|
|
|
};
|
|
|
|
|
|
|
|
void mem_read(Stream & mem, DDSPixelFormat & pf);
|
|
|
|
void mem_read(Stream & mem, DDSCaps & caps);
|
|
|
|
void mem_read(Stream & mem, DDSHeader & header);
|
This is patch: [#7975] imbuf for DDS textures: improved read support and a few bugs fixed
Kent
Notes From the author:
The attached patch syncs the DDS code in Blender with the latest revision
(324) of the nvidia texture tools. This fixes a few minor issues and adds
support for a more types of DDS textures, in particular uncompressed textures
that don't have the standard 16, 24, or 32 bits per pixel.
Note: I have started using the nvidia texture tools convention for naming
integer types (uint, uint16, uint8, uint64 etc.) because doing so makes it
much easier to merge patches from upstream. Since the code is compiled
separately from the rest of Blender, this likely does not pose a problem.
However, if there turns out to be a good reason for avoiding those nvidia type
names from upstream, I'd be happy to fix it.
Regards,
Amorilia
2007-12-26 21:46:30 +00:00
|
|
|
void mem_read(Stream & mem, DDSHeader10 & header);
|
2007-06-25 19:50:25 +00:00
|
|
|
|
2012-10-09 13:36:42 +00:00
|
|
|
#endif /* __DIRECTDRAWSURFACE_H__ */
|