~jaytaoko/nuxcodesamples/nuxcodesamples-gst-video-decode

« back to all changes in this revision

Viewing changes to src/visual-fx/AbstractEffectShader.h

  • Committer: Jay Taoko
  • Date: 2012-01-07 19:20:32 UTC
  • Revision ID: jay.taoko@canonical.com-20120107192032-5fymlfzbeyx84fz3
- Visual FX program

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef ABSTRACTEFFECTSHADER_H
 
2
#define ABSTRACTEFFECTSHADER_H
 
3
 
 
4
#include "Nux/Utils.h"
 
5
 
 
6
#define ATTRIB_INVALID             -1
 
7
#define ATTRIB_POSITION             0
 
8
#define ATTRIB_WEIGHT               1
 
9
#define ATTRIB_NORMAL               2
 
10
#define ATTRIB_COLOR                3
 
11
#define ATTRIB_COLOR_PRIMARY        3
 
12
#define ATTRIB_COLOR_SECONDARY      4
 
13
#define ATTRIB_FOGCOORD       5
 
14
#define ATTRIB_TEXCOORD       8
 
15
#define ATTRIB_TEXCOORD0      8
 
16
#define ATTRIB_TEXCOORD1      9
 
17
#define ATTRIB_TEXCOORD2      10
 
18
#define ATTRIB_TEXCOORD3      11
 
19
#define ATTRIB_TEXCOORD4      12
 
20
#define ATTRIB_TEXCOORD5      13
 
21
#define ATTRIB_TEXCOORD6      14
 
22
#define ATTRIB_TEXCOORD7      15
 
23
 
 
24
#if defined(NUX_OS_WINDOWS)
 
25
#define PKGDATADIR "../../data/"
 
26
#endif
 
27
 
 
28
class AbstractEffectShader
 
29
{
 
30
public:
 
31
    AbstractEffectShader();
 
32
    virtual ~AbstractEffectShader();
 
33
    //void SetLightColor(float red, float green, float blue, float alpha);
 
34
    
 
35
    void SetMaterialAmbientColor(float red, float green, float blue, float alpha);
 
36
    void SetMaterialDiffuseColor(float red, float green, float blue, float alpha);
 
37
    void SetMaterialSpecularColor(float red, float green, float blue, float alpha);
 
38
    
 
39
    void SetGlobalMaterialAmbientColor(float red, float green, float blue, float alpha);
 
40
    void SetGlobalMaterialDiffuseColor(float red, float green, float blue, float alpha);
 
41
    void SetGlobalMaterialSpecularColor(float red, float green, float blue, float alpha);
 
42
 
 
43
    void SetMaterialSpecularExponent(float exponent);
 
44
    void SetAmbientCoefficient(float Ka);
 
45
    void SetObjectAlpha(float alpha);
 
46
 
 
47
    virtual void ReloadShader();
 
48
    virtual void Draw(nux::GraphicsEngine& GfxContext, nux::Geometry Viewport, const nux::Matrix4& CameraMatrix, const nux::Matrix4& ProjectionMatrix);
 
49
 
 
50
    nux::NString gPinkShader0;
 
51
 
 
52
    void RenderTexture(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture,
 
53
        nux::Color color,
 
54
        float x, float y, 
 
55
        float width, float height,
 
56
        bool inversey = false);
 
57
 
 
58
    void RenderTextureASM(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture,
 
59
        nux::Color color,
 
60
        float x, float y, 
 
61
        float width, float height,
 
62
        bool inversey = false);
 
63
 
 
64
    void RenderTextureExponentiation(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture, float exponent, float brightness, float x, float y, float width, float height, bool inversey);
 
65
    void RenderTextureExponentiationASM(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture, float exponent, float brightness, float x, float y, float width, float height, bool inversey);
 
66
 
 
67
    void RenderTextureAlpha(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture,
 
68
        nux::Color color,
 
69
        float x, float y, 
 
70
        float width, float height,
 
71
        bool inversey);
 
72
 
 
73
    void RenderHorizontalBlur(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture, float sigma, unsigned int num_tap, float x, float y, float width, float height, bool inversey = false);
 
74
    void RenderHorizontalBlurASM(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture, float sigma, unsigned int num_tap, float x, float y, float width, float height, bool inversey = false);
 
75
    void RenderVerticalBlur(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture, float sigma, unsigned int num_tap, float x, float y, float width, float height, bool inversey = false);
 
76
    void RenderVerticalBlurASM(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture, float sigma, unsigned int num_tap, float x, float y, float width, float height, bool inversey = false);
 
77
 
 
78
    void RenderColorMatrixFilter(nux::GraphicsEngine& GfxContext, nux::ObjectPtr<nux::IOpenGLTexture2D> Texture,
 
79
        float *array20,
 
80
//         nux::Vector4 v0,
 
81
//         nux::Vector4 v1,
 
82
//         nux::Vector4 v2,
 
83
//         nux::Vector4 v3,
 
84
//         nux::Vector4 v4,
 
85
        float x, float y, float width, float height, bool inversey);
 
86
 
 
87
protected:
 
88
    //nux::Color m_LightColor;
 
89
    nux::Color m_MaterialAmbientColor;
 
90
    nux::Color m_MaterialDiffuseColor;
 
91
    nux::Color m_MaterialSpecularColor;
 
92
 
 
93
    nux::Color m_GlobalMaterialAmbientColor;
 
94
    nux::Color m_GlobalMaterialDiffuseColor;
 
95
    nux::Color m_GlobalMaterialSpecularColor;
 
96
 
 
97
    float m_MaterialSpecularExponent;
 
98
    float m_AmbientCoefficient;
 
99
    float m_ObjectAlpha;
 
100
 
 
101
    nux::GLShaderParameter* vxtunf_ObjectMatrix;
 
102
    nux::GLShaderParameter* vxtunf_CameraMatrix;
 
103
    nux::GLShaderParameter* vxtunf_ProjectionMatrix;
 
104
    nux::GLShaderParameter* vxtunf_InverseObjectToCameraMatrix;
 
105
    nux::GLShaderParameter* frgunf_ObjectAlpha;
 
106
 
 
107
    nux::ObjectPtr<nux::IOpenGLShaderProgram> m_TextureProg;
 
108
    nux::ObjectPtr<nux::IOpenGLShaderProgram> m_ExponentProg;
 
109
    nux::ObjectPtr<nux::IOpenGLShaderProgram> m_TextureAlphaProg;
 
110
    nux::ObjectPtr<nux::IOpenGLShaderProgram> m_HorizontalGaussProg;
 
111
    nux::ObjectPtr<nux::IOpenGLShaderProgram> m_VerticalGaussProg;
 
112
    nux::ObjectPtr<nux::IOpenGLShaderProgram> m_ColorMatrixFilterProg;
 
113
 
 
114
    unsigned int m_VertexProgramASM;
 
115
    unsigned int m_FragmentProgramASM;
 
116
    unsigned int m_ExponentProgramASM;
 
117
    unsigned int m_SeparableBlurProgramASM;
 
118
};
 
119
 
 
120
 
 
121
void SetFrameBufferHelper(nux::GraphicsEngine& GfxContext,
 
122
                          nux::ObjectPtr<nux::IOpenGLFrameBufferObject>& fbo,
 
123
                          nux::ObjectPtr<nux::IOpenGLTexture2D>& colorbuffer,
 
124
                          nux::ObjectPtr<nux::IOpenGLTexture2D>& depthbuffer,
 
125
                          int width, int height);
 
126
 
 
127
void GaussianWeights(float **weights, float sigma, unsigned int num_tap);
 
128
 
 
129
#endif // ABSTRACTEFFECTSHADER_H