2016-03-21 04:10:14 +00:00
|
|
|
#ifndef _R3DSHADER_H_
|
|
|
|
#define _R3DSHADER_H_
|
|
|
|
|
|
|
|
#include "Pkgs/glew.h"
|
|
|
|
#include "Model.h"
|
|
|
|
|
|
|
|
namespace New3D {
|
|
|
|
|
|
|
|
class R3DShader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
R3DShader();
|
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
bool LoadShader (const char* vertexShader = nullptr, const char* fragmentShader = nullptr);
|
|
|
|
void SetMeshUniforms (const Mesh* m);
|
|
|
|
void SetModelStates (const Model* model);
|
|
|
|
void SetViewportUniforms (const Viewport *vp);
|
|
|
|
void Start ();
|
|
|
|
void SetShader (bool enable = true);
|
2016-03-21 04:10:14 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
// shader IDs
|
2016-03-21 04:10:14 +00:00
|
|
|
GLuint m_shaderProgram;
|
|
|
|
GLuint m_vertexShader;
|
|
|
|
GLuint m_fragmentShader;
|
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
// mesh uniform locations
|
2016-05-04 00:35:07 +00:00
|
|
|
GLint m_locTexture1;
|
|
|
|
GLint m_locTexture2;
|
|
|
|
GLint m_locTexture1Enabled;
|
|
|
|
GLint m_locTexture2Enabled;
|
2016-03-21 04:10:14 +00:00
|
|
|
GLint m_locTextureAlpha;
|
|
|
|
GLint m_locAlphaTest;
|
2016-12-09 14:13:46 +00:00
|
|
|
GLint m_locMicroTexScale;
|
2017-03-28 20:24:44 +00:00
|
|
|
GLint m_locBaseTexSize;
|
2016-03-21 04:10:14 +00:00
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
// cached mesh values
|
2016-05-04 00:35:07 +00:00
|
|
|
bool m_textured1;
|
|
|
|
bool m_textured2;
|
2016-03-22 23:39:59 +00:00
|
|
|
bool m_textureAlpha; // use alpha in texture
|
|
|
|
bool m_alphaTest; // discard fragment based on alpha (ogl does this with fixed function)
|
|
|
|
float m_fogIntensity;
|
|
|
|
bool m_doubleSided;
|
|
|
|
bool m_lightEnabled;
|
2016-05-15 16:24:49 +00:00
|
|
|
float m_shininess;
|
|
|
|
float m_specularCoefficient;
|
2016-05-27 19:30:40 +00:00
|
|
|
bool m_layered;
|
2016-12-09 14:13:46 +00:00
|
|
|
float m_microTexScale;
|
2017-03-28 20:24:44 +00:00
|
|
|
float m_baseTexSize[2];
|
2016-03-21 04:10:14 +00:00
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
// cached model values
|
|
|
|
enum class MatDet { notset, negative, positive, zero };
|
|
|
|
MatDet m_matDet;
|
2016-03-21 04:10:14 +00:00
|
|
|
|
2016-03-22 23:39:59 +00:00
|
|
|
// are our cache values dirty
|
|
|
|
bool m_dirtyMesh;
|
|
|
|
bool m_dirtyModel;
|
|
|
|
|
|
|
|
// viewport uniform locations
|
2016-03-21 04:10:14 +00:00
|
|
|
GLint m_locFogIntensity;
|
2017-04-02 21:03:59 +00:00
|
|
|
GLint m_locFogDensity;
|
|
|
|
GLint m_locFogStart;
|
|
|
|
GLint m_locFogColour;
|
|
|
|
GLint m_locFogAttenuation;
|
|
|
|
GLint m_locFogAmbient;
|
|
|
|
|
|
|
|
// lighting
|
|
|
|
GLint m_locLighting;
|
2016-03-21 04:10:14 +00:00
|
|
|
GLint m_locLightEnable;
|
|
|
|
GLint m_locShininess;
|
2016-05-15 16:24:49 +00:00
|
|
|
GLint m_locSpecCoefficient;
|
2017-04-02 21:03:59 +00:00
|
|
|
GLint m_locSpotEllipse;
|
|
|
|
GLint m_locSpotRange;
|
|
|
|
GLint m_locSpotColor;
|
|
|
|
GLint m_locSpotFogColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // New3D
|
2016-03-21 04:10:14 +00:00
|
|
|
|
|
|
|
#endif
|