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