本文整理汇总了C++中JSONWriter::writeString方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONWriter::writeString方法的具体用法?C++ JSONWriter::writeString怎么用?C++ JSONWriter::writeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONWriter
的用法示例。
在下文中一共展示了JSONWriter::writeString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
dumpBoolean(JSONWriter &json, GLboolean value)
{
switch (value) {
case GL_FALSE:
json.writeString("GL_FALSE");
break;
case GL_TRUE:
json.writeString("GL_TRUE");
break;
default:
json.writeInt(static_cast<GLint>(value));
break;
}
}
示例2: malloc
inline void
dumpShader(JSONWriter &json, const char *name, T *pShader) {
if (!pShader) {
return;
}
HRESULT hr;
UINT SizeOfData = 0;
hr = pShader->GetFunction(NULL, &SizeOfData);
if (SUCCEEDED(hr)) {
void *pData;
pData = malloc(SizeOfData);
if (pData) {
hr = pShader->GetFunction(pData, &SizeOfData);
if (SUCCEEDED(hr)) {
com_ptr<IDisassemblyBuffer> pDisassembly;
hr = DisassembleShader((const DWORD *)pData, &pDisassembly);
if (SUCCEEDED(hr)) {
json.beginMember(name);
json.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */);
json.endMember();
}
}
free(pData);
}
}
}
示例3: getPrivateData
inline void
dumpShader(JSONWriter &json, const char *name, T *pShader) {
if (!pShader) {
return;
}
/*
* There is no method to get the shader byte code, so the creator is supposed to
* attach it via the SetPrivateData method.
*/
std::vector<BYTE> ShaderBytecode = getPrivateData(pShader, GUID_D3DSTATE);
if (ShaderBytecode.empty()) {
return;
}
com_ptr<IDisassemblyBuffer> pDisassembly;
HRESULT hr;
hr = DisassembleShader(&ShaderBytecode[0], ShaderBytecode.size(), &pDisassembly);
if (SUCCEEDED(hr)) {
json.beginMember(name);
json.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */);
json.endMember();
}
}
示例4: glGetShaderiv
static void
dumpShader(JSONWriter &json, GLuint shader)
{
if (!shader) {
return;
}
GLint shader_type = 0;
glGetShaderiv(shader, GL_SHADER_TYPE, &shader_type);
if (!shader_type) {
return;
}
GLint source_length = 0;
glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &source_length);
if (!source_length) {
return;
}
GLchar *source = new GLchar[source_length];
GLsizei length = 0;
source[0] = 0;
glGetShaderSource(shader, source_length, &length, source);
json.beginMember(enumToString(shader_type));
json.writeString(source);
json.endMember();
delete [] source;
}
示例5: glGetObjectParameterivARB
static void
dumpShaderObj(JSONWriter &json, GLhandleARB shaderObj)
{
if (!shaderObj) {
return;
}
GLint shader_type = 0;
glGetObjectParameterivARB(shaderObj, GL_OBJECT_TYPE_ARB, &shader_type);
if (!shader_type) {
return;
}
GLint source_length = 0;
glGetObjectParameterivARB(shaderObj, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &source_length);
if (!source_length) {
return;
}
GLcharARB *source = new GLcharARB[source_length];
GLsizei length = 0;
source[0] = 0;
glGetShaderSource(shaderObj, source_length, &length, source);
json.beginMember(enumToString(shader_type));
json.writeString(source);
json.endMember();
delete [] source;
}
示例6: glGetProgramiv
static inline void
dumpProgram(JSONWriter &json, GLint program)
{
GLint attached_shaders = 0;
glGetProgramiv(program, GL_ATTACHED_SHADERS, &attached_shaders);
if (!attached_shaders) {
return;
}
ShaderMap shaderMap;
GLuint *shaders = new GLuint[attached_shaders];
GLsizei count = 0;
glGetAttachedShaders(program, attached_shaders, &count, shaders);
std::sort(shaders, shaders + count);
for (GLsizei i = 0; i < count; ++ i) {
getShaderSource(shaderMap, shaders[i]);
}
delete [] shaders;
for (ShaderMap::const_iterator it = shaderMap.begin(); it != shaderMap.end(); ++it) {
json.beginMember(it->first);
json.writeString(it->second);
json.endMember();
}
}
示例7: enumToString
void
dumpEnum(JSONWriter &json, GLenum pname)
{
const char *s = enumToString(pname);
if (s) {
json.writeString(s);
} else {
json.writeInt(pname);
}
}
示例8: glGetProgramivARB
static inline void
dumpArbProgram(JSONWriter &json, GLenum target)
{
if (!glIsEnabled(target)) {
return;
}
GLint program_length = 0;
glGetProgramivARB(target, GL_PROGRAM_LENGTH_ARB, &program_length);
if (!program_length) {
return;
}
GLchar *source = new GLchar[program_length + 1];
source[0] = 0;
glGetProgramStringARB(target, GL_PROGRAM_STRING_ARB, source);
source[program_length] = 0;
json.beginMember(enumToString(target));
json.writeString(source);
json.endMember();
delete [] source;
}