X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2F3dengfx%2Fsrc%2F3dengfx%2Ftextures.hpp;fp=src%2F3dengfx%2Fsrc%2F3dengfx%2Ftextures.hpp;h=3923f868d33848f54c5ef88ca63bda0112d61829;hb=6e23259dbabaeb1711a2a5ca25b9cb421f693759;hp=0000000000000000000000000000000000000000;hpb=fe068fa879814784c45e0cb2e65dac489e8f5594;p=summerhack diff --git a/src/3dengfx/src/3dengfx/textures.hpp b/src/3dengfx/src/3dengfx/textures.hpp new file mode 100644 index 0000000..3923f86 --- /dev/null +++ b/src/3dengfx/src/3dengfx/textures.hpp @@ -0,0 +1,67 @@ +/* +Copyright 2004 John Tsiombikas + +This file is part of the 3dengfx, realtime visualization system. + +3dengfx is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +3dengfx is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with 3dengfx; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef _TEXTURES_HPP_ +#define _TEXTURES_HPP_ + +#include +#include "gfx/pbuffer.hpp" +#include "3denginefx_types.hpp" + +/* ---- Texture class ---- +** it does NOT hold the actual pixel data, if we need access to +** the pixels we have to call lock() then the data are retrieved from +** OpenGL, and unlock() updates the OpenGL texture from our modified +** pixel data in pbuf. +** if we wish to just set some pixel data without first retrieving the +** actual data from OpenGL, we can use the function set_pixel_data() with a +** new PixelBuffer as argument (this is copied, not referenced) +*/ +class Texture : public PixelBuffer { +private: + // for animated textures this will hold all the tex_ids of the frames + std::vector frame_tex_id; + unsigned int active_frame; + + TextureDim type; + +public: + unsigned int tex_id; /* OpenGL texture id + * (for animated textures this is the active tex_id) + */ + + Texture(int x = -1, int y = -1, TextureDim type = TEX_2D); + Texture(int x, TextureDim type = TEX_1D); + ~Texture(); + + void add_frame(); + void add_frame(const PixelBuffer &pbuf); + + void set_active_frame(unsigned int frame); + unsigned int get_active_frame() const; + + void lock(CubeMapFace cube_map_face = CUBE_MAP_PX); // get a valid pixel pointer + void unlock(CubeMapFace cube_map_face = CUBE_MAP_PX); // update system data & invalidate pointer + + void set_pixel_data(const PixelBuffer &pbuf, CubeMapFace cube_map_face = CUBE_MAP_PX); + + TextureDim get_type() const; +}; + +#endif // _TEXTURES_HPP_