/* _______ __ __ __ ______ __ __ _______ __ __ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ * * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson * * Js_./ * Per Larsson a.k.a finalman _RqZ{a<^_aa * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a// * _Qhm`] _f "'c 1!5m * Visit: http://guichan.darkbits.org )Qk

ws?a-?' ._/L #' * binary forms, with or without )4d[#7r, . ' )d`)[ * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' * that the following conditions are met: j<. a J@\ * this list of conditions and the j(]1u #if defined (DELETE) #undef DELETE #endif #endif #if defined (__APPLE__) #include #else #include #endif #include #include "guisan/color.hpp" #include "guisan/platform.hpp" #include "guisan/image.hpp" namespace gcn { /** * OpenGL implementation of Image. */ class GCN_EXTENSION_DECLSPEC OpenGLImage : public Image { public: /** * Constructor. Loads an image from an array of pixels. The pixel array is * is copied in the constructor and should thus be freed after the constructor * has been called. * * NOTE: The functions getPixel and putPixel are only guaranteed to work * before an image has been converted to display format. * * @param pixels to load from. * @param width the width of the image. * @param height the height of the image. * @param convertToDisplayFormat true if the image should be converted * to display, false otherwise. */ OpenGLImage(unsigned int* pixels, int width, int height, bool convertToDisplayFormat = true); /** * Constructor. Load an image from an OpenGL texture handle. The width * and height specifies the size of the "interesting" part of the * texture, the real width and height of the texture are assumed to * be the closest higher power of two. * * @param textureHandle the texture handle from which to load. * @param width the width of the image. * @param height the height of the image. * @param autoFree true if the surface should automatically be deleted. */ OpenGLImage(GLuint textureHandle, int width, int height, bool autoFree); /** * Destructor. */ virtual ~OpenGLImage(); /** * Gets the OpenGL texture handle for the image. * * @return the OpenGL texture handle for the image. */ [[nodiscard]] virtual GLuint getTextureHandle() const; /** * Gets the width of texture. * * @return the width of the texture. */ [[nodiscard]] virtual int getTextureWidth() const; /** * Gets the height of the texture. * * @return the height of the texture. */ [[nodiscard]] virtual int getTextureHeight() const; // Inherited from Image void free() override; [[nodiscard]] int getWidth() const override; [[nodiscard]] int getHeight() const override; Color getPixel(int x, int y) override; void putPixel(int x, int y, const Color& color) override; void convertToDisplayFormat() override; protected: GLuint mTextureHandle; unsigned int* mPixels; bool mAutoFree; int mWidth; int mHeight; int mTextureWidth; int mTextureHeight; }; } #endif // end GCN_OPENGLIMAGE_HPP