コード例 #1
0
void setXSwapInterval(int interval)
{
    if(glXSwapIntervalEXT)
    {
        DENG2_ASSERT(de::CanvasWindow::mainExists());
        glXSwapIntervalEXT(QX11Info::display(), de::CanvasWindow::main().canvas().winId(), interval);
    }
}
コード例 #2
0
 void attach(GLShader const *shader)
 {
     DENG2_ASSERT(shader->isReady());
     alloc();
     glAttachShader(name, shader->glName());
     LIBGUI_ASSERT_GL_OK();
     shaders.insert(holdRef(shader));
 }
コード例 #3
0
    void assetAvailabilityChanged(String const &identifier, filesys::AssetObserver::Event event) override
    {
        LOG_RES_MSG("Model asset \"%s\" is now %s")
                << identifier
                << (event == filesys::AssetObserver::Added? "available" :
                                                            "unavailable");

        if (event == filesys::AssetObserver::Added)
        {
            bank.add(identifier, App::asset(identifier).absolutePath("path"));

            // Begin loading the model right away.
            bank.load(identifier);
        }
        else
        {
            auto const &model = bank.model<render::Model const>(identifier);

            // Unload programs used by the various rendering passes.
            for (auto const &pass : model.passes)
            {
                DENG2_ASSERT(pass.program);
                unloadProgram(*static_cast<Program *>(pass.program));
            }

            // Alternatively, the entire model may be using a single program.
            if (model.passes.isEmpty())
            {
                if (model.program())
                {
                    unloadProgram(*static_cast<Program *>(model.program()));
                }
            }
            else
            {
                DENG2_ASSERT(!model.program());
            }

            bank.remove(identifier);
            {
                DENG2_GUARD(pendingModels);
                pendingModels.value.remove(identifier);
            }
        }
    }
コード例 #4
0
void GLSubBuffer::setVertices(dsize count, void const *data)
{
    DENG2_ASSERT(count <= d->hostRange.size());

    dsize const elementSize = d->format.first->stride;
    d->host->setData(elementSize * d->hostRange.start, data,
                     elementSize * count);
    d->size = count;
}
コード例 #5
0
angle_t Mobj_AimAtTarget(mobj_t *mob)
{
    DENG2_ASSERT(mob);
    if(auto const *target = mob->target)
    {
        return Mobj_AimAtPoint2(mob, target->origin, target->flags & MF_SHADOW);
    }
    return mob->angle;
}
コード例 #6
0
void NativeFile::close()
{
    DENG2_GUARD(this);

    flush();
    DENG2_ASSERT(!d->out);

    d->closeInput();
}
コード例 #7
0
void OperatorExpression::verifyAssignable(Value *value)
{
    DENG2_ASSERT(value != 0);
    if (!dynamic_cast<RefValue *>(value))
    {
        throw NotAssignableError("OperatorExpression::verifyAssignable",
            "Cannot assign to: " + value->asText());
    }
}
コード例 #8
0
void GLShader::compile(Type shaderType, IByteArray const &source)
{
#ifndef LIBGUI_GLES2
    // With non-ES OpenGL, ignore the precision attributes.
    static QByteArray prefix("#ifndef GL_ES\n#define lowp\n#define mediump\n#define highp\n#endif\n");
#endif

    DENG2_ASSERT(shaderType == Vertex || shaderType == Fragment);

    setState(NotReady);

    // Keep a copy of the source for possible recompilation.
    d->compiledSource = source;

    d->type = shaderType;
    d->alloc();

    // Additional predefined symbols for the shader.
    QByteArray predefs;
    if (shaderType == Vertex)
    {
        predefs = QByteArray("#define DENG_VERTEX_SHADER\n");
    }
    else
    {
        predefs = QByteArray("#define DENG_FRAGMENT_SHADER\n");
    }

    // Prepare the shader source. This would be the time to substitute any
    // remaining symbols in the shader source.
    Block src = prefixToSource(source, prefix + predefs);

    char const *srcPtr = src.constData();
    LIBGUI_GL.glShaderSource(d->name, 1, &srcPtr, 0);

    LIBGUI_GL.glCompileShader(d->name);

    // Check the compilation status.
    GLint status;
    LIBGUI_GL.glGetShaderiv(d->name, GL_COMPILE_STATUS, &status);
    if (!status)
    {
        dint32 logSize = 0;
        dint32 count = 0;
        LIBGUI_GL.glGetShaderiv(d->name, GL_INFO_LOG_LENGTH, &logSize);

        Block log(logSize);
        LIBGUI_GL.glGetShaderInfoLog(d->name, logSize, &count, reinterpret_cast<GLchar *>(log.data()));

        throw CompilerError("GLShader::compile",
                            "Compilation of " + String(d->type == Fragment? "fragment" : "vertex") +
                            " shader failed:\n" + log);
    }

    setState(Ready);
}
コード例 #9
0
LogSink &LogSink::operator << (LogEntry const &entry)
{
    DENG2_ASSERT(formatter());

    foreach (String line, formatter()->logEntryToTextLines(entry))
    {
        *this << line;
    }
    return *this;
}
コード例 #10
0
ファイル: smoother.cpp プロジェクト: gnuzinho/Doomsday-Engine
dd_bool Smoother_Evaluate(Smoother const *sm, coord_t *xyz)
{
    DENG2_ASSERT(sm);
    pos_t const *past = &sm->past;
    pos_t const *now = &sm->now;

    if(!Smoother_IsValid(sm))
        return false;

    if(sm->at < past->time)
    {
        // Before our time.
        xyz[VX] = past->xyz[VX];
        xyz[VY] = past->xyz[VY];
        xyz[VZ] = past->xyz[VZ];
        //LOGDEV_XVERBOSE("Smoother %p falling behind") << sm;
        return true;
    }
    //DENG_ASSERT(sm->at <= now->time);
    if(now->time <= past->time)
    {
        // Too far in the ever-shifting future.
        xyz[VX] = now->xyz[VX];
        xyz[VY] = now->xyz[VY];
        xyz[VZ] = now->xyz[VZ];
        //LOGDEV_XVERBOSE("Smoother %p stalling") << sm;
        return true;
    }

    // We're somewhere between past and now.
    float const t = (sm->at - past->time) / (now->time - past->time);
    for(int i = 0; i < 3; ++i)
    {
        // Linear interpolation.
        xyz[i] = now->xyz[i] * t + past->xyz[i] * (1-t);
    }

/*#ifdef _DEBUG
    {
        float dt = sm->at - sm->prevAt;
        //Smoother_Debug(sm);
        if(dt > 0)
        {
            float diff[2] = { xyz[0] - sm->prevEval[0], xyz[1] - sm->prevEval[1] };
            LOGDEV_MSG("Smoother_Evaluate: [%05.3f] diff = %06.3f  %06.3f")
                << dt << diff[0]/dt << diff[1]/dt;
            ((Smoother *)sm)->prevEval[0] = xyz[0];
            ((Smoother *)sm)->prevEval[1] = xyz[1];
        }
        ((Smoother *)sm)->prevAt = sm->at;
    }
#endif*/
    return true;
}
コード例 #11
0
AABoxd Contact::objectBounds() const
{
    switch(_type)
    {
    case ContactLumobj: return objectAs<Lumobj>().bounds();
    case ContactMobj:   return Mobj_Bounds(objectAs<mobj_t>());

    default: break;
    }
    DENG2_ASSERT(false);
    return AABoxd();
}
コード例 #12
0
ddouble Contact::objectRadius() const
{
    switch(_type)
    {
    case ContactLumobj: return objectAs<Lumobj>().radius();
    case ContactMobj:   return Mobj_VisualRadius(objectAs<mobj_t>());

    default: break;
    }
    DENG2_ASSERT(false);
    return 0;
}
コード例 #13
0
 inline Rule const &anchorPos(Rule::Semantic anchorInput)
 {
     if(anchorInput == Rule::AnchorX)
     {
         return *normalizedAnchorX;
     }
     else
     {
         DENG2_ASSERT(anchorInput == Rule::AnchorY);
         return *normalizedAnchorY;
     }
 }
コード例 #14
0
ファイル: pathtree.cpp プロジェクト: gnuzinho/Doomsday-Engine
PathTree::Node &PathTree::insert(Path const &path)
{
    DENG2_GUARD(this);

    PathTree::Node *node = d->buildNodesForPath(path);
    DENG2_ASSERT(node != 0);

    // There is now one more unique path in the tree.
    d->size++;

    return *node;
}
コード例 #15
0
ファイル: counted.cpp プロジェクト: cmbruns/Doomsday-Engine
void Counted::release() const
{
    Counted const *c = (!_delegate? this : _delegate);

    //qDebug() << "Counted" << c << typeid(*c).name() << "ref dec'd to" << c->_refCount - 1;

    DENG2_ASSERT(c->_refCount > 0);
    if(!--c->_refCount)
    {
        delete c;
    }
}
コード例 #16
0
Vector3d Contact::objectOrigin() const
{
    switch(_type)
    {
    case ContactLumobj: return objectAs<Lumobj>().origin();
    case ContactMobj:   return Mobj_Origin(objectAs<mobj_t>());

    default: break;
    }
    DENG2_ASSERT(false);
    return Vector3d();
}
コード例 #17
0
 /// Sets the currently executed statement.
 void setCurrent(Statement const *statement)
 {
     if (controlFlow.size())
     {
         evaluator.reset();
         flow().setCurrent(statement);
     }
     else
     {
         DENG2_ASSERT(statement == NULL);
     }
 }
コード例 #18
0
void GLSubBuffer::setBatchVertices(int batchIndex, dsize elementCount, void *data)
{
    DENG2_ASSERT(d->batchIndexOffset >= 0);

    dsize const elementSize = d->format.first->stride;
    duint8 *elems = reinterpret_cast<duint8 *>(data);
    for (dsize i = 0; i < elementCount; ++i)
    {
        *reinterpret_cast<float *>(elems + d->batchIndexOffset + i * elementSize)
                = float(batchIndex);
    }
    setVertices(elementCount, data);
}
コード例 #19
0
mobj_t *Mobj_LaunchMissileAtAngle2(mobj_t *mob, mobj_t *missile, angle_t angle,
    coord_t const targetPos[], coord_t const sourcePos[], coord_t extraMomZ)
{
    DENG2_ASSERT(mob);

    if(missile)
    {
        // Remember the source (i.e., us) for tracking kills, etc...
        missile->target = mob;
    }

    return P_LaunchMissile(missile, angle, targetPos, sourcePos, extraMomZ);
}
コード例 #20
0
    void writeMisc()
    {
#if __JHEXEN__
        beginSegment(ASEG_MISC);
        for (int i = 0; i < MAXPLAYERS; ++i)
        {
            Writer_WriteInt32(writer, localQuakeHappening[i]);
        }
#endif
#if __JDOOM__
        DENG2_ASSERT(theBossBrain != 0);
        theBossBrain->write(thisPublic);
#endif
    }
コード例 #21
0
void FoldPanelWidget::panelDismissed()
{
    PanelWidget::panelDismissed();

    if(d->title)
    {
        d->title->setOpacity(.8f, .5f);
    }

    content().notifySelfAndTree(&Widget::deinitialize);

    DENG2_ASSERT(d->container == 0);
    d->container = takeContent();
}
コード例 #22
0
void T_BuildPillar(pillar_t *pillar)
{
    DENG2_ASSERT(pillar);

    // First, raise the floor
    result_e res1 = T_MovePlane(pillar->sector, pillar->floorSpeed, pillar->floorDest, pillar->crush, 0, pillar->direction); // floorOrCeiling, direction
    // Then, lower the ceiling
    result_e res2 = T_MovePlane(pillar->sector, pillar->ceilingSpeed, pillar->ceilingDest, pillar->crush, 1, -pillar->direction);
    if(res1 == pastdest && res2 == pastdest)
    {
        P_ToXSector(pillar->sector)->specialData = 0;
        SN_StopSequenceInSec(pillar->sector);
        P_NotifySectorFinished(P_ToXSector(pillar->sector)->tag);
        Thinker_Remove(&pillar->thinker);
    }
}
コード例 #23
0
    void writePolyobjs()
    {
#if __JHEXEN__
        beginSegment(ASEG_POLYOBJS);

        Writer_WriteInt32(writer, numpolyobjs);
        for (int i = 0; i < numpolyobjs; ++i)
        {
            Polyobj *po = Polyobj_ById(i);
            DENG2_ASSERT(po != 0);
            po->write(thisPublic);
        }

        // endSegment();
#endif
    }
コード例 #24
0
void AbstractLink::disconnect()
{
    if (d->status != Disconnected)
    {
        DENG2_ASSERT(d->socket.get() != 0);

        d->timeout = 0;
        d->socket->close(); // emits signal

        d->status = Disconnected;

        QObject::disconnect(d->socket.get(), SIGNAL(addressResolved()), this, SIGNAL(addressResolved()));
        QObject::disconnect(d->socket.get(), SIGNAL(connected()), this, SLOT(socketConnected()));
        QObject::disconnect(d->socket.get(), SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
        QObject::disconnect(d->socket.get(), SIGNAL(messagesReady()), this, SIGNAL(packetsReady()));
    }
}
コード例 #25
0
ファイル: json.cpp プロジェクト: gnuzinho/Doomsday-Engine
 QVariant parseString()
 {
     QVarLengthArray<QChar, 1024> result;
     QChar c = next();
     DENG2_ASSERT(c == '\"');
     forever
     {
         c = nextNoSkip();
         if(c == '\\')
         {
             // Escape.
             c = nextNoSkip();
             if(c == '\"' || c == '\\' || c == '/')
                 result.append(c);
             else if(c == 'b')
                 result.append('\b');
             else if(c == 'f')
                 result.append('\f');
             else if(c == 'n')
                 result.append('\n');
             else if(c == 'r')
                 result.append('\r');
             else if(c == 't')
                 result.append('\t');
             else if(c == 'u')
             {
                 QString code = source.mid(pos, 4);
                 pos += 4;
                 result.append(QChar(ushort(code.toLong(0, 16))));
             }
             else error("unknown escape sequence in string");
         }
         else if(c == '\"')
         {
             // End of string.
             break;
         }
         else
         {
             result.append(c);
         }
     }
     return QString(result.constData(), result.size());
 }
コード例 #26
0
    ~Impl()
    {
        qDeleteAll(eventHandlers);

        // The base class will delete all children, but we need to deinitialize
        // them first.
        self().notifyTree(&Widget::deinitialize);

        deinitBlur();

        /*
         * Deinitialization must occur before destruction so that GL resources
         * are not leaked. Derived classes are responsible for deinitializing
         * first before beginning destruction.
         */
#ifdef DENG2_DEBUG
        if (inited) qDebug() << "GuiWidget" << thisPublic << self().name() << "is still inited!";
        DENG2_ASSERT(!inited);
#endif
    }
コード例 #27
0
    void buildSubspaceGeometries()
    {
        for(ConvexSubspaceProxy const &subspace : subspaces)
        {
            /// @todo Move BSP leaf construction here?
            BspLeaf &bspLeaf = *subspace.bspLeaf();

            subspace.buildGeometry(bspLeaf, *mesh);

            // Account the new segments.
            /// @todo Refactor away.
            for(OrderedSegment const &oseg : subspace.segments())
            {
                if(oseg.segment->hasHEdge())
                {
                    // There is now one more line segment.
                    segmentCount += 1;
                }
            }
        }

        /*
         * Finalize the built geometry by adding a twin half-edge for any
         * which don't yet have one.
         */
        for(ConvexSubspaceProxy const &convexSet : subspaces)
        for(OrderedSegment const &oseg : convexSet.segments())
        {
            LineSegmentSide *seg = oseg.segment;

            if(seg->hasHEdge() && !seg->back().hasHEdge())
            {
                HEdge *hedge = &seg->hedge();
                DENG2_ASSERT(!hedge->hasTwin());

                // Allocate the twin from the same mesh.
                hedge->setTwin(hedge->mesh().newHEdge(seg->back().from()));
                hedge->twin().setTwin(hedge);
            }
        }
    }
コード例 #28
0
    void createFileLogSink(bool truncate)
    {
        if (!outputPath.isEmpty())
        {
            File *existing = (!truncate? App::rootFolder().tryLocate<File>(outputPath) : nullptr);
            if (!existing)
            {
                outputFile = &App::rootFolder().replaceFile(outputPath);
            }
            else
            {
                outputFile = existing;
            }
            outputFile->audienceForDeletion() += this;

            // Add a sink for the file.
            DENG2_ASSERT(!fileLogSink);
            fileLogSink = new FileLogSink(*outputFile);
            sinks.insert(fileLogSink);
        }
    }
コード例 #29
0
    /**
     * Compose a new backing store with an optimal layout.
     */
    void defragment()
    {
        DENG2_ASSERT(hasBacking());

        IAllocator::Allocations const oldLayout = allocator->allocs();
        if (!allocator->optimize())
        {
            // Optimization did not work out.
            mayDefrag = false;
            return;
        }

        Image defragged(QImage(QSize(backing.size().x, backing.size().y), backing.qtFormat()));
        defragged.fill(Image::Color(0, 0, 0, 0));

        // Copy all the images to their optimal places.
        IAllocator::Allocations optimal = allocator->allocs();
        DENG2_FOR_EACH(IAllocator::Allocations, i, optimal)
        {
            defragged.draw(backing.subImage(oldLayout[i.key()]),
                           i.value().topLeft);
        }
コード例 #30
0
bool LineEditWidget::handleEvent(Event const &event)
{
    // There are only key press events.
    DENG2_ASSERT(event.type() == Event::KeyPress);
    KeyEvent const &ev = event.as<KeyEvent>();

    bool eaten = true;

    // Insert text?
    if(!ev.text().isEmpty())
    {
        insert(ev.text());
    }
    else
    {
        // Control character.
        eaten = handleControlKey(ev.key());
    }

    if(eaten) return true;

    return TextWidget::handleEvent(event);
}