/*---------------------------------------------------------------------------* Project: Horizon File: demo_ProgramObject.h Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 46365 $ *---------------------------------------------------------------------------*/ #ifndef DEMO_PROGRAM_OBJECT_H_ #define DEMO_PROGRAM_OBJECT_H_ #include #include #include "demo/Utility/demo_Utility.h" #include "demo/RenderData/demo_TrianglesRenderData.h" namespace demo { /*! :private @brief Maximum number of shader that the ProgramObject class can maintain */ const u32 PROGRAM_OBJECT_MAX_SHADERS = 1; /*! :private @brief Base class for the shader program. */ class ProgramObject : private nn::util::NonCopyable { public: /*! :private @brief Constructor. */ ProgramObject(void); /*! :private @brief Destructor. */ virtual ~ProgramObject(void); public: /*! :private @brief Performs initialization for the shader program object. */ virtual bool Initialize(const GLuint shaderId) = 0; /*! :private @brief Performs termination for the shader program object. */ virtual bool Finalize(void) = 0; public: /*! :private @brief Sets the rendering state before the shader program object is used. */ virtual bool Begin(void); /*! :private @brief Uses shader program object. */ virtual bool Use(void) = 0; /*! :private @brief Sets the rendering state after the shader program object is used. */ virtual bool End(void); public: /*! :private @brief Gets vertex attributes set in the shader program object. @return Vertex attributes */ virtual u32 GetVertexAttributes(void); /*! :private @brief Sets whether to convert the 3-dimensional vertex position coordinates to clip coordinates using the projection matrix and model view matrix. @param[in] use3d Whether to convert to the clip coordinate system (true or false) */ virtual void SetUse3d(const bool use3d); /*! :private @brief Sets the projection matrix for the shader program object. @param[in] projectionMatrix Projection matrix */ virtual void SetProjectionMatrix(const nn::math::MTX44& projectionMatrix); /*! :private @brief Sets the model view matrix for the shader program object. @param[in] modelViewMatrix Model view matrix */ virtual void SetModelViewMatrix(const nn::math::MTX44& modelViewMatrix); /*! :private @brief Sets a texture object handle. @param[in] textureId Texture object handle */ virtual void SetTextureId(const GLuint textureId); /*! :private @brief Updates the internal state of the shader program object. */ virtual void Update(void); protected: virtual void InitializeVertexAttributes(void); virtual void InitializeUniforms(void); virtual void UpdateModelViewProjectionMatrix(void); protected: bool m_Initialized; bool m_Padding0[3]; u32 m_VertexAttributes; bool m_Use3d; u8 m_Padding[3]; GLuint m_ProgramId; GLuint m_ShaderIds[PROGRAM_OBJECT_MAX_SHADERS]; GLint m_UniformLocation[MAX_UNIFORM_LOCATIONS_NUM]; nn::math::MTX44 m_ProjectionMatrix; nn::math::MTX44 m_ModelViewMatrix; }; } #endif