The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
shader.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Boldizsár Lipka <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 
16 #ifdef SDL_GPU
17 
18 #include "gpu.hpp"
19 #include "image.hpp"
20 #include <string>
21 #include <vector>
22 #include <boost/noncopyable.hpp>
23 #include "exceptions.hpp"
24 
25 #define SHADER_EFFECT_NONE 0
26 #define SHADER_EFFECT_FLIP 1
27 #define SHADER_EFFECT_FLOP 2
28 #define SHADER_EFFECT_GRAYSCALE 4
29 
30 namespace sdl {
31 
32 class timage;
33 
34 class shader_program
35 {
36 public:
37  shader_program(const std::string &vsrc, const std::string &fsrc);
38  shader_program();
39  ~shader_program();
40 
41  shader_program(const shader_program &prog);
42  const shader_program& operator =(const shader_program &prog);
43 
44  void activate();
45  void deactivate();
46 
47  void set_color_mod(int r, int g, int b, int a);
48  void set_submerge(float val);
49  void set_effects(int effects);
50  void set_overlay(const sdl::timage &img);
51 
52 private:
53  Uint32 program_object_, vertex_object_, fragment_object_;
54  GPU_ShaderBlock block_;
55  int attr_color_mod_, attr_submerge_, attr_effects_;
56  int uni_overlay_;
57  // we need to retain a copy of the overlay texture to prevent it from
58  // getting deleted
59  sdl::timage overlay_image_;
60  unsigned *refcount_;
61 };
62 
63 class shader_error : public game::error
64 {
65 public:
66  shader_error(const std::string &op);
67 };
68 
69 }
70 #endif
GLuint const GLfloat * val
Definition: glew.h:2614
GLboolean GLboolean g
Definition: glew.h:7319
GLdouble GLdouble GLdouble b
Definition: glew.h:6966
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:7319
GLdouble GLdouble GLdouble r
Definition: glew.h:1374
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:27
GLint GLvoid * img
Definition: glew.h:1353
GLsizei const GLcharARB ** string
Definition: glew.h:4503