Esempio n. 1
0
        handle open(const char* file_, const char* mode, error_policy ep)
        {
#ifdef OX_DEBUG
            if (!strstr(mode, "b"))
                log::warning("file::open for file '%s' should be called with 'b' (means binary) flag", file_);
#endif
            //OX_ASSERT(_openedFiles == 0);
            LOGD("open file: %s %s %d", file_, mode, _openedFiles);
            char file[512];
            path::normalize(file_, file);
            LOGD("q1");


            fileHandle* fh = 0;
            _nfs.open(file, mode, ep_ignore_error, fh);

            LOGD("q3");

            if (!fh)
            {
                handleErrorPolicy(ep, "can't open file: %s", file);
            }

            return (handle)fh;
        }
Esempio n. 2
0
        bool rename(const char* src, const char* dest, error_policy ep)
        {
            bool ok = _nfs.renameFile(src, dest) == FileSystem::status_ok;
            if (!ok)
            {
                handleErrorPolicy(ep, "can't rename file: %s to %s", src, dest);
            }

            return ok;
        }
Esempio n. 3
0
        bool deleteFile(const char* path, error_policy ep)
        {
            bool ok = _nfs.deleteFile(path) == FileSystem::status_ok;
            if (!ok)
            {
                handleErrorPolicy(ep, "can't delete file: %s", path);
            }

            return ok;
        }
Esempio n. 4
0
	FileSystem::status ZipFileSystem::_open(const char *file, const char *mode, error_policy ep, file::fileHandle *&fh)
	{
		const file_entry *entry = _zips.getEntry(file);
		if (entry)
		{
			fh = new fileHandleZip(entry);
			return status_ok;
		}

		handleErrorPolicy(ep, "can't find zip file entry: %s", file);
		return status_error;
	}
Esempio n. 5
0
    Resource* Resources::get(const std::string& id_, error_policy ep) const
    {
        std::string id = lower(id_);

        resourcesMap::const_iterator it = _resourcesMap.find(id);

        if (it != _resourcesMap.end())
        {
            return it->second.get();
        }

        handleErrorPolicy(ep, "can't find resource: '%s' in '%s'", id.c_str(), _name.c_str());
        return 0;
    }
Esempio n. 6
0
        bool read(const char* file_, buffer& dest, error_policy ep)
        {
            LOGD("open file: %s %s %d", file_, mode, _openedFiles);
            char file[512];
            path::normalize(file_, file);

            dest.data.clear();
            bool ok = _nfs.read(file, dest, ep) == FileSystem::status_ok;
            if (!ok)
            {
                handleErrorPolicy(ep, "can't read file: %s to buffer", file);
            }
            return ok;
        }
        FileSystem::status ZipFileSystem::_open(const char* file, const char* mode, error_policy ep, file::fileHandle*& fh)
        {
            const file_entry* entry = _zips.getEntryByName(file);
            if (entry)
            {
                if (*mode == 's')
                    fh = new fileHandleZipStreaming(entry, _zips);
                else
                    fh = new fileHandleZip(entry);
                return status_ok;
            }

            handleErrorPolicy(ep, "can't find zip file entry: %s", file);
            return status_error;
        }
Esempio n. 8
0
	Resource *Resources::get(const string &id_, error_policy ep)
	{	
		string id = lower(id_);

		resources::iterator it = lower_bound(_fastAccessResources.begin(), _fastAccessResources.end(), id.c_str(), ObjectBasePredicate());
		
		if (it != _fastAccessResources.end())
		{
			if ((*it)->getName() == id)
				return (*it);
		}

		handleErrorPolicy(ep, "can't find resource: '%s' in '%s'", id.c_str(), _name.c_str());
		return 0;
	}
Esempio n. 9
0
		handle open(const char *file_, const char *mode, error_policy ep)
		{
			//OX_ASSERT(_openedFiles == 0);
			LOGD("open file: %s %s %d", file_, mode, _openedFiles);
			char file[512];
			path::normalize(file_, file);
			LOGD("q1");


			fileHandle *fh = 0;
			_nfs.open(file, mode, ep_ignore_error, fh);

			LOGD("q3");

			if (!fh)
			{
				handleErrorPolicy(ep, "can't open file: %s", file);
			}

			return fh;
		}
Esempio n. 10
0
	Resource *Resources::get(const string &id_, error_policy ep)
	{	
		string id = lower(id_);

#ifdef __S3E__
		resources::iterator it = lower_bound(_resources.begin(), _resources.end(), id, findPred);
#else
		ResAnim r;
		r.setName(id);
		ResPred pr;
		resources::iterator it = lower_bound(_resources.begin(), _resources.end(), &r, pr);
#endif

		if (it != _resources.end())
		{
			if ((*it)->getName() == id)
				return (*it);
		}

		
		handleErrorPolicy(ep, "can't find resource: '%s' in '%s'", id.c_str(), _name.c_str());
		return 0;
	}
    unsigned int ShaderProgramGL::createShader(unsigned int type, const char* data, const char* prepend, const char* append, error_policy ep)
    {
        GLuint shader = oxglCreateShader(type);

        const char* sources[16];
        const char** ptr = &sources[0];

        bool gles = false;

#ifdef __S3E__
        gles = true;
#elif OXYGINE_SDL
        int profile = 0;
        SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile);

        gles = profile == SDL_GL_CONTEXT_PROFILE_ES;
#else
#endif


#ifndef   EMSCRIPTEN
        if (!gles)
        {
            //log::messageln("not gles version");

            static const char nonGLES[] =
                "#define lowp\n"
                "#define mediump\n"
                "#define highp\n";

            *ptr = nonGLES;
            ptr++;
        }
#endif

#ifdef __ANDROID__
        *ptr = "#define ANDROID 1\n";
        ptr++;
#endif




        if (prepend)
        {
            *ptr = prepend;
            ptr++;
        }

        *ptr = data;
        ptr++;

        if (append)
        {
            *ptr = append;
            ptr++;
        }

        int num = (int)(ptr - sources);
        oxglShaderSource(shader, num, sources, 0);
        oxglCompileShader(shader);

        std::string log;
        bool success = getShaderBuildLog(shader, log);

        if (success)
        {
            log::messageln("compiled shader: %s", log.c_str());
        }
        else
        {
            handleErrorPolicy(ep, "can't compile shader: %s", log.c_str());
        }

        checkGLError();

        return shader;
    }