]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/bkgrnd2d/bkgrnd2d.h
reformat code! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / contrib / bkgrnd2d / bkgrnd2d.h
1 /*
2    Copyright (C) 2003 Reed Mideke.
3
4    This file is part of GtkRadiant.
5
6    GtkRadiant 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.
10
11    GtkRadiant 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.
15
16    You should have received a copy of the GNU General Public License
17    along with GtkRadiant; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21 //
22 // bkgrnd2d Plugin
23 //
24 // Code by reyalP aka Reed Mideke
25 //
26 // Based on spritemodel source code by hydra
27 //
28
29 #include "plugin.h"
30
31 class CBackgroundImage {
32 private:
33     qtexture_t *m_tex;
34     VIEWTYPE m_vt;
35
36 // which components of a vec3_t correspond to x and y in the image
37     unsigned m_ix, m_iy;
38
39 public:
40     CBackgroundImage(VIEWTYPE vt);
41 //  ~CBackgroundImage();
42
43     float m_alpha;     // vertex alpha
44     bool m_bActive;
45
46 // x and y axis are in relation to the screen, not world, making rendering
47 // the same for each view type. Whoever sets them is responsible for
48 // shuffling.
49 // units are world units.
50 // TODO should be private
51     float m_xmin, m_ymin, m_xmax, m_ymax;
52
53 // load file, create new tex, cleanup old tex, set new tex
54     bool Load(const char *filename);
55
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
61     bool Valid()
62     { return (m_tex && (m_xmin != m_xmax) && (m_ymin != m_ymax)); }
63 };
64
65 class CBackgroundRender : public IGL2DWindow {
66 public:
67
68     CBackgroundRender();
69
70     virtual ~CBackgroundRender();
71
72 protected:
73     int refCount;
74
75 public:
76
77 // IGL2DWindow IGL3DWindow interface
78     void IncRef()
79     { refCount++; }
80
81     void DecRef()
82     {
83         refCount--;
84         if (refCount <= 0) {
85             delete this;
86         }
87     }
88
89     void Draw2D(VIEWTYPE vt);
90
91     void Register();
92 };
93
94 extern CBackgroundImage backgroundXY, backgroundXZ, backgroundYZ;
95 extern CBackgroundRender render;