/*---------------------------------------------------------------------------* Project: NintendoWare File: SmPrimitive.h Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. 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. $Revision: 1 $ *---------------------------------------------------------------------------*/ #ifndef SM_PRIMITIVE_H_ #define SM_PRIMITIVE_H_ #include "../include/SmBase.h" #include "../include/SmFile.h" #include "../include/SmCommandUtility.h" //------------------------------------------------------------------------------ // 1頂点情報 struct SmVertexPC { nw::math::VEC2 position; nw::ut::Color8 color; }; //------------------------------------------------------------------------------ // ステートやシェーダーの管理を行う class SmOgl : public SmBase { public: // todo:demo_GraphicsDrawing からレンタル enum { SMP_ATTR_POSITION = 0, SMP_ATTR_COLOR, SMP_ATTR_OFFSET, SMP_ATTR_TEXCOORD0 }; private: // コンストラクタ SmOgl( const wchar_t* shaderName ); // デストラクタ virtual ~SmOgl(); public: // SmOgl の初期化 static SmOgl* InitializeSmOgl( const wchar_t* shaderName ); // SmOgl の終了 static void TerminateSmOgl(); // 2D エントリ開始 void SetBegin2D(); void SetupMaterial(); void SetupTexEnv(); private: GLuint m_ProgramID; GLuint m_ShaderID; SmFile m_ShaderFile; nw::math::MTX44 m_ProjectionMatrix; nw::math::MTX44 m_ViewMatrix; SmCommandReuser m_SetBeginCmd; SmStaticCommandCache::CopiedCmdCache m_CopiedCmdCache; }; //------------------------------------------------------------------------------ // 2Dポリゴンを描画するクラス class Sm2DPrimPC : public SmBase { // todo:demo_GraphicsDrawing からレンタル enum { VTXATTR_POSITION = 0, VTXATTR_COLOR, VTXATTR_TEXCOORD0 }; public: // コンストラクタ Sm2DPrimPC( uint vertexCnt ); // デストラクタ ~Sm2DPrimPC(); // 現在積まれている頂点で更新する void Update(); // 描画する void Render( GLenum entryMode, f32 posX = 0.f, f32 posY = 0.f ); // 頂点を登録する void SetVertex( uint vertexIdx, f32 x, f32 y, nw::ut::Color8 color ); // 頂点カラーを登録する void SetVertexColor( nw::ut::Color8 color ); private: void RenderSub( GLenum entryMode ); private: SmVertexPC* m_pVertex; uint m_VertexCnt; bool m_VertexUpdate; SmCommandReuser m_CmdCache; SmStaticCommandCache::CopiedCmdCache m_CopiedCmdCache; }; //------------------------------------------------------------------------------ // 動的な2Dポリゴンを描画するクラス class Sm2DDynamicPrimPC : public SmBase { // todo:demo_GraphicsDrawing からレンタル enum { VTXATTR_POSITION = 0, VTXATTR_COLOR, VTXATTR_TEXCOORD0 }; public: // コンストラクタ Sm2DDynamicPrimPC(); // デストラクタ ~Sm2DDynamicPrimPC(){} // エントリ開始 bool Begin( uint vertexCnt, // 頂点数 GLenum entryMode, // エントリモード f32 posX = 0.f, f32 posY = 0.f ); // 頂点を登録する void SetVertex( f32 x, f32 y, nw::ut::Color8 color ); // エントリ終了 void End(); private: Sm2DPrimPC* m_pPrimitive; uint m_VertexCnt; uint m_EntryCnt; GLenum m_EntryMode; f32 m_OffsetX; f32 m_OffsetY; }; #endif // SM_PRIMITIVE_H_