当前位置: 首页>>代码示例>>C++>>正文


C++ NzString::Set方法代码示例

本文整理汇总了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;
}
开发者ID:GuillaumeBelz,项目名称:NazaraEngine,代码行数:56,代码来源:InputStream.cpp

示例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;
}
开发者ID:BigFax,项目名称:NazaraEngine,代码行数:22,代码来源:ShaderStage.cpp

示例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;
}
开发者ID:BigFax,项目名称:NazaraEngine,代码行数:24,代码来源:ShaderStage.cpp

示例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;
}
开发者ID:merydwin,项目名称:NazaraEngine,代码行数:94,代码来源:Material.cpp


注:本文中的NzString::Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。