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


C++ GCN_EXCEPTION函数代码示例

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


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

示例1: GCN_EXCEPTION

    void OpenGLImage::convertToDisplayFormat()
    {
		if (mPixels == NULL)
		{
			throw GCN_EXCEPTION("Image has already been converted to display format");
		}

        glGenTextures(1, &mTextureHandle);
        glBindTexture(GL_TEXTURE_2D, mTextureHandle);

        glTexImage2D(GL_TEXTURE_2D,
                     0,
                     4,
                     mTextureWidth,
                     mTextureHeight,
                     0,
                     GL_RGBA,
                     GL_UNSIGNED_BYTE,
                     mPixels);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        delete[] mPixels;
		mPixels = NULL;

        GLenum error = glGetError();
        if (error)
        {
            std::string errmsg;
            switch (error)
            {
              case GL_INVALID_ENUM:
                  errmsg = "GL_INVALID_ENUM";
                  break;

              case GL_INVALID_VALUE:
                  errmsg = "GL_INVALID_VALUE";
                  break;

              case GL_INVALID_OPERATION:
                  errmsg = "GL_INVALID_OPERATION";
                  break;

              case GL_STACK_OVERFLOW:
                  errmsg = "GL_STACK_OVERFLOW";
                  break;

              case GL_STACK_UNDERFLOW:
                  errmsg = "GL_STACK_UNDERFLOW";
                  break;

              case GL_OUT_OF_MEMORY:
                  errmsg = "GL_OUT_OF_MEMORY";
                  break;
            }

            throw GCN_EXCEPTION(std::string("Unable to convert to OpenGL display format, glGetError said: ") + errmsg);
        }
    }
开发者ID:Mistranger,项目名称:stratagus2,代码行数:60,代码来源:openglimage.cpp

示例2: gk_create_keeper

        void AllegroGlyphKeeperFont::load(const std::string& filename, int w, int h)
        {
            mKeeper = gk_create_keeper(0,0);

            if (mKeeper == NULL)
            {
                throw GCN_EXCEPTION("Can't create keeper.");
            }

            mFace = gk_load_face_from_file(filename.c_str(), 0);

            if (mFace == NULL)
            {
                throw GCN_EXCEPTION("Can't load font from file.");
            }

            mRend = gk_create_renderer(mFace,mKeeper);
        
            if (mRend == NULL)
            {
                throw GCN_EXCEPTION("Can't create renderer.");
            }

            gk_rend_set_hinting_off(mRend);
            gk_rend_set_size_pixels(mRend, w, h);
            gk_rend_set_text_color_rgb(mRend, 0, 0, 0);
        }
开发者ID:k1rn1l,项目名称:naruto-hand-signs-fighting,代码行数:27,代码来源:allegroglyphkeeperfont.cpp

示例3: load

        virtual Image* load(const std::string& filename,
                            bool convertToDisplayFormat = true)
        {
            SDL_Surface *loadedSurface = loadSDLSurface(filename);

            if (loadedSurface == NULL)
            {
                throw GCN_EXCEPTION(
                        std::string("Unable to load image file: ") + filename);
            }

            SDL_Surface *surface = convertToStandardFormat(loadedSurface);
            SDL_FreeSurface(loadedSurface);

            if (surface == NULL)
            {
                throw GCN_EXCEPTION(
                        std::string("Not enough memory to load: ") + filename);
            }

            OpenGLImage *image = new OpenGLImage((unsigned int*)surface->pixels,
                                                 surface->w,
                                                 surface->h,
                                                 convertToDisplayFormat);
            SDL_FreeSurface(surface);

            return image;
        }
开发者ID:DakaraOnline,项目名称:AONX,代码行数:28,代码来源:openglsdlimageloader.hpp

示例4: GCN_EXCEPTION

    void DirectX3DGraphics::drawImage(const Image* image,
                                      int srcX,
                                      int srcY,
                                      int dstX,
                                      int dstY,
                                      int width,
                                      int height)
    {
		const DirectX3DImage* srcImage = dynamic_cast<const DirectX3DImage*>(image);

        if (srcImage == NULL)
        {
            throw GCN_EXCEPTION("Trying to draw an image of unknown format, must be a DirectXImage.");
        }

        if (mClipStack.empty())
        {
            throw GCN_EXCEPTION("Clip stack is empty, perhaps you called a draw funtion outside of _beginDraw() and _endDraw()?");
        }

        const ClipRectangle& top = mClipStack.top();
        
       
        dstX += top.xOffset;
        dstY += top.yOffset;

         
        // Find DirectX texture coordinates
        float texX1 = srcX / (float)srcImage->getTextureWidth();
        float texY1 = srcY / (float)srcImage->getTextureHeight();
        float texX2 = (srcX+width) / (float)srcImage->getTextureWidth();
        float texY2 = (srcY+height) / (float)srcImage->getTextureHeight();
          
  
        // Check if blending already is enabled
        if (!mAlpha)
        {
            mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
        }

        DWORD color = 0xFFFFFFFF;
     
        VertexWithTexture vertices[]=
        {
            {(float)dstX, (float)dstY + height, 0.0f, 1.0f, color, texX1, texY2},
            {(float)dstX, (float)dstY, 0.0f, 1.0f, color, texX1, texY1},
            {(float)dstX + width, (float)dstY + height, 0.0f, 1.0f, color, texX2, texY2},
            {(float)dstX + width, (float)dstY, 0.0f, 1.0f, color, texX2, texY1},
        };

        mDevice->SetFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1);
        mDevice->SetTexture(0, srcImage->getTexture());
        mDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(VertexWithTexture));
        mDevice->SetTexture(0, 0);

        if (!mAlpha)
        {
            mDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); 
        }
    }
开发者ID:andryblack,项目名称:guichan,代码行数:60,代码来源:directx3dgraphics.cpp

示例5: GCN_EXCEPTION

    Color CairoImage::getPixel(int x, int y)
    {
        if (!mCairoSurface)
        {
            throw GCN_EXCEPTION("Trying to get a pixel from a non loaded image.");
        }

        int stride=cairo_image_surface_get_stride(mCairoSurface);
        int yindex=y*stride;
        unsigned char *imagePixels=cairo_image_surface_get_data(mCairoSurface);
        if (!imagePixels)
        {
            throw GCN_EXCEPTION("Surface data are not available (surface is not of type cairo_image_surface or has been finished)");
        }
        // deal differently with each surface format
        switch(cairo_image_surface_get_format(mCairoSurface))
        {
            case CAIRO_FORMAT_ARGB32:
                return GetColorFromARGB(*((unsigned long*)(&imagePixels[x*4 + yindex])));
                break;
            case CAIRO_FORMAT_RGB24:
                return GetColorFromRGB(*((unsigned long*)(&imagePixels[x*4 + yindex])));
                break;
            case CAIRO_FORMAT_A8:
                return Color(0,0,0,imagePixels[x + yindex]);
                break;
            default :
                return Color(0,0,0);
                //do nothing
                break;
        }
    }
开发者ID:andryblack,项目名称:guichan,代码行数:32,代码来源:cairoimage.cpp

示例6: GCN_EXCEPTION

    void COCOS2DXGraphics::drawImage(const Image* image,
                                int srcX,
                                int srcY,
                                int dstX,
                                int dstY,
                                int width,
                                int height)
    {
        if (mClipStack.empty())
        {
            throw GCN_EXCEPTION("Clip stack is empty, perhaps you called a draw funtion outside of _beginDraw() and _endDraw()?");
        }

        const ClipRectangle& top = mClipStack.top();

        SDLMOD_Rect src;
        SDLMOD_Rect dst;
        src.x = srcX;
        src.y = srcY;
        src.w = width;
        src.h = height;
        dst.x = dstX + top.xOffset;
        dst.y = dstY + top.yOffset;

        const COCOS2DXImage* srcImage = dynamic_cast<const COCOS2DXImage*>(image);

        if (srcImage == NULL)
        {
            throw GCN_EXCEPTION("Trying to draw an image of unknown format, must be an SDLImage.");
        }

        SDLMOD_BlitSurface(srcImage->getSurface(), &src, mTarget, &dst);
    }
开发者ID:weimingtom,项目名称:guichan_cocos2dx,代码行数:33,代码来源:cocos2dxgraphics.cpp

示例7: IMG_Load_RW

gcn::Image* InfraellyImageLoader::load(SDL_RWops *source_Rwop, bool freeRWOP, bool convertToDisplayFormat){
    //load the rWop into a SDL Surface
    SDL_Surface *loadedSurface = IMG_Load_RW(source_Rwop, freeRWOP);

    if (loadedSurface == NULL)
    {
        throw GCN_EXCEPTION( std::string("Unable to load image file: ") );
    }

    SDL_Surface *surface = convertToStandardFormat(loadedSurface);
    SDL_FreeSurface(loadedSurface);

    if (surface == NULL)
    {
        throw GCN_EXCEPTION( std::string("Not enough memory to load: ") );
    }

    gcn::Image *image = new gcn::SDLImage(surface, true);

    if (convertToDisplayFormat)
    {
        image->convertToDisplayFormat();
    }

    return image;
}
开发者ID:Infraelly,项目名称:old-infraelly-engine,代码行数:26,代码来源:InfraellyImageLoader.cpp

示例8: SDL_RWFromMem

gcn::Image* InfraellyImageLoader::load(unsigned char *buffer, long bufferLength, bool convertToDisplayFormat){
    //make rWop out of character buffer
    SDL_RWops *source_Rwop = SDL_RWFromMem(buffer, bufferLength);

    //load the rWop into a SDL Surface
    SDL_Surface *loadedSurface = IMG_Load_RW(source_Rwop, 1);

    if (loadedSurface == NULL)
    {
        throw GCN_EXCEPTION( std::string("Unable to load image file: ") );
    }

    SDL_Surface *surface = convertToStandardFormat(loadedSurface);
    SDL_FreeSurface(loadedSurface);

    if (surface == NULL)
    {
        throw GCN_EXCEPTION( std::string("Not enough memory to load: ") );
    }

    gcn::Image *image = new gcn::SDLImage(surface, true);

    if (convertToDisplayFormat)
    {
        image->convertToDisplayFormat();
    }

    return image;
}
开发者ID:Infraelly,项目名称:old-infraelly-engine,代码行数:29,代码来源:InfraellyImageLoader.cpp

示例9: loadSDLSurface

    Image* GLUTImageLoader::load(const std::string& filename,
                                bool convertToDisplayFormat)
    {
        SDLMOD_Surface *loadedSurface = loadSDLSurface(filename);

        if (loadedSurface == NULL)
        {
            throw GCN_EXCEPTION(
                    std::string("Unable to load image file: ") + filename);
        }

#if 0
        SDLMOD_Surface *surface = convertToStandardFormat(loadedSurface);
        SDLMOD_FreeSurface(loadedSurface);

        if (surface == NULL)
        {
            throw GCN_EXCEPTION(
                    std::string("Not enough memory to load: ") + filename);
        }
#else
		SDLMOD_Surface *surface = loadedSurface;
#endif

        Image *image = new GLUTImage(surface, true);

        if (convertToDisplayFormat)
        {
            image->convertToDisplayFormat();
        }

        return image;
    }
开发者ID:weimingtom,项目名称:guichan_memory,代码行数:33,代码来源:glutimageloader.cpp

示例10: GCN_EXCEPTION

    void FocusHandler::applyChanges()
    {
        if (mToBeFocused != NULL)
        {
            unsigned int i = 0;
            int toBeFocusedIndex = -1;
            for (i = 0; i < mWidgets.size(); ++i)
            {      
                if (mWidgets[i] == mToBeFocused)
                {
                    toBeFocusedIndex = i;
                    break;                
                }
            }    
            
            if (toBeFocusedIndex < 0)
            {
                throw GCN_EXCEPTION("Trying to focus a none existing widget.");
            }

            Widget *oldFocused = mFocusedWidget;

            if (oldFocused != mToBeFocused)
            {
                mFocusedWidget = mWidgets.at(toBeFocusedIndex);
                
                if (oldFocused != NULL)
                {
                    oldFocused->lostFocus();
                }
                
                mWidgets.at(toBeFocusedIndex)->gotFocus();
            }
            mToBeFocused = NULL;
        }

        if (mToBeDragged != NULL)
        {
            unsigned int i = 0;
            int toBeDraggedIndex = -1;
            for (i = 0; i < mWidgets.size(); ++i)
            {      
                if (mWidgets[i] == mToBeDragged)
                {
                    toBeDraggedIndex = i;                
                    break;
                }
            }    

            if (toBeDraggedIndex < 0)
            {
                throw GCN_EXCEPTION("Trying to give drag to a none existing widget");
            }
            
             mDraggedWidget = mWidgets.at(toBeDraggedIndex);
             mToBeDragged = NULL;            
        }
    }    
开发者ID:OneSleepyDev,项目名称:boswars_osd,代码行数:58,代码来源:focushandler.cpp

示例11: os

    void ImageFont::addGlyph(unsigned char c, int &x,
                             int &y, const Color& separator)
    {
        ImageLoader* il = Image::_getImageLoader();
        
        Color color;
        do
        {
            ++x;

            if (x >= il->getWidth())
            {
                y += mHeight + 1;
                x = 0;

                if (y >= il->getHeight())
                {
                    std::string str;
                    std::ostringstream os(str);
                    os << "Image ";
                    os << mFilename;
                    os << " with font is corrupt near character '";
                    os << c;
                    os << "'";
                    throw GCN_EXCEPTION(os.str());
                }
            }            

            color = il->getPixel(x, y);

        } while (color == separator);
        
        int w = 0;
        
        do
        {
            ++w;

            if (x+w >= il->getWidth())
            {
                std::string str;
                std::ostringstream os(str);
                os << "Image ";
                os << mFilename;
                os << " with font is corrupt near character '";
                os << c;
                os << "'";
                throw GCN_EXCEPTION(os.str());
            }            
            
            color = il->getPixel(x + w, y);
            
        } while (color != separator);
        
        mGlyph[c] = Rectangle(x, y, w, mHeight);
        
        x += w;        
    }
开发者ID:k1643,项目名称:StratagusAI,代码行数:58,代码来源:imagefont.cpp

示例12: os

    Rectangle ImageFont::scanForGlyph(unsigned char glyph, 
                                      int x,
                                      int y,
                                      const Color& separator)
    {
        Color color;
        do
        {
            ++x;

            if (x >= mImage->getWidth())
            {
                y += mHeight + 1;
                x = 0;

                if (y >= mImage->getHeight())
                {
                    std::string str;
                    std::ostringstream os(str);
                    os << "Image ";
                    os << mFilename;
                    os << " with font is corrupt near character '";
                    os << glyph;
                    os << "'";
                    throw GCN_EXCEPTION(os.str());
                }
            }

            color = mImage->getPixel(x, y);

        } while (color == separator);

        int width = 0;

        do
        {
            ++width;

            if (x + width >= mImage->getWidth())
            {
                std::string str;
                std::ostringstream os(str);
                os << "Image ";
                os << mFilename;
                os << " with font is corrupt near character '";
                os << glyph;
                os << "'";
                throw GCN_EXCEPTION(os.str());
            }

            color = mImage->getPixel(x + width, y);

        } while (color != separator);

        return Rectangle(x, y, width, mHeight);
    }
开发者ID:Infraelly,项目名称:old-infraelly-engine,代码行数:56,代码来源:imagefont.cpp

示例13: GCN_EXCEPTION

    ImageFont::ImageFont(Image* image, 
                         const std::string& glyphs)
    {
        mFilename = "Image*";
        if (image == NULL)
        {
                GCN_EXCEPTION("Font image is NULL");
        }
        mImage = image;

        Color separator = mImage->getPixel(0, 0);
                
        int i = 0;
        for (i = 0;
             i < mImage->getWidth() && separator == mImage->getPixel(i, 0);
             ++i)
        {
        }
        
        if (i >= mImage->getWidth())
        {
            throw GCN_EXCEPTION("Corrupt image.");
        }

        int j = 0;
        for (j = 0; j < mImage->getHeight(); ++j)
        {
            if (separator == mImage->getPixel(i, j))
            {
                break;
            }
        }

        mHeight = j;
        int x = 0, y = 0;
        unsigned char k;

        for (i = 0; i < (int)glyphs.size(); ++i)
        {
            k = glyphs.at(i);
            mGlyph[k] = scanForGlyph(k, x, y, separator);
            // Update x och y with new coordinates.
            x = mGlyph[k].x + mGlyph[k].width;
            y =  mGlyph[k].y;
        }

        int w = mImage->getWidth();
        int h = mImage->getHeight();
        mImage->convertToDisplayFormat();

        mRowSpacing = 0;
        mGlyphSpacing = 0;
    }
开发者ID:Infraelly,项目名称:old-infraelly-engine,代码行数:53,代码来源:imagefont.cpp

示例14: GCN_EXCEPTION

    void SDLImageLoader::putPixel(int x, int y, const Color& color)
    {
        if (mCurrentImage == NULL)
        {
            throw GCN_EXCEPTION("No image prepared.");
        }

        if (x < 0 || y < 0 || x >= mCurrentImage->w || y >= mCurrentImage->h)
        {
            throw GCN_EXCEPTION("x and y out of image bound.");
        }
    
        SDLputPixel(mCurrentImage, x, y, color);    
    }
开发者ID:k1643,项目名称:StratagusAI,代码行数:14,代码来源:sdlimageloader.cpp

示例15: GCN_EXCEPTION

void gcn::Panel::add(gcn::Widget *widget)
{
    // width of current widget exceeds remaining space, go down 1 row
    int dimx = _nextx + _spacingX + widget->getDimension().width;
    if(dimx > getChildrenArea().width || (_slotsx > 0 && _usedx >= _slotsx))
    {
        _usedx = 0;
        _nextx = _spacingX;
        _usedy++;
        _nexty += (_maxheight + _spacingY);
        _maxheight = 0;
    }

    // height of current widget exceeds remaining space, whoops
    int dimy = _nexty + _spacingY + widget->getDimension().height;
    if(dimy > getChildrenArea().height && _slotsy >= 0 && _usedy >= _slotsy)
    {
        throw GCN_EXCEPTION("height exceeded, can't add more widgets");
    }

    widget->setPosition(_nextx, _nexty);
    Container::add(widget);
    _maxheight = std::max(_maxheight, widget->getDimension().height);
    
    _nextx += (_spacingX + widget->getDimension().width);
    _usedx++;
}
开发者ID:IamusNavarathna,项目名称:lv3proj,代码行数:27,代码来源:Panel.cpp


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