Пример #1
0
    bool load(const ResourcePtr& resource) {
        if(!Font::FTLibrary::Instance().library)
            return false;

        if(face) {
            FT_Done_Face(face);
        }

        if(resource && resource->getResourceStream()) {
            font_data = resource->getResourceStream()->readIntoMemory();
            if(FT_New_Memory_Face(Font::FTLibrary::Instance().library,
                                  static_cast<MemoryStream*>(font_data.get())->data(),
                                  font_data->size(),
                                  0,
                                  &face)) {
                return false;
            }
            FT_Select_Charmap(face, FT_ENCODING_UNICODE);
            return true;
        } else {
            if(FT_New_Face(Font::FTLibrary::Instance().library,
                           string::WStringToString(resource->getName()).c_str(),
                           0,
                           &face)) {
                return false;
            }
            return true;
        }
        return false;
    }
Пример #2
0
 bool CgGLShader::initialize(const ResourcePtr& resource, const ShaderDesc& desc) {
     CGprofile profile;
     mDesc = desc;
     switch (desc.type) {
     case ukn::ST_FragmentShader:
         profile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
         break;
     case ukn::ST_VertexShader:
         profile = cgGLGetLatestProfile(CG_GL_VERTEX);
         break;
     case ukn::ST_GeometryShader:
         profile = cgGLGetLatestProfile(CG_GL_GEOMETRY);
         
         break;
     }
     StreamPtr stream = resource->readIntoMemory();
     if(!stream)
         return false;
     
     MemoryStream* memStream = ((MemoryStream*)stream.get());
     std::string content(memStream->data(), memStream->data() + memStream->size());
     mProgram = cgCreateProgram(mContext, 
         CG_SOURCE, 
         content.c_str(), 
         profile, 
         desc.entry.c_str(), 
         cgGLGetOptimalOptions(profile));
     if(_check_error(mContext)) {
         cgGLLoadProgram(mProgram);
         mProfile = profile;
         return _check_error(mContext);
     }
     return false;;
 }
Пример #3
0
bool ConfigParserXmlImpl::open(ResourcePtr resource) {
    StreamPtr dataStream = resource->getResourceStream()->readIntoMemory();
    if(dataStream) {
        if(!mDocument) {
            mDocument = new pugi::xml_document;
        }
        bool result = mDocument->load_buffer((void*)static_cast<MemoryStream*>(dataStream.get())->data(), dataStream->size(), pugi::encoding_wchar);
        if(result) {
            mName = resource->getName();
            mCurrNode = mDocument->root();
            return result;
        }
    }
    return false;
}
Пример #4
0
 bool CgDxShader::initialize(D3D11GraphicDevice* device, const ResourcePtr& resource, const ShaderDesc& desc) {
     mDesc = desc;
     
     StreamPtr stream = resource->readIntoMemory();
     if(!stream)
         return false;
     MemoryStream* memStream = ((MemoryStream*)stream.get());
     std::string content(memStream->data(), memStream->data() + memStream->size());
     
     CGprofile profile = _d3d_feature_level_to_cgprofile(device->getDeviceFeatureLevel(), desc.type);
     mProgram = cgCreateProgram(mContext, 
         CG_SOURCE, 
         content.c_str(), 
         profile, 
         desc.entry.c_str(), 
         cgD3D11GetOptimalOptions(profile));
     if(_check_error(mContext) &&
         D3D11Debug::CHECK_RESULT( cgD3D11LoadProgram(mProgram, 0))) {
             return true;
     }
     return false;
 }