]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/bkgrnd2d/bkgrnd2d.h
* moved zeroradiant (1.6) into trunk
[xonotic/netradiant.git] / contrib / bkgrnd2d / bkgrnd2d.h
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 //
23 // bkgrnd2d Plugin
24 //
25 // Code by reyalP aka Reed Mideke
26 //
27 // Based on spritemodel source code by hydra
28 //
29
30 #include "plugin.h"
31
32 class CBackgroundImage {
33 private:
34         qtexture_t *m_tex;
35   VIEWTYPE m_vt;
36   
37 // which components of a vec3_t correspond to x and y in the image
38   unsigned m_ix,m_iy;
39
40 public:
41         CBackgroundImage(VIEWTYPE vt);
42 //  ~CBackgroundImage();
43
44         float m_alpha; // vertex alpha
45         bool m_bActive;
46         
47 // x and y axis are in relation to the screen, not world, making rendering
48 // the same for each view type. Whoever sets them is responsible for 
49 // shuffling.
50 // units are world units.
51 // TODO should be private
52         float m_xmin,m_ymin,m_xmax,m_ymax;
53
54 // load file, create new tex, cleanup old tex, set new tex
55         bool Load(const char *filename); 
56         void Cleanup(); // free texture, free tex, set make tex NULL
57         bool SetExtentsMM(); // set extents by ET mapcoordsmaxs/mapcoordsmins
58         bool SetExtentsSel(); // set extents by selection
59         void Render();
60         bool Valid() { return (m_tex && (m_xmin != m_xmax) && (m_ymin != m_ymax)); }
61 };
62
63 class CBackgroundRender : public IGL2DWindow {
64 public:
65
66   CBackgroundRender();
67   virtual ~CBackgroundRender();
68
69 protected:
70         int refCount;
71
72 public:
73
74   // IGL2DWindow IGL3DWindow interface
75         void IncRef() { refCount++; }
76         void DecRef() { refCount--; if (refCount <= 0) delete this; }
77         void Draw2D( VIEWTYPE vt );
78         void Register();
79 };
80
81 extern CBackgroundImage backgroundXY,backgroundXZ,backgroundYZ;
82 extern CBackgroundRender render;
83