00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_VIDEO_RENDERBACKENDS_OPENGL_GLEIMAGE_H
00023 #define FIFE_VIDEO_RENDERBACKENDS_OPENGL_GLEIMAGE_H
00024
00025
00026 #include <vector>
00027
00028
00029 #include "util/base/fife_stdint.h"
00030
00031
00032 #include <SDL_video.h>
00033
00034
00035
00036
00037
00038 #include "video/image.h"
00039 #include "video/opengl/fife_opengl.h"
00040
00041 namespace FIFE {
00042 struct GLRenderState;
00043
00053 class GLeImage : public Image {
00054 public:
00055 GLeImage(IResourceLoader* loader = 0);
00056 GLeImage(const std::string& name, IResourceLoader* loader = 0);
00057 GLeImage(SDL_Surface* surface);
00058 GLeImage(const std::string& name, SDL_Surface* surface);
00059 GLeImage(const uint8_t* data, uint32_t width, uint32_t height);
00060 GLeImage(const std::string& name, const uint8_t* data, uint32_t width, uint32_t height);
00061
00062 virtual ~GLeImage();
00063 virtual void invalidate();
00064 virtual void setSurface(SDL_Surface* surface);
00065 virtual void render(const Rect& rect, uint8_t alpha = 255, uint8_t const* rgb = 0);
00066 virtual void renderZ(const Rect& rect, float vertexZ, uint8_t alpha = 255, bool forceNewBatch = false, uint8_t const* rgb = 0);
00067 virtual void useSharedImage(const ImagePtr& shared, const Rect& region);
00068 virtual void forceLoadInternal();
00069 virtual void copySubimage(uint32_t xoffset, uint32_t yoffset, const ImagePtr& img);
00070 virtual void load();
00071 virtual void free();
00072
00073 GLuint getTexId() const;
00074 const GLfloat* getTexCoords() const;
00075 bool isCompressed() const { return m_compressed; }
00076 void setCompressed(bool compressed) { m_compressed = compressed; }
00077 private:
00078
00079 GLfloat m_tex_coords[4];
00080
00081
00082 bool m_compressed;
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00099 GLuint m_texId;
00100
00103 void cleanup();
00104
00107 void resetGlimage();
00108
00111 void generateGLTexture();
00112 void generateGLSharedTexture(const GLeImage* shared, const Rect& region);
00113 void validateShared();
00114
00115 inline bool renderCheck(const Rect& rect, uint8_t alpha);
00116
00117 uint32_t m_chunk_size_w;
00118 uint32_t m_chunk_size_h;
00119
00120 SDL_Color m_colorkey;
00121
00122 GLeImage* m_shared_img;
00123
00124 ImagePtr m_atlas_img;
00125
00126 std::string m_atlas_name;
00127 };
00128
00129 }
00130
00131 #endif
00132