这篇教程C++ BufferData函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BufferData函数的典型用法代码示例。如果您正苦于以下问题:C++ BufferData函数的具体用法?C++ BufferData怎么用?C++ BufferData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BufferData函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GrAssertbool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) { GrAssert(fBufferID); GrAssert(!isLocked()); if (srcSizeInBytes > this->sizeInBytes()) { return false; } this->bind(); GrGLenum usage = dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW;#if !GR_GL_USE_BUFFER_DATA_NULL_HINT // Note that we're cheating on the size here. Currently no methods // allow a partial update that preserves contents of non-updated // portions of the buffer (and lock() does a glBufferData(..size, NULL..)) GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage));#else if (this->sizeInBytes() == srcSizeInBytes) { GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage)); } else { // Before we call glBufferSubData we give the driver a hint using // glBufferData with NULL. This makes the old buffer contents // inaccessible to future draws. The GPU may still be processing draws // that reference the old contents. With this hint it can assign a // different allocation for the new contents to avoid flushing the gpu // past draws consuming the old contents. GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, this->sizeInBytes(), NULL, usage)); GL_CALL(BufferSubData(GR_GL_ARRAY_BUFFER, 0, srcSizeInBytes, src)); }#endif return true;}
开发者ID:AliFarahnak,项目名称:XobotOS,代码行数:30,
示例2: BufferDatavoid CSave::BufferString( char *pdata, int len ){ char c = 0; BufferData( pdata, len ); // Write the string BufferData( &c, 1 ); // Write a null terminator}
开发者ID:swmpdg,项目名称:HLEnhanced,代码行数:7,
示例3: VALIDATEvoid GrGLBuffer::onMap() { if (this->wasDestroyed()) { return; } VALIDATE(); SkASSERT(!this->isMapped()); if (0 == fBufferID) { fMapPtr = fCPUData; VALIDATE(); return; } // TODO: Make this a function parameter. bool readOnly = (kXferGpuToCpu_GrBufferType == fIntendedType); // Handling dirty context is done in the bindBuffer call switch (this->glCaps().mapBufferType()) { case GrGLCaps::kNone_MapBufferType: break; case GrGLCaps::kMapBuffer_MapBufferType: { GrGLenum target = this->glGpu()->bindBuffer(fIntendedType, this); // Let driver know it can discard the old data if (GR_GL_USE_BUFFER_DATA_NULL_HINT || fGLSizeInBytes != fSizeInBytes) { GL_CALL(BufferData(target, fSizeInBytes, nullptr, fUsage)); } GL_CALL_RET(fMapPtr, MapBuffer(target, readOnly ? GR_GL_READ_ONLY : GR_GL_WRITE_ONLY)); break; } case GrGLCaps::kMapBufferRange_MapBufferType: { GrGLenum target = this->glGpu()->bindBuffer(fIntendedType, this); // Make sure the GL buffer size agrees with fDesc before mapping. if (fGLSizeInBytes != fSizeInBytes) { GL_CALL(BufferData(target, fSizeInBytes, nullptr, fUsage)); } GrGLbitfield writeAccess = GR_GL_MAP_WRITE_BIT; if (kXferCpuToGpu_GrBufferType != fIntendedType) { // TODO: Make this a function parameter. writeAccess |= GR_GL_MAP_INVALIDATE_BUFFER_BIT; } GL_CALL_RET(fMapPtr, MapBufferRange(target, 0, fSizeInBytes, readOnly ? GR_GL_MAP_READ_BIT : writeAccess)); break; } case GrGLCaps::kChromium_MapBufferType: { GrGLenum target = this->glGpu()->bindBuffer(fIntendedType, this); // Make sure the GL buffer size agrees with fDesc before mapping. if (fGLSizeInBytes != fSizeInBytes) { GL_CALL(BufferData(target, fSizeInBytes, nullptr, fUsage)); } GL_CALL_RET(fMapPtr, MapBufferSubData(target, 0, fSizeInBytes, readOnly ? GR_GL_READ_ONLY : GR_GL_WRITE_ONLY)); break; } } fGLSizeInBytes = fSizeInBytes; VALIDATE();}
开发者ID:BertiKarsunke,项目名称:skia,代码行数:59,
示例4: TokenHashvoid CSave::BufferHeader( const char *pname, int size ){ short hashvalue = TokenHash( pname ); if( size > 1 << ( sizeof( short ) * 8 ) ) ALERT( at_error, "CSave :: BufferHeader() size parameter exceeds 'short'!" ); BufferData( ( const char * ) &size, sizeof( short ) ); BufferData( ( const char * ) &hashvalue, sizeof( short ) );}
开发者ID:swmpdg,项目名称:HLEnhanced,代码行数:8,
示例5: assertRlist *RlistFromSplitRegex(const char *string, const char *regex, size_t max_entries, bool allow_blanks){ assert(string); if (!string) { return NULL; } const char *sp = string; size_t entry_count = 0; int start = 0; int end = 0; Rlist *result = NULL; Buffer *buffer = BufferNewWithCapacity(CF_MAXVARSIZE); pcre *rx = CompileRegex(regex); if (rx) { while ((entry_count < max_entries) && StringMatchWithPrecompiledRegex(rx, sp, &start, &end)) { if (end == 0) { break; } BufferClear(buffer); BufferAppend(buffer, sp, start); if (allow_blanks || BufferSize(buffer) > 0) { RlistAppendScalar(&result, BufferData(buffer)); entry_count++; } sp += end; } pcre_free(rx); } if (entry_count < max_entries) { BufferClear(buffer); size_t remaining = strlen(sp); BufferAppend(buffer, sp, remaining); if ((allow_blanks && sp != string) || BufferSize(buffer) > 0) { RlistAppendScalar(&result, BufferData(buffer)); } } BufferDestroy(buffer); return result;}
开发者ID:bahamat,项目名称:cfengine-core,代码行数:57,
示例6: VALIDATEvoid* GrGLBufferImpl::map(GrGpuGL* gpu) { VALIDATE(); SkASSERT(!this->isMapped()); if (0 == fDesc.fID) { fMapPtr = fCPUData; } else { switch (gpu->glCaps().mapBufferType()) { case GrGLCaps::kNone_MapBufferType: VALIDATE(); return NULL; case GrGLCaps::kMapBuffer_MapBufferType: this->bind(gpu); // Let driver know it can discard the old data if (GR_GL_USE_BUFFER_DATA_NULL_HINT || fDesc.fSizeInBytes != fGLSizeInBytes) { fGLSizeInBytes = fDesc.fSizeInBytes; GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, NULL, fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW)); } GR_GL_CALL_RET(gpu->glInterface(), fMapPtr, MapBuffer(fBufferType, GR_GL_WRITE_ONLY)); break; case GrGLCaps::kMapBufferRange_MapBufferType: { this->bind(gpu); // Make sure the GL buffer size agrees with fDesc before mapping. if (fDesc.fSizeInBytes != fGLSizeInBytes) { fGLSizeInBytes = fDesc.fSizeInBytes; GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, NULL, fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW)); } static const GrGLbitfield kAccess = GR_GL_MAP_INVALIDATE_BUFFER_BIT | GR_GL_MAP_WRITE_BIT; GR_GL_CALL_RET(gpu->glInterface(), fMapPtr, MapBufferRange(fBufferType, 0, fGLSizeInBytes, kAccess)); break; } case GrGLCaps::kChromium_MapBufferType: this->bind(gpu); // Make sure the GL buffer size agrees with fDesc before mapping. if (fDesc.fSizeInBytes != fGLSizeInBytes) { fGLSizeInBytes = fDesc.fSizeInBytes; GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, NULL, fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW)); } GR_GL_CALL_RET(gpu->glInterface(), fMapPtr, MapBufferSubData(fBufferType, 0, fGLSizeInBytes, GR_GL_WRITE_ONLY)); break; } } VALIDATE(); return fMapPtr;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:56,
示例7: BufferLengthHandle<Value> MerlinImage::New(const Arguments& args) { HandleScope scope; size_t len = BufferLength(args[0]->ToObject()); node::Buffer *tmp = node::Buffer::New(len); memcpy(BufferData(tmp), BufferData(args[0]->ToObject()), len); MerlinImage* img = new MerlinImage(tmp); img->Wrap(args.This()); return scope.Close(args.This());}
开发者ID:ncb000gt,项目名称:merlin,代码行数:10,
示例8: SkASSERTbool GrGLBufferImpl::updateData(GrGpuGL* gpu, const void* src, size_t srcSizeInBytes) { SkASSERT(!this->isMapped()); VALIDATE(); if (srcSizeInBytes > fDesc.fSizeInBytes) { return false; } if (0 == fDesc.fID) { memcpy(fCPUData, src, srcSizeInBytes); return true; } this->bind(gpu); GrGLenum usage = fDesc.fDynamic ? DYNAMIC_USAGE_PARAM : GR_GL_STATIC_DRAW;#if GR_GL_USE_BUFFER_DATA_NULL_HINT if (fDesc.fSizeInBytes == srcSizeInBytes) { GL_CALL(gpu, BufferData(fBufferType, (GrGLsizeiptr) srcSizeInBytes, src, usage)); } else { // Before we call glBufferSubData we give the driver a hint using // glBufferData with NULL. This makes the old buffer contents // inaccessible to future draws. The GPU may still be processing // draws that reference the old contents. With this hint it can // assign a different allocation for the new contents to avoid // flushing the gpu past draws consuming the old contents. fGLSizeInBytes = fDesc.fSizeInBytes; GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, NULL, usage)); GL_CALL(gpu, BufferSubData(fBufferType, 0, (GrGLsizeiptr) srcSizeInBytes, src)); }#else // Note that we're cheating on the size here. Currently no methods // allow a partial update that preserves contents of non-updated // portions of the buffer (map() does a glBufferData(..size, NULL..)) bool doSubData = false;#if GR_GL_MAC_BUFFER_OBJECT_PERFOMANCE_WORKAROUND static int N = 0; // 128 was chosen experimentally. At 256 a slight hitchiness was noticed // when dragging a Chromium window around with a canvas tab backgrounded. doSubData = 0 == (N % 128); ++N;#endif if (doSubData) { // The workaround is to do a glBufferData followed by glBufferSubData. // Chromium's command buffer may turn a glBufferSubData where the size // exactly matches the buffer size into a glBufferData. So we tack 1 // extra byte onto the glBufferData. fGLSizeInBytes = srcSizeInBytes + 1; GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, NULL, usage)); GL_CALL(gpu, BufferSubData(fBufferType, 0, srcSizeInBytes, src)); } else { fGLSizeInBytes = srcSizeInBytes; GL_CALL(gpu, BufferData(fBufferType, fGLSizeInBytes, src, usage)); }#endif return true;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:54,
示例9: GrAssertbool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) { GrAssert(fBufferID); GrAssert(!isLocked()); if (srcSizeInBytes > this->sizeInBytes()) { return false; } this->bind(); GrGLenum usage = dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW;#if GR_GL_USE_BUFFER_DATA_NULL_HINT if (this->sizeInBytes() == srcSizeInBytes) { GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage)); } else { // Before we call glBufferSubData we give the driver a hint using // glBufferData with NULL. This makes the old buffer contents // inaccessible to future draws. The GPU may still be processing // draws that reference the old contents. With this hint it can // assign a different allocation for the new contents to avoid // flushing the gpu past draws consuming the old contents. GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, this->sizeInBytes(), NULL, usage)); GL_CALL(BufferSubData(GR_GL_ARRAY_BUFFER, 0, srcSizeInBytes, src)); }#else // Note that we're cheating on the size here. Currently no methods // allow a partial update that preserves contents of non-updated // portions of the buffer (lock() does a glBufferData(..size, NULL..)) bool doSubData = false;#if GR_GL_MAC_BUFFER_OBJECT_PERFOMANCE_WORKAROUND static int N = 0; // 128 was chosen experimentally. At 256 a slight hitchiness was noticed // when dragging a Chromium window around with a canvas tab backgrounded. doSubData = 0 == (N % 128); ++N;#endif if (doSubData) { // The workaround is to do a glBufferData followed by glBufferSubData. // Chromium's command buffer may turn a glBufferSubData where the size // exactly matches the buffer size into a glBufferData. So we tack 1 // extra byte onto the glBufferData. GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes + 1, NULL, usage)); GL_CALL(BufferSubData(GR_GL_ARRAY_BUFFER, 0, srcSizeInBytes, src)); } else { GL_CALL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage)); }#endif return true;}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:49,
示例10: RunCmpCommandstatic VersionCmpResult RunCmpCommand(EvalContext *ctx, const char *command, const char *v1, const char *v2, Attributes a, const Promise *pp, PromiseResult *result){ Buffer *expanded_command = BufferNew(); { VarRef *ref_v1 = VarRefParseFromScope("v1", PACKAGES_CONTEXT); EvalContextVariablePut(ctx, ref_v1, v1, CF_DATA_TYPE_STRING, "source=promise"); VarRef *ref_v2 = VarRefParseFromScope("v2", PACKAGES_CONTEXT); EvalContextVariablePut(ctx, ref_v2, v2, CF_DATA_TYPE_STRING, "source=promise"); ExpandScalar(ctx, NULL, PACKAGES_CONTEXT, command, expanded_command); EvalContextVariableRemove(ctx, ref_v1); VarRefDestroy(ref_v1); EvalContextVariableRemove(ctx, ref_v2); VarRefDestroy(ref_v2); } FILE *pfp = a.packages.package_commands_useshell ? cf_popen_sh(BufferData(expanded_command), "w") : cf_popen(BufferData(expanded_command), "w", true); if (pfp == NULL) { cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Can not start package version comparison command '%s'. (cf_popen: %s)", BufferData(expanded_command), GetErrorStr()); *result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL); BufferDestroy(expanded_command); return VERCMP_ERROR; } Log(LOG_LEVEL_VERBOSE, "Executing '%s'", BufferData(expanded_command)); int retcode = cf_pclose(pfp); if (retcode == -1) { cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Error during package version comparison command execution '%s'. (cf_pclose: %s)", BufferData(expanded_command), GetErrorStr()); *result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL); BufferDestroy(expanded_command); return VERCMP_ERROR; } BufferDestroy(expanded_command); return retcode == 0;}
开发者ID:ddurieux,项目名称:core,代码行数:48,
示例11: CreateProgramT// --------------------------------------------------------------------------------------------------------------------bool SimpleSolution::Init(const std::vector<RotationCubeProblem::Vertex>& _vertices, const std::vector<RotationCubeProblem::Index>& _indices, size_t _objectCount){ mObjectCount = _objectCount; mIndexCount = _indices.size(); // Program const char* kUniformNames[] = { "gTex", nullptr }; mProgram = CreateProgramT("cubes_gl_simple_vs.glsl", "cubes_gl_simple_fs.glsl", kUniformNames, &mUniformLocation); if (mProgram == 0) { console::warn("Unable to initialize solution '%s', shader compilation/linking failed.", GetName().c_str()); return false; } glGenVertexArrays(1, &mVertexArrayObject); glBindVertexArray(mVertexArrayObject); GLuint UB0 = glGetUniformBlockIndex(mProgram, "UB0"); glUniformBlockBinding(mProgram, UB0, 0); GLuint UB1 = glGetUniformBlockIndex(mProgram, "UB1"); glUniformBlockBinding(mProgram, UB1, 1); GLint uniformBufferOffsetAlignment = 0; glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uniformBufferOffsetAlignment); mMatrixStride = iceil(sizeof(Matrix), uniformBufferOffsetAlignment); glGenBuffers(1, &mVertexBuffer); glGenBuffers(1, &mIndexBuffer); glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); BufferData(GL_ARRAY_BUFFER, _vertices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer); BufferData(GL_ELEMENT_ARRAY_BUFFER, _indices, GL_STATIC_DRAW); glGenBuffers(1, &mUniformBuffer0); glGenBuffers(1, &mUniformBuffer1); glGenVertexArrays(1, &mVAO); glBindVertexArray(mVAO); mStorage.resize(mMatrixStride); return glGetError() == GL_NO_ERROR;}
开发者ID:yjaelex,项目名称:glperf,代码行数:49,
示例12: assertchar *VarRefToString(const VarRef *ref, bool qualified){ assert(ref->lval); Buffer *buf = BufferNew(); if (qualified && VarRefIsQualified(ref)) { const char *ns = ref->ns ? ref->ns : "default"; BufferAppend(buf, ns, strlen(ns)); BufferAppend(buf, ":", sizeof(char)); BufferAppend(buf, ref->scope, strlen(ref->scope)); BufferAppend(buf, ".", sizeof(char)); } BufferAppend(buf, ref->lval, strlen(ref->lval)); for (size_t i = 0; i < ref->num_indices; i++) { BufferAppend(buf, "[", sizeof(char)); BufferAppend(buf, ref->indices[i], strlen(ref->indices[i])); BufferAppend(buf, "]", sizeof(char)); } char *var_string = xstrdup(BufferData(buf)); BufferDestroy(&buf); return var_string;}
开发者ID:nperron,项目名称:core,代码行数:28,
示例13: ShowContextsFormattedstatic void ShowContextsFormatted(EvalContext *ctx){ ClassTableIterator *iter = EvalContextClassTableIteratorNewGlobal(ctx, NULL, true, true); Class *cls = NULL; Seq *seq = SeqNew(1000, free); while ((cls = ClassTableIteratorNext(iter))) { char *class_name = ClassRefToString(cls->ns, cls->name); StringSet *tagset = EvalContextClassTags(ctx, cls->ns, cls->name); Buffer *tagbuf = StringSetToBuffer(tagset, ','); char *line; xasprintf(&line, "%-60s %-40s", class_name, BufferData(tagbuf)); SeqAppend(seq, line); BufferDestroy(tagbuf); free(class_name); } SeqSort(seq, (SeqItemComparator)strcmp, NULL); printf("%-60s %-40s/n", "Class name", "Meta tags"); for (size_t i = 0; i < SeqLength(seq); i++) { const char *context = SeqAt(seq, i); printf("%s/n", context); } SeqDestroy(seq); ClassTableIteratorDestroy(iter);}
开发者ID:tzz,项目名称:core,代码行数:35,
示例14: ShowVariablesFormattedstatic void ShowVariablesFormatted(EvalContext *ctx){ VariableTableIterator *iter = EvalContextVariableTableIteratorNew(ctx, NULL, NULL, NULL); Variable *v = NULL; Seq *seq = SeqNew(2000, free); while ((v = VariableTableIteratorNext(iter))) { char *varname = VarRefToString(v->ref, true); Writer *w = StringWriter(); switch (DataTypeToRvalType(v->type)) { case RVAL_TYPE_CONTAINER: JsonWriteCompact(w, RvalContainerValue(v->rval)); break; default: RvalWrite(w, v->rval); } const char *var_value; if (StringIsPrintable(StringWriterData(w))) { var_value = StringWriterData(w); } else { var_value = "<non-printable>"; } StringSet *tagset = EvalContextVariableTags(ctx, v->ref); Buffer *tagbuf = StringSetToBuffer(tagset, ','); char *line; xasprintf(&line, "%-40s %-60s %-40s", varname, var_value, BufferData(tagbuf)); SeqAppend(seq, line); BufferDestroy(tagbuf); WriterClose(w); free(varname); } SeqSort(seq, (SeqItemComparator)strcmp, NULL); printf("%-40s %-60s %-40s/n", "Variable name", "Variable value", "Meta tags"); for (size_t i = 0; i < SeqLength(seq); i++) { const char *variable = SeqAt(seq, i); printf("%s/n", variable); } SeqDestroy(seq); VariableTableIteratorDestroy(iter);}
开发者ID:cstroe,项目名称:core,代码行数:60,
示例15: setup_quad_index_bufferstatic uint32_t setup_quad_index_buffer(const GrGLInterface* gl) { static const int kMaxQuads = 1;//1 << 12; // max possible: (1 << 14) - 1; GR_STATIC_ASSERT(4 * kMaxQuads <= 65535); static const uint16_t kPattern[] = { 0, 1, 2, 0, 2, 3 }; static const int kPatternSize = 6; static const int kVertCount = 4; static const int kIndicesCount = kPatternSize * kMaxQuads; int size = kPatternSize * kMaxQuads * sizeof(uint16_t); uint16_t* data = SkNEW_ARRAY(uint16_t, kMaxQuads * kPatternSize); for (int i = 0; i < kMaxQuads; ++i) { int baseIdx = i * kPatternSize; uint16_t baseVert = (uint16_t)(i * kVertCount); for (int j = 0; j < kPatternSize; ++j) { data[baseIdx+j] = baseVert + kPattern[j]; } } GrGLuint quadIBO; GR_GL_CALL(gl, GenBuffers(1, &quadIBO)); GR_GL_CALL(gl, BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, quadIBO)); GR_GL_CALL(gl, BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, size, data, GR_GL_STATIC_DRAW)); SkDELETE_ARRAY(data); return kIndicesCount;}
开发者ID:ReyCG,项目名称:skia,代码行数:27,
示例16: test_extract_reference_static void test_extract_reference_(const char *scalar, bool expect_success, const char *outer, const char *inner){ Buffer *b = BufferNew(); size_t len = strlen(scalar); bool success = ExtractScalarReference(b, scalar, len, false); assert_true(success == expect_success); assert_string_equal(outer, BufferData(b)); BufferClear(b); success = ExtractScalarReference(b, scalar, len, true); assert_true(success == expect_success); assert_string_equal(inner, BufferData(b)); BufferDestroy(b);}
开发者ID:GregorioDiStefano,项目名称:core,代码行数:16,
示例17: GrAssertbool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) { GrAssert(fBufferID); GrAssert(!isLocked()); if (srcSizeInBytes > size()) { return false; } this->bind(); GrGLenum usage = dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW; if (size() == srcSizeInBytes) { GR_GL(BufferData(GR_GL_ARRAY_BUFFER, srcSizeInBytes, src, usage)); } else { GR_GL(BufferData(GR_GL_ARRAY_BUFFER, size(), NULL, usage)); GR_GL(BufferSubData(GR_GL_ARRAY_BUFFER, 0, srcSizeInBytes, src)); } return true;}
开发者ID:ACSOP,项目名称:android_external_skia,代码行数:16,
示例18: BufferDatavoid GLEmitter::Draw(RenderPhase phase, GLShader& shader) const{ if(materialPhase != phase) return; BufferData(); shader.Bind(); shader.SetTexture(0, texture); glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); glVertexAttribPointer(shader.attributeLocations[0], 4, GL_FLOAT, GL_FALSE, 4 * 10, 0); glVertexAttribPointer(shader.attributeLocations[1], 4, GL_FLOAT, GL_FALSE, 4 * 10, (GLvoid*)(4 * 4)); glVertexAttribPointer(shader.attributeLocations[2], 2, GL_FLOAT, GL_FALSE, 4 * 10, (GLvoid*)(8 * 4)); glEnableVertexAttribArray(shader.attributeLocations[0]); glEnableVertexAttribArray(shader.attributeLocations[1]); glEnableVertexAttribArray(shader.attributeLocations[2]); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]); glDrawElements(GL_TRIANGLES, 6 * numParticles, GL_UNSIGNED_SHORT, 0); glDisableVertexAttribArray(shader.attributeLocations[0]); glDisableVertexAttribArray(shader.attributeLocations[1]); glDisableVertexAttribArray(shader.attributeLocations[2]); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glUseProgram(0);}
开发者ID:Vavassor,项目名称:meteor,代码行数:31,
示例19: sizeofvoid GLCpuPosInstancedArraysBench::setupSingleVbo(const GrGLInterface* gl, const SkMatrix* viewMatrices) { // Constants for our various shader programs Vertex vertices[kVerticesPerTri * kNumTri]; for (uint32_t i = 0; i < kNumTri; i++) { Vertex* v = &vertices[i * kVerticesPerTri]; v[0].fPositions.set(-1.0f, -1.0f); v[1].fPositions.set( 1.0f, -1.0f); v[2].fPositions.set( 1.0f, 1.0f); SkPoint* position = reinterpret_cast<SkPoint*>(v); viewMatrices[i].mapPointsWithStride(position, sizeof(Vertex), kVerticesPerTri); // set colors float color = i == kNumTri - 1 ? 1.0f : 0.0f; for (uint32_t j = 0; j < kVerticesPerTri; j++) { uint32_t offset = 0; v->fColors[offset++] = color; v->fColors[offset++] = 0.0f; v->fColors[offset++] = 0.0f; v++; } } GrGLuint vbo; // setup VBO GR_GL_CALL(gl, GenBuffers(1, &vbo)); GR_GL_CALL(gl, BindBuffer(GR_GL_ARRAY_BUFFER, vbo)); GR_GL_CALL(gl, EnableVertexAttribArray(0)); GR_GL_CALL(gl, EnableVertexAttribArray(1)); GR_GL_CALL(gl, VertexAttribPointer(0, 2, GR_GL_FLOAT, GR_GL_FALSE, sizeof(Vertex), (GrGLvoid*)0)); GR_GL_CALL(gl, VertexAttribPointer(1, 3, GR_GL_FLOAT, GR_GL_FALSE, sizeof(Vertex), (GrGLvoid*)(sizeof(SkPoint)))); GR_GL_CALL(gl, BufferData(GR_GL_ARRAY_BUFFER, sizeof(vertices), vertices, GR_GL_STATIC_DRAW)); fBuffers.push_back(vbo);}
开发者ID:johnkit,项目名称:skia,代码行数:35,
示例20: test_zeroBufferstatic void test_zeroBuffer(void){ char *element0 = xstrdup("element0"); unsigned int element0size = strlen(element0); const char *element0pointer = NULL; Buffer *buffer = BufferNew(); assert_int_equal(element0size, BufferSet(buffer, element0, element0size)); element0pointer = buffer->buffer; assert_int_equal(element0size, buffer->used); assert_int_equal(element0size, BufferSize(buffer)); BufferZero(buffer); assert_int_equal(DEFAULT_BUFFER_SIZE, buffer->capacity); assert_int_equal(0, buffer->used); assert_int_equal(0, BufferSize(buffer)); const char *data = BufferData(buffer); assert_string_equal(data, ""); assert_true(element0pointer == buffer->buffer); BufferZero(NULL); assert_int_equal(0, BufferDestroy(&buffer)); /* * Release the resources */ BufferDestroy(&buffer); free (element0);}
开发者ID:lpefferkorn,项目名称:core,代码行数:26,
示例21: SaveBufferCallbackstatic bool SaveBufferCallback(const char *dest_filename, void *param, NewLineMode new_line_mode){ FILE *fp = safe_fopen(dest_filename, (new_line_mode == NewLineMode_Native) ? "wt" : "w"); if (!fp) { Log(LOG_LEVEL_ERR, "Unable to open destination file '%s' for writing. (fopen: %s)", dest_filename, GetErrorStr()); return false; } Buffer *output_buffer = param; size_t bytes_written = fwrite(BufferData(output_buffer), sizeof(char), BufferSize(output_buffer), fp); if (bytes_written != BufferSize(output_buffer)) { Log(LOG_LEVEL_ERR, "Error writing to output file '%s' when writing. %zd bytes written but expected %d. (fclose: %s)", dest_filename, bytes_written, BufferSize(output_buffer), GetErrorStr()); fclose(fp); return false; } if (fclose(fp) == -1) { Log(LOG_LEVEL_ERR, "Unable to close file '%s' after writing. (fclose: %s)", dest_filename, GetErrorStr()); return false; } return true;}
开发者ID:lra,项目名称:core,代码行数:30,
示例22: BufferSearchAndReplace// returns NULL on success, otherwise an error stringconst char* BufferSearchAndReplace(Buffer *buffer, const char *pattern, const char *substitute, const char *options){ assert(buffer); assert(pattern); assert(substitute); assert(options); int err; pcre_wrap_job *job = pcre_wrap_compile(pattern, substitute, options, &err); if (job == NULL) { return pcre_wrap_strerror(err); } size_t length = BufferSize(buffer); char *result; if (0 > (err = pcre_wrap_execute(job, (char*)BufferData(buffer), length, &result, &length))) { return pcre_wrap_strerror(err); } BufferSet(buffer, result, length); free(result); pcre_wrap_free_job(job); return NULL;}
开发者ID:GregorioDiStefano,项目名称:core,代码行数:29,
示例23: test_generic_interfacestatic void test_generic_interface(void){ /* * This test might seem short, but it is intentional. * All the parsing tests should be implemented directly * on the corresponding parser test. Keep this test as * lean as possible. */ IPAddress *address = NULL; Buffer *buffer = NULL; buffer = BufferNew(); assert_true(buffer != NULL); BufferSet(buffer, "127.0.0.1", strlen("127.0.0.1")); address = IPAddressNew(buffer); assert_true(address != NULL); assert_int_equal(IP_ADDRESS_TYPE_IPV4, IPAddressType(address)); assert_string_equal("127.0.0.1", BufferData(IPAddressGetAddress(address))); assert_int_equal(0, IPAddressGetPort(address)); assert_int_equal(0, IPAddressDestroy(&address)); BufferSet(buffer, "127.0.0.1:8080", strlen("127.0.0.1:8080")); address = IPAddressNew(buffer); assert_true(address != NULL); assert_int_equal(IP_ADDRESS_TYPE_IPV4, IPAddressType(address)); assert_string_equal("127.0.0.1", BufferData(IPAddressGetAddress(address))); assert_int_equal(8080, IPAddressGetPort(address)); assert_int_equal(0, IPAddressDestroy(&address)); BufferSet(buffer, "0:1:2:3:4:5:6:7", strlen("0:1:2:3:4:5:6:7")); address = IPAddressNew(buffer); assert_true(address != NULL); assert_int_equal(IP_ADDRESS_TYPE_IPV6, IPAddressType(address)); assert_string_equal("0:1:2:3:4:5:6:7", BufferData(IPAddressGetAddress(address))); assert_int_equal(0, IPAddressGetPort(address)); assert_int_equal(0, IPAddressDestroy(&address)); BufferSet(buffer, "[0:1:2:3:4:5:6:7]:9090", strlen("[0:1:2:3:4:5:6:7]:9090")); address = IPAddressNew(buffer); assert_true(address != NULL); assert_int_equal(IP_ADDRESS_TYPE_IPV6, IPAddressType(address)); assert_string_equal("0:1:2:3:4:5:6:7", BufferData(IPAddressGetAddress(address))); assert_int_equal(9090, IPAddressGetPort(address)); assert_int_equal(0, IPAddressDestroy(&address)); BufferDestroy(buffer);}
开发者ID:GregorioDiStefano,项目名称:core,代码行数:47,
示例24: BufferRewritevoid BufferRewrite(Buffer *buffer, BufferFilterFn filter, const bool invert){ assert(buffer); Buffer *rewrite = BufferFilter(buffer, filter, invert); BufferSet(buffer, BufferData(rewrite), BufferSize(rewrite)); BufferDestroy(rewrite);}
开发者ID:GregorioDiStefano,项目名称:core,代码行数:8,
注:本文中的BufferData函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BufferDestroy函数代码示例 C++ Buffer函数代码示例 |