2 Copyright 2004 John Tsiombikas <nuclear@siggraph.org>
4 This file is part of the 3dengfx, realtime visualization system.
6 3dengfx is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 3dengfx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with 3dengfx; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef _TEXTURES_HPP_
21 #define _TEXTURES_HPP_
24 #include "gfx/pbuffer.hpp"
25 #include "3denginefx_types.hpp"
27 /* ---- Texture class ----
28 ** it does NOT hold the actual pixel data, if we need access to
29 ** the pixels we have to call lock() then the data are retrieved from
30 ** OpenGL, and unlock() updates the OpenGL texture from our modified
31 ** pixel data in pbuf.
32 ** if we wish to just set some pixel data without first retrieving the
33 ** actual data from OpenGL, we can use the function set_pixel_data() with a
34 ** new PixelBuffer as argument (this is copied, not referenced)
36 class Texture : public PixelBuffer {
38 // for animated textures this will hold all the tex_ids of the frames
39 std::vector<unsigned int> frame_tex_id;
40 unsigned int active_frame;
45 unsigned int tex_id; /* OpenGL texture id
46 * (for animated textures this is the active tex_id)
49 Texture(int x = -1, int y = -1, TextureDim type = TEX_2D);
50 Texture(int x, TextureDim type = TEX_1D);
54 void add_frame(const PixelBuffer &pbuf);
56 void set_active_frame(unsigned int frame);
57 unsigned int get_active_frame() const;
59 void lock(CubeMapFace cube_map_face = CUBE_MAP_PX); // get a valid pixel pointer
60 void unlock(CubeMapFace cube_map_face = CUBE_MAP_PX); // update system data & invalidate pointer
62 void set_pixel_data(const PixelBuffer &pbuf, CubeMapFace cube_map_face = CUBE_MAP_PX);
64 TextureDim get_type() const;
67 #endif // _TEXTURES_HPP_