1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__
6
#define __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__
8
#include "IrrCompileConfig.h"
9
#ifdef _IRR_COMPILE_WITH_OPENGL_
11
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
12
#define GL_GLEXT_LEGACY 1
14
#define GL_GLEXT_PROTOTYPES 1
16
#ifdef _IRR_WINDOWS_API_
17
#define WIN32_LEAN_AND_MEAN
20
#elif defined(_IRR_OSX_PLATFORM_)
21
#include <OpenGL/gl.h>
22
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
24
#include <SDL/SDL_video.h>
25
#include <SDL/SDL_opengl.h>
30
#include "IMaterialRenderer.h"
38
class IShaderConstantSetCallBack;
39
class IMaterialRenderer;
41
//! Class for using vertex and pixel shaders with OpenGL
42
class COpenGLShaderMaterialRenderer : public IMaterialRenderer
47
COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
48
s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,
49
IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData);
52
virtual ~COpenGLShaderMaterialRenderer();
54
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
55
bool resetAllRenderstates, IMaterialRendererServices* services);
57
virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype);
59
virtual void OnUnsetMaterial();
61
//! Returns if the material is transparent.
62
virtual bool isTransparent() const;
66
//! constructor only for use by derived classes who want to
67
//! create a fall back material for example.
68
COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
69
IShaderConstantSetCallBack* callback,
70
IMaterialRenderer* baseMaterial, s32 userData=0);
72
// must not be called more than once!
73
void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram,
74
const c8* pixelShaderProgram, E_VERTEX_TYPE type);
76
bool createPixelShader(const c8* pxsh);
77
bool createVertexShader(const c8* vtxsh);
78
bool checkError(const irr::c8* type);
80
COpenGLDriver* Driver;
81
IShaderConstantSetCallBack* CallBack;
82
IMaterialRenderer* BaseMaterial;
85
// We have 4 values here, [0] is the non-fog version, the other three are
86
// ARB_fog_linear, ARB_fog_exp, and ARB_fog_exp2 in that order
87
core::array<GLuint> PixelShader;
92
} // end namespace video
93
} // end namespace irr