]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/bkgrnd2d/bkgrnd2d.h
ported PrtView plugin
[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         void Cleanup(); // free texture, free tex, set make tex NULL
56         bool SetExtentsMM(); // set extents by ET mapcoordsmaxs/mapcoordsmins
57         bool SetExtentsSel(); // set extents by selection
58         void Render();
59         bool Valid() { return (m_tex && (m_xmin != m_xmax) && (m_ymin != m_ymax)); }
60 };
61
62 class CBackgroundRender : public IGL2DWindow {
63 public:
64
65   CBackgroundRender();
66   virtual ~CBackgroundRender();
67
68 protected:
69         int refCount;
70
71 public:
72
73   // IGL2DWindow IGL3DWindow interface
74         void IncRef() { refCount++; }
75         void DecRef() { refCount--; if (refCount <= 0) delete this; }
76         void Draw2D( VIEWTYPE vt );
77         void Register();
78 };
79
80 extern CBackgroundImage backgroundXY,backgroundXZ,backgroundYZ;
81 extern CBackgroundRender render;
82