mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
Graphic3d_TextureRoot::GetCompressedImage() - added new interface for fetching compressed texture image. Default implementation detects DDS image files using Image_DDSParser parser. Graphic3d_TextureRoot::GetImage() has been extended with new parameter - the list of image formats supported by OpenGL driver. Graphic3d_TextureRoot::convertToCompatible() implicitly converts BGRA image to RGBA on OpenGL ES, which normally does not support BGR formats. OpenGl_Caps::isTopDownTextureUV - new property defines how application defines UV texture coordinates in primitive arrays. OpenGl_Context::SetTextureMatrix() compares this flag with OpenGl_Texture::IsTopDown() and automatically flips V coordinate in case of mismatch. OpenGl_Texture now holds exact number of mipmap levels instead of Boolean flag indicating that they are defined. This allows loading DDS files with incomplete mipmap level set by setting GL_TEXTURE_MAX_LEVEL to appropriate value instead of default 1000 (causing black textures in case if mipmap levels are not defined till 1x1). Fixed order of texture coordinates transformation within GLSL program to match FFP matrix: Rotate -> Translate -> Scale (previously Rotation was applied afterwards).
63 lines
2.7 KiB
C++
63 lines
2.7 KiB
C++
// Copyright (c) 2020 OPEN CASCADE SAS
|
|
//
|
|
// This file is part of Open CASCADE Technology software library.
|
|
//
|
|
// This library is free software; you can redistribute it and/or modify it under
|
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
// by the Free Software Foundation, with special exception defined in the file
|
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
// distribution for complete text of the license and disclaimer of any warranty.
|
|
//
|
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
// commercial license or contractual agreement.
|
|
|
|
#ifndef _Image_DDSParser_HeaderFile
|
|
#define _Image_DDSParser_HeaderFile
|
|
|
|
#include <Image_CompressedPixMap.hxx>
|
|
#include <NCollection_Buffer.hxx>
|
|
|
|
class Image_SupportedFormats;
|
|
|
|
//! Auxiliary tool for parsing DDS file structure (without decoding).
|
|
class Image_DDSParser
|
|
{
|
|
public:
|
|
|
|
//! Load the face from DDS file.
|
|
//! @param theSupported [in] list of supported image formats
|
|
//! @param theFile [in] file path
|
|
//! @param theFaceIndex [in] face index, within [0, Image_CompressedPixMap::NbFaces()) range;
|
|
//! use -1 to skip reading the face data
|
|
//! @param theFileOffset [in] offset to the DDS data
|
|
//! @return loaded face or NULL if file cannot be read or not valid DDS file
|
|
Standard_EXPORT static Handle(Image_CompressedPixMap) Load (const Handle(Image_SupportedFormats)& theSupported,
|
|
const TCollection_AsciiString& theFile,
|
|
const Standard_Integer theFaceIndex,
|
|
const int64_t theFileOffset = 0);
|
|
|
|
//! Load the face from DDS file.
|
|
//! @param theSupported [in] list of supported image formats
|
|
//! @param theBuffer [in] pre-loaded file data, should be at least of 128 bytes long defining DDS header.
|
|
//! @param theFaceIndex [in] face index, within [0, Image_CompressedPixMap::NbFaces()) range;
|
|
//! use -1 to skip reading the face data
|
|
//! @return loaded face or NULL if file cannot be read or not valid DDS file
|
|
Standard_EXPORT static Handle(Image_CompressedPixMap) Load (const Handle(Image_SupportedFormats)& theSupported,
|
|
const Handle(NCollection_Buffer)& theBuffer,
|
|
const Standard_Integer theFaceIndex);
|
|
|
|
|
|
private:
|
|
|
|
struct DDSPixelFormat;
|
|
struct DDSFileHeader;
|
|
|
|
private:
|
|
|
|
//! Parse DDS header.
|
|
static Handle(Image_CompressedPixMap) parseHeader (const DDSFileHeader& theHeader);
|
|
|
|
};
|
|
|
|
#endif // _Image_DDSParser_HeaderFile
|