1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: demo_RenderSystemDrawing.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_SYSTEM_DRAWING_H_ 17 #define DEMO_RENDER_SYSTEM_DRAWING_H_ 18 19 #include "demo/Utility/demo_Utility.h" 20 #include "demo/Render/demo_RenderSystem.h" 21 #include "demo/Render/demo_GraphicsDrawing.h" 22 23 namespace demo 24 { 25 /* Please see man pages for details 26 27 */ 28 29 /* Please see man pages for details 30 31 32 33 */ 34 const u32 MAX_TEXTURES_NUM = 16; 35 36 /* Please see man pages for details 37 38 39 40 */ 41 const u32 MAX_TEXTURED_TRIANGLES_NUM = 64; 42 43 /* Please see man pages for details 44 45 46 47 */ 48 const u32 MAX_TEXTURED_INDICES_NUM = MAX_TEXTURED_TRIANGLES_NUM * 3; 49 50 class RenderSystemDrawing : public demo::RenderSystem 51 { 52 public: 53 RenderSystemDrawing(void); 54 virtual ~RenderSystemDrawing(void); 55 56 public: 57 virtual void Initialize(const uptr fcramAddress, const size_t memorySize, 58 const u32 commandBufferSize = 0x40000, const u32 requestNum = 128, 59 const bool serialRunMode = true, 60 const DisplayBuffersDescription& displayBuffers0Desc = DisplayBuffersDescription::GetDefaultDisplay0Description(), 61 const DisplayBuffersDescription& displayBuffers1Desc = DisplayBuffersDescription::GetDefaultDisplay1Description(), 62 const FrameBufferDescription& frameBuffer0Desc = FrameBufferDescription::GetDefaultDisplay0FrameBufferDescription(), 63 const DisplayBuffersDescription& displayBuffers0ExtDesc = DisplayBuffersDescription::GetDefaultDisplay0ExtDescription(), 64 const bool isFillBlackLCD = true ); 65 66 public: 67 /* Please see man pages for details 68 69 70 71 72 73 74 75 */ 76 void InitializeTriangles(const u32 maxTrianglesNum = demo::MAX_TRIANGLES_NUM); 77 78 /* Please see man pages for details 79 80 81 82 83 84 85 86 */ 87 void InitializeSquares(const u32 maxSquaresNum = demo::MAX_SQUARES_NUM); 88 89 /* Please see man pages for details 90 91 92 93 94 95 96 97 */ 98 void InitializeTexts(const u32 maxLength = demo::MAX_TEXT_LENGTH); 99 100 /* Please see man pages for details 101 102 103 104 105 106 107 108 */ 109 void InitializeTexturedTriangles(const u32 maxTrianglesNum = MAX_TEXTURED_TRIANGLES_NUM); 110 111 virtual void Finalize(void); 112 113 virtual void SetViewport(const GLint x, const GLint y, const GLsizei width, const GLsizei height); 114 115 virtual void SetClearColor(const s32 display, const f32 red, const f32 green, const f32 blue, const f32 alpha); 116 117 virtual void Clear(const GLbitfield mask = (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) ); 118 119 public: 120 /* Please see man pages for details 121 122 123 124 125 126 127 */ 128 virtual void SetColor(const f32 red, const f32 green, const f32 blue, const f32 alpha); 129 130 /* Please see man pages for details 131 132 133 134 135 136 */ 137 virtual void SetColor(const f32 red, const f32 green, const f32 blue); 138 139 /* Please see man pages for details 140 141 142 143 */ 144 virtual void SetDepth(const f32 depth); 145 146 /* Please see man pages for details 147 148 149 150 */ 151 virtual void SetAutoDepth(const bool enableAutoDepth); 152 153 154 public: 155 /* Please see man pages for details 156 157 158 159 */ 160 virtual void SetPointSize(const f32 pointSize); 161 162 /* Please see man pages for details 163 164 165 166 167 */ 168 virtual void DrawPoint(const f32 windowCoordinateX, const f32 windowCoordinateY); 169 170 public: 171 /* Please see man pages for details 172 173 174 175 */ 176 virtual void SetLineWidth(const f32 lineWidth); 177 178 /* Please see man pages for details 179 180 181 182 183 184 185 */ 186 virtual void DrawLine(const f32 windowCoordinateX0, const f32 windowCoordinateY0, 187 const f32 windowCoordinateX1, const f32 windowCoordinateY1); 188 189 public: 190 /* Please see man pages for details 191 192 193 194 195 196 197 198 199 200 201 202 203 */ 204 virtual void FillSquare(const f32 windowCoordinateX0, const f32 windowCoordinateY0, 205 const f32 windowCoordinateX1, const f32 windowCoordinateY1, 206 const f32 windowCoordinateX2, const f32 windowCoordinateY2, 207 const f32 windowCoordinateX3, const f32 windowCoordinateY3); 208 209 public: 210 /* Please see man pages for details 211 212 213 214 215 216 217 */ 218 virtual void FillRectangle(const f32 windowCoordinateX, 219 const f32 windowCoordinateY, 220 const f32 width, const f32 height); 221 222 public: 223 /* Please see man pages for details 224 225 226 227 228 229 230 231 232 233 234 */ 235 virtual void FillTriangle(const f32 windowCoordinateX0, const f32 windowCoordinateY0, 236 const f32 windowCoordinateX1, const f32 windowCoordinateY1, 237 const f32 windowCoordinateX2, const f32 windowCoordinateY2); 238 239 public: 240 /* Please see man pages for details 241 242 243 244 245 246 */ 247 virtual void SetFontSize(const f32 fontSize); 248 249 /* Please see man pages for details 250 251 252 253 254 255 256 257 258 259 */ 260 virtual void DrawText(const f32 windowCoordinateX, const f32 windowCoordinateY, const char* format, ...); 261 262 263 public: 264 /* Please see man pages for details 265 266 267 268 269 */ 270 virtual bool HasTexture(const GLuint textureId); 271 272 /* Please see man pages for details 273 274 275 276 277 278 279 280 281 282 283 284 285 286 */ 287 virtual bool GenerateTexture(const GLenum target, 288 const GLenum internalFormat, 289 const GLsizei width, const GLsizei height, 290 const GLenum format, const GLenum type, void* pixels, 291 GLuint& textureId); 292 293 /* Please see man pages for details 294 295 296 297 298 */ 299 virtual bool DeleteTexture(const GLuint textureId); 300 301 protected: 302 virtual bool FindTextureArrayIndex(const GLuint textureId, 303 u32& arrayIndex); 304 305 public: 306 /* Please see man pages for details 307 308 309 310 311 312 313 314 315 316 317 318 319 320 */ 321 virtual void FillTexturedRectangle(const GLuint textureId, 322 const f32 windowCoordinateX, const f32 windowCoordinateY, 323 const f32 rectangleWidth, const f32 rectangleHeight, 324 const f32 imageWidth, const f32 imageHeight, 325 const f32 textureWidth, const f32 textureHeight); 326 327 /* Please see man pages for details 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 */ 347 virtual void FillTexturedTriangle(const GLuint textureId, 348 const f32 windowCoordinateX0, const f32 windowCoordinateY0, 349 const f32 texcoordS0, const f32 texcoordT0, 350 const f32 windowCoordinateX1, const f32 windowCoordinateY1, 351 const f32 texcoordS1, const f32 texcoordT1, 352 const f32 windowCoordinateX2, const f32 windowCoordinateY2, 353 const f32 texcoordS2, const f32 texcoordT2); 354 355 /* Please see man pages for details 356 357 */ 358 359 public: 360 virtual void SwapBuffers(void); 361 362 protected: 363 virtual void Flush(void); 364 virtual void FlushTexturedPrimitives(void); 365 366 protected: 367 GraphicsDrawing m_GraphicsDrawing; 368 369 protected: 370 bool m_InitializeTexturedTriangles; 371 bool m_UseDecalTextureProgram; 372 bool m_Padding[2]; 373 374 u32 m_MaxTexturedTrianglesNum; 375 GLuint m_TextureIdArray[demo::MAX_TEXTURES_NUM]; 376 377 u32 m_TotalTexturedTrianglesNumArray[demo::MAX_TEXTURES_NUM]; 378 demo::TrianglesRenderData m_TexturedTrianglesRenderDataArray[demo::MAX_TEXTURES_NUM]; 379 380 f32 m_ClearColorArray[3][4]; 381 }; 382 383 } 384 385 #endif 386