Example #1
0
void S_MapMusic(de::Uri const *mapUri)
{
    if(!mapUri) mapUri = &gameMapUri;

#ifdef __JHEXEN__
    MapInfo const *mapInfo = hexDefs.getMapInfo(mapUri);
    int const cdTrack = mapInfo->geti("cdTrack");
    String const lump = mapInfo->gets("songLump").compareWithoutCase("DEFSONG")? mapInfo->gets("songLump") : "";

    LOG_RES_VERBOSE("S_MapMusic: %s lump: %s") << mapUri->compose() << lump;

    // Update the 'currentmap' music definition.
    int const defIndex = Def_Get(DD_DEF_MUSIC, "currentmap", 0);
    Def_Set(DD_DEF_MUSIC, defIndex, DD_LUMP,     lump.toUtf8().constData());
    Def_Set(DD_DEF_MUSIC, defIndex, DD_CD_TRACK, &cdTrack);

    if(S_StartMusic("currentmap", true))
    {
        // Set the game status cvar for the map music.
        Con_SetInteger2("map-music", defIndex, SVF_WRITE_OVERRIDE);
    }
#else
    ddmapinfo_t ddMapInfo;
    if(Def_Get(DD_DEF_MAP_INFO, mapUri->compose().toUtf8().constData(), &ddMapInfo))
    {
        if(S_StartMusicNum(ddMapInfo.music, true))
        {
            // Set the game status cvar for the map music.
            Con_SetInteger2("map-music", ddMapInfo.music, SVF_WRITE_OVERRIDE);
        }
    }
#endif
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool ShaderSourceProvider::loadFile(const String& fullFileName, CharArray* fileContents)
{
#ifdef WIN32
    std::ifstream file(fullFileName.ptr());
#else
    std::ifstream file(fullFileName.toUtf8().ptr());
#endif

    if (!file.is_open())
    {
        return false;
    }

    std::string line;
    while (file.good())
    {
        getline(file, line);

        size_t c;
        for (c = 0; c < line.length(); c++)
        {
            fileContents->push_back(line[c]);
        }

        fileContents->push_back('\n');
    }

    file.close();

    return true;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool XmlDocumentImpl::loadFile(const String& fileName)
{
#ifdef WIN32
    FILE* filePtr = NULL;
    if (_wfopen_s(&filePtr, fileName.c_str(), L"rb") != 0)
    {
        return false;
    }
#else
    FILE* filePtr = fopen(fileName.toUtf8().ptr(), "rb");
    if (!filePtr) 
    {
        return false;
    }
#endif

    TiXmlDocument doc;

    bool loadOk = doc.LoadFile(filePtr);
    fclose(filePtr);
    filePtr = NULL;

    if (!loadOk)
    {
        return false;
    }

    return setFromTiXmlDoc(doc);
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool XmlElementImpl::getAttributeBool(const String& attributeName, bool defaultVal, bool* found /*= NULL*/) const
{
    if (found) *found = false;

    String val;
    const char* attrValue = Attribute(attributeName.toUtf8().ptr());
    if (attrValue)
    {
        val = attrValue;
    }
    
    if (val.isEmpty()) return defaultVal;

    if (found) *found = true;

    if (val[0] == '1') return true;
    if (val[0] == '0') return false;

    val.toLower();

    if (val == "yes" || val == "on" || val == "true") return true;
    if (val == "no"  || val == "off" || val == "false") return false;

    return defaultVal;
}
Example #5
0
static bool writeConsoleState(Path const &filePath)
{
    if(filePath.isEmpty()) return false;

    // Ensure the destination directory exists.
    String fileDir = filePath.toString().fileNamePath();
    if(!fileDir.isEmpty())
    {
        F_MakePath(fileDir.toUtf8().constData());
    }

    if(FILE *file = fopen(filePath.toUtf8().constData(), "wt"))
    {
        LOG_SCR_VERBOSE("Writing state to \"%s\"...")
                << NativePath(filePath).pretty();

        writeHeaderComment(file);
        fprintf(file, "#\n# CONSOLE VARIABLES\n#\n\n");
        writeVariablesToFile(file);

        fprintf(file, "\n#\n# ALIASES\n#\n\n");
        writeAliasesToFile(file);
        fclose(file);
        return true;
    }

    LOG_SCR_WARNING("Failed opening \"%s\" for writing")
            << NativePath(filePath).pretty();

    return false;
}
Example #6
0
static bool writeBindingsState(Path const &filePath)
{
    if(filePath.isEmpty()) return false;

    // Ensure the destination directory exists.
    String fileDir = filePath.toString().fileNamePath();
    if(!fileDir.isEmpty())
    {
        F_MakePath(fileDir.toUtf8().constData());
    }

    if(FILE *file = fopen(filePath.toUtf8().constData(), "wt"))
    {
        LOG_SCR_VERBOSE("Writing bindings to \"%s\"...")
                << NativePath(filePath).pretty();

        writeHeaderComment(file);
        B_WriteToFile(file);
        fclose(file);
        return true;
    }

    LOG_SCR_WARNING("Failed opening \"%s\" for writing")
            << NativePath(filePath).pretty();

    return false;
}
Example #7
0
void DS::Stream::writeSafeString(const String& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        StringBuffer<chr16_t> buffer = value.toUtf16();
        uint16_t length = value.length() & 0x0FFF;
        chr16_t* data = new chr16_t[length];
        memcpy(data, buffer.data(), length * sizeof(chr16_t));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(chr16_t));
        write<chr16_t>(0);
        delete[] data;
    } else {
        StringBuffer<chr8_t> buffer = (format == e_StringUTF8) ? value.toUtf8()
                                                               : value.toRaw();
        uint16_t length = value.length() & 0x0FFF;
        chr8_t* data = new chr8_t[length];
        memcpy(data, buffer.data(), length * sizeof(chr8_t));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(chr8_t));
        delete[] data;
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
cvf::Vec3d XmlElementImpl::getAttributeVector(const String& attributeName, const cvf::Vec3d& defaultVal, bool* found) const
{
    if (found) *found = false;

    String val;
    const char* attrValue = Attribute(attributeName.toUtf8().ptr());
    if (attrValue)
    {
        val = attrValue;
    }

    if (val.isEmpty()) return defaultVal;

    if (found) *found = true;

    std::vector<String> tokens = val.split();
    if (tokens.size() == 3)
    {
        cvf::Vec3d vec;
        vec.x() = atof(tokens[0].toAscii().ptr());
        vec.y() = atof(tokens[1].toAscii().ptr());
        vec.z() = atof(tokens[2].toAscii().ptr());
        return vec;
    }

    return defaultVal;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
cvf::Color3f XmlElementImpl::getAttributeColor(const String& attributeName, const cvf::Color3f& defaultColor, bool* found /*= NULL*/) const
{
    if (found) *found = false;

    String val;
    const char* attrValue = Attribute(attributeName.toUtf8().ptr());
    if (attrValue)
    {
        val = attrValue;
    }

    if (val.isEmpty()) return defaultColor;

    if (found) *found = true;

    std::vector<String> tokens = val.split();
    if (tokens.size() == 3)
    {
        cvf::Color3f color;
        color.r() = (float)atof(tokens[0].toAscii().ptr());
        color.g() = (float)atof(tokens[1].toAscii().ptr());
        color.b() = (float)atof(tokens[2].toAscii().ptr());
        return color;
    }

    return defaultColor;
}
Example #10
0
Font::Font(const String& family, int pointSize) :
	desc_(pango_font_description_from_string(family.toUtf8())),
	isStrikeout_(false),
	isUnderline_(false)
{
	setPointSize(std::max(pointSize, 1));
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool ShaderSourceRepositoryFile::rawShaderSource(ShaderIdent shaderIdent, CharArray* rawSource)
{
    String fullFileName = fileNameFromIdent(shaderIdent);

#ifdef WIN32
    std::ifstream file(fullFileName.ptr());
#else
    std::ifstream file(fullFileName.toUtf8().ptr());
#endif

    if (file.is_open())
    {
        std::string line;
        while (file.good())
        {
            getline(file, line);

            size_t c;
            for (c = 0; c < line.length(); c++)
            {
                rawSource->push_back(line[c]);
            }

            rawSource->push_back('\n');
        }

        file.close();

        return true;
    }

    return ShaderSourceRepository::rawShaderSource(shaderIdent, rawSource);
}
Example #12
0
    void sendMessage()
    {
        String const msg = self.messageAsText();
        if(msg.isEmpty()) return;

        if(destination == 0)
        {
            // Send the message to all other players.
            if(!IS_NETGAME)
            {
                // Send it locally.
                for(dint i = 0; i < MAXPLAYERS; ++i)
                {
                    D_NetMessageNoSound(i, msg.toUtf8().constData());
                }
            }
            else
            {
                String const cmd = String("chat %1").arg(msg);
                char buf[256]; M_StrCatQuoted(buf, cmd.toUtf8().constData(), 256);
                DD_Execute(false, buf);
            }
        }
        else
        {
            // Send to all on the same team (team = color).
            for(dint i = 0; i < MAXPLAYERS; ++i)
            {
                if(!players[i].plr->inGame) continue;
                if(destination != cfg.playerColor[i]) continue;

                if(!IS_NETGAME)
                {
                    // Send it locally.
                    D_NetMessageNoSound(i, msg.toUtf8().constData());
                }
                else
                {
                    String const cmd = String("chatnum %1 %2").arg(i).arg(msg);
                    char buf[256]; M_StrCatQuoted(buf, cmd.toUtf8().constData(), 256);
                    DD_Execute(false, buf);
                }
            }
        }

        playSentSound();
    }
Example #13
0
        ConvertSavegameTask(String const &sourcePath, String const &gameId)
        {
            // Ensure the game is defined (sanity check).
            if (DoomsdayApp::games().contains(gameId))
            {
                // Ensure the output folder exists if it doesn't already.
                String const outputPath = String("/home/savegames") / gameId;
                FileSystem::get().makeFolder(outputPath);

                Str_Set(Str_InitStd(&parm.sourcePath),     sourcePath.toUtf8().constData());
                Str_Set(Str_InitStd(&parm.outputPath),     outputPath.toUtf8().constData());
                Str_Set(Str_InitStd(&parm.fallbackGameId), gameId.toUtf8().constData());
            }
            else
            {
                LOG_ERROR("Game \"%s\" does not exist") << gameId;
            }
        }
Example #14
0
void DxBuilder::buildPixelShader(const ASTEffect& effect, ASTTechnique& technique)
{
   const ASTFunction* pfunction = effect.findFunction(technique.mPixel.mEntry);

   String code = UTEXT("// generated pixel shader\n\n");

   String num;
   NumberConverter& conv = NumberConverter::getInstance();
   for ( std::size_t index = 0; index < effect.mTextures.size(); ++index )
   {
      ASTTexture* ptexture = effect.mTextures[index];
      code += UTEXT("Texture2D ") + ptexture->mName + UTEXT(" : register(t");

      int reg = ptexture->mRegister;
      if ( reg == -1 )
      {
         reg = (int) index;
      }
      
      code += conv.format(num, reg) + UTEXT(");\n");
      num = UTEXT("");
   }

   for ( std::size_t index = 0; index < effect.mSamplers.size(); ++index )
   {
      ASTSampler* psampler = effect.mSamplers[index];
      code += UTEXT("SamplerState ") + psampler->mName + UTEXT(" : register(s");
      
      int reg = psampler->mRegister;
      if ( reg == -1 )
      {
         reg = index;
      }
      
      code += conv.format(num, (int)reg) + UTEXT(");\n");
      num = UTEXT("");
   }

   code += buildStructs(effect, *pfunction);
   code += buildFunction(*pfunction);

   std::string data = code.toUtf8();
   std::string entry = technique.mPixel.mEntry.toUtf8();
   std::string target = technique.mPixel.mTarget.toUtf8();
   uint32_t flags = D3DCOMPILE_ENABLE_STRICTNESS;

   ID3DBlob *presult, *perror;
   HRESULT hr = D3DCompile(data.c_str(), data.length(), NULL, NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, entry.c_str(), target.c_str(), flags, 0, &presult, &perror);
   if ( FAILED(hr) )
   {
      std::string d3derror = "Shader compile error: " + std::string((const char*)perror->GetBufferPointer());
      throw std::exception(d3derror.c_str());
   }
      
   technique.mPixel.mCompiledCode.writeBlob(presult->GetBufferPointer(), presult->GetBufferSize());
}
void CVarTextualSliderWidget::updateGeometry()
{
    String const valueAsText = d->valueAsText();

    FR_PushAttrib();
    FR_SetFont(page().predefinedFont(mn_page_fontid_t(font())));
    Size2Raw size; FR_TextSize(&size, valueAsText.toUtf8().constData());
    geometry().setSize(Vector2ui(size.width, size.height));
    FR_PopAttrib();
}
Example #16
0
/* 'fputs' function.
 * The problem is fputs doesn't inserts '\0' symbol at
 * the line end.
 * This functions calls fputs and fputc('\0') in the end.
 */
void rfc::String::putToFile(const String &str, FILE *fileOut)
{
	std::string stdStr = str.toStdString();

	std::fputs(str.toUtf8().constData(), fileOut);
	std::fputc('\0', fileOut);

	// const char *s = str.toUtf8().constData();
	// String::putToFile(str., fileOut);
} /* end of 'fileSaveStr' function */
Example #17
0
void DS::Stream::writeString(const String& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        StringBuffer<chr16_t> buffer = value.toUtf16();
        writeBytes(buffer.data(), buffer.length());
    } else {
        StringBuffer<chr8_t> buffer = (format == e_StringUTF8) ? value.toUtf8()
                                                               : value.toRaw();
        writeBytes(buffer.data(), buffer.length());
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
float XmlElementImpl::getAttributeFloat(const String& attributeName, float defaultVal, bool* found /*= NULL*/) const
{
    if (found) *found = false;

    String val;
    const char* attrValue = Attribute(attributeName.toUtf8().ptr());
    if (attrValue)
    {
        val = attrValue;
    }
    if (val.isEmpty()) return defaultVal;

    if (found) *found = true;

    if (val == "Undefined") return cvf::UNDEFINED_FLOAT;

    float floatValue = defaultVal;
    if (QueryFloatAttribute(attributeName.toUtf8().ptr(), &floatValue) != TIXML_SUCCESS) return defaultVal;

    return floatValue;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
double XmlElementImpl::getAttributeDouble(const String& attributeName, double defaultVal, bool* found /*= NULL*/) const
{
    if (found) *found = false;

    String val;
    const char* attrValue = Attribute(attributeName.toUtf8().ptr());
    if (attrValue)
    {
        val = attrValue;
    }

    if (val.isEmpty()) return defaultVal;

    if (found) *found = true;

    if (val == "Undefined") return cvf::UNDEFINED_DOUBLE;

    double doubleValue = defaultVal;
    if (QueryDoubleAttribute(attributeName.toUtf8().ptr(), &doubleValue) != TIXML_SUCCESS) return defaultVal;

    return doubleValue;
}
Example #20
0
FileId::Md5Hash FileId::hash(String path)
{
    // Ensure we've a normalized path.
    if(QDir::isRelativePath(path))
    {
        path = App_BasePath() / path;
    }

#if defined(WIN32) || defined(MACOSX)
    // This is a case insensitive operation.
    path = path.toUpper();
#endif
    return QCryptographicHash::hash(path.toUtf8(), QCryptographicHash::Md5);
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void XmlDocumentImpl::setDeclaration(const String& version, const String& encoding, const String& standalone)
{
    TiXmlDeclaration* pDecl = NULL;

    // Must use FirstChild() as RootElement() cast to TiXmlElement, which is a different type to TiXmlDeclaration
    if (FirstChild())
    {
        pDecl = FirstChild()->ToDeclaration();
    }

    if (pDecl)
    {
        // Update the declaration
        TiXmlDeclaration newDecl(version.toUtf8().ptr(), encoding.toUtf8().ptr(), standalone.toUtf8().ptr());
        *pDecl = newDecl;
    }
    else
    {
        // Create a new declaration
        pDecl = new TiXmlDeclaration(version.toUtf8().ptr(), encoding.toUtf8().ptr(), standalone.toUtf8().ptr());
        LinkEndChild(pDecl);
    }
}
Example #22
0
    bool open(const String& mode)
    {
        CVF_ASSERT(m_filePtr == NULL);

#ifdef WIN32
        if (_wfopen_s(&m_filePtr, m_fileName.c_str(), mode.c_str()) != 0)
        {
            m_filePtr = NULL;
        }
#else
        m_filePtr = ::fopen(m_fileName.toUtf8().ptr(), mode.toUtf8().ptr());
#endif

        return m_filePtr != NULL;
    }
Example #23
0
bool
write_vmat_compressed(const String& fn, size_t xdim, size_t ydim, int map_cnt)
{
  //Form1->Memo1->Lines->Add("saving compressed, compress bound: "+IntToStr(compressBound(64000)));
  gzFile f = gzopen(fn.toUtf8().constData(), "w");
  if (!f) {
    Form1->Memo1->Lines->Add(" FATAL ERROR: Could not open compressed vmat file: "+fn);
    return false;
  }
#if ZLIB_VERNUM >= 0x1240
  int ok = gzbuffer(f, gz_buf_size);
  if (0 != ok) {
    Form1->Memo1->Lines->Add(" FATAL ERROR: Could not set gz buffer for file: "+fn);
    return false;
  }
#endif
  //ok = gzsetparams(f, lvl, strat);

  gzwrite(f, magic, strlen(magic));
  gzwrite(f, (const char*)&xdim, sizeof(xdim));
  gzwrite(f, (const char*)&ydim, sizeof(ydim));
  gzwrite(f, (const char*)&map_cnt, sizeof(map_cnt));

  BFOC_size_t empty = 0;  

  for (size_t y=0; y<ydim; y++) {
    for (size_t x=0; x<xdim; x++) {
      if (!vmat[y][x]) {
	gzwrite(f, (const char*)&empty, sizeof(empty));
      } else {
	// f << size << <list of index-value pairs>
	const Biodiv_Features_Occur_Container& occ = vmat[y][x];
	BFOC_size_t n = occ.size();
	gzwrite(f, (const char*)&n, sizeof(n));
	for (BFOC_size_t spp=occ.first(); spp!=occ.overflow(); spp=occ.next(spp)) {
	  //f << spp << vmat[y][x][spp];
	  gzwrite(f, (const char*)&spp, sizeof(spp));
	  gzwrite(f, (const char*)&(vmat[y][x][spp]), sizeof(typeof(vmat[y][x][spp])));
	}
      }
    }
    if (0 == (y+1)%REPORT_PERIOD)
      Form1->Memo1->Lines->Add(" Written "+IntToStr(y+1)+" rows...");
  }

  gzclose(f);
  return true;
}
Example #24
0
   void CPU::throwException(VirtualContext& context, const String& exceptionname, const String& reason)
   {
      VirtualClass& klass = context.resolveClass(exceptionname);
      VirtualObject& exception = instantiate(context, klass, -1);
      String callstack = buildCallStack();

      exception.getMember(0).setString(context.mStringCache.lookup(reason));
      exception.getMember(1).setString(context.mStringCache.lookup(callstack));

      if ( !handleException(context, exception) )
      {
         String msg = UTEXT("Unhandled exception '") + klass.getName() + UTEXT("'\n") + callstack;
         std::string m = msg.toUtf8();
         Log::getInstance().error(m.c_str());
      }
   }
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
String XmlElementImpl::getAttributeString(const String& attributeName, const String& defaultVal /*= ""*/, bool* found /*= NULL*/) const
{
    if (found) *found = false;

    const char* attrValue = Attribute(attributeName.toUtf8().ptr());
    if (!attrValue)
    {
        return defaultVal;
    }

    String val = String::fromUtf8(attrValue);

    if (found) *found = true;

    return val;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
int XmlElementImpl::getAttributeInt(const String& attributeName, int defaultVal, bool* found /*= NULL*/) const
{
    int intValue = defaultVal;
    if (QueryIntAttribute(attributeName.toUtf8().ptr(), &intValue) == TIXML_SUCCESS)
    {
        if (found) *found = true;

        return intValue;
    }
    else
    {
        if (found) *found = false;

        return defaultVal;
    }
}
Example #27
0
AutoStr *P_NameForMapEntityDef(MapEntityDef const *def)
{
    String name;  // Not found.
    if (def)
    {
        ::entityDefs->forAll([&def, &name] (StringPool::Id id)
        {
            if (::entityDefs->userPointer(id) == def)
            {
                name = ::entityDefs->string(id);
                return LoopAbort;
            }
            return LoopContinue;
        });
    }
    return AutoStr_FromText(name.toUtf8().constData());
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
cvf::int64 XmlElementImpl::getAttributeInt64(const String& attributeName, cvf::int64 defaultVal, bool* found /*= NULL*/) const
{
    cvf::int64 int64Value = defaultVal;
    if (QueryValueAttribute<cvf::int64>(attributeName.toUtf8().ptr(), &int64Value) == TIXML_SUCCESS)
    {
        if (found) *found = true;

        return int64Value;
    }
    else
    {
        if (found) *found = false;

        return defaultVal;
    }

}
Example #29
0
bool ProjectGenerator::write(const String& filename, const String& output, bool force)
{
   if ( !force && FileSystem::getInstance().exists(filename) )
   {
      return false;
   }
   
   StdioFile file;
   if ( file.open(filename, File::EWrite | File::EText) )
   {
      file.write(output);
      return true;
   }

   std::cerr << "Could not write to file " << filename.toUtf8() << std::endl;
   
   return false;
}
Example #30
0
void DxBuilder::buildVertexShader(const ASTEffect& effect, ASTTechnique& technique)
{
   const ASTFunction* pfunction = effect.findFunction(technique.mVertex.mEntry);
   if ( pfunction->mArguments.size() == 1 && pfunction->mArguments[0]->mpType->isStruct() )
   {
      const ASTStruct& input = pfunction->mArguments[0]->mpType->getStruct();
      technique.mpLayout = buildInputLayout(input);
   }

   String code = UTEXT("// generated vertex shader\n\n");
   
   String num;
   NumberConverter& conv = NumberConverter::getInstance();
   for ( std::size_t index = 0; index < effect.mBuffers.size(); ++index )
   {
      const ASTBuffer* pbuffer = effect.mBuffers[index];
      code += UTEXT("cbuffer ") + pbuffer->mName;

      int reg = pbuffer->mRegister;
      if ( reg == -1 )
         reg = (int) index;
      
      code += UTEXT(" : register(b") + conv.format(num, reg) + UTEXT(")\n{") + pbuffer->mBody + UTEXT("};\n\n");
   }

   code += buildStructs(effect, *pfunction);
   code += buildFunction(*pfunction);

   std::string data = code.toUtf8();
   std::string entry = technique.mVertex.mEntry.toUtf8();
   std::string target = technique.mVertex.mTarget.toUtf8();
   uint32_t flags = D3DCOMPILE_ENABLE_STRICTNESS;

   ID3DBlob *presult, *perror;
   HRESULT hr = D3DCompile(data.c_str(), data.length(), NULL, NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, entry.c_str(), target.c_str(), flags, 0, &presult, &perror);
   if ( FAILED(hr) )
   {
      std::string d3derror = "Shader compile error: " + std::string((const char*)perror->GetBufferPointer());
      throw std::exception(d3derror.c_str());
   }

   technique.mVertex.mCompiledCode.writeBlob(presult->GetBufferPointer(), presult->GetBufferSize());
}