SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppDemoSceneTextureCompression Class Reference

Class for texture compression test scene. More...

#include <AppDemoSceneTextureCompression.h>

Inheritance diagram for AppDemoSceneTextureCompression:
[legend]

Public Member Functions

 AppDemoSceneTextureCompression ()
 
void registerAssetsToLoad (SLAssetLoader &al) override
 All scene specific assets have to be registered for async loading in here. More...
 
void assemble (SLAssetManager *am, SLSceneView *sv) override
 After parallel loading of the assets the scene gets assembled in here. More...
 
- Public Member Functions inherited from SLScene
 SLScene (const SLstring &name)
 
 ~SLScene () override
 
void initOculus (SLstring shaderDir)
 
void root3D (SLNode *root3D)
 
void root2D (SLNode *root2D)
 
void skybox (SLSkybox *skybox)
 
void stopAnimations (SLbool stop)
 
void info (SLstring i)
 
void loadTimeMS (SLfloat loadTimeMS)
 
SLAnimManageranimManager ()
 
SLAssetManagerassetManager ()
 
SLNoderoot3D ()
 
SLNoderoot2D ()
 
SLSkyboxskybox ()
 
SLstringinfo ()
 
SLfloat elapsedTimeMS () const
 
SLfloat elapsedTimeSec () const
 
SLVEventHandlereventHandlers ()
 
SLfloat loadTimeMS () const
 
SLVLightlights ()
 
SLfloat fps () const
 
AvgFloatframeTimesMS ()
 
AvgFloatupdateTimesMS ()
 
AvgFloatupdateAnimTimesMS ()
 
AvgFloatupdateAABBTimesMS ()
 
AvgFloatupdateDODTimesMS ()
 
SLNodesingleNodeSelected ()
 Returns the node if only one is selected. See also SLMesh::selectNodeMesh. More...
 
SLMeshsingleMeshFullSelected ()
 Returns the node if only one is selected. See also SLMesh::selectNodeMesh. More...
 
SLVNodeselectedNodes ()
 
SLVMeshselectedMeshes ()
 
SLbool stopAnimations () const
 
SLint numSceneCameras ()
 Returns the number of camera nodes in the scene. More...
 
SLCameranextCameraInScene (SLCamera *activeSVCam)
 Returns the next camera in the scene if there is one. More...
 
bool onUpdate (bool renderTypeIsRT, bool voxelsAreShown, bool forceCPUSkinning)
 Updates animations and AABBs. More...
 
void init (SLAssetManager *am)
 
virtual void unInit ()
 
void selectNodeMesh (SLNode *nodeToSelect, SLMesh *meshToSelect)
 Handles the full mesh selection from double-clicks. More...
 
void deselectAllNodesAndMeshes ()
 Deselects all nodes and its meshes. More...
 
SLGLOculusoculus ()
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 

Private Attributes

SLGLTexture_texPng
 
SLGLTexture_texJpgQ90
 
SLGLTexture_texJpgQ40
 
SLGLTexture_texKtxBcmp255
 
SLGLTexture_texKtxBcmp128
 
SLGLTexture_texKtxBcmp001
 
SLGLTexture_texKtxUastc4
 
SLGLTexture_texKtxUastc2
 
SLGLTexture_texKtxUastc0
 

Additional Inherited Members

- Protected Attributes inherited from SLScene
SLVLight _lights
 Vector of all lights. More...
 
SLVEventHandler _eventHandlers
 Vector of all event handler. More...
 
SLAnimManager _animManager
 Animation manager instance. More...
 
SLAssetManager_assetManager
 Pointer to the external assetManager. More...
 
SLNode_root3D
 Root node for 3D scene. More...
 
SLNode_root2D
 Root node for 2D scene displayed in ortho projection. More...
 
SLSkybox_skybox
 pointer to skybox More...
 
SLstring _info
 scene info string More...
 
SLVNode _selectedNodes
 Vector of selected nodes. See SLMesh::selectNodeMesh. More...
 
SLVMesh _selectedMeshes
 Vector of selected meshes. See SLMesh::selectNodeMesh. More...
 
SLfloat _loadTimeMS
 time to load scene in ms More...
 
SLfloat _frameTimeMS
 Last frame time in ms. More...
 
SLfloat _lastUpdateTimeMS
 Last time after update in ms. More...
 
SLfloat _fps
 Averaged no. of frames per second. More...
 
AvgFloat _frameTimesMS
 Averaged total time per frame in ms. More...
 
AvgFloat _updateTimesMS
 Averaged time for update in ms. More...
 
AvgFloat _updateAABBTimesMS
 Averaged time for update the nodes AABB in ms. More...
 
AvgFloat _updateAnimTimesMS
 Averaged time for update the animations in ms. More...
 
AvgFloat _updateDODTimesMS
 Averaged time for update the SLEntities graph. More...
 
SLbool _stopAnimations
 Global flag for stopping all animations. More...
 
std::unique_ptr< SLGLOculus_oculus
 Oculus Rift interface. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

Class for texture compression test scene.

Definition at line 20 of file AppDemoSceneTextureCompression.h.

Constructor & Destructor Documentation

◆ AppDemoSceneTextureCompression()

AppDemoSceneTextureCompression::AppDemoSceneTextureCompression ( )

Definition at line 20 of file AppDemoSceneTextureCompression.cpp.

20  : SLScene("Texture Compression Test Scene")
21 {
22  info("Texture Compression Test Scene");
23 }
SLScene(const SLstring &name)
Definition: SLScene.cpp:39
SLstring & info()
Definition: SLScene.h:102

Member Function Documentation

◆ assemble()

void AppDemoSceneTextureCompression::assemble ( SLAssetManager am,
SLSceneView sv 
)
overridevirtual

After parallel loading of the assets the scene gets assembled in here.

Remarks
All scene-specific assets have to be loaded async by overriding SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and assembling means that it happens in a parallel thread and that in there are no OpenGL calls allowed. OpenGL calls are only allowed in the main thread. It is important that all object instantiations within SLScene::assemble do NOT call any OpenGL functions (gl*) because they happen in a parallel thread. All objects that get rendered have to do their initialization when they are used the first time during rendering in the main thread.

Reimplemented from SLScene.

Definition at line 89 of file AppDemoSceneTextureCompression.cpp.

90 {
91  // Create a scene group node
92  SLNode* scene = new SLNode("scene node");
93  this->root3D(scene);
94 
95  // Create a light source node
96  SLLightSpot* light1 = new SLLightSpot(am, this, 0.1f);
97  light1->translation(5, 5, 5);
98  light1->name("light node");
99  scene->addChild(light1);
100 
101  SLCamera* cam1 = new SLCamera("Camera 1");
102  cam1->clipNear(0.1f);
103  cam1->clipFar(100);
104  cam1->translation(0, 0, 4.2f);
105  cam1->lookAt(0, 0, 0);
106  cam1->focalDist(4.2f);
107  cam1->background().colors(SLCol4f(0.7f, 0.7f, 0.7f),
108  SLCol4f(0.2f, 0.2f, 0.2f));
109  cam1->setInitialState();
110  scene->addChild(cam1);
111 
112  // Position for rectangle and uv out of earth texture
113  SLVec2f pMin(-.5f, -.5f), pMax(.5f, .5f);
114  SLVec2f tMin(.47f, .69f), tMax(.56f, .81f);
115 
116  //.........................................................................
117  SLMaterial* matPng = new SLMaterial(am,
118  "matPng",
119  _texPng);
120  SLMesh* rectMeshPng = new SLRectangle(am,
121  pMin,
122  pMax,
123  tMin,
124  tMax,
125  1,
126  1,
127  "rectMeshPng",
128  matPng);
129  SLNode* rectNodePng = new SLNode(rectMeshPng,
130  "rectNodePng");
131  rectNodePng->translate(-1.05f, 1.05f, 0);
132  scene->addChild(rectNodePng);
133  //.........................................................................
134  SLMaterial* matJpgQ90 = new SLMaterial(am,
135  "matJpgQ90",
136  _texJpgQ90);
137  SLMesh* rectMeshJpgQ90 = new SLRectangle(am,
138  pMin,
139  pMax,
140  tMin,
141  tMax,
142  1,
143  1,
144  "rectMeshJpgQ90",
145  matJpgQ90);
146  SLNode* rectNodeJpgQ90 = new SLNode(rectMeshJpgQ90,
147  "rectNodeJpgQ90");
148  rectNodeJpgQ90->translate(0, 1.05f, 0);
149  scene->addChild(rectNodeJpgQ90);
150  //.........................................................................
151  SLMaterial* matJpgQ40 = new SLMaterial(am,
152  "matJpgQ40",
153  _texJpgQ40);
154  SLMesh* rectMeshJpgQ40 = new SLRectangle(am,
155  pMin,
156  pMax,
157  tMin,
158  tMax,
159  1,
160  1,
161  "rectMeshJpgQ40",
162  matJpgQ40);
163  SLNode* rectNodeJpgQ40 = new SLNode(rectMeshJpgQ40,
164  "rectNodeJpgQ40");
165  rectNodeJpgQ40->translate(1.05f, 1.05f, 0);
166  scene->addChild(rectNodeJpgQ40);
167  //.........................................................................
168  SLMaterial* matKtxBcmp255 = new SLMaterial(am,
169  "matKtxBcmp255",
171  SLMesh* rectMeshKtxBcmp255 = new SLRectangle(am,
172  pMin,
173  pMax,
174  tMin,
175  tMax,
176  1,
177  1,
178  "rectMeshKtxBcmp255",
179  matKtxBcmp255);
180  SLNode* rectNodeKtxBcmp255 = new SLNode(rectMeshKtxBcmp255,
181  "rectNodeKtxBcmp255");
182  rectNodeKtxBcmp255->translate(-1.05f, 0, 0);
183  scene->addChild(rectNodeKtxBcmp255);
184  //.........................................................................
185  SLMaterial* matKtxBcmp128 = new SLMaterial(am,
186  "matKtxBcmp128",
188  SLMesh* rectMeshKtxBcmp128 = new SLRectangle(am,
189  pMin,
190  pMax,
191  tMin,
192  tMax,
193  1,
194  1,
195  "rectMeshKtxBcmp128",
196  matKtxBcmp128);
197  SLNode* rectNodeKtxBcmp128 = new SLNode(rectMeshKtxBcmp128,
198  "rectNodeKtxBcmp128");
199  rectNodeKtxBcmp128->translate(0, 0, 0);
200  scene->addChild(rectNodeKtxBcmp128);
201  //.........................................................................
202  SLMaterial* matKtxBcmp001 = new SLMaterial(am,
203  "matKtxBcmp001",
205  SLMesh* rectMeshKtxBcmp001 = new SLRectangle(am,
206  pMin,
207  pMax,
208  tMin,
209  tMax,
210  1,
211  1,
212  "rectMeshKtxBcmp001",
213  matKtxBcmp001);
214  SLNode* rectNodeKtxBcmp001 = new SLNode(rectMeshKtxBcmp001,
215  "rectNodeKtxBcmp001");
216  rectNodeKtxBcmp001->translate(1.05f, 0, 0);
217  scene->addChild(rectNodeKtxBcmp001);
218  //.........................................................................
219  SLMaterial* matKtxUastc4 = new SLMaterial(am,
220  "matKtxUastc4",
221  _texKtxUastc4);
222  SLMesh* rectMeshKtxUastc4 = new SLRectangle(am,
223  pMin,
224  pMax,
225  tMin,
226  tMax,
227  1,
228  1,
229  "rectMeshKtxUastc4",
230  matKtxUastc4);
231  SLNode* rectNodeKtxUastc4 = new SLNode(rectMeshKtxUastc4,
232  "rectNodeKtxUastc4");
233  rectNodeKtxUastc4->translate(1.05f, -1.05f, 0);
234  scene->addChild(rectNodeKtxUastc4);
235  //.........................................................................
236  SLMaterial* matKtxUastc2 = new SLMaterial(am,
237  "matKtxUastc2",
238  _texKtxUastc2);
239  SLMesh* rectMeshKtxUastc2 = new SLRectangle(am,
240  pMin,
241  pMax,
242  tMin,
243  tMax,
244  1,
245  1,
246  "rectMeshKtxUastc2",
247  matKtxUastc2);
248  SLNode* rectNodeKtxUastc2 = new SLNode(rectMeshKtxUastc2,
249  "rectNodeKtxUastc2");
250  rectNodeKtxUastc2->translate(0, -1.05f, 0);
251  scene->addChild(rectNodeKtxUastc2);
252  //.........................................................................
253  SLMaterial* matKtxUastc0 = new SLMaterial(am,
254  "matKtxUastc0",
255  _texKtxUastc0);
256  SLMesh* rectMeshKtxUastc0 = new SLRectangle(am,
257  pMin,
258  pMax,
259  tMin,
260  tMax,
261  1,
262  1,
263  "rectMeshKtxUastc0",
264  matKtxUastc0);
265  SLNode* rectNodeKtxUastc0 = new SLNode(rectMeshKtxUastc0,
266  "rectNodeKtxUastc0");
267  rectNodeKtxUastc0->translate(-1.05f, -1.05f, 0);
268  scene->addChild(rectNodeKtxUastc0);
269  //.........................................................................
270  // Add active camera
271  sv->camera(cam1);
272 
273  // Save energy
274  sv->doWaitOnIdle(true);
275 }
SLVec4< SLfloat > SLCol4f
Definition: SLVec4.h:237
void colors(const SLCol4f &uniformColor)
Sets a uniform background color.
Active or visible camera node class.
Definition: SLCamera.h:54
void clipFar(const SLfloat cFar)
Definition: SLCamera.h:109
void clipNear(const SLfloat cNear)
Definition: SLCamera.h:108
void focalDist(const SLfloat f)
Definition: SLCamera.h:116
SLBackground & background()
Definition: SLCamera.h:165
SLLightSpot class for a spot light source.
Definition: SLLightSpot.h:36
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
An SLMesh object is a triangulated mesh, drawn with one draw call.
Definition: SLMesh.h:134
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
void addChild(SLNode *child)
Definition: SLNode.cpp:207
void translation(const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
Definition: SLNode.cpp:828
void setInitialState()
Definition: SLNode.cpp:1084
void lookAt(SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world)
Definition: SLNode.h:652
void translate(const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
Definition: SLNode.cpp:906
void name(const SLstring &Name)
Definition: SLObject.h:34
SLRectangle creates a rectangular mesh with a certain resolution.
Definition: SLRectangle.h:29
SLNode * root3D()
Definition: SLScene.h:99
friend class SLNode
Definition: SLScene.h:48
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
void camera(SLCamera *camera)
Definition: SLSceneView.h:145
void doWaitOnIdle(SLbool doWI)
Definition: SLSceneView.h:149

◆ registerAssetsToLoad()

void AppDemoSceneTextureCompression::registerAssetsToLoad ( SLAssetLoader al)
overridevirtual

All scene specific assets have to be registered for async loading in here.

All assets the should be loaded in parallel must be registered in here.

Remarks
All scene sspecific assets have to be loaded async by overriding SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and assembling means that it happens in a parallel thread and that in there are no OpenGL calls allowed. OpenGL calls are only allowed in the main thread.

Reimplemented from SLScene.

Definition at line 26 of file AppDemoSceneTextureCompression.cpp.

27 {
28  SLint min = GL_LINEAR_MIPMAP_LINEAR;
29  SLint mag = GL_LINEAR;
30 
33  "earth2048_C.png",
34  min,
35  mag);
38  "earth2048_C_Q90.jpg",
39  min,
40  mag);
43  "earth2048_C_Q40.jpg",
44  min,
45  mag);
46 
47  /* Console commands to generate the following KTX files
48  ./../../../externals/prebuilt/mac64_ktx_v4.0.0-beta7-cpvr/release/toktx --automipmap --linear --lower_left_maps_to_s0t0 --bcmp --clevel 4 --qlevel 255 earth2048_C_bcmp_Q255.ktx2 earth2048_C.png
49  ./../../../externals/prebuilt/mac64_ktx_v4.0.0-beta7-cpvr/release/toktx --automipmap --linear --lower_left_maps_to_s0t0 --bcmp --clevel 4 --qlevel 128 earth2048_C_bcmp_Q128.ktx2 earth2048_C.png
50  ./../../../externals/prebuilt/mac64_ktx_v4.0.0-beta7-cpvr/release/toktx --automipmap --linear --lower_left_maps_to_s0t0 --bcmp --clevel 4 --qlevel 1 earth2048_C_bcmp_Q001.ktx2 earth2048_C.png
51  ./../../../externals/prebuilt/mac64_ktx_v4.0.0-beta7-cpvr/release/toktx --automipmap --linear --lower_left_maps_to_s0t0 --uastc 4 --zcmp 19 earth2048_C_uastc4.ktx2 earth2048_C.png
52  ./../../../externals/prebuilt/mac64_ktx_v4.0.0-beta7-cpvr/release/toktx --automipmap --linear --lower_left_maps_to_s0t0 --uastc 2 --zcmp 19 earth2048_C_uastc2.ktx2 earth2048_C.png
53  ./../../../externals/prebuilt/mac64_ktx_v4.0.0-beta7-cpvr/release/toktx --automipmap --linear --lower_left_maps_to_s0t0 --uastc 0 --zcmp 19 earth2048_C_uastc0.ktx2 earth2048_C.png
54  */
55 
58  "earth2048_C_bcmp_Q255.ktx2",
59  min,
60  mag);
63  "earth2048_C_bcmp_Q128.ktx2",
64  min,
65  mag);
68  "earth2048_C_bcmp_Q001.ktx2",
69  min,
70  mag);
73  "earth2048_C_uastc4.ktx2",
74  min,
75  mag);
78  "earth2048_C_uastc2.ktx2",
79  min,
80  mag);
83  "earth2048_C_uastc0.ktx2",
84  min,
85  mag);
86 }
int SLint
Definition: SL.h:170
static SLstring texturePath
Path to texture images.
Definition: AppCommon.h:86
void addTextureToLoad(SLGLTexture *&texture, const SLstring &path, SLint min_filter=GL_LINEAR_MIPMAP_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT)
Add 2D textures with internal image allocation.

Member Data Documentation

◆ _texJpgQ40

SLGLTexture* AppDemoSceneTextureCompression::_texJpgQ40
private

Definition at line 47 of file AppDemoSceneTextureCompression.h.

◆ _texJpgQ90

SLGLTexture* AppDemoSceneTextureCompression::_texJpgQ90
private

Definition at line 46 of file AppDemoSceneTextureCompression.h.

◆ _texKtxBcmp001

SLGLTexture* AppDemoSceneTextureCompression::_texKtxBcmp001
private

Definition at line 50 of file AppDemoSceneTextureCompression.h.

◆ _texKtxBcmp128

SLGLTexture* AppDemoSceneTextureCompression::_texKtxBcmp128
private

Definition at line 49 of file AppDemoSceneTextureCompression.h.

◆ _texKtxBcmp255

SLGLTexture* AppDemoSceneTextureCompression::_texKtxBcmp255
private

Definition at line 48 of file AppDemoSceneTextureCompression.h.

◆ _texKtxUastc0

SLGLTexture* AppDemoSceneTextureCompression::_texKtxUastc0
private

Definition at line 53 of file AppDemoSceneTextureCompression.h.

◆ _texKtxUastc2

SLGLTexture* AppDemoSceneTextureCompression::_texKtxUastc2
private

Definition at line 52 of file AppDemoSceneTextureCompression.h.

◆ _texKtxUastc4

SLGLTexture* AppDemoSceneTextureCompression::_texKtxUastc4
private

Definition at line 51 of file AppDemoSceneTextureCompression.h.

◆ _texPng

SLGLTexture* AppDemoSceneTextureCompression::_texPng
private

Definition at line 45 of file AppDemoSceneTextureCompression.h.


The documentation for this class was generated from the following files: