1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: SmPrimitive.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. 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 $Revision: 1 $ 14 *---------------------------------------------------------------------------*/ 15 #ifndef SM_PRIMITIVE_H_ 16 #define SM_PRIMITIVE_H_ 17 18 #include "../include/SmBase.h" 19 #include "../include/SmFile.h" 20 #include "../include/SmCommandUtility.h" 21 22 23 24 //------------------------------------------------------------------------------ 25 // �P���_��� 26 struct SmVertexPC 27 { 28 nw::math::VEC2 position; 29 nw::ut::Color8 color; 30 }; 31 32 33 //------------------------------------------------------------------------------ 34 // �X�e�[�g��V�F�[�_�[�̊Ǘ����s�� 35 class SmOgl : public SmBase 36 { 37 public: 38 // todo:demo_GraphicsDrawing ���烌���^�� 39 enum 40 { 41 SMP_ATTR_POSITION = 0, 42 SMP_ATTR_COLOR, 43 SMP_ATTR_OFFSET, 44 SMP_ATTR_TEXCOORD0 45 }; 46 47 private: 48 // �R���X�g���N�^ 49 SmOgl( const wchar_t* shaderName ); 50 51 // �f�X�g���N�^ 52 virtual ~SmOgl(); 53 54 public: 55 56 // SmOgl �̏����� 57 static SmOgl* InitializeSmOgl( const wchar_t* shaderName ); 58 59 // SmOgl �̏I�� 60 static void TerminateSmOgl(); 61 62 // 2D �G���g���J�n 63 void SetBegin2D(); 64 65 void SetupMaterial(); 66 void SetupTexEnv(); 67 68 private: 69 GLuint m_ProgramID; 70 GLuint m_ShaderID; 71 SmFile m_ShaderFile; 72 73 nw::math::MTX44 m_ProjectionMatrix; 74 nw::math::MTX44 m_ViewMatrix; 75 76 SmCommandReuser m_SetBeginCmd; 77 SmStaticCommandCache::CopiedCmdCache m_CopiedCmdCache; 78 }; 79 80 81 //------------------------------------------------------------------------------ 82 // 2D�|���S����`�悷��N���X 83 class Sm2DPrimPC : public SmBase 84 { 85 // todo:demo_GraphicsDrawing ���烌���^�� 86 enum 87 { 88 VTXATTR_POSITION = 0, 89 VTXATTR_COLOR, 90 VTXATTR_TEXCOORD0 91 }; 92 93 public: 94 // �R���X�g���N�^ 95 Sm2DPrimPC( uint vertexCnt ); 96 97 // �f�X�g���N�^ 98 ~Sm2DPrimPC(); 99 100 // ���ݐς܂�Ă��钸�_�ōX�V���� 101 void Update(); 102 103 // �`�悷�� 104 void Render( GLenum entryMode, f32 posX = 0.f, f32 posY = 0.f ); 105 106 // ���_��o�^���� 107 void SetVertex( uint vertexIdx, f32 x, f32 y, nw::ut::Color8 color ); 108 109 // ���_�J���[��o�^���� 110 void SetVertexColor( nw::ut::Color8 color ); 111 112 private: 113 void RenderSub( GLenum entryMode ); 114 115 116 private: 117 SmVertexPC* m_pVertex; 118 uint m_VertexCnt; 119 120 bool m_VertexUpdate; 121 SmCommandReuser m_CmdCache; 122 123 SmStaticCommandCache::CopiedCmdCache m_CopiedCmdCache; 124 }; 125 126 127 //------------------------------------------------------------------------------ 128 // ���I��2D�|���S����`�悷��N���X 129 class Sm2DDynamicPrimPC : public SmBase 130 { 131 // todo:demo_GraphicsDrawing ���烌���^�� 132 enum 133 { 134 VTXATTR_POSITION = 0, 135 VTXATTR_COLOR, 136 VTXATTR_TEXCOORD0 137 }; 138 139 public: 140 // �R���X�g���N�^ 141 Sm2DDynamicPrimPC(); 142 143 // �f�X�g���N�^ ~Sm2DDynamicPrimPC()144 ~Sm2DDynamicPrimPC(){} 145 146 // �G���g���J�n 147 bool Begin( uint vertexCnt, // ���_�� 148 GLenum entryMode, // �G���g�����[�h 149 f32 posX = 0.f, 150 f32 posY = 0.f ); 151 152 // ���_��o�^���� 153 void SetVertex( f32 x, f32 y, nw::ut::Color8 color ); 154 155 // �G���g���I�� 156 void End(); 157 158 private: 159 Sm2DPrimPC* m_pPrimitive; 160 uint m_VertexCnt; 161 uint m_EntryCnt; 162 GLenum m_EntryMode; 163 f32 m_OffsetX; 164 f32 m_OffsetY; 165 }; 166 167 168 #endif // SM_PRIMITIVE_H_ 169