本文整理汇总了C++中JSONWriter::beginMember方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONWriter::beginMember方法的具体用法?C++ JSONWriter::beginMember怎么用?C++ JSONWriter::beginMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONWriter
的用法示例。
在下文中一共展示了JSONWriter::beginMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glGetProgramivARB
static inline void
dumpArbProgramUniforms(JSONWriter &json, GLenum target, const char *prefix)
{
if (!glIsEnabled(target)) {
return;
}
GLint program_parameters = 0;
glGetProgramivARB(target, GL_PROGRAM_PARAMETERS_ARB, &program_parameters);
if (!program_parameters) {
return;
}
GLint max_program_local_parameters = 0;
glGetProgramivARB(target, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &max_program_local_parameters);
for (GLint index = 0; index < max_program_local_parameters; ++index) {
GLdouble params[4] = {0, 0, 0, 0};
glGetProgramLocalParameterdvARB(target, index, params);
if (!params[0] && !params[1] && !params[2] && !params[3]) {
continue;
}
char name[256];
snprintf(name, sizeof name, "%sprogram.local[%i]", prefix, index);
json.beginMember(name);
json.beginArray();
json.writeFloat(params[0]);
json.writeFloat(params[1]);
json.writeFloat(params[2]);
json.writeFloat(params[3]);
json.endArray();
json.endMember();
}
GLint max_program_env_parameters = 0;
glGetProgramivARB(target, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &max_program_env_parameters);
for (GLint index = 0; index < max_program_env_parameters; ++index) {
GLdouble params[4] = {0, 0, 0, 0};
glGetProgramEnvParameterdvARB(target, index, params);
if (!params[0] && !params[1] && !params[2] && !params[3]) {
continue;
}
char name[256];
snprintf(name, sizeof name, "%sprogram.env[%i]", prefix, index);
json.beginMember(name);
json.beginArray();
json.writeFloat(params[0]);
json.writeFloat(params[1]);
json.writeFloat(params[2]);
json.writeFloat(params[3]);
json.endArray();
json.endMember();
}
}
示例2: glGetIntegerv
/**
* Dump images of current draw drawable/window.
*/
static void
dumpDrawableImages(JSONWriter &json, Context &context)
{
GLint width, height;
if (!getDrawableBounds(&width, &height)) {
return;
}
GLint draw_buffer = GL_NONE;
if (context.ES) {
draw_buffer = GL_BACK;
} else {
glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer);
glReadBuffer(draw_buffer);
}
if (draw_buffer != GL_NONE) {
GLint read_buffer = GL_NONE;
if (!context.ES) {
glGetIntegerv(GL_READ_BUFFER, &read_buffer);
}
GLint alpha_bits = 0;
#if 0
// XXX: Ignore alpha until we are able to match the traced visual
glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);
#endif
GLenum format = alpha_bits ? GL_RGBA : GL_RGB;
json.beginMember(enumToString(draw_buffer));
dumpReadBufferImage(json, width, height, format);
json.endMember();
if (!context.ES) {
glReadBuffer(read_buffer);
}
}
if (!context.ES) {
GLint depth_bits = 0;
glGetIntegerv(GL_DEPTH_BITS, &depth_bits);
if (depth_bits) {
json.beginMember("GL_DEPTH_COMPONENT");
dumpReadBufferImage(json, width, height, GL_DEPTH_COMPONENT);
json.endMember();
}
GLint stencil_bits = 0;
glGetIntegerv(GL_STENCIL_BITS, &stencil_bits);
if (stencil_bits) {
json.beginMember("GL_STENCIL_INDEX");
dumpReadBufferImage(json, width, height, GL_STENCIL_INDEX);
json.endMember();
}
}
}
示例3: getRenderTargetViewImage
void
dumpFramebuffer(JSONWriter &json, ID3D11DeviceContext *pDevice)
{
json.beginMember("framebuffer");
json.beginObject();
ID3D11RenderTargetView *pRenderTargetViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];
ID3D11DepthStencilView *pDepthStencilView;
pDevice->OMGetRenderTargets(ARRAYSIZE(pRenderTargetViews), pRenderTargetViews,
&pDepthStencilView);
for (UINT i = 0; i < ARRAYSIZE(pRenderTargetViews); ++i) {
if (!pRenderTargetViews[i]) {
continue;
}
image::Image *image;
DXGI_FORMAT dxgiFormat;
image = getRenderTargetViewImage(pDevice, pRenderTargetViews[i],
&dxgiFormat);
if (image) {
char label[64];
_snprintf(label, sizeof label, "RENDER_TARGET_%u", i);
JSONWriter::ImageDesc imgDesc;
imgDesc.depth = 1;
imgDesc.format = getDXGIFormatName(dxgiFormat);
json.beginMember(label);
json.writeImage(image, imgDesc);
json.endMember(); // RENDER_TARGET_*
delete image;
}
pRenderTargetViews[i]->Release();
}
if (pDepthStencilView) {
image::Image *image;
DXGI_FORMAT dxgiFormat;
image = getDepthStencilViewImage(pDevice, pDepthStencilView,
&dxgiFormat);
if (image) {
JSONWriter::ImageDesc imgDesc;
imgDesc.depth = 1;
imgDesc.format = getDXGIFormatName(dxgiFormat);
json.beginMember("DEPTH_STENCIL");
json.writeImage(image, imgDesc);
json.endMember();
delete image;
}
pDepthStencilView->Release();
}
json.endObject();
json.endMember(); // framebuffer
}
示例4: getRenderTargetImage
void
dumpFramebuffer(JSONWriter &json, IDirect3DDevice9 *pDevice)
{
HRESULT hr;
json.beginMember("framebuffer");
json.beginObject();
D3DCAPS9 Caps;
pDevice->GetDeviceCaps(&Caps);
for (UINT i = 0; i < Caps.NumSimultaneousRTs; ++i) {
IDirect3DSurface9 *pRenderTarget = NULL;
hr = pDevice->GetRenderTarget(i, &pRenderTarget);
if (FAILED(hr)) {
continue;
}
if (!pRenderTarget) {
continue;
}
image::Image *image;
image = getRenderTargetImage(pDevice, pRenderTarget);
if (image) {
char label[64];
_snprintf(label, sizeof label, "RENDER_TARGET_%u", i);
json.beginMember(label);
json.writeImage(image, "UNKNOWN");
json.endMember(); // RENDER_TARGET_*
}
pRenderTarget->Release();
}
IDirect3DSurface9 *pDepthStencil = NULL;
hr = pDevice->GetDepthStencilSurface(&pDepthStencil);
if (SUCCEEDED(hr) && pDepthStencil) {
image::Image *image;
image = getSurfaceImage(pDevice, pDepthStencil);
if (image) {
json.beginMember("DEPTH_STENCIL");
json.writeImage(image, "UNKNOWN");
json.endMember(); // RENDER_TARGET_*
}
}
json.endObject();
json.endMember(); // framebuffer
}
示例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: 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;
}
示例7: 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();
}
}
示例8: enumToString
/**
* Dump the image of the currently bound read buffer.
*/
static inline void
dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format,
GLint internalFormat = GL_NONE)
{
GLint channels = _gl_format_channels(format);
if (internalFormat == GL_NONE) {
internalFormat = format;
}
Context context;
json.beginObject();
// Tell the GUI this is no ordinary object, but an image
json.writeStringMember("__class__", "image");
json.writeNumberMember("__width__", width);
json.writeNumberMember("__height__", height);
json.writeNumberMember("__depth__", 1);
json.writeStringMember("__format__", enumToString(internalFormat));
// Hardcoded for now, but we could chose types more adequate to the
// texture internal format
json.writeStringMember("__type__", "uint8");
json.writeBoolMember("__normalized__", true);
json.writeNumberMember("__channels__", channels);
GLenum type = GL_UNSIGNED_BYTE;
#if DEPTH_AS_RGBA
if (format == GL_DEPTH_COMPONENT) {
type = GL_UNSIGNED_INT;
channels = 4;
}
#endif
GLubyte *pixels = new GLubyte[width*height*channels];
// TODO: reset imaging state too
context.resetPixelPackState();
glReadPixels(0, 0, width, height, format, type, pixels);
context.restorePixelPackState();
json.beginMember("__data__");
char *pngBuffer;
int pngBufferSize;
image::writePixelsToBuffer(pixels, width, height, channels, true, &pngBuffer, &pngBufferSize);
//std::cerr <<" Before = "<<(width * height * channels * sizeof *pixels)
// <<", after = "<<pngBufferSize << ", ratio = " << double(width * height * channels * sizeof *pixels)/pngBufferSize;
json.writeBase64(pngBuffer, pngBufferSize);
free(pngBuffer);
json.endMember(); // __data__
delete [] pixels;
json.endObject();
}
示例9: 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();
}
}
示例10: ARRAYSIZE
void
dumpTextures(JSONWriter &json, ID3D11DeviceContext *pDevice)
{
json.beginMember("textures");
json.beginObject();
ID3D11ShaderResourceView *pShaderResourceViews[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
pDevice->VSGetShaderResources(0, ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
dumpStageTextures(json, pDevice, "VS", ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
pDevice->HSGetShaderResources(0, ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
dumpStageTextures(json, pDevice, "HS", ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
pDevice->DSGetShaderResources(0, ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
dumpStageTextures(json, pDevice, "DS", ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
pDevice->GSGetShaderResources(0, ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
dumpStageTextures(json, pDevice, "GS", ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
pDevice->PSGetShaderResources(0, ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
dumpStageTextures(json, pDevice, "PS", ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
json.endObject();
json.endMember(); // textures
}
示例11: 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);
}
}
}
示例12: glGetIntegerv
static inline void
dumpTextures(JSONWriter &json)
{
json.beginMember("textures");
json.beginObject();
GLint active_texture = GL_TEXTURE0;
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
GLint max_texture_coords = 0;
glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);
GLint max_combined_texture_image_units = 0;
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);
GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);
for (GLint unit = 0; unit < max_units; ++unit) {
GLenum texture = GL_TEXTURE0 + unit;
glActiveTexture(texture);
dumpTexture(json, GL_TEXTURE_1D, GL_TEXTURE_BINDING_1D);
dumpTexture(json, GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D);
dumpTexture(json, GL_TEXTURE_3D, GL_TEXTURE_BINDING_3D);
dumpTexture(json, GL_TEXTURE_RECTANGLE, GL_TEXTURE_BINDING_RECTANGLE);
dumpTexture(json, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BINDING_CUBE_MAP);
}
glActiveTexture(active_texture);
json.endObject();
json.endMember(); // textures
}
示例13:
static void
dumpShaders(JSONWriter &json, ID3D10Device *pDevice)
{
json.beginMember("shaders");
json.beginObject();
com_ptr<ID3D10VertexShader> pVertexShader;
pDevice->VSGetShader(&pVertexShader);
if (pVertexShader) {
dumpShader<ID3D10DeviceChild>(json, "VS", pVertexShader);
}
com_ptr<ID3D10GeometryShader> pGeometryShader;
pDevice->GSGetShader(&pGeometryShader);
if (pGeometryShader) {
dumpShader<ID3D10DeviceChild>(json, "GS", pGeometryShader);
}
com_ptr<ID3D10PixelShader> pPixelShader;
pDevice->PSGetShader(&pPixelShader);
if (pPixelShader) {
dumpShader<ID3D10DeviceChild>(json, "PS", pPixelShader);
}
json.endObject();
json.endMember(); // shaders
}
示例14: getTextureImage
void
dumpTextures(JSONWriter &json, IDirect3DDevice9 *pDevice)
{
HRESULT hr;
json.beginMember("textures");
json.beginObject();
for (DWORD Stage = 0; Stage < 16; ++Stage) {
com_ptr<IDirect3DBaseTexture9> pTexture;
hr = pDevice->GetTexture(Stage, &pTexture);
if (FAILED(hr)) {
continue;
}
if (!pTexture) {
continue;
}
D3DRESOURCETYPE Type = pTexture->GetType();
DWORD NumFaces = Type == D3DRTYPE_CUBETEXTURE ? 6 : 1;
DWORD NumLevels = pTexture->GetLevelCount();
for (DWORD Face = 0; Face < NumFaces; ++Face) {
for (DWORD Level = 0; Level < NumLevels; ++Level) {
image::Image *image;
image = getTextureImage(pDevice, pTexture, static_cast<D3DCUBEMAP_FACES>(Face), Level);
if (image) {
char label[128];
if (Type == D3DRTYPE_CUBETEXTURE) {
_snprintf(label, sizeof label, "PS_RESOURCE_%lu_FACE_%lu_LEVEL_%lu", Stage, Face, Level);
} else {
_snprintf(label, sizeof label, "PS_RESOURCE_%lu_LEVEL_%lu", Stage, Level);
}
json.beginMember(label);
json.writeImage(image);
json.endMember(); // PS_RESOURCE_*
}
}
}
}
json.endObject();
json.endMember(); // textures
}
示例15:
void
dumpTextures(JSONWriter &json, IDirect3DDevice7 *pDevice)
{
json.beginMember("textures");
json.beginObject();
json.endObject();
json.endMember(); // textures
}