0024224: Suspicious logics in changing clipping planes at OpenGl_Structure
[occt.git] / src / Graphic3d / Graphic3d_TextureEnv.cxx
CommitLineData
b311480e 1// Created on: 1997-07-28
2// Created by: Pierre CHALAMET
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21#include <Graphic3d_TextureEnv.ixx>
22#include <Graphic3d_TypeOfTexture.hxx>
23#include <Graphic3d_TypeOfTextureMode.hxx>
bf75be98 24#include <Graphic3d_TextureParams.hxx>
7fd59977 25#include <TCollection_AsciiString.hxx>
7fd59977 26
27static const char *NameOfTexture_to_FileName[] =
28{
29 "env_clouds.rgb",
30 "env_cv.rgb",
31 "env_medit.rgb",
32 "env_pearl.rgb",
33 "env_sky1.rgb",
34 "env_sky2.rgb",
35 "env_lines.rgb",
36 "env_road.rgb"
37};
38
bf75be98 39// =======================================================================
40// function : Graphic3d_TextureEnv
41// purpose :
42// =======================================================================
43Graphic3d_TextureEnv::Graphic3d_TextureEnv (const TCollection_AsciiString& theFileName)
44: Graphic3d_TextureRoot (theFileName, Graphic3d_TOT_2D_MIPMAP),
45 myName (Graphic3d_NOT_ENV_UNKNOWN)
7fd59977 46{
bf75be98 47 myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
48 myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
49 Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
50 Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
7fd59977 51}
52
bf75be98 53// =======================================================================
54// function : Graphic3d_TextureEnv
55// purpose :
56// =======================================================================
57Graphic3d_TextureEnv::Graphic3d_TextureEnv (const Graphic3d_NameOfTextureEnv theNOT)
58: Graphic3d_TextureRoot (NameOfTexture_to_FileName[theNOT], Graphic3d_TOT_2D_MIPMAP),
59 myName (theNOT)
7fd59977 60{
bf75be98 61 myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
62 myTexId = TCollection_AsciiString ("Graphic3d_TextureEnv_")
63 + NameOfTexture_to_FileName[theNOT];
64
65 myParams->SetFilter (Graphic3d_TOTF_TRILINEAR);
66 myParams->SetGenMode (Graphic3d_TOTM_SPHERE,
67 Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
68 Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
7fd59977 69}
70
bf75be98 71// =======================================================================
72// function : Name
73// purpose :
74// =======================================================================
75Graphic3d_NameOfTextureEnv Graphic3d_TextureEnv::Name() const
76{
7fd59977 77 return myName;
78}
79
bf75be98 80// =======================================================================
81// function : NumberOfTextures
82// purpose :
83// =======================================================================
84Standard_Integer Graphic3d_TextureEnv::NumberOfTextures()
85{
7fd59977 86 return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
87}
88
bf75be98 89// =======================================================================
90// function : TextureName
91// purpose :
92// =======================================================================
93TCollection_AsciiString Graphic3d_TextureEnv::TextureName (const Standard_Integer theRank)
94{
95 if(theRank < 1 || theRank > NumberOfTextures())
96 {
97 Standard_OutOfRange::Raise ("BAD index of texture");
98 }
99
100 TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
101 Standard_Integer i = aFileName.SearchFromEnd(".");
102 return aFileName.SubString (5, i - 1);
7fd59977 103}