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