1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     demo_RenderData.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  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   $Rev: 46365 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef DEMO_RENDER_DATA_H_
17 #define DEMO_RENDER_DATA_H_
18 
19 #include <nn/gx.h>
20 #include <nn/util.h>
21 
22 namespace demo
23 {
24 
25     /*!
26     :private
27 
28     @brief    Gets the width of the LCD.
29 
30     @param[in]    display    Target LCD (NN_GX_DISPLAY0 or NN_GX_DISPLAY1)
31     @return       LCD width
32     */
33     f32 GetLcdWidth(const s32 display);
34 
35     /*!
36     :private
37 
38     @brief    Gets the height of the LCD.
39 
40     @param[in]    display    Target LCD (NN_GX_DISPLAY0 or NN_GX_DISPLAY1)
41     @return       LCD height
42     */
43     f32 GetLcdHeight(const s32 display);
44 
45     /*!
46     :private
47 
48     @brief Base class for the rendering data.
49     */
50     class RenderData : private nn::util::NonCopyable<RenderData>
51     {
52     public:
53         /*!
54         :private
55 
56         @brief    Constructor.
57         */
58         RenderData(void);
59         /*!
60         :private
61 
62         @brief    Destructor.
63         */
64         virtual ~RenderData(void);
65 
66     public:
67         /*!
68         :private
69 
70         @brief    Initializes the rendering data.
71         */
72         virtual void Initialize(void);
73 
74         /*!
75         :private
76 
77         @brief    Finalizes the rendering data.
78         */
79         virtual void Finalize(void);
80 
81     public:
82         /*!
83         :private
84 
85         @brief    Performs rendering using the rendering data.
86         */
87         virtual void Draw(void) = 0;
88 
89     public:
90         /*!
91         :private
92 
93         @brief    Sets the window size to convert from the normalized device coordinate system to the window coordinate system.
94 
95         @param[in]    windowWidth    Window width
96         @param[in]    windowHeight   Window height
97         */
98         virtual void SetWindowSize(const f32 windowWidth, const f32 windowHeight);
99 
100     public:
101         /*!
102         :private
103 
104         @brief   Converts provided window coordinates to normalized device coordinates.
105 
106         @param[in]    windowCoordinateX    X-coordinate for the window coordinates
107         @param[in]    windowCoordinateY    Y-coordinate for the window coordinates
108         @param[out]   normalizedDeviceCoordinateX      X-coordinate for the normalized device coordinates
109         @param[out]   normalizedDeviceCoordinateY      Y-coordinate for the normalized device coordinates
110         */
111         virtual void GetNormalizedDeviceCoordinateXY(const f32 windowCoordinateX, const f32 windowCoordinateY,
112             f32& normalizedDeviceCoordinateX, f32& normalizedDeviceCoordinateY);
113 
114         /*!
115         :private
116 
117         @brief   Converts the Y-coordinate for the provided window coordinates to an X-coordinate for the normalized device coordinates.
118 
119         @param[in]    windowCoordinateY    Y-coordinate for the window coordinates
120         @return       X-coordinate for the normalized device coordinates
121         */
122         virtual f32 GetNormalizedDeviceCoordinateX(const f32 windowCoordinateY);
123 
124         /*!
125         :private
126 
127         @brief   Converts the X-coordinate for the provided window coordinates to a Y-coordinate for the normalized device coordinates.
128 
129         @param[in]    windowCoordinateX    X-coordinate for the window coordinates
130         @return       Y-coordinate for the normalized device coordinates
131         */
132         virtual f32 GetNormalizedDeviceCoordinateY(const f32 windowCoordinateX);
133 
134     protected:
135         virtual void CalculateInverseWindowSize(void);
136 
137     protected:
138         s32 m_RenderTarget;
139         f32 m_WindowWidth;
140         f32 m_WindowHeight;
141 
142         f32 m_InverseWindowWidth;
143         f32 m_InverseWindowHeight;
144     };
145 
146 }
147 
148 #endif
149