added 3dengfx into the repo, probably not the correct version for this
[summerhack] / src / 3dengfx / src / 3dengfx / gfxprog.hpp
1 /*
2 This file is part of the 3dengfx, realtime visualization system.
3
4 Copyright (c) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
5
6 3dengfx 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 3dengfx 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 3dengfx; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 /* GPU programs support (shaders)
22  *
23  * Author: John Tsiombikas 2005
24  */
25 #ifndef _GFXPROG_HPP_
26 #define _GFXPROG_HPP_
27
28 #include <list>
29 #include "opengl.h"
30 #include "n3dmath2/n3dmath2.hpp"
31
32 enum {
33         PROG_VERTEX     = GL_VERTEX_SHADER_ARB,
34         PROG_PIXEL      = GL_FRAGMENT_SHADER_ARB
35 };
36
37 typedef unsigned int Shader;
38
39 class GfxProg {
40 private:
41         unsigned int prog;
42         std::list<Shader> sdr_list;
43         bool linked;
44         
45         void (*update_handler)(GfxProg*);
46
47 public:
48         GfxProg(Shader vertex = 0, Shader pixel = 0);
49         ~GfxProg();
50
51         void add_shader(Shader sdr);
52         void link();
53
54         bool is_linked() const;
55         unsigned int get_id() const;
56
57         bool set_parameter(const char *pname, int val);
58         bool set_parameter(const char *pname, scalar_t val);
59         bool set_parameter(const char *pname, const Vector2 &val);
60         bool set_parameter(const char *pname, const Vector3 &val);
61         bool set_parameter(const char *pname, const Vector4 &val);
62         bool set_parameter(const char *pname, const Matrix4x4 &val);
63
64         void set_update_handler(void (*func)(GfxProg*));
65
66         friend void set_gfx_program(GfxProg *prog);
67 };
68         
69
70 #endif  // _GFXPROG_HPP_