Use separate shaders in the OpenGL3 driver.
--HG-- branch : gsoc2013-dfighterhg/feature/gsoc2013-dfighter
parent
ace1b5386b
commit
32e814ecb6
@ -1,161 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef I_PROGRAM_OBJECT_H
|
||||
#define I_PROGRAM_OBJECT_H
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
|
||||
class IProgram;
|
||||
|
||||
class IProgramObject
|
||||
{
|
||||
public:
|
||||
|
||||
enum EUniform
|
||||
{
|
||||
MVPMatrix,
|
||||
MVMatrix,
|
||||
NormalMatrix,
|
||||
TexMatrix0,
|
||||
TexMatrix1,
|
||||
TexMatrix2,
|
||||
TexMatrix3,
|
||||
Constant0,
|
||||
Constant1,
|
||||
Constant2,
|
||||
Constant3,
|
||||
Diffuse,
|
||||
Color,
|
||||
Sampler0,
|
||||
Sampler1,
|
||||
Sampler2,
|
||||
Sampler3,
|
||||
AlphaTreshold,
|
||||
FogStart,
|
||||
FogEnd,
|
||||
FogColor,
|
||||
FogDensity,
|
||||
Light0Dir,
|
||||
Light1Dir,
|
||||
Light2Dir,
|
||||
Light3Dir,
|
||||
Light4Dir,
|
||||
Light5Dir,
|
||||
Light6Dir,
|
||||
Light7Dir,
|
||||
Light0ColDiff,
|
||||
Light1ColDiff,
|
||||
Light2ColDiff,
|
||||
Light3ColDiff,
|
||||
Light4ColDiff,
|
||||
Light5ColDiff,
|
||||
Light6ColDiff,
|
||||
Light7ColDiff,
|
||||
Light0ColAmb,
|
||||
Light1ColAmb,
|
||||
Light2ColAmb,
|
||||
Light3ColAmb,
|
||||
Light4ColAmb,
|
||||
Light5ColAmb,
|
||||
Light6ColAmb,
|
||||
Light7ColAmb,
|
||||
Light0ColSpec,
|
||||
Light1ColSpec,
|
||||
Light2ColSpec,
|
||||
Light3ColSpec,
|
||||
Light4ColSpec,
|
||||
Light5ColSpec,
|
||||
Light6ColSpec,
|
||||
Light7ColSpec,
|
||||
Light0Shininess,
|
||||
Light1Shininess,
|
||||
Light2Shininess,
|
||||
Light3Shininess,
|
||||
Light4Shininess,
|
||||
Light5Shininess,
|
||||
Light6Shininess,
|
||||
Light7Shininess,
|
||||
Light0Pos,
|
||||
Light1Pos,
|
||||
Light2Pos,
|
||||
Light3Pos,
|
||||
Light4Pos,
|
||||
Light5Pos,
|
||||
Light6Pos,
|
||||
Light7Pos,
|
||||
Light0ConstAttn,
|
||||
Light1ConstAttn,
|
||||
Light2ConstAttn,
|
||||
Light3ConstAttn,
|
||||
Light4ConstAttn,
|
||||
Light5ConstAttn,
|
||||
Light6ConstAttn,
|
||||
Light7ConstAttn,
|
||||
Light0LinAttn,
|
||||
Light1LinAttn,
|
||||
Light2LinAttn,
|
||||
Light3LinAttn,
|
||||
Light4LinAttn,
|
||||
Light5LinAttn,
|
||||
Light6LinAttn,
|
||||
Light7LinAttn,
|
||||
Light0QuadAttn,
|
||||
Light1QuadAttn,
|
||||
Light2QuadAttn,
|
||||
Light3QuadAttn,
|
||||
Light4QuadAttn,
|
||||
Light5QuadAttn,
|
||||
Light6QuadAttn,
|
||||
Light7QuadAttn,
|
||||
NUM_UNIFORMS
|
||||
};
|
||||
|
||||
IProgramObject(){}
|
||||
|
||||
virtual ~IProgramObject(){}
|
||||
|
||||
virtual bool attachVertexProgram( IProgram *shader ) = 0;
|
||||
|
||||
virtual bool attachPixelProgram( IProgram *shader ) = 0;
|
||||
|
||||
virtual bool detachVertexProgram( IProgram *shader ) = 0;
|
||||
|
||||
virtual bool detachPixelProgram( IProgram *shader ) = 0;
|
||||
|
||||
unsigned int getProgramId() const{ return programId; }
|
||||
|
||||
virtual bool link( std::string &log ) = 0;
|
||||
|
||||
virtual bool validate( std::string &log ) = 0;
|
||||
|
||||
virtual void cacheUniformIndices() = 0;
|
||||
|
||||
virtual int getUniformIndex( EUniform uniform ) = 0;
|
||||
|
||||
bool isLinked() const{ return linked; }
|
||||
|
||||
protected:
|
||||
unsigned int programId;
|
||||
bool linked;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,64 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "driver_glsl_shader_base.h"
|
||||
#include "stdopengl.h"
|
||||
#include "driver_opengl_extension.h"
|
||||
|
||||
#define MAX_SHADER_COMPILE_INFOLOG 1024
|
||||
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
|
||||
void CGLSLShaderBase::shaderSource( const char *source )
|
||||
{
|
||||
nlassert( shaderId != 0 );
|
||||
|
||||
const GLchar *p[1];
|
||||
p[ 0 ] = source;
|
||||
GLint lengths[ 1 ];
|
||||
lengths[ 0 ] = strlen( source );
|
||||
|
||||
nglShaderSource( shaderId, 1, p, lengths );
|
||||
}
|
||||
|
||||
bool CGLSLShaderBase::compile( std::string &log )
|
||||
{
|
||||
nglCompileShader( shaderId );
|
||||
|
||||
GLint ok;
|
||||
nglGetShaderiv( shaderId, GL_COMPILE_STATUS, &ok );
|
||||
|
||||
if( ok != GL_TRUE )
|
||||
{
|
||||
char infoLog[ MAX_SHADER_COMPILE_INFOLOG ];
|
||||
nglGetShaderInfoLog( shaderId, MAX_SHADER_COMPILE_INFOLOG, NULL, infoLog );
|
||||
log.assign( infoLog );
|
||||
return false;
|
||||
}
|
||||
|
||||
compiled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef GLSL_SHADER_BASE_H
|
||||
#define GLSL_SHADER_BASE_H
|
||||
|
||||
#include "nel/3d/i_program.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
/// Base class for OpenGL shader objects
|
||||
class CGLSLShaderBase : public IProgram
|
||||
{
|
||||
public:
|
||||
CGLSLShaderBase() : IProgram(){}
|
||||
|
||||
~CGLSLShaderBase(){}
|
||||
|
||||
void shaderSource( const char *source );
|
||||
bool compile( std::string &log );
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,120 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/i_program.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
const char *IProgram::uniformNames[ NUM_UNIFORMS ] =
|
||||
{
|
||||
"mvpMatrix",
|
||||
"mvMatrix",
|
||||
"normalMatrix",
|
||||
"texMatrix0",
|
||||
"texMatrix1",
|
||||
"texMatrix2",
|
||||
"texMatrix3",
|
||||
"constant0",
|
||||
"constant1",
|
||||
"constant2",
|
||||
"constant3",
|
||||
"diffuse",
|
||||
"mcolor",
|
||||
"sampler0",
|
||||
"sampler1",
|
||||
"sampler2",
|
||||
"sampler3",
|
||||
"alphaTreshold",
|
||||
"fogStart",
|
||||
"fogEnd",
|
||||
"fogColor",
|
||||
"fogDensity",
|
||||
"light0Dir",
|
||||
"light1Dir",
|
||||
"light2Dir",
|
||||
"light3Dir",
|
||||
"light4Dir",
|
||||
"light5Dir",
|
||||
"light6Dir",
|
||||
"light7Dir",
|
||||
"light0ColDiff",
|
||||
"light1ColDiff",
|
||||
"light2ColDiff",
|
||||
"light3ColDiff",
|
||||
"light4ColDiff",
|
||||
"light5ColDiff",
|
||||
"light6ColDiff",
|
||||
"light7ColDiff",
|
||||
"light0ColAmb",
|
||||
"light1ColAmb",
|
||||
"light2ColAmb",
|
||||
"light3ColAmb",
|
||||
"light4ColAmb",
|
||||
"light5ColAmb",
|
||||
"light6ColAmb",
|
||||
"light7ColAmb",
|
||||
"light0ColSpec",
|
||||
"light1ColSpec",
|
||||
"light2ColSpec",
|
||||
"light3ColSpec",
|
||||
"light4ColSpec",
|
||||
"light5ColSpec",
|
||||
"light6ColSpec",
|
||||
"light7ColSpec",
|
||||
"light0Shininess",
|
||||
"light1Shininess",
|
||||
"light2Shininess",
|
||||
"light3Shininess",
|
||||
"light4Shininess",
|
||||
"light5Shininess",
|
||||
"light6Shininess",
|
||||
"light7Shininess",
|
||||
"light0Pos",
|
||||
"light1Pos",
|
||||
"light2Pos",
|
||||
"light3Pos",
|
||||
"light4Pos",
|
||||
"light5Pos",
|
||||
"light6Pos",
|
||||
"light7Pos",
|
||||
"light0ConstAttn",
|
||||
"light1ConstAttn",
|
||||
"light2ConstAttn",
|
||||
"light3ConstAttn",
|
||||
"light4ConstAttn",
|
||||
"light5ConstAttn",
|
||||
"light6ConstAttn",
|
||||
"light7ConstAttn",
|
||||
"light0LinAttn",
|
||||
"light1LinAttn",
|
||||
"light2LinAttn",
|
||||
"light3LinAttn",
|
||||
"light4LinAttn",
|
||||
"light5LinAttn",
|
||||
"light6LinAttn",
|
||||
"light7LinAttn",
|
||||
"light0QuadAttn",
|
||||
"light1QuadAttn",
|
||||
"light2QuadAttn",
|
||||
"light3QuadAttn",
|
||||
"light4QuadAttn",
|
||||
"light5QuadAttn",
|
||||
"light6QuadAttn",
|
||||
"light7QuadAttn"
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue