]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/iglrender.h
[dpkdir] introducing dpkdeps.h
[xonotic/netradiant.git] / 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 GLenum mode;
45 GLfloat density;
46 GLfloat start;
47 GLfloat end;
48 GLint index;
49 Vector4 colour;
50 };
51
52 //! A collection of opengl state information.
53 class OpenGLState
54 {
55 public:
56 enum ESort
57 {
58         eSortFirst = 0,
59         eSortOpaque = 1,
60         eSortMultiFirst = 2,
61         eSortMultiLast = 1023,
62         eSortOverbrighten = 1024,
63         eSortFullbright = 1025,
64         eSortHighlight = 1026,
65         eSortTranslucent = 1027,
66         eSortOverlayFirst = 1028,
67         eSortOverlayLast = 2047,
68         eSortControlFirst = 2048,
69         eSortControlLast = 3071,
70         eSortGUI0 = 3072,
71         eSortGUI1 = 3073,
72         eSortLast = 4096,
73 };
74
75 unsigned int m_state;
76 std::size_t m_sort;
77 GLint m_texture;
78 GLint m_texture1;
79 GLint m_texture2;
80 GLint m_texture3;
81 GLint m_texture4;
82 GLint m_texture5;
83 GLint m_texture6;
84 GLint m_texture7;
85 Vector4 m_colour;
86 GLenum m_blend_src, m_blend_dst;
87 GLenum m_depthfunc;
88 GLenum m_alphafunc;
89 GLfloat m_alpharef;
90 GLfloat m_linewidth;
91 GLfloat m_pointsize;
92 GLint m_linestipple_factor;
93 GLushort m_linestipple_pattern;
94 OpenGLFogState m_fog;
95 GLProgram* m_program;
96
97 OpenGLState() : m_program( 0 ){
98 }
99 };
100
101 class OpenGLStateLibrary
102 {
103 public:
104 INTEGER_CONSTANT( Version, 1 );
105 STRING_CONSTANT( Name, "openglshaderlibrary" );
106
107 virtual void getDefaultState( OpenGLState& state ) const = 0;
108
109 virtual void insert( const char* name, const OpenGLState& state ) = 0;
110 virtual void erase( const char* name ) = 0;
111 };
112
113 #include "modulesystem.h"
114
115 template<typename Type>
116 class GlobalModule;
117 typedef GlobalModule<OpenGLStateLibrary> GlobalOpenGLStateLibraryModule;
118
119 template<typename Type>
120 class GlobalModuleRef;
121 typedef GlobalModuleRef<OpenGLStateLibrary> GlobalOpenGLStateLibraryModuleRef;
122
123 inline OpenGLStateLibrary& GlobalOpenGLStateLibrary(){
124         return GlobalOpenGLStateLibraryModule::getTable();
125 }
126
127 #endif