Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/2d-recalc/src/lib/graphics/shader.h @ 5379

Last change on this file since 5379 was 5323, checked in by bensch, 19 years ago

orxonox/trunk: Shaders can now be loaded via the ResourceManager

File size: 1.7 KB
Line 
1/*!
2 * @file shader.h
3 * @brief Definition of the Shader rendering class
4*/
5
6#ifndef _SHADER_H
7#define _SHADER_H
8
9#include "base_object.h"
10#include "glincl.h"
11
12template<class T> class Array;
13
14typedef enum
15{
16  SHADER_NONE       = 0,
17  SHADER_FRAGMENT   = 1,
18  SHADER_VERTEX     = 0,
19
20} SHADER_TYPE;
21
22// FORWARD DECLARATION
23
24
25//! A class for ...
26class Shader : public BaseObject {
27
28  public:
29  Shader(const char* vertexShaderFile = NULL, const char* fragmentShaderFile = NULL);
30  virtual ~Shader();
31  static Shader* getShader(const char* vertexShaderFile, const char* fragmentShaderFile);
32  static bool unload(Shader* shader);
33
34  bool loadShaderProgramm(SHADER_TYPE type, const char* fileName);
35  void activateShader();
36  static void deactivateShader();
37  void deleteProgram(SHADER_TYPE type);
38
39  char* fileRead(const char* fileName);
40  Array<char*>* fileReadArray(const char* fileName);
41
42  static bool checkShaderAbility();
43
44  inline static bool shaderActive() { return (Shader::storedShader != NULL)?true:false; };
45  inline static Shader* getActiveShader() { return Shader::storedShader; };
46  inline static void suspendShader() { Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
47  inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; };
48
49
50  void printError(GLhandleARB program);
51  void debug() const;
52
53  private:
54
55 private:
56   char*                  fragmentShaderFile;
57   char*                  vertexShaderFile;
58   GLhandleARB            shaderProgram;
59   GLhandleARB            vertexShader;
60   GLhandleARB            fragmentShader;
61
62   static Shader*         storedShader;
63};
64
65#endif /* _SHADER_H */
Note: See TracBrowser for help on using the repository browser.