Beispiel #1
0
bool ICQClient::sendThruServer(Message *msg, void *_data)
{
    ICQUserData *data = (ICQUserData*)_data;
    Contact *contact = getContacts()->contact(msg->contact());
    if ((contact == NULL) || (data == NULL))
        return false;
    SendMsg s;
    switch (msg->type()){
    case MessageGeneric:
        if ((data->Status != ICQ_STATUS_OFFLINE) &&
                hasCap(data, CAP_RTF) && (msg->getFlags() & MESSAGE_RICHTEXT) &&
                !data->bBadClient){
            s.flags  = SEND_RTF;
            s.msg    = msg;
            s.text   = msg->getRichText();
            s.uin    = data->Uin;
            sendQueue.push_front(s);
            send(false);
            return true;
        }
        if ((data->Status != ICQ_STATUS_OFFLINE) &&
                hasCap(data, CAP_UTF) &&
                !data->bBadClient){
            s.flags  = SEND_UTF;
            s.msg    = msg;
            s.text   = msg->getPlainText();
            s.uin    = data->Uin;
            sendQueue.push_front(s);
            send(false);
            return true;
        }
        s.flags	= SEND_PLAIN;
        s.msg	= msg;
        s.text	= msg->getPlainText();
        s.uin	= data->Uin;
        sendQueue.push_front(s);
        send(false);
        return true;
    case MessageURL:
    case MessageContact:
	case MessageCheckInvisible:
        s.flags = SEND_RAW;
        s.msg   = msg;
        s.uin	= data->Uin;
        sendQueue.push_front(s);
        send(false);
        return true;
    }
    return false;
}
Beispiel #2
0
    void
    BufferToTexture::performAction(GLSourceBuffer theSourceBuffer)
    {
        if (theSourceBuffer == FRAME_BUFFER) {
            glReadBuffer(GL_BACK);
        }

        unsigned myWidth = getWidth();
        unsigned myHeight = getHeight();
        GLuint myTextureID = _myTexture->getTextureId();
        AC_DEBUG << "BufferToTexture::performAction '" << _myTexture->get<NameTag>() << "' id=" << _myTexture->get<IdTag>() << " offset=" << _myOffset << " " << myWidth << "x" << myHeight << " texId=" << myTextureID;
        if (_myCopyToImage) {

            ImagePtr myImage = _myTexture->getImage();
            if (!myImage) {
                AC_WARNING << "Texture '" << _myTexture->get<NameTag>() << "' id=" << _myTexture->get<IdTag>() << " has no image associated";
            } else {
                AC_DEBUG << "BufferToTexture::performAction copy to image '" << myImage->get<NameTag>() << "' id=" << myImage->get<IdTag>();

                // copy framebuffer to Image raster
                PixelEncodingInfo myPixelEncodingInfo = getDefaultGLTextureParams(myImage->getRasterEncoding());
                myPixelEncodingInfo.internalformat = asGLTextureInternalFormat(_myTexture->getInternalEncoding());

                glReadPixels(_myOffset[0],_myOffset[1], myWidth,myHeight,
                        myPixelEncodingInfo.externalformat, myPixelEncodingInfo.pixeltype,
                        myImage->getRasterPtr()->pixels().begin());
                CHECK_OGL_ERROR;

                //_myTexture->preload();
            }
        } else if (myTextureID > 0) {
            GLenum myTextureTarget = asGLTextureTarget(_myTexture->getType());
            if (myTextureTarget == GL_TEXTURE_2D) {
                AC_DEBUG << "BufferToTexture::performAction copy to texture";

                // copy framebuffer to texture
                glBindTexture(GL_TEXTURE_2D, myTextureID);
                glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0,0, _myOffset[0],_myOffset[1], myWidth,myHeight);
                CHECK_OGL_ERROR;

                // generate mipmap levels
                if (hasCap("GL_GENERATE_MIPMAP") && _myTexture->get<TextureMipmapTag>()) {
                    AC_TRACE << "BufferToTexture::performAction: generating mipmap levels";
                    glGenerateMipmapEXT(GL_TEXTURE_2D);
                    CHECK_OGL_ERROR;
                }

                glBindTexture(GL_TEXTURE_2D, 0);
            } else {
                AC_WARNING << "Copy to texture only supported for 'texture_2d'";
            }
        } else {
            AC_DEBUG << "BufferToTexture::performAction texture '" << _myTexture->get<NameTag>() << "' is not valid";
        }
    }