本文整理汇总了C++中NzString::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ NzString::Set方法的具体用法?C++ NzString::Set怎么用?C++ NzString::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NzString
的用法示例。
在下文中一共展示了NzString::Set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadLine
NzString NzInputStream::ReadLine(unsigned int lineSize)
{
NzString line;
if (lineSize == 0) // Taille maximale indéterminée
{
const unsigned int bufferSize = 64;
char buffer[bufferSize+1];
buffer[bufferSize] = '\0';
unsigned int readSize;
do
{
readSize = Read(buffer, bufferSize);
const char* ptr = std::strchr(buffer, '\n');
if (ptr)
{
unsigned int pos = ptr-buffer;
if (m_streamOptions & nzStreamOption_Text && pos > 0 && buffer[pos-1] == '\r')
line.Append(buffer, pos-1);
else
line.Append(buffer, pos);
if (!SetCursorPos(GetCursorPos() - readSize + pos + 1))
NazaraWarning("Failed to reset cursos pos");
break;
}
else
line.Append(buffer, readSize);
}
while (readSize == bufferSize);
}
else
{
line.Set(lineSize, '\0');
unsigned int readSize = Read(&line[0], lineSize);
unsigned int pos = line.Find('\n');
if (pos <= readSize) // Faux uniquement si le caractère n'est pas présent (npos étant le plus grand entier)
{
if (m_streamOptions & nzStreamOption_Text && pos > 0 && line[pos-1] == '\r')
line.Resize(pos);
else
line.Resize(pos+1);
if (!SetCursorPos(GetCursorPos() - readSize + pos + 1))
NazaraWarning("Failed to reset cursos pos");
}
else
line.Resize(readSize);
}
return line;
}
示例2: GetSource
NzString NzShaderStage::GetSource() const
{
#if NAZARA_RENDERER_SAFE
if (!m_id)
{
NazaraError("Shader stage is not initialized");
return NzString();
}
#endif
NzString source;
GLint length = 0;
glGetShaderiv(m_id, GL_SHADER_SOURCE_LENGTH, &length);
if (length > 1) // Le caractère de fin compte
{
source.Set(length - 1, '\0'); // La taille retournée est celle du buffer (Avec caractère de fin)
glGetShaderSource(m_id, length, nullptr, &source[0]);
}
return source;
}
示例3: GetLog
NzString NzShaderStage::GetLog() const
{
#if NAZARA_RENDERER_SAFE
if (!m_id)
{
NazaraError("Shader stage is not initialized");
return NzString();
}
#endif
NzString log;
GLint length = 0;
glGetShaderiv(m_id, GL_INFO_LOG_LENGTH, &length);
if (length > 1) // Le caractère de fin faisant partie du compte
{
log.Set(length - 1, '\0'); // La taille retournée est celle du buffer (Avec caractère de fin)
glGetShaderInfoLog(m_id, length, nullptr, &log[0]);
}
else
log = "No log.";
return log;
}
示例4: Initialize
bool NzMaterial::Initialize()
{
bool glsl140 = (NzOpenGL::GetGLSLVersion() >= 140);
// Basic shader
{
std::unique_ptr<NzUberShaderPreprocessor> uberShader(new NzUberShaderPreprocessor);
uberShader->SetPersistent(false);
NzString fragmentShader;
NzString vertexShader;
if (glsl140)
{
const nzUInt8 coreFragmentShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/core.frag.h>
};
const nzUInt8 coreVertexShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/core.vert.h>
};
fragmentShader.Set(reinterpret_cast<const char*>(coreFragmentShader), sizeof(coreFragmentShader));
vertexShader.Set(reinterpret_cast<const char*>(coreVertexShader), sizeof(coreVertexShader));
}
else
{
const nzUInt8 compatibilityFragmentShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/compatibility.frag.h>
};
const nzUInt8 compatibilityVertexShader[] = {
#include <Nazara/Graphics/Resources/Shaders/Basic/compatibility.vert.h>
};
fragmentShader.Set(reinterpret_cast<const char*>(compatibilityFragmentShader), sizeof(compatibilityFragmentShader));
vertexShader.Set(reinterpret_cast<const char*>(compatibilityVertexShader), sizeof(compatibilityVertexShader));
}
uberShader->SetShader(nzShaderStage_Fragment, fragmentShader, "ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING");
uberShader->SetShader(nzShaderStage_Vertex, vertexShader, "FLAG_INSTANCING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH");
NzUberShaderLibrary::Register("Basic", uberShader.get());
uberShader.release();
}
// PhongLighting shader
{
std::unique_ptr<NzUberShaderPreprocessor> uberShader(new NzUberShaderPreprocessor);
uberShader->SetPersistent(false);
NzString fragmentShader;
NzString vertexShader;
if (glsl140)
{
const nzUInt8 coreFragmentShader[] = {
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h>
};
const nzUInt8 coreVertexShader[] = {
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h>
};
fragmentShader.Set(reinterpret_cast<const char*>(coreFragmentShader), sizeof(coreFragmentShader));
vertexShader.Set(reinterpret_cast<const char*>(coreVertexShader), sizeof(coreVertexShader));
}
else
{
const nzUInt8 compatibilityFragmentShader[] = {
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/compatibility.frag.h>
};
const nzUInt8 compatibilityVertexShader[] = {
#include <Nazara/Graphics/Resources/Shaders/PhongLighting/compatibility.vert.h>
};
fragmentShader.Set(reinterpret_cast<const char*>(compatibilityFragmentShader), sizeof(compatibilityFragmentShader));
vertexShader.Set(reinterpret_cast<const char*>(compatibilityVertexShader), sizeof(compatibilityVertexShader));
}
uberShader->SetShader(nzShaderStage_Fragment, fragmentShader, "FLAG_DEFERRED ALPHA_MAPPING ALPHA_TEST DIFFUSE_MAPPING EMISSIVE_MAPPING LIGHTING NORMAL_MAPPING PARALLAX_MAPPING SPECULAR_MAPPING");
uberShader->SetShader(nzShaderStage_Vertex, vertexShader, "FLAG_DEFERRED FLAG_INSTANCING COMPUTE_TBNMATRIX LIGHTING PARALLAX_MAPPING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH");
NzUberShaderLibrary::Register("PhongLighting", uberShader.get());
uberShader.release();
}
s_defaultMaterial = new NzMaterial;
s_defaultMaterial->SetPersistent(true);
s_defaultMaterial->Enable(nzRendererParameter_FaceCulling, false);
s_defaultMaterial->SetFaceFilling(nzFaceFilling_Line);
return true;
}