1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: demo_ShaderManager.h 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 46365 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef DEMO_SHADER_MANAGER_H_ 17 #define DEMO_SHADER_MANAGER_H_ 18 19 #include <nn/gx.h> 20 #include <nn/math.h> 21 22 #include "demo/ShaderProgram/demo_ProgramObject.h" 23 #include "demo/ShaderProgram/demo_ColorFillProgram.h" 24 #include "demo/ShaderProgram/demo_FontProgram.h" 25 #include "demo/ShaderProgram/demo_DecalTextureProgram.h" 26 27 namespace demo 28 { 29 30 /*! 31 :private 32 33 @brief Maximum shader binary count for ShaderManager class 34 */ 35 const u32 MAX_SHADER_BINARY_NUM = 1; 36 37 /*! 38 :private 39 40 @brief Maximum shader count of a single shader binary for the ShaderManager class 41 */ 42 const u32 MAX_SHADER_PROGRAM_NUM = 3; 43 44 /*! 45 :private 46 47 @brief Enumerate type indicating the basic shader 48 */ 49 enum ShaderType 50 { 51 COLOR_FILL_SHADER = 0, //!< vertex color shader 52 FONT_SHADER = 1, //!< font shader 53 DECAL_TEXTURE_SHADER = 2, //!< decal texture shader 54 BASIC_SHADER_BINARY_SHADER_NUM = 3 //!< total number of basic shaders 55 }; 56 57 /*! 58 :private 59 60 @brief Shader binary index of basic shader 61 */ 62 const u32 BASIC_SHADER_BINARY_INDEX = 0; 63 64 /*! 65 :private 66 67 @brief Class that manages shaders. 68 */ 69 70 class ShaderManager : private nn::util::NonCopyable<ShaderManager> 71 { 72 public: 73 /*! 74 :private 75 76 @brief Constructor. 77 */ 78 ShaderManager(void); 79 80 /*! 81 :private 82 83 @brief Destructor. 84 */ 85 virtual ~ShaderManager(void); 86 87 public: 88 /*! 89 :private 90 91 @brief Performs initial process. 92 */ 93 virtual bool Initialize(void); 94 95 /*! 96 :private 97 98 @brief Performs shutdown. 99 */ 100 virtual bool Finalize(void); 101 protected: 102 virtual bool InitializeBasicShader(void); 103 104 public: 105 /*! 106 :private 107 108 @brief Gets vertex attributes of specified shader. 109 @param[in] shaderType Shader type 110 @return Vertex attributes 111 */ 112 u32 GetVertexAttributes(const ShaderType shaderType); 113 114 /*! 115 :private 116 117 @brief Gets pointer to specified shader. 118 119 @param[in] shaderType Shader type 120 @return Shader program pointer 121 */ 122 ProgramObject* GetShaderProgram(const ShaderType shaderType); 123 124 protected: 125 bool m_Initialized; 126 u8 m_Padding[3]; 127 GLuint m_ShaderProgramIdArray[MAX_SHADER_BINARY_NUM][MAX_SHADER_PROGRAM_NUM]; 128 ProgramObject* m_ShaderProgramPtrArray[MAX_SHADER_BINARY_NUM][MAX_SHADER_PROGRAM_NUM]; 129 130 protected: 131 ColorFillProgram m_ColorFillProgram; 132 FontProgram m_FontProgram; 133 DecalTextureProgram m_DecalTextureProgram; 134 }; 135 136 } 137 138 #endif 139