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