X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Frendering-basic-pbr%2Frendering-basic-pbr-example.cpp;h=1239401798502312f3e813e9668ba4a1f35f869b;hb=3ed8a2ec80028af2772bb63b007f3c406e550391;hp=b461ce4eb7bfeeb8cd84655957adc5fb3c7e09d0;hpb=a30d584d434429797d9bd88a269d9ce026aa030e;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp b/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp index b461ce4..1239401 100644 --- a/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp +++ b/examples/rendering-basic-pbr/rendering-basic-pbr-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ #include "ktx-loader.h" #include "model-skybox.h" #include "model-pbr.h" +#include +#include using namespace Dali; using namespace Toolkit; @@ -390,21 +392,30 @@ public: */ bool LoadShaderCode( const std::string& fullpath, std::vector& output ) { - FILE* f = fopen( fullpath.c_str(), "rb" ); - - if( NULL == f ) + Dali::FileStream fileStream( fullpath, FileStream::READ | FileStream::BINARY ); + FILE* file = fileStream.GetFile(); + if( NULL == file ) { return false; } - fseek( f, 0, SEEK_END ); - size_t size = ftell( f ); - fseek( f, 0, SEEK_SET ); - output.resize( size + 1 ); - std::fill( output.begin(), output.end(), 0 ); - ssize_t result = fread( output.data(), size, 1, f ); - fclose( f ); - return ( result >= 0 ); + bool retValue = false; + if( ! fseek( file, 0, SEEK_END ) ) + { + long int size = ftell( file ); + + if( ( size != -1L ) && + ( ! fseek( file, 0, SEEK_SET ) ) ) + { + output.resize( size + 1 ); + std::fill( output.begin(), output.end(), 0 ); + ssize_t result = fread( output.data(), size, 1, file ); + + retValue = ( result >= 0 ); + } + } + + return retValue; } /** @@ -451,20 +462,10 @@ private: }; -void RunTest( Application& application ) -{ - BasicPbrController test( application ); - - application.MainLoop(); -} - -// Entry point for Linux & Tizen applications -// int DALI_EXPORT_API main( int argc, char **argv ) { Application application = Application::New( &argc, &argv); - - RunTest( application ); - + BasicPbrController test( application ); + application.MainLoop(); return 0; }