1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: GrRenderer.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 18 #include <nn/os.h> 19 #include <nn/fs.h> 20 21 #include <nn/gr.h> 22 23 #include <nw/ut.h> 24 #include <nw/demo.h> 25 26 27 //! @brief 直方体の頂点ストリーム・インデックスストリームのデータを保持するクラスです。 28 class PrimitiveBox 29 { 30 private: 31 NW_DISALLOW_COPY_AND_ASSIGN(PrimitiveBox); 32 33 public: 34 static const u32 VERTEX_NUM = 36; 35 PrimitiveBox()36 PrimitiveBox() {} 37 ~PrimitiveBox()38 virtual ~PrimitiveBox() {} 39 40 void Initialize(const nn::math::VEC3& halfEdges); 41 Finalize()42 void Finalize() {} 43 44 f32 m_StreamPosition[VERTEX_NUM * 3]; 45 f32 m_StreamNormal [VERTEX_NUM * 3]; 46 f32 m_StreamColor [VERTEX_NUM * 4]; 47 u16 m_StreamIndex [VERTEX_NUM * 1]; 48 }; 49 50 51 //! @brief 直方体を描画するクラスです。 52 class GrPrimitiveRenderer 53 { 54 private: 55 NW_DISALLOW_COPY_AND_ASSIGN(GrPrimitiveRenderer); 56 57 public: GrPrimitiveRenderer()58 GrPrimitiveRenderer() 59 : m_DeviceAllocator(NULL), 60 m_ShaderBinary(NULL), 61 m_PrimitiveBox(NULL) 62 {} 63 ~GrPrimitiveRenderer()64 virtual ~GrPrimitiveRenderer() {} 65 66 public: 67 virtual void Initialize( 68 nw::demo::DemoAllocator* deviceAllocator, 69 const wchar_t* shaderFilePath); 70 71 virtual void Finalize(); 72 73 void InitializeShader(const wchar_t* shaderFilePath); 74 75 // プリミティブの初期化 76 void InitializePrimitive(); 77 78 void InitializeEnvironments(); 79 80 // 無効化のコマンドを生成します MakeDisableCommand(bit32 * command)81 bit32* MakeDisableCommand(bit32* command) 82 { 83 return nn::gr::CTR::MakeDisableAllCommand(command); 84 } 85 86 bit32* MakeSceneBeginCommand(bit32* command); 87 88 bit32* MakeDrawBoxCommand(bit32* command, const nn::math::MTX34& worldMatrix); 89 MakeSceneEndCommand(bit32 * command)90 bit32* MakeSceneEndCommand(bit32* command) 91 { 92 return MakeDisableCommand(command); 93 } 94 95 96 private: 97 nw::demo::DemoAllocator* m_DeviceAllocator; 98 99 u8* m_ShaderBinary; 100 nn::gr::Shader m_Shader; 101 102 nn::math::MTX34 m_Mtx; 103 nn::math::MTX44 m_ProjectionMtx; 104 nn::math::MTX34 m_ViewMtx; 105 106 nn::gr::BindSymbolVSFloat m_BindSymbolWorldMtx; 107 nn::gr::BindSymbolVSFloat m_BindSymbolProjMtx; 108 nn::gr::BindSymbolVSFloat m_BindSymbolViewMtx; 109 110 nn::gr::Viewport m_Viewport; 111 nn::gr::Scissor m_Scissor; 112 113 PrimitiveBox* m_PrimitiveBox; 114 nn::gr::Vertex m_VertexBox; 115 nn::gr::Vertex::IndexStream m_IndexStreamBox; 116 }; 117 118