Skip to content

Commit

Permalink
Rename ShaderRenderer conventions enum
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolassavva-autodesk committed Aug 24, 2023
1 parent 414623c commit d0d21fc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions source/MaterialXRender/ShaderRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ const float DEFAULT_FAR_PLANE = 100.0f;
// ShaderRenderer methods
//

ShaderRenderer::ShaderRenderer(unsigned int width, unsigned int height, Image::BaseType baseType, ConventionAPI conventionAPI) :
ShaderRenderer::ShaderRenderer(unsigned int width, unsigned int height, Image::BaseType baseType, MatrixConvention matrixConvention) :
_width(width),
_height(height),
_baseType(baseType),
_conventionAPI(conventionAPI)
_matrixConvention(matrixConvention)
{
// Initialize a default camera.
float fH = std::tan(DEFAULT_FIELD_OF_VIEW / 360.0f * PI) * DEFAULT_NEAR_PLANE;
float fW = fH * 1.0f;
_camera = Camera::create();
_camera->setViewMatrix(Camera::createViewMatrix(DEFAULT_EYE_POSITION, DEFAULT_TARGET_POSITION, DEFAULT_UP_VECTOR));

if (_conventionAPI == ShaderRenderer::ConventionAPI::METAL)
if (_matrixConvention == ShaderRenderer::MatrixConvention::Metal)
{
_camera->setProjectionMatrix(Camera::createPerspectiveMatrixZP(-fW, fW, -fH, fH, DEFAULT_NEAR_PLANE, DEFAULT_FAR_PLANE));
}
else // ConventionAPI::OPENGL (default)
else // MatrixConvention::OpenGL (default)
{
_camera->setProjectionMatrix(Camera::createPerspectiveMatrix(-fW, fW, -fH, fH, DEFAULT_NEAR_PLANE, DEFAULT_FAR_PLANE));
}
Expand Down
12 changes: 6 additions & 6 deletions source/MaterialXRender/ShaderRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ using ShaderRendererPtr = std::shared_ptr<class ShaderRenderer>;
class MX_RENDER_API ShaderRenderer
{
public:
/// API viewing conventions designation (default to OpenGL).
enum class ConventionAPI
/// Viewing API matrix conventions designation (default to OpenGL).
enum class MatrixConvention
{
OPENGL = 0,
METAL = 1
OpenGL = 0,
Metal = 1
};
/// A map with name and source code for each shader stage.
using StageMap = StringMap;
Expand Down Expand Up @@ -130,14 +130,14 @@ class MX_RENDER_API ShaderRenderer

protected:
ShaderRenderer(unsigned int width, unsigned int height, Image::BaseType baseType,
ConventionAPI conventionAPI = ConventionAPI::OPENGL);
MatrixConvention matrixConvention = MatrixConvention::OpenGL);

protected:
unsigned int _width;
unsigned int _height;
Image::BaseType _baseType;

ConventionAPI _conventionAPI;
MatrixConvention _matrixConvention;

CameraPtr _camera;
ImageHandlerPtr _imageHandler;
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXRenderGlsl/GlslRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GlslRendererPtr GlslRenderer::create(unsigned int width, unsigned int height, Im
}

GlslRenderer::GlslRenderer(unsigned int width, unsigned int height, Image::BaseType baseType) :
ShaderRenderer(width, height, baseType, ConventionAPI::OPENGL),
ShaderRenderer(width, height, baseType, MatrixConvention::OpenGL),
_initialized(false),
_screenColor(DEFAULT_SCREEN_COLOR_LIN_REC709)
{
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXRenderMsl/MslRenderer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}

MslRenderer::MslRenderer(unsigned int width, unsigned int height, Image::BaseType baseType) :
ShaderRenderer(width, height, baseType, ConventionAPI::METAL),
ShaderRenderer(width, height, baseType, MatrixConvention::Metal),
_initialized(false),
_screenColor(DEFAULT_SCREEN_COLOR_LIN_REC709)
{
Expand Down

0 comments on commit d0d21fc

Please sign in to comment.