1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_GlImplement.cpp
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: 23868 $
14  *---------------------------------------------------------------------------*/
15 /*------------------------------------------------------------------------------*/
16 /*                                                                              */
17 /*  Copyright (c) 2009, Digital Media Professionals Inc. All rights reserved.   */
18 /*                                                                              */
19 /*------------------------------------------------------------------------------*/
20 
21 #include <nw/gfx/gfx_GlImplement.h>
22 
23 
24 //===============================================================
25 //
26 // WARNING: このヘッダーに含まれるAPIや構造体を直接参照しないでください。
27 //
28 //===============================================================
29 
30 namespace nw {
31 namespace gfx {
32 namespace internal {
33 
34 //---------------------------------------------------------------------------
35 void
nwgfxAddVramDmaCommand(void * srcaddr,void * dstaddr,GLsizei size)36 nwgfxAddVramDmaCommand(void* srcaddr, void* dstaddr, GLsizei size)
37 {
38     nngxAddVramDmaCommand( srcaddr, dstaddr, size);
39 }
40 
41 //---------------------------------------------------------------------------
42 void
nwgfxClear(u32 colorAddr,u32 colorSize,u32 clearColor,u32 colorWidth,u32 depthAddr,u32 depthSize,u32 clearDepth,u32 depthWidth)43 nwgfxClear(
44     u32 colorAddr, u32 colorSize, u32 clearColor, u32 colorWidth,
45     u32 depthAddr, u32 depthSize, u32 clearDepth, u32 depthWidth
46 )
47 {
48     nngxAddMemoryFillCommand(
49         reinterpret_cast<GLvoid*>(colorAddr), colorSize, clearColor, colorWidth,
50         reinterpret_cast<GLvoid*>(depthAddr), depthSize, clearDepth, depthWidth
51     );
52 }
53 
54 //---------------------------------------------------------------------------
55 void
GetFrameBufferState(GLuint fboID,u32 * pColorAddr,u32 * pDepthAddr)56 GetFrameBufferState(
57     GLuint fboID,
58     u32* pColorAddr,
59     u32* pDepthAddr
60 )
61 {
62     glBindFramebuffer( GL_FRAMEBUFFER, fboID );
63 
64     if ( pColorAddr )
65     {
66         s32 renderID;
67         s32 addr;
68 
69         glGetFramebufferAttachmentParameteriv(
70             GL_FRAMEBUFFER,
71             GL_COLOR_ATTACHMENT0,
72             GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
73             &renderID );
74 
75         glBindRenderbuffer(GL_RENDERBUFFER, renderID);
76 
77         glGetRenderbufferParameteriv(
78             GL_RENDERBUFFER,
79             GL_RENDERBUFFER_DATA_ADDR_DMP,
80             &addr );
81 
82         *pColorAddr = static_cast<u32>(addr);
83     }
84 
85     if ( pDepthAddr )
86     {
87         s32 renderID;
88         s32 addr;
89 
90         glGetFramebufferAttachmentParameteriv(
91             GL_FRAMEBUFFER,
92             GL_DEPTH_ATTACHMENT,
93             GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
94             &renderID );
95 
96         glBindRenderbuffer(GL_RENDERBUFFER, renderID);
97 
98         glGetRenderbufferParameteriv(
99             GL_RENDERBUFFER,
100             GL_RENDERBUFFER_DATA_ADDR_DMP,
101             &addr );
102 
103         *pDepthAddr = static_cast<u32>(addr);
104     }
105 }
106 
107 } // namespace internal
108 } // namespace gfx
109 } // namespace nw
110 
111 
112