]> de.git.xonotic.org Git - voretournament/voretournament.git/blob - misc/mediasource/extra/netradiant-src/include/iglrender.h
Include netRadiant source in this GIT
[voretournament/voretournament.git] / misc / mediasource / extra / netradiant-src / include / iglrender.h
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
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 #if !defined(INCLUDED_IGLRENDER_H)
23 #define INCLUDED_IGLRENDER_H
24
25 #include "igl.h"
26 #include "generic/vector.h"
27 class AABB;
28 class Matrix4;
29
30
31 class GLProgram
32 {
33 public:
34   virtual void enable() = 0;
35   virtual void disable() = 0;
36   virtual void setParameters(const Vector3& viewer, const Matrix4& localToWorld, const Vector3& origin, const Vector3& colour, const Matrix4& world2light) = 0;
37 };
38
39 class OpenGLFogState
40 {
41 public:
42   OpenGLFogState() : mode(GL_EXP), density(0), start(0), end(0), index(0), colour(1, 1, 1, 1)
43   {
44   }
45   GLenum mode;
46   GLfloat density;
47   GLfloat start;
48   GLfloat end;
49   GLint index;
50   Vector4 colour;
51 };
52
53 //! A collection of opengl state information.
54 class OpenGLState
55 {
56 public:
57   enum ESort
58   {
59     eSortFirst = 0,
60     eSortOpaque = 1,
61     eSortMultiFirst = 2,
62     eSortMultiLast = 1023,
63     eSortOverbrighten = 1024,
64     eSortFullbright = 1025,
65     eSortHighlight = 1026,
66     eSortTranslucent = 1027,
67     eSortOverlayFirst = 1028,
68     eSortOverlayLast = 2047,
69     eSortControlFirst = 2048,
70     eSortControlLast = 3071,
71     eSortGUI0 = 3072,
72     eSortGUI1 = 3073,
73     eSortLast = 4096,
74   };
75
76   unsigned int m_state;
77   std::size_t m_sort;
78   GLint m_texture;
79   GLint m_texture1;
80   GLint m_texture2;
81   GLint m_texture3;
82   GLint m_texture4;
83   GLint m_texture5;
84   GLint m_texture6;
85   GLint m_texture7;
86   Vector4 m_colour;
87   GLenum m_blend_src, m_blend_dst;
88   GLenum m_depthfunc;
89   GLenum m_alphafunc;
90   GLfloat m_alpharef;
91   GLfloat m_linewidth;
92   GLfloat m_pointsize;
93   GLint m_linestipple_factor;
94   GLushort m_linestipple_pattern;
95   OpenGLFogState m_fog;
96   GLProgram* m_program;
97
98   OpenGLState() : m_program(0)
99   {
100   }
101 };
102
103 class OpenGLStateLibrary
104 {
105 public:
106   INTEGER_CONSTANT(Version, 1);
107   STRING_CONSTANT(Name, "openglshaderlibrary");
108
109   virtual void getDefaultState(OpenGLState& state) const = 0;
110
111   virtual void insert(const char* name, const OpenGLState& state) = 0;
112   virtual void erase(const char* name) = 0;
113 };
114
115 #include "modulesystem.h"
116
117 template<typename Type>
118 class GlobalModule;
119 typedef GlobalModule<OpenGLStateLibrary> GlobalOpenGLStateLibraryModule;
120
121 template<typename Type>
122 class GlobalModuleRef;
123 typedef GlobalModuleRef<OpenGLStateLibrary> GlobalOpenGLStateLibraryModuleRef;
124
125 inline OpenGLStateLibrary& GlobalOpenGLStateLibrary()
126 {
127   return GlobalOpenGLStateLibraryModule::getTable();
128 }
129
130 #endif