mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +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).
109 lines
4.3 KiB
C++
109 lines
4.3 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_CompressedPixMap_HeaderFile
|
|
#define _Image_CompressedPixMap_HeaderFile
|
|
|
|
#include <Image_Format.hxx>
|
|
#include <Image_CompressedFormat.hxx>
|
|
#include <NCollection_Array1.hxx>
|
|
#include <NCollection_Buffer.hxx>
|
|
#include <Standard_Type.hxx>
|
|
|
|
//! Compressed pixmap data definition.
|
|
//! It is defined independently from Image_PixMap, which defines only uncompressed formats.
|
|
class Image_CompressedPixMap : public Standard_Transient
|
|
{
|
|
DEFINE_STANDARD_RTTIEXT(Image_CompressedPixMap, Standard_Transient)
|
|
public:
|
|
|
|
//! Return base (uncompressed) pixel format.
|
|
Image_Format BaseFormat() const { return myBaseFormat; }
|
|
|
|
//! Set base (uncompressed) pixel format.
|
|
void SetBaseFormat (Image_Format theFormat) { myBaseFormat = theFormat; }
|
|
|
|
//! Return compressed format.
|
|
Image_CompressedFormat CompressedFormat() const { return myFormat; }
|
|
|
|
//! Set compressed format.
|
|
void SetCompressedFormat (Image_CompressedFormat theFormat) { myFormat = theFormat; }
|
|
|
|
//! Return raw (compressed) data.
|
|
const Handle(NCollection_Buffer)& FaceData() const { return myFaceData; }
|
|
|
|
//! Set raw (compressed) data.
|
|
void SetFaceData (const Handle(NCollection_Buffer)& theBuffer) { myFaceData = theBuffer; }
|
|
|
|
//! Return Array of mipmap sizes, including base level.
|
|
const NCollection_Array1<Standard_Integer>& MipMaps() const { return myMipMaps; }
|
|
|
|
//! Return Array of mipmap sizes, including base level.
|
|
NCollection_Array1<Standard_Integer>& ChangeMipMaps() { return myMipMaps; }
|
|
|
|
//! Return TRUE if complete mip map level set (up to 1x1 resolution).
|
|
Standard_Boolean IsCompleteMipMapSet() const { return myIsCompleteMips; }
|
|
|
|
//! Set if complete mip map level set (up to 1x1 resolution).
|
|
void SetCompleteMipMapSet (Standard_Boolean theIsComplete) { myIsCompleteMips = theIsComplete; }
|
|
|
|
//! Return surface length in bytes.
|
|
Standard_Size FaceBytes() const { return myFaceBytes; }
|
|
|
|
//! Set surface length in bytes.
|
|
void SetFaceBytes (Standard_Size theSize) { myFaceBytes = theSize; }
|
|
|
|
//! Return surface width.
|
|
Standard_Integer SizeX() const { return mySizeX; }
|
|
|
|
//! Return surface height.
|
|
Standard_Integer SizeY() const { return mySizeY; }
|
|
|
|
//! Set surface width x height.
|
|
void SetSize (Standard_Integer theSizeX, Standard_Integer theSizeY)
|
|
{
|
|
mySizeX = theSizeX;
|
|
mySizeY = theSizeY;
|
|
}
|
|
|
|
//! Return TRUE if image layout is top-down (always true).
|
|
bool IsTopDown() const { return true; }
|
|
|
|
//! Return number of faces in the file; should be 6 for cubemap.
|
|
Standard_Integer NbFaces() const { return myNbFaces; }
|
|
|
|
//! Set number of faces in the file.
|
|
void SetNbFaces (Standard_Integer theSize) { myNbFaces = theSize; }
|
|
|
|
public:
|
|
|
|
//! Empty constructor.
|
|
Image_CompressedPixMap()
|
|
: myFaceBytes (0), myNbFaces (0), mySizeX (0), mySizeY (0), myBaseFormat (Image_Format_UNKNOWN), myFormat (Image_CompressedFormat_UNKNOWN), myIsCompleteMips (false) {}
|
|
|
|
protected:
|
|
|
|
NCollection_Array1<Standard_Integer> myMipMaps; //!< Array of mipmap sizes, including base level
|
|
Handle(NCollection_Buffer) myFaceData; //!< raw compressed data
|
|
Standard_Size myFaceBytes; //!< surface length in bytes
|
|
Standard_Integer myNbFaces; //!< number of faces in the file
|
|
Standard_Integer mySizeX; //!< surface width
|
|
Standard_Integer mySizeY; //!< surface height
|
|
Image_Format myBaseFormat; //!< base (uncompressed) pixel format
|
|
Image_CompressedFormat myFormat; //!< compressed format
|
|
Standard_Boolean myIsCompleteMips; //!< flag indicating complete mip map level set (up to 1x1 resolution)
|
|
|
|
};
|
|
|
|
#endif // _Image_CompressedPixMap_HeaderFile
|