The Win32 bindings for the OpenGl version of the renderers, contexts and shaders were created.
The main plugin-based shader class was created (hlslModularProgram).
The class exposes the all- important Activate, Init, Reshape, Render methods.
Init takes in a templatized object that, depending on the definition, contains different fields to activate and deactivate features.
Starting supported features were:
- usesVertexPositions (denotes that the vertex shader will have Position defined as an input parameter) -> exposes vertexPosition_AttributeName as a configuration parameter, which then the plugin will use to retrieve the relevant attribute location where a mesh's Position will be uploaded
- usesVertexNormals (denotes that the vertex shader will have Position defined as an input parameter) -> exposes vertexNormal_AttributeName as a configuration parameter, which then the plugin will use to retrieve the relevant attribute location where a mesh's Normals will be uploaded
- usesTexUvs
- usesLights
- usesMaterials
Since these were enough to get going, the rest would have to wait a bit.
After some necessary work of actually implementing the Plugins that were using the above attributes, the first, simplistic, per-vertex lighted sphere appeared on the screen. No screenshots for that I'm afraid :)
An example of the way the class is instantiated follows
//The template parameters activate and deactivate the features
typedef grg::xlslModularProgram < _myApi,
true, true, true, true, true, false, false > shaderType;
auto shader = new shaderType(Context());
shader->createProgram("data\\shaders\\PerFragment_vs.glsl", "data\\shaders\\PerFragment_BlinnPhong_fs.glsl");
//The configuration object's fields change depending on the template parameters defined in the shader
auto config = shader->getConfigurationObject();
config.core_EntityManager = &entityManager;
config.light_CoordinateSpace = grg::CoordinateSpaces::WORLD_SPACE;
config.light_UniformBlockName = "Lights";
config.material_UniformName = "material";
config.matrix_Camera = &camera;
config.matrix_UniformBlockName = "Matrices";
config.vertexPos_AttributeName = "position";
config.vertexNormal_AttributeName = "normal";
shader->init(config);
grg::xlslTechnique<_myApi> temp = grg::xlslTechnique<_myApi>();
temp.push_back(shader);
shaderManager.addTechnique(temp);
An example of the way the class is instantiated follows
//The template parameters activate and deactivate the features
typedef grg::xlslModularProgram < _myApi,
true, true, true, true, true, false, false > shaderType;
auto shader = new shaderType(Context());
shader->createProgram("data\\shaders\\PerFragment_vs.glsl", "data\\shaders\\PerFragment_BlinnPhong_fs.glsl");
//The configuration object's fields change depending on the template parameters defined in the shader
auto config = shader->getConfigurationObject();
config.core_EntityManager = &entityManager;
config.light_CoordinateSpace = grg::CoordinateSpaces::WORLD_SPACE;
config.light_UniformBlockName = "Lights";
config.material_UniformName = "material";
config.matrix_Camera = &camera;
config.matrix_UniformBlockName = "Matrices";
config.vertexPos_AttributeName = "position";
config.vertexNormal_AttributeName = "normal";
shader->init(config);
grg::xlslTechnique<_myApi> temp = grg::xlslTechnique<_myApi>();
temp.push_back(shader);
shaderManager.addTechnique(temp);
No comments:
Post a Comment