1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: demolib.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:$ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_SND_DEMO_DEMOLIB_H_ 17 #define NW_SND_DEMO_DEMOLIB_H_ 18 19 #include <GLES2/gl2.h> 20 #include <GLES2/gl2ext.h> 21 #include <nw/font.h> 22 #include <nw/font/font_RectDrawer.h> 23 #include <nw/demo.h> 24 25 #ifdef NW_PLATFORM_CTRWIN 26 #define NW_SND_DEMO_PATH_PREFIX "romfiles/" 27 #else 28 #define NW_SND_DEMO_PATH_PREFIX "rom:/" 29 #endif 30 31 namespace nw { 32 namespace snd { 33 namespace demolib { 34 35 class AppBase 36 { 37 public: 38 void Initialize(); 39 void Finalize(); 40 void Run(); 41 42 protected: OnInitialize()43 virtual void OnInitialize() {} OnFinalize()44 virtual void OnFinalize() {} OnDrawUpLCD(nw::font::TextWriter &)45 virtual void OnDrawUpLCD( nw::font::TextWriter& ) {} OnDrawDownLCD(nw::font::TextWriter &)46 virtual void OnDrawDownLCD( nw::font::TextWriter& ) {} OnUpdatePad(nw::demo::Pad &)47 virtual void OnUpdatePad( nw::demo::Pad& ) {} OnUpdate()48 virtual void OnUpdate() {} 49 50 virtual void LoadDspComponent(); 51 52 protected: 53 AppBase(); 54 void* MemAlloc( size_t size, u8 alignment = 4 ); 55 void MemFree( void* memory ); SetDraw(bool enable)56 void SetDraw( bool enable ) { m_IsDraw = enable; } IsDraw()57 bool IsDraw() const { return m_IsDraw; } 58 59 private: 60 void InitializeSDK(); 61 void FinalizeSDK(); 62 63 bool InitializeFont(); 64 void FinalizeFont(); 65 66 void InitializeShaders(); 67 void FinalizeShaders(); 68 69 void InitializeDrawStringBuffer(); 70 void FinalizeDrawStringBuffer(); 71 72 void InitializeGX(); 73 void InitializeDraw( int width, int height ); 74 void SetupTextCamera( nw::font::RectDrawer* pDrawer, int width, int height ); 75 76 void DrawStringPreProcess( 77 nw::font::TextWriter& writer, 78 const nw::gfx::FrameBufferObject& frameBufferObject, 79 int width, 80 int height ); 81 void DrawStringPostProcess( 82 nw::font::TextWriter& writer, 83 int width, 84 int height ); 85 86 void Draw(); 87 void Update(); 88 void UpdatePad(); 89 90 nw::font::DispStringBuffer* AllocDispStringBuffer( int charMax ); 91 92 nw::font::ResFont m_Font; 93 nw::font::RectDrawer m_Drawer; 94 95 void* m_pMemoryForRomFileSystem; 96 void* m_pMemoryForDrawBuffer; 97 nw::font::DispStringBuffer* m_pDrawStringBufferUpperLcd; 98 nw::font::DispStringBuffer* m_pDrawStringBufferLowerLcd; 99 100 bool m_IsDraw; 101 }; 102 103 104 105 106 107 } // namespace nw::snd::demolib 108 } // namespace nw::snd 109 } // namespace nw 110 111 #endif /* NW_SND_DEMO_DEMOLIB_H_ */ 112 113