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


C++ IsContextLost函数代码示例

本文整理汇总了C++中IsContextLost函数的典型用法代码示例。如果您正苦于以下问题:C++ IsContextLost函数的具体用法?C++ IsContextLost怎么用?C++ IsContextLost使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了IsContextLost函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LastColorAttachmentEnum

void
WebGL2Context::ReadBuffer(GLenum mode)
{
    if (IsContextLost())
        return;

    const bool isColorAttachment = (mode >= LOCAL_GL_COLOR_ATTACHMENT0 &&
                                    mode <= LastColorAttachmentEnum());

    if (mode != LOCAL_GL_NONE && mode != LOCAL_GL_BACK && !isColorAttachment) {
        ErrorInvalidEnum("readBuffer: `mode` must be one of NONE, BACK, or "
                         "COLOR_ATTACHMENTi. Was %s",
                         EnumName(mode));
        return;
    }

    if (mBoundReadFramebuffer) {
        if (mode != LOCAL_GL_NONE &&
            !isColorAttachment)
        {
            ErrorInvalidOperation("readBuffer: If READ_FRAMEBUFFER is non-null, `mode` "
                                  "must be COLOR_ATTACHMENTi or NONE. Was %s",
                                  EnumName(mode));
            return;
        }

        MakeContextCurrent();
        gl->fReadBuffer(mode);
        return;
    }

    // Operating on the default framebuffer.
    if (mode != LOCAL_GL_NONE &&
        mode != LOCAL_GL_BACK)
    {
        ErrorInvalidOperation("readBuffer: If READ_FRAMEBUFFER is null, `mode`"
                              " must be BACK or NONE. Was %s",
                              EnumName(mode));
        return;
    }

    gl->Screen()->SetReadBuffer(mode);
}
开发者ID:Think-Software,项目名称:newtab-dev,代码行数:43,代码来源:WebGL2ContextFramebuffers.cpp

示例2: GetStateTrackingSlot

void
WebGLContext::Enable(GLenum cap)
{
    if (IsContextLost())
        return;

    if (!ValidateCapabilityEnum(cap, "enable"))
        return;

    realGLboolean* trackingSlot = GetStateTrackingSlot(cap);

    if (trackingSlot)
    {
        *trackingSlot = 1;
    }

    MakeContextCurrent();
    gl->fEnable(cap);
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:19,代码来源:WebGLContextState.cpp

示例3: GetQuerySlotByTarget

void
WebGL2Context::EndQuery(GLenum target)
{
    if (IsContextLost())
        return;

    if (!ValidateQueryTarget(target, "endQuery"))
        return;

    WebGLRefPtr<WebGLQuery>& querySlot = GetQuerySlotByTarget(target);
    WebGLQuery* activeQuery = querySlot.get();

    if (!activeQuery || target != activeQuery->mType)
    {
        /* From GLES's EXT_occlusion_query_boolean:
         *     marks the end of the sequence of commands to be tracked for the
         *     query type given by <target>. The active query object for
         *     <target> is updated to indicate that query results are not
         *     available, and the active query object name for <target> is reset
         *     to zero. When the commands issued prior to EndQueryEXT have
         *     completed and a final query result is available, the query object
         *     active when EndQueryEXT is called is updated by the GL. The query
         *     object is updated to indicate that the query results are
         *     available and to contain the query result. If the active query
         *     object name for <target> is zero when EndQueryEXT is called, the
         *     error INVALID_OPERATION is generated.
         */
        ErrorInvalidOperation("endQuery: There is no active query of type %s.",
                              GetQueryTargetEnumString(target));
        return;
    }

    MakeContextCurrent();

    if (target == LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) {
        gl->fEndQuery(LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
    } else {
        gl->fEndQuery(SimulateOcclusionQueryTarget(gl, target));
    }

    UpdateBoundQuery(target, nullptr);
    NS_DispatchToCurrentThread(new WebGLQuery::AvailableRunnable(activeQuery));
}
开发者ID:Nazi-Nigger,项目名称:gecko-dev,代码行数:43,代码来源:WebGL2ContextQueries.cpp

示例4: ErrorInvalidEnumInfo

void
WebGL2Context::GetInternalformatParameter(JSContext* cx, GLenum target,
                                          GLenum internalformat, GLenum pname,
                                          JS::MutableHandleValue retval,
                                          ErrorResult& rv)
{
  if (IsContextLost())
    return;

  if (target != LOCAL_GL_RENDERBUFFER) {
    return ErrorInvalidEnumInfo("getInternalfomratParameter: target must be "
                                "RENDERBUFFER. Was:", target);
  }

  // GL_INVALID_ENUM is generated if internalformat is not color-,
  // depth-, or stencil-renderable.
  // TODO: When format table queries lands.

  if (pname != LOCAL_GL_SAMPLES) {
    return ErrorInvalidEnumInfo("getInternalformatParameter: pname must be SAMPLES. "
                                "Was:", pname);
  }

  GLint* samples = nullptr;
  GLint sampleCount = 0;
  gl->fGetInternalformativ(LOCAL_GL_RENDERBUFFER, internalformat,
                           LOCAL_GL_NUM_SAMPLE_COUNTS, 1, &sampleCount);
  if (sampleCount > 0) {
    samples = new GLint[sampleCount];
    gl->fGetInternalformativ(LOCAL_GL_RENDERBUFFER, internalformat, LOCAL_GL_SAMPLES,
                             sampleCount, samples);
  }

  JSObject* obj = dom::Int32Array::Create(cx, this, sampleCount, samples);
  if (!obj) {
    rv = NS_ERROR_OUT_OF_MEMORY;
  }

  delete[] samples;

  retval.setObjectOrNull(obj);
}
开发者ID:Danielzac,项目名称:gecko-dev,代码行数:42,代码来源:WebGL2ContextRenderbuffers.cpp

示例5: ErrorOutOfMemory

void
WebGLContext::BufferDataT(GLenum target,
                          const BufferT& data,
                          GLenum usage)
{
    if (IsContextLost())
        return;

    if (!ValidateBufferTarget(target, "bufferData"))
        return;

    const WebGLRefPtr<WebGLBuffer>& bufferSlot = GetBufferSlotByTarget(target);

    data.ComputeLengthAndData();

    // Careful: data.Length() could conceivably be any uint32_t, but GLsizeiptr
    // is like intptr_t.
    if (!CheckedInt<GLsizeiptr>(data.Length()).isValid())
        return ErrorOutOfMemory("bufferData: bad size");

    if (!ValidateBufferUsageEnum(usage, "bufferData: usage"))
        return;

    WebGLBuffer* boundBuffer = bufferSlot.get();

    if (!boundBuffer)
        return ErrorInvalidOperation("bufferData: no buffer bound!");

    MakeContextCurrent();
    InvalidateBufferFetching();

    GLenum error = CheckedBufferData(target, data.Length(), data.Data(), usage);

    if (error) {
        GenerateWarning("bufferData generated error %s", ErrorName(error));
        return;
    }

    boundBuffer->SetByteLength(data.Length());
    if (!boundBuffer->ElementArrayCacheBufferData(data.Data(), data.Length()))
        return ErrorOutOfMemory("bufferData: out of memory");
}
开发者ID:Manishearth,项目名称:gecko-dev,代码行数:42,代码来源:WebGLContextBuffers.cpp

示例6: ErrorInvalidValue

void
WebGL2Context::BindSampler(GLuint unit, WebGLSampler* sampler)
{
    if (IsContextLost())
        return;

    if (!ValidateObjectAllowDeletedOrNull("bindSampler", sampler))
        return;

    if (GLint(unit) >= mGLMaxTextureUnits)
        return ErrorInvalidValue("bindSampler: unit must be < %d", mGLMaxTextureUnits);

    if (sampler && sampler->IsDeleted())
        return ErrorInvalidOperation("bindSampler: binding deleted sampler");

    WebGLContextUnchecked::BindSampler(unit, sampler);
    InvalidateResolveCacheForTextureWithTexUnit(unit);

    mBoundSamplers[unit] = sampler;
}
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:20,代码来源:WebGL2ContextSamplers.cpp

示例7: ErrorInvalidOperation

void
WebGL2Context::SamplerParameterfv(WebGLSampler* sampler, GLenum pname, const dom::Float32Array& param)
{
    if (IsContextLost())
        return;

    if (!sampler || sampler->IsDeleted())
        return ErrorInvalidOperation("samplerParameterfv: invalid sampler");

    param.ComputeLengthAndData();
    if (param.Length() < 1)
        return /* TODO(djg): Error message */;

    /* TODO(djg): All of these calls in ES3 only take 1 param */
    if (!ValidateSamplerParameterParams(pname, WebGLIntOrFloat(param.Data()[0]), "samplerParameterfv"))
        return;

    sampler->SamplerParameter1f(pname, param.Data()[0]);
    WebGLContextUnchecked::SamplerParameterfv(sampler, pname, param.Data());
}
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:20,代码来源:WebGL2ContextSamplers.cpp

示例8: ErrorInvalidOperation

void
WebGLContext::EndQuery(GLenum target, const char* funcName)
{
    if (!funcName) {
        funcName = "endQuery";
    }

    if (IsContextLost())
        return;

    const auto& slot = ValidateQuerySlotByTarget(funcName, target);
    if (!slot)
        return;

    const auto& query = *slot;
    if (!query)
        return ErrorInvalidOperation("%s: Query target not active.", funcName);

    query->EndQuery();
}
开发者ID:artines1,项目名称:gecko-dev,代码行数:20,代码来源:WebGL2ContextQueries.cpp

示例9:

void
WebGL2Context::DeleteSampler(WebGLSampler* sampler)
{
    if (IsContextLost())
        return;

    if (!ValidateObjectAllowDeletedOrNull("deleteSampler", sampler))
        return;

    if (!sampler || sampler->IsDeleted())
        return;

    for (int n = 0; n < mGLMaxTextureUnits; n++) {
        if (mBoundSamplers[n] == sampler) {
            mBoundSamplers[n] = nullptr;
        }
    }

    sampler->RequestDelete();
}
开发者ID:Nazi-Nigger,项目名称:gecko-dev,代码行数:20,代码来源:WebGL2ContextSamplers.cpp

示例10: ErrorInvalidOperation

void
WebGL2Context::PauseTransformFeedback()
{
    if (IsContextLost())
        return;

    WebGLTransformFeedback* tf = mBoundTransformFeedback;
    MOZ_ASSERT(tf);
    if (!tf)
        return;

    if (!tf->mIsActive || tf->mIsPaused) {
        return ErrorInvalidOperation("%s: transform feedback is not active or is paused",
                                     "pauseTransformFeedback");
    }

    MakeContextCurrent();
    gl->fPauseTransformFeedback();
    tf->mIsPaused = true;
}
开发者ID:Nazi-Nigger,项目名称:gecko-dev,代码行数:20,代码来源:WebGL2ContextTransformFeedback.cpp

示例11: InvalidateBufferFetching

void
WebGLContext::VertexAttribDivisor(GLuint index, GLuint divisor)
{
    if (IsContextLost())
        return;

    if (!ValidateAttribIndex(index, "vertexAttribDivisor"))
        return;

    MOZ_ASSERT(mBoundVertexArray);

    WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index];
    vd.mDivisor = divisor;

    InvalidateBufferFetching();

    MakeContextCurrent();

    gl->fVertexAttribDivisor(index, divisor);
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:20,代码来源:WebGLContextVertices.cpp

示例12: ErrorInvalidValue

/* This doesn't belong here. It's part of state querying */
void
WebGL2Context::GetIndexedParameter(GLenum target, GLuint index,
                                   dom::Nullable<dom::OwningWebGLBufferOrLongLong>& retval)
{
    retval.SetNull();
    if (IsContextLost())
        return;

    GLint64 data = 0;

    MakeContextCurrent();

    switch (target) {
    case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
        if (index >= mGLMaxTransformFeedbackSeparateAttribs)
            return ErrorInvalidValue("getIndexedParameter: index should be less than "
                                     "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS");

        retval.SetValue().SetAsWebGLBuffer() =
            mBoundTransformFeedbackBuffers[index].get();
        return;

    case LOCAL_GL_UNIFORM_BUFFER_BINDING:
        if (index >= mGLMaxUniformBufferBindings)
            return ErrorInvalidValue("getIndexedParameter: index should be than "
                                     "MAX_UNIFORM_BUFFER_BINDINGS");

        retval.SetValue().SetAsWebGLBuffer() = mBoundUniformBuffers[index].get();
        return;

    case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_START:
    case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
    case LOCAL_GL_UNIFORM_BUFFER_START:
    case LOCAL_GL_UNIFORM_BUFFER_SIZE:
        gl->fGetInteger64i_v(target, index, &data);
        retval.SetValue().SetAsLongLong() = data;
        return;
    }

    ErrorInvalidEnumInfo("getIndexedParameter: target", target);
}
开发者ID:bolt-dev,项目名称:gecko-dev,代码行数:42,代码来源:WebGL2ContextUniforms.cpp

示例13: ErrorInvalidEnum

void
WebGL2Context::ClearBufferuiv(GLenum buffer, GLint drawBuffer, const Uint32Arr& src,
                              GLuint srcElemOffset)
{
    const char funcName[] = "clearBufferuiv";
    if (IsContextLost())
        return;

    if (buffer != LOCAL_GL_COLOR)
        return ErrorInvalidEnum("%s: buffer must be COLOR.", funcName);

    if (!ValidateClearBuffer(funcName, buffer, drawBuffer, src.elemCount, srcElemOffset,
                             LOCAL_GL_UNSIGNED_INT))
    {
        return;
    }

    ScopedDrawCallWrapper wrapper(*this);
    const auto ptr = src.elemBytes + srcElemOffset;
    gl->fClearBufferuiv(buffer, drawBuffer, ptr);
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:21,代码来源:WebGL2ContextMRTs.cpp

示例14: WebGLExtensionID

void
WebGLContext::GetSupportedExtensions(dom::Nullable< nsTArray<nsString> >& retval,
                                     dom::CallerType callerType)
{
    retval.SetNull();
    if (IsContextLost())
        return;

    nsTArray<nsString>& arr = retval.SetValue();

    for (size_t i = 0; i < size_t(WebGLExtensionID::Max); i++) {
        const auto extension = WebGLExtensionID(i);
        if (extension == WebGLExtensionID::MOZ_debug)
            continue; // Hide MOZ_debug from this list.

        if (IsExtensionSupported(callerType, extension)) {
            const char* extStr = GetExtensionString(extension);
            arr.AppendElement(NS_ConvertUTF8toUTF16(extStr));
        }
    }
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:21,代码来源:WebGLContextExtensions.cpp

示例15: ErrorInvalidValue

void
WebGLContext::Clear(GLbitfield mask)
{
    const char funcName[] = "clear";

    if (IsContextLost())
        return;

    MakeContextCurrent();

    uint32_t m = mask & (LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT | LOCAL_GL_STENCIL_BUFFER_BIT);
    if (mask != m)
        return ErrorInvalidValue("%s: invalid mask bits", funcName);

    if (mask == 0) {
        GenerateWarning("Calling gl.clear(0) has no effect.");
    } else if (mRasterizerDiscardEnabled) {
        GenerateWarning("Calling gl.clear() with RASTERIZER_DISCARD enabled has no effects.");
    }

    if (mBoundDrawFramebuffer) {
        if (!mBoundDrawFramebuffer->ValidateAndInitAttachments(funcName))
            return;

        gl->fClear(mask);
        return;
    } else {
        ClearBackbufferIfNeeded();
    }

    // Ok, we're clearing the default framebuffer/screen.
    {
        ScopedMaskWorkaround autoMask(*this);
        gl->fClear(mask);
    }

    Invalidate();
    mShouldPresent = true;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:39,代码来源:WebGLContextFramebufferOperations.cpp


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