本文整理汇总了C++中JSONWriter::endObject方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONWriter::endObject方法的具体用法?C++ JSONWriter::endObject怎么用?C++ JSONWriter::endObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONWriter
的用法示例。
在下文中一共展示了JSONWriter::endObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glGetIntegerv
void
dumpTextures(JSONWriter &json, Context &context)
{
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);
/*
* At least the Android software GL implementation doesn't return the
* proper value for this, but rather returns 0. The GL(ES) specification
* mandates a minimum value of 2, so use this as a fall-back value.
*/
max_units = std::max(max_units, 2);
for (GLint unit = 0; unit < max_units; ++unit) {
GLenum texture = GL_TEXTURE0 + unit;
glActiveTexture(texture);
dumpTexture(json, context, GL_TEXTURE_1D, GL_TEXTURE_BINDING_1D);
dumpTexture(json, context, GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D);
dumpTexture(json, context, GL_TEXTURE_3D, GL_TEXTURE_BINDING_3D);
dumpTexture(json, context, GL_TEXTURE_RECTANGLE, GL_TEXTURE_BINDING_RECTANGLE);
dumpTexture(json, context, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BINDING_CUBE_MAP);
}
glActiveTexture(active_texture);
json.endObject();
json.endMember(); // textures
}
示例2: 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();
}
示例3: 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
}
示例4: 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
}
示例5:
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
}
示例6:
void
dumpTextures(JSONWriter &json, IDirect3DDevice7 *pDevice)
{
json.beginMember("textures");
json.beginObject();
json.endObject();
json.endMember(); // textures
}
示例7: 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
}
示例8: dumpCurrentProgram
static inline void
dumpShaders(JSONWriter &json)
{
json.beginMember("shaders");
json.beginObject();
dumpCurrentProgram(json);
dumpArbProgram(json, GL_FRAGMENT_PROGRAM_ARB);
dumpArbProgram(json, GL_VERTEX_PROGRAM_ARB);
json.endObject();
json.endMember(); //shaders
}
示例9: dumpProgramUniforms
static void
dumpProgramUniformsStage(JSONWriter &json, GLint program, const char *stage)
{
if (program) {
json.beginMember(stage);
json.beginObject();
dumpProgramUniforms(json, program);
json.endObject();
json.endMember();
}
}
示例10: 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
}
示例11: dumpRasterizerState
static void
dumpParameters(JSONWriter &json, ID3D11DeviceContext *pDeviceContext)
{
// TODO: dump description of current bound state
json.beginMember("parameters");
json.beginObject();
dumpRasterizerState(json, pDeviceContext);
dumpBlendState(json, pDeviceContext);
dumpDepthStencilState(json, pDeviceContext);
json.endObject();
json.endMember(); // parameters
}
示例12: 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
}
示例13: getRenderTargetViewImage
void
dumpFramebuffer(JSONWriter &json, ID3D10Device *pDevice)
{
json.beginMember("framebuffer");
json.beginObject();
ID3D10RenderTargetView *pRenderTargetViews[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT];
ID3D10DepthStencilView *pDepthStencilView;
pDevice->OMGetRenderTargets(ARRAYSIZE(pRenderTargetViews), pRenderTargetViews,
&pDepthStencilView);
for (UINT i = 0; i < ARRAYSIZE(pRenderTargetViews); ++i) {
if (!pRenderTargetViews[i]) {
continue;
}
image::Image *image;
image = getRenderTargetViewImage(pDevice, pRenderTargetViews[i]);
if (image) {
char label[64];
_snprintf(label, sizeof label, "RENDER_TARGET_%u", i);
json.beginMember(label);
json.writeImage(image);
json.endMember(); // RENDER_TARGET_*
delete image;
}
pRenderTargetViews[i]->Release();
}
if (pDepthStencilView) {
image::Image *image;
image = getDepthStencilViewImage(pDevice, pDepthStencilView);
if (image) {
json.beginMember("DEPTH_STENCIL");
json.writeImage(image);
json.endMember();
delete image;
}
pDepthStencilView->Release();
}
json.endObject();
json.endMember(); // framebuffer
}
示例14: resetPixelPackState
/**
* Dump the image of the currently bound read buffer.
*/
static inline void
dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format)
{
GLint channels = __gl_format_channels(format);
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);
// 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);
GLubyte *pixels = new GLubyte[width*height*channels];
resetPixelPackState();
glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, pixels);
restorePixelPackState();
json.beginMember("__data__");
char *pngBuffer;
int pngBufferSize;
Image::writePixelsToBuffer(pixels, width, height, channels, false, &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();
}
示例15:
static void
dumpShaders(JSONWriter &json, ID3D11DeviceContext *pDeviceContext)
{
json.beginMember("shaders");
json.beginObject();
com_ptr<ID3D11VertexShader> pVertexShader;
pDeviceContext->VSGetShader(&pVertexShader, NULL, NULL);
if (pVertexShader) {
dumpShader<ID3D11DeviceChild>(json, "VS", pVertexShader);
}
com_ptr<ID3D11HullShader> pHullShader;
pDeviceContext->HSGetShader(&pHullShader, NULL, NULL);
if (pHullShader) {
dumpShader<ID3D11DeviceChild>(json, "HS", pHullShader);
}
com_ptr<ID3D11DomainShader> pDomainShader;
pDeviceContext->DSGetShader(&pDomainShader, NULL, NULL);
if (pDomainShader) {
dumpShader<ID3D11DeviceChild>(json, "DS", pDomainShader);
}
com_ptr<ID3D11GeometryShader> pGeometryShader;
pDeviceContext->GSGetShader(&pGeometryShader, NULL, NULL);
if (pGeometryShader) {
dumpShader<ID3D11DeviceChild>(json, "GS", pGeometryShader);
}
com_ptr<ID3D11PixelShader> pPixelShader;
pDeviceContext->PSGetShader(&pPixelShader, NULL, NULL);
if (pPixelShader) {
dumpShader<ID3D11DeviceChild>(json, "PS", pPixelShader);
}
json.endObject();
json.endMember(); // shaders
}