1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: lyt_Window.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: 26741 $
14 *---------------------------------------------------------------------------*/
15
16 #include "precompiled.h"
17
18 #include <nw/lyt/lyt_Common.h>
19 #include <nw/lyt/lyt_DrawInfo.h>
20 #include <nw/lyt/lyt_GraphicsResource.h>
21 #include <nw/lyt/lyt_Layout.h>
22 #include <nw/lyt/lyt_Window.h>
23 #include <nw/lyt/lyt_Material.h>
24 #include <nw/lyt/lyt_Animation.h>
25 #include <nw/lyt/lyt_ResourceAccessor.h>
26 #include <nw/lyt/lyt_Stopwatch.h>
27
28 namespace nw
29 {
30 namespace lyt
31 {
32 namespace local
33 {
34 namespace
35 {
36
37 struct Rect
38 {
39 f32 x, y, w, h;
40
Positionnw::lyt::local::__anon634751120111::Rect41 const math::VEC2& Position() const
42 {
43 return *(const math::VEC2 *)&this->x;
44 }
45
Sizenw::lyt::local::__anon634751120111::Rect46 const nw::lyt::Size& Size() const
47 {
48 return *(const nw::lyt::Size *)&this->w;
49 }
50 };
51
52 struct TextureFlipInfo
53 {
54 u8 coords[VERTEX_MAX][2];
55 u8 idx[2];
56
57 };
58
59 const TextureFlipInfo&
GetTexutreFlipInfo(u8 textureFlip)60 GetTexutreFlipInfo(u8 textureFlip)
61 {
62 NW_ASSERT(textureFlip < TEXTUREFLIP_MAX);
63
64 static TextureFlipInfo flipInfos[] =
65 {
66 { { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } }, { 0, 1 } }, // TEXTUREFLIP_NONE
67 { { { 1, 0 }, { 0, 0 }, { 1, 1 }, { 0, 1 } }, { 0, 1 } }, // TEXTUREFLIP_FLIPH
68 { { { 0, 1 }, { 1, 1 }, { 0, 0 }, { 1, 0 } }, { 0, 1 } }, // TEXTUREFLIP_FLIPV
69 { { { 0, 1 }, { 0, 0 }, { 1, 1 }, { 1, 0 } }, { 1, 0 } }, // TEXTUREFLIP_ROTATE90
70 { { { 1, 1 }, { 0, 1 }, { 1, 0 }, { 0, 0 } }, { 0, 1 } }, // TEXTUREFLIP_ROTATE180
71 { { { 1, 0 }, { 1, 1 }, { 0, 0 }, { 0, 1 } }, { 1, 0 } }, // TEXTUREFLIP_ROTATE270
72 };
73
74 return flipInfos[textureFlip];
75 }
76
77 void
GetLTFrameSize(math::VEC2 * pPt,Size * pSize,const math::VEC2 & basePt,const Size & winSize,const WindowFrameSize & frameSize)78 GetLTFrameSize(
79 math::VEC2* pPt,
80 Size* pSize,
81 const math::VEC2& basePt,
82 const Size& winSize,
83 const WindowFrameSize& frameSize
84 )
85 {
86 *pPt = basePt;
87
88 pSize->width = winSize.width - frameSize.r;
89 pSize->height = frameSize.t;
90 }
91
92 void
GetLTTexCoord(math::VEC2 texCds[],const Size & polSize,const TexSize & texSize,u8 textureFlip)93 GetLTTexCoord(
94 math::VEC2 texCds[],
95 const Size& polSize,
96 const TexSize& texSize,
97 u8 textureFlip
98 )
99 {
100 const TextureFlipInfo& flipInfo = GetTexutreFlipInfo(textureFlip);
101 const int ix = flipInfo.idx[0];
102 const int iy = flipInfo.idx[1];
103 const math::VEC2 tSz(texSize.width, texSize.height);
104
105 texCds[VERTEX_LT][ix] = texCds[VERTEX_LB][ix] = flipInfo.coords[VERTEX_LT][ix];
106 texCds[VERTEX_LT][iy] = texCds[VERTEX_RT][iy] = flipInfo.coords[VERTEX_LT][iy];
107
108 texCds[VERTEX_RB][ix] = texCds[VERTEX_RT][ix] = polSize.width / ((flipInfo.coords[VERTEX_RT][ix] - flipInfo.coords[VERTEX_LT][ix]) * tSz[ix]) + flipInfo.coords[VERTEX_LT][ix];
109 texCds[VERTEX_RB][iy] = texCds[VERTEX_LB][iy] = polSize.height / ((flipInfo.coords[VERTEX_LB][iy] - flipInfo.coords[VERTEX_LT][iy]) * tSz[iy]) + flipInfo.coords[VERTEX_LT][iy];
110 }
111
112 void
GetRTFrameSize(math::VEC2 * pPt,Size * pSize,const math::VEC2 & basePt,const Size & winSize,const WindowFrameSize & frameSize)113 GetRTFrameSize(
114 math::VEC2* pPt,
115 Size* pSize,
116 const math::VEC2& basePt,
117 const Size& winSize,
118 const WindowFrameSize& frameSize
119 )
120 {
121 using namespace nw::math;
122
123 *pPt = VEC2(basePt.x + winSize.width - frameSize.r, basePt.y);
124
125 pSize->width = frameSize.r;
126 pSize->height = winSize.height - frameSize.b;
127 }
128
129 void
GetRTTexCoord(math::VEC2 texCds[],const Size & polSize,const TexSize & texSize,u8 textureFlip)130 GetRTTexCoord(
131 math::VEC2 texCds[],
132 const Size& polSize,
133 const TexSize& texSize,
134 u8 textureFlip
135 )
136 {
137 const TextureFlipInfo& flipInfo = GetTexutreFlipInfo(textureFlip);
138 const int ix = flipInfo.idx[0];
139 const int iy = flipInfo.idx[1];
140 const math::VEC2 tSz(texSize.width, texSize.height);
141
142 texCds[VERTEX_RT][ix] = texCds[VERTEX_RB][ix] = flipInfo.coords[VERTEX_RT][ix];
143 texCds[VERTEX_RT][iy] = texCds[VERTEX_LT][iy] = flipInfo.coords[VERTEX_RT][iy];
144
145 texCds[VERTEX_LB][ix] = texCds[VERTEX_LT][ix] = polSize.width / ((flipInfo.coords[VERTEX_LT][ix] - flipInfo.coords[VERTEX_RT][ix]) * tSz[ix]) + flipInfo.coords[VERTEX_RT][ix];
146 texCds[VERTEX_LB][iy] = texCds[VERTEX_RB][iy] = polSize.height / ((flipInfo.coords[VERTEX_RB][iy] - flipInfo.coords[VERTEX_RT][iy]) * tSz[iy]) + flipInfo.coords[VERTEX_RT][iy];
147 }
148
149 void
GetLBFrameSize(math::VEC2 * pPt,Size * pSize,const math::VEC2 & basePt,const Size & winSize,const WindowFrameSize & frameSize)150 GetLBFrameSize(
151 math::VEC2* pPt,
152 Size* pSize,
153 const math::VEC2& basePt,
154 const Size& winSize,
155 const WindowFrameSize& frameSize
156 )
157 {
158 *pPt = math::VEC2(basePt.x, basePt.y - frameSize.t);
159
160 pSize->width = frameSize.l;
161 pSize->height = winSize.height - frameSize.t;
162 }
163
164 void
GetLBTexCoord(math::VEC2 texCds[],const Size & polSize,const TexSize & texSize,u8 textureFlip)165 GetLBTexCoord(
166 math::VEC2 texCds[],
167 const Size& polSize,
168 const TexSize& texSize,
169 u8 textureFlip
170 )
171 {
172 const TextureFlipInfo& flipInfo = GetTexutreFlipInfo(textureFlip);
173 const int ix = flipInfo.idx[0];
174 const int iy = flipInfo.idx[1];
175 const math::VEC2 tSz(texSize.width, texSize.height);
176
177 texCds[VERTEX_LB][ix] = texCds[VERTEX_LT][ix] = flipInfo.coords[VERTEX_LB][ix];
178 texCds[VERTEX_LB][iy] = texCds[VERTEX_RB][iy] = flipInfo.coords[VERTEX_LB][iy];
179
180 texCds[VERTEX_RT][ix] = texCds[VERTEX_RB][ix] = polSize.width / ((flipInfo.coords[VERTEX_RB][ix] - flipInfo.coords[VERTEX_LB][ix]) * tSz[ix]) + flipInfo.coords[VERTEX_LB][ix];
181 texCds[VERTEX_RT][iy] = texCds[VERTEX_LT][iy] = polSize.height / ((flipInfo.coords[VERTEX_LT][iy] - flipInfo.coords[VERTEX_LB][iy]) * tSz[iy]) + flipInfo.coords[VERTEX_LB][iy];
182 }
183
184 void
GetRBFrameSize(math::VEC2 * pPt,Size * pSize,const math::VEC2 & basePt,const Size & winSize,const WindowFrameSize & frameSize)185 GetRBFrameSize(
186 math::VEC2* pPt,
187 Size* pSize,
188 const math::VEC2& basePt,
189 const Size& winSize,
190 const WindowFrameSize& frameSize
191 )
192 {
193 *pPt = math::VEC2(basePt.x + frameSize.l, basePt.y - winSize.height + frameSize.b);
194
195 pSize->width = winSize.width - frameSize.l;
196 pSize->height = frameSize.b;
197 }
198
199 void
GetRBTexCoord(math::VEC2 texCds[],const Size & polSize,const TexSize & texSize,u8 textureFlip)200 GetRBTexCoord(
201 math::VEC2 texCds[],
202 const Size& polSize,
203 const TexSize& texSize,
204 u8 textureFlip
205 )
206 {
207 const TextureFlipInfo& flipInfo = GetTexutreFlipInfo(textureFlip);
208 const int ix = flipInfo.idx[0];
209 const int iy = flipInfo.idx[1];
210 const math::VEC2 tSz(texSize.width, texSize.height);
211
212 texCds[VERTEX_RB][ix] = texCds[VERTEX_RT][ix] = flipInfo.coords[VERTEX_RB][ix];
213 texCds[VERTEX_RB][iy] = texCds[VERTEX_LB][iy] = flipInfo.coords[VERTEX_RB][iy];
214
215 texCds[VERTEX_LT][ix] = texCds[VERTEX_LB][ix] = polSize.width / ((flipInfo.coords[VERTEX_LB][ix] - flipInfo.coords[VERTEX_RB][ix]) * tSz[ix]) + flipInfo.coords[VERTEX_RB][ix];
216 texCds[VERTEX_LT][iy] = texCds[VERTEX_RT][iy] = polSize.height / ((flipInfo.coords[VERTEX_RT][iy] - flipInfo.coords[VERTEX_RB][iy]) * tSz[iy]) + flipInfo.coords[VERTEX_RB][iy];
217 }
218
219 #ifdef NW_LYT_DMPGL_ENABLED
220
221 // @brief フレームのテクスチャ座標変換を設定します。
222 //
223 // @param gres グラフィックスリソースです。
224 // @param frame フレーム番号です。
225 // @param flip テクスチャフリップ番号です。
226 void
SetupFrameTransform(const GraphicsResource & gres,WindowFrame frame,TextureFlip flip)227 SetupFrameTransform(
228 const GraphicsResource& gres,
229 WindowFrame frame,
230 TextureFlip flip)
231 {
232 static const u32 frameFlag[WINDOWFRAME_MAX] =
233 {
234 internal::FRAMESPECFLAG_FRAME_LT, // WINDOWFRAME_LT
235 internal::FRAMESPECFLAG_FRAME_RT, // WINDOWFRAME_RT
236 internal::FRAMESPECFLAG_FRAME_LB, // WINDOWFRAME_LG
237 internal::FRAMESPECFLAG_FRAME_RB, // WINDOWFRAME_RB
238 internal::FRAMESPECFLAG_FRAME_LB, // WINDOWFRAME_L
239 internal::FRAMESPECFLAG_FRAME_RT, // WINDOWFRAME_R
240 internal::FRAMESPECFLAG_FRAME_LT, // WINDOWFRAME_T
241 internal::FRAMESPECFLAG_FRAME_RB // WINDOWFRAME_B
242 };
243
244 static const u32 flipFlag[TEXTUREFLIP_MAX] =
245 {
246 internal::FRAMESPECFLAG_NORMAL, // TEXTUREFLIP_NONE
247 internal::FRAMESPECFLAG_FLIP_HFLIP, // TEXTUREFLIP_FLIPH
248 internal::FRAMESPECFLAG_FLIP_VFLIP, // TEXTUREFLIP_FLIPV
249 internal::FRAMESPECFLAG_FLIP_R90, // TEXTUREFLIP_ROTATE90
250 internal::FRAMESPECFLAG_FLIP_R180, // TEXTUREFLIP_ROTATE180
251 internal::FRAMESPECFLAG_FLIP_R270 // TEXTUREFLIP_ROTATE270
252 };
253
254 GLint loc = gres.GetUniformLocation(gres.UNIFORM_uFrameSpec);
255 u32 flag =frameFlag[frame] | flipFlag[flip];
256
257 glUniform4f(loc, (f32)flag, 0, 0, 0);
258 NW_GL_ASSERT();
259 }
260
261 #endif // NW_LYT_DMPGL_ENABLED
262
263 } // nw::lyt::local::{anonymous}
264 } // nw::lyt::local
265
266 NW_UT_RUNTIME_TYPEINFO_DEFINITION(Window, Window::Base); // 実行時型情報の実体を定義
267
~Frame()268 Window::Frame::~Frame()
269 {
270 if (pMaterial && !pMaterial->IsUserAllocated())
271 {
272 Layout::DeleteObj(pMaterial);
273 }
274 pMaterial = 0;
275 }
276
Window(u8 contentTexNum,u8 frameTexNum)277 Window::Window(
278 u8 contentTexNum,
279 u8 frameTexNum
280 )
281 {
282 NW_ASSERT(contentTexNum <= TexMapMax);
283 NW_ASSERT(frameTexNum <= TexMapMax);
284
285 const u8 frameNum = 1;
286 u8 frameTexNums[frameNum];
287 frameTexNums[WINDOWFRAME_LT] = frameTexNum;
288
289 InitTexNum(contentTexNum, frameTexNums, frameNum);
290 }
291
Window(u8 contentTexNum,u8 frameLTTexNum,u8 frameRTTexNum,u8 frameRBTexNum,u8 frameLBTexNum)292 Window::Window(
293 u8 contentTexNum,
294 u8 frameLTTexNum,
295 u8 frameRTTexNum,
296 u8 frameRBTexNum,
297 u8 frameLBTexNum
298 )
299 {
300 NW_ASSERT(contentTexNum <= TexMapMax);
301 NW_ASSERT(frameLTTexNum <= TexMapMax);
302 NW_ASSERT(frameRTTexNum <= TexMapMax);
303 NW_ASSERT(frameRBTexNum <= TexMapMax);
304 NW_ASSERT(frameLBTexNum <= TexMapMax);
305
306 const u8 frameNum = 4;
307 u8 frameTexNums[frameNum];
308 frameTexNums[WINDOWFRAME_LT] = frameLTTexNum;
309 frameTexNums[WINDOWFRAME_RT] = frameRTTexNum;
310 frameTexNums[WINDOWFRAME_RB] = frameRBTexNum;
311 frameTexNums[WINDOWFRAME_LB] = frameLBTexNum;
312
313 InitTexNum(contentTexNum, frameTexNums, frameNum);
314 }
315
Window(u8 contentTexNum,u8 cornerLTTexNum,u8 cornerRTTexNum,u8 cornerRBTexNum,u8 cornerLBTexNum,u8 frameLTexNum,u8 frameTTexNum,u8 frameRTexNum,u8 frameBTexNum)316 Window::Window(
317 u8 contentTexNum,
318 u8 cornerLTTexNum,
319 u8 cornerRTTexNum,
320 u8 cornerRBTexNum,
321 u8 cornerLBTexNum,
322 u8 frameLTexNum,
323 u8 frameTTexNum,
324 u8 frameRTexNum,
325 u8 frameBTexNum
326 )
327 {
328 NW_ASSERT(contentTexNum <= TexMapMax);
329 NW_ASSERT(cornerLTTexNum <= TexMapMax);
330 NW_ASSERT(cornerRTTexNum <= TexMapMax);
331 NW_ASSERT(cornerRBTexNum <= TexMapMax);
332 NW_ASSERT(cornerLBTexNum <= TexMapMax);
333 NW_ASSERT(frameLTexNum <= TexMapMax);
334 NW_ASSERT(frameTTexNum <= TexMapMax);
335 NW_ASSERT(frameRTexNum <= TexMapMax);
336 NW_ASSERT(frameBTexNum <= TexMapMax);
337
338 const u8 frameNum = 8;
339 u8 frameTexNums[frameNum];
340 frameTexNums[WINDOWFRAME_LT] = cornerLTTexNum;
341 frameTexNums[WINDOWFRAME_RT] = cornerRTTexNum;
342 frameTexNums[WINDOWFRAME_RB] = cornerRBTexNum;
343 frameTexNums[WINDOWFRAME_LB] = cornerLBTexNum;
344 frameTexNums[WINDOWFRAME_L ] = frameLTexNum;
345 frameTexNums[WINDOWFRAME_T ] = frameTTexNum;
346 frameTexNums[WINDOWFRAME_R ] = frameRTexNum;
347 frameTexNums[WINDOWFRAME_B ] = frameBTexNum;
348
349 InitTexNum(contentTexNum, frameTexNums, frameNum);
350
351 }
352
Window(const res::Window * pBlock,const ResBlockSet & resBlockSet)353 Window::Window(
354 const res::Window* pBlock,
355 const ResBlockSet& resBlockSet
356 )
357 : Base(pBlock)
358 {
359 const res::WindowContent *const pResContent = internal::ConvertOffsToPtr<res::WindowContent>(pBlock, pBlock->contentOffset);
360 const u8 texCoordNum = ut::Min(pResContent->texCoordNum, u8(TexMapMax));
361
362 InitContent(texCoordNum);
363
364 m_ContentInflation = pBlock->inflation;
365
366 NW_NULL_ASSERT(resBlockSet.pMaterialList);
367 const u32 *const matOffsTbl = internal::ConvertOffsToPtr<u32>(resBlockSet.pMaterialList, sizeof(*resBlockSet.pMaterialList));
368
369 // content
370 // 頂点カラー
371 for (int i = 0; i < VERTEXCOLOR_MAX; ++i)
372 {
373 m_Content.vtxColors[i] = pResContent->vtxCols[i];
374 }
375
376 // テクスチャ座標
377 if (texCoordNum > 0)
378 {
379 if (! m_Content.texCoordAry.IsEmpty())
380 {
381 m_Content.texCoordAry.Copy(
382 reinterpret_cast<const char*>(pResContent) + sizeof(*pResContent),
383 texCoordNum);
384 }
385 }
386
387 // マテリアルの作成
388 {
389 const res::Material *const pResMaterial = internal::ConvertOffsToPtr<res::Material>(resBlockSet.pMaterialList, matOffsTbl[pResContent->materialIdx]);
390 m_pMaterial = Layout::NewObj<Material>(pResMaterial, resBlockSet);
391 }
392
393 // Frame
394 m_FrameNum = 0;
395 m_Frames = 0;
396 if (pBlock->frameNum > 0)
397 {
398 InitFrame(pBlock->frameNum);
399
400 const u32 *const frameOffsetTable = internal::ConvertOffsToPtr<u32>(pBlock, pBlock->frameOffsetTableOffset);
401 for (int i = 0; i < m_FrameNum; ++i)
402 {
403 const res::WindowFrame *const pResWindowFrame = internal::ConvertOffsToPtr<res::WindowFrame>(pBlock, frameOffsetTable[i]);
404 m_Frames[i].textureFlip = pResWindowFrame->textureFlip;
405
406 // マテリアルの初期化
407 const res::Material *const pResMaterial = internal::ConvertOffsToPtr<res::Material>(resBlockSet.pMaterialList, matOffsTbl[pResWindowFrame->materialIdx]);
408 m_Frames[i].pMaterial = Layout::NewObj<Material>(pResMaterial, resBlockSet);
409 }
410 }
411 }
412
413 void
InitTexNum(u8 contentTexNum,u8 frameTexNums[],u8 frameNum)414 Window::InitTexNum(
415 u8 contentTexNum,
416 u8 frameTexNums[],
417 u8 frameNum
418 )
419 {
420 InitContent(contentTexNum);
421
422 m_ContentInflation.l = 0;
423 m_ContentInflation.r = 0;
424 m_ContentInflation.t = 0;
425 m_ContentInflation.b = 0;
426
427 // マテリアルの作成
428 m_pMaterial = Layout::NewObj<Material>();
429 if (m_pMaterial)
430 {
431 m_pMaterial->ReserveMem(contentTexNum, contentTexNum, contentTexNum);
432 }
433
434 // Frame
435 InitFrame(frameNum);
436
437 for (int i = 0; i < m_FrameNum; ++i)
438 {
439 // マテリアルの作成
440 m_Frames[i].pMaterial = Layout::NewObj<Material>();
441 if (m_Frames[i].pMaterial)
442 {
443 m_Frames[i].pMaterial->ReserveMem(frameTexNums[i], frameTexNums[i], frameTexNums[i]);
444 }
445 }
446 }
447
448 void
InitContent(u8 texNum)449 Window::InitContent(u8 texNum)
450 {
451 if (texNum > 0)
452 {
453 ReserveTexCoord(texNum);
454 }
455
456 #ifdef NW_LYT_DRAWER_ENABLE
457 m_IsTexCoordInited = false;
458 #endif
459 }
460
461 void
InitFrame(u8 frameNum)462 Window::InitFrame(u8 frameNum)
463 {
464 m_FrameNum = 0;
465 m_Frames = Layout::NewArray<Frame>(frameNum);
466 if (m_Frames)
467 {
468 m_FrameNum = frameNum;
469 }
470 }
471
~Window()472 Window::~Window()
473 {
474 // OSReport("Window::~Window()\n");
475
476 Layout::DeleteArray(m_Frames, m_FrameNum);
477
478 if (m_pMaterial && ! m_pMaterial->IsUserAllocated())
479 {
480 Layout::DeleteObj(m_pMaterial);
481 m_pMaterial = 0;
482 }
483
484 m_Content.texCoordAry.Free();
485 }
486
487 void
ReserveTexCoord(u8 num)488 Window::ReserveTexCoord(u8 num)
489 {
490 m_Content.texCoordAry.Reserve(num);
491 }
492
493 u8
GetTexCoordNum() const494 Window::GetTexCoordNum() const
495 {
496 return m_Content.texCoordAry.GetSize();
497 }
498
499 void
SetTexCoordNum(u8 num)500 Window::SetTexCoordNum(u8 num)
501 {
502 m_Content.texCoordAry.SetSize(num);
503 }
504
505 void
GetTexCoord(u32 idx,TexCoordQuad coords) const506 Window::GetTexCoord(
507 u32 idx,
508 TexCoordQuad coords
509 ) const
510 {
511 m_Content.texCoordAry.GetCoord(idx, coords);
512 }
513
514 void
SetTexCoord(u32 idx,const TexCoordQuad coords)515 Window::SetTexCoord(
516 u32 idx,
517 const TexCoordQuad coords
518 )
519 {
520 m_Content.texCoordAry.SetCoord(idx, coords);
521
522 Material* pMaterial = this->GetContentMaterial();
523 if (pMaterial != NULL)
524 {
525 pMaterial->SetTextureDirty();
526 }
527 }
528
529 Material*
FindMaterialByName(const char * findName,bool bRecursive)530 Window::FindMaterialByName(
531 const char* findName,
532 bool bRecursive
533 )
534 {
535 if (m_pMaterial)
536 {
537 if (internal::EqualsMaterialName(m_pMaterial->GetName(), findName))
538 {
539 return m_pMaterial;
540 }
541 }
542 for (int i = 0; i < m_FrameNum; ++i)
543 {
544 if (internal::EqualsMaterialName(m_Frames[i].pMaterial->GetName(), findName))
545 {
546 return m_Frames[i].pMaterial;
547 }
548 }
549
550 if (bRecursive)
551 {
552 // 子供に一致するものが無いか検索
553 for (PaneList::Iterator it = GetChildList().GetBeginIter(); it != GetChildList().GetEndIter(); ++it)
554 {
555 if (Material* pMat = it->FindMaterialByName(findName, bRecursive))
556 {
557 return pMat;
558 }
559 }
560 }
561
562 return 0;
563 }
564
565 const ut::Color8
GetVtxColor(u32 idx) const566 Window::GetVtxColor(u32 idx) const
567 {
568 NW_ASSERT(idx < VERTEXCOLOR_MAX);
569
570 return m_Content.vtxColors[idx];
571 }
572
573 void
SetVtxColor(u32 idx,ut::Color8 value)574 Window::SetVtxColor(
575 u32 idx,
576 ut::Color8 value
577 )
578 {
579 NW_ASSERT(idx < VERTEXCOLOR_MAX);
580
581 m_Content.vtxColors[idx] = value;
582 }
583
584 u8
GetVtxColorElement(u32 idx) const585 Window::GetVtxColorElement(u32 idx) const
586 {
587 return internal::GetVtxColorElement(m_Content.vtxColors, idx);
588 }
589
590 void
SetVtxColorElement(u32 idx,u8 value)591 Window::SetVtxColorElement(u32 idx, u8 value)
592 {
593 internal::SetVtxColorElement(m_Content.vtxColors, idx, value);
594 }
595
596 #ifdef NW_LYT_DMPGL_ENABLED
597
598 void
DrawSelf(const DrawInfo & drawInfo)599 Window::DrawSelf(const DrawInfo& drawInfo)
600 {
601 NW_LYT_STOPWATCH_MEASURE(-500, "nw::lyt::Window::DrawSelf");
602
603 // 行列
604 LoadMtx(drawInfo);
605
606 const WindowFrameSize frameSize = GetFrameSize(m_FrameNum, m_Frames);
607 const math::VEC2 basePt = GetVtxPos();
608
609 // contentの描画
610 DrawContent(drawInfo, basePt, frameSize, GetGlobalAlpha());
611
612 // frameの描画
613 switch (m_FrameNum)
614 {
615 case 1:
616 DrawFrame(drawInfo, basePt, m_Frames[WINDOWFRAME_LT], frameSize, GetGlobalAlpha());
617 break;
618 case 4:
619 DrawFrame4(drawInfo, basePt, m_Frames, frameSize, GetGlobalAlpha());
620 break;
621 case 8:
622 DrawFrame8(drawInfo, basePt, m_Frames, frameSize, GetGlobalAlpha());
623 break;
624 }
625 }
626
627 void
DrawContent(const DrawInfo & drawInfo,const math::VEC2 & basePt,const WindowFrameSize & frameSize,u8 alpha)628 Window::DrawContent(
629 const DrawInfo& drawInfo,
630 const math::VEC2& basePt,
631 const WindowFrameSize& frameSize,
632 u8 alpha
633 )
634 {
635 m_pMaterial->SetupGraphics(drawInfo, alpha);
636
637 internal::DrawQuad(
638 drawInfo,
639 math::VEC2(basePt.x + frameSize.l - m_ContentInflation.l, basePt.y - frameSize.t + m_ContentInflation.t),
640 Size(GetSize().width - frameSize.l + m_ContentInflation.l - frameSize.r + m_ContentInflation.r, GetSize().height - frameSize.t + m_ContentInflation.t - frameSize.b + m_ContentInflation.b),
641 m_Content.texCoordAry.GetSize(),
642 m_Content.texCoordAry.GetArray(),
643 m_Content.vtxColors);
644 }
645
646 void
DrawFrame(const DrawInfo & drawInfo,const math::VEC2 & basePt,const Frame & frame,const WindowFrameSize & frameSize,u8 alpha)647 Window::DrawFrame(
648 const DrawInfo& drawInfo,
649 const math::VEC2& basePt,
650 const Frame& frame,
651 const WindowFrameSize& frameSize,
652 u8 alpha
653 )
654 {
655 NW_LYT_STOPWATCH_MEASURE(-501, "nw::lyt::Window::DrawFrame");
656
657 // フレームのテクスチャがない場合は何もしない
658 if (frame.pMaterial->GetTexMapNum() == 0)
659 {
660 return;
661 }
662
663 frame.pMaterial->SetupGraphics(drawInfo, alpha, false);
664
665 math::VEC2 polPt;
666 Size polSize;
667
668 GraphicsResource& gres = *drawInfo.GetGraphicsResource();
669
670 local::GetLTFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
671 local::SetupFrameTransform(gres, WINDOWFRAME_LT, TEXTUREFLIP_NONE);
672 internal::DrawQuad(drawInfo, polPt, polSize);
673
674 local::GetRTFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
675 local::SetupFrameTransform(gres, WINDOWFRAME_RT, TEXTUREFLIP_FLIPH);
676 internal::DrawQuad(drawInfo, polPt, polSize);
677
678 local::GetRBFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
679 local::SetupFrameTransform(gres, WINDOWFRAME_RB, TEXTUREFLIP_ROTATE180);
680 internal::DrawQuad(drawInfo, polPt, polSize);
681
682 local::GetLBFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
683 local::SetupFrameTransform(gres, WINDOWFRAME_LB, TEXTUREFLIP_FLIPV);
684 internal::DrawQuad(drawInfo, polPt, polSize);
685 }
686
687 void
DrawFrame4(const DrawInfo & drawInfo,const math::VEC2 & basePt,const Frame * frames,const WindowFrameSize & frameSize,u8 alpha)688 Window::DrawFrame4(
689 const DrawInfo& drawInfo,
690 const math::VEC2& basePt,
691 const Frame* frames,
692 const WindowFrameSize& frameSize,
693 u8 alpha
694 )
695 {
696 NW_LYT_STOPWATCH_MEASURE(-502, "nw::lyt::Window::DrawFrame4");
697
698 math::VEC2 polPt[WINDOWFRAME_RB + 1];
699 Size polSize[WINDOWFRAME_RB + 1];
700 bool bRepeat = false;
701 GraphicsResource& gres = *drawInfo.GetGraphicsResource();
702
703 local::GetLTFrameSize(&polPt[WINDOWFRAME_LT], &polSize[WINDOWFRAME_LT], basePt, GetSize(), frameSize);
704 local::GetRTFrameSize(&polPt[WINDOWFRAME_RT], &polSize[WINDOWFRAME_RT], basePt, GetSize(), frameSize);
705 local::GetLBFrameSize(&polPt[WINDOWFRAME_LB], &polSize[WINDOWFRAME_LB], basePt, GetSize(), frameSize);
706 local::GetRBFrameSize(&polPt[WINDOWFRAME_RB], &polSize[WINDOWFRAME_RB], basePt, GetSize(), frameSize);
707
708 for (int i = WINDOWFRAME_LT; i <= WINDOWFRAME_RB; ++i)
709 {
710 const Frame& frame = frames[i];
711
712 if (frame.pMaterial && frame.pMaterial->GetTexMapNum() > 0)
713 {
714 frame.pMaterial->SetupGraphics(drawInfo, alpha, false);
715 local::SetupFrameTransform(gres, WindowFrame(i), frame.GetTextureFlip());
716 if (!bRepeat)
717 {
718 internal::DrawQuad(drawInfo, polPt[i], polSize[i]);
719 bRepeat = true;
720 }
721 else
722 {
723 internal::DrawQuad_Repeat(drawInfo, polPt[i], polSize[i]);
724 }
725 }
726 }
727 }
728
729 void
DrawFrame8(const DrawInfo & drawInfo,const math::VEC2 & basePt,const Frame * frames,const WindowFrameSize & frameSize,u8 alpha)730 Window::DrawFrame8(
731 const DrawInfo& drawInfo,
732 const math::VEC2& basePt,
733 const Frame* frames,
734 const WindowFrameSize& frameSize,
735 u8 alpha
736 )
737 {
738 NW_LYT_STOPWATCH_MEASURE(-503, "nw::lyt::Window::DrawFrame8");
739
740 const f32 x0 = basePt.x;
741 const f32 x1 = basePt.x + frameSize.l;
742 const f32 x2 = basePt.x + this->GetSize().width - frameSize.r;
743
744 const f32 y0 = basePt.y;
745 const f32 y1 = basePt.y - frameSize.t;
746 const f32 y2 = basePt.y - this->GetSize().height + frameSize.b;
747
748 const f32 w0 = frameSize.l;
749 const f32 w1 = this->GetSize().width - frameSize.l - frameSize.r;
750 const f32 w2 = frameSize.r;
751
752 const f32 h0 = frameSize.t;
753 const f32 h1 = this->GetSize().height - frameSize.t - frameSize.b;
754 const f32 h2 = frameSize.b;
755
756 const local::Rect frameRect[WINDOWFRAME_MAX] =
757 {
758 { x0, y0, w0, h0 }, // LT
759 { x2, y0, w2, h0 }, // RT
760 { x0, y2, w0, h2 }, // LB
761 { x2, y2, w2, h2 }, // RB
762 { x0, y1, w0, h1 }, // L
763 { x2, y1, w2, h1 }, // R
764 { x1, y0, w1, h0 }, // T
765 { x1, y2, w1, h2 }, // B
766 };
767
768 GraphicsResource& gres = *drawInfo.GetGraphicsResource();
769 bool bRepeat = false;
770
771 for (int i = 0; i < WINDOWFRAME_MAX; ++i)
772 {
773 const Frame& frame = frames[i];
774
775 if (frame.pMaterial->GetTexMapNum() > 0) // Corner LT
776 {
777 frame.pMaterial->SetupGraphics(drawInfo, alpha, false);
778 local::SetupFrameTransform(gres, WindowFrame(i), frame.GetTextureFlip());
779 if (!bRepeat)
780 {
781 internal::DrawQuad(drawInfo, frameRect[i].Position(), frameRect[i].Size());
782 bRepeat = true;
783 }
784 else
785 {
786 internal::DrawQuad_Repeat(drawInfo, frameRect[i].Position(), frameRect[i].Size());
787 }
788 }
789 }
790 }
791
792 #endif // NW_LYT_DMPGL_ENABLED
793
794 const WindowFrameSize
GetFrameSize(u8 frameNum,const Window::Frame * frames) const795 Window::GetFrameSize(
796 u8 frameNum,
797 const Window::Frame* frames
798 ) const
799 {
800 WindowFrameSize ret = { 0, 0, 0, 0 };
801
802 switch (frameNum)
803 {
804 case 1:
805 {
806 Material* pMaterial = frames[WINDOWFRAME_LT].pMaterial;
807 if (pMaterial != NULL && pMaterial->GetTexMapNum() > 0)
808 {
809 TexSize texSize = pMaterial->GetTexMap(0).GetSize();
810 ret.l = texSize.width;
811 ret.t = texSize.height;
812 ret.r = texSize.width;
813 ret.b = texSize.height;
814 }
815 }
816 break;
817 case 4:
818 case 8:
819 {
820 Material* pMaterialLT = frames[WINDOWFRAME_LT].pMaterial;
821 if (pMaterialLT != NULL && pMaterialLT->GetTexMapNum() > 0)
822 {
823 ret.t = pMaterialLT->GetTexMap(0).GetHeight();
824 }
825
826 Material *pMaterialRT = frames[WINDOWFRAME_RT].pMaterial;
827 if (pMaterialRT != NULL && pMaterialRT->GetTexMapNum() > 0)
828 {
829 ret.r = pMaterialRT->GetTexMap(0).GetWidth();
830 }
831
832 Material *pMaterialRB = frames[WINDOWFRAME_RB].pMaterial;
833 if (pMaterialRB != NULL && pMaterialRB->GetTexMapNum() > 0)
834 {
835 ret.b = pMaterialRB->GetTexMap(0).GetHeight();
836 }
837
838 Material *pMaterialLB = frames[WINDOWFRAME_LB].pMaterial;
839 if (pMaterialLB != NULL && pMaterialLB->GetTexMapNum() > 0)
840 {
841 ret.l = pMaterialLB->GetTexMap(0).GetWidth();
842 }
843 }
844 break;
845 }
846
847 return ret;
848 }
849
850 u8
GetMaterialNum() const851 Window::GetMaterialNum() const
852 {
853 return u8(1 + m_FrameNum);
854 }
855
856 Material*
GetMaterial(u32 idx) const857 Window::GetMaterial(u32 idx) const
858 {
859 NW_WARNING(idx < GetMaterialNum(), "idx >= GetMaterialNum() : %d >= %d", idx, GetMaterialNum());
860
861 return idx == 0 ? GetContentMaterial(): GetFrameMaterial(WindowFrame(idx - 1));
862 }
863
864 Material*
GetFrameMaterial(WindowFrame frameIdx) const865 Window::GetFrameMaterial(WindowFrame frameIdx) const
866 {
867 NW_ASSERT(frameIdx < WINDOWFRAME_MAX);
868
869 if (frameIdx >= m_FrameNum)
870 {
871 return NULL;
872 }
873
874 return m_Frames[frameIdx].pMaterial;
875 }
876
SetFrameMaterial(WindowFrame frameIdx,Material * pMaterial)877 void Window::SetFrameMaterial(WindowFrame frameIdx, Material* pMaterial)
878 {
879 NW_ASSERT(frameIdx < WINDOWFRAME_MAX);
880
881 if (m_Frames[frameIdx].pMaterial == pMaterial)
882 {
883 return;
884 }
885
886 if (m_Frames[frameIdx].pMaterial != NULL &&
887 !m_Frames[frameIdx].pMaterial->IsUserAllocated())
888 {
889 Layout::DeleteObj(m_Frames[frameIdx].pMaterial);
890 }
891
892 m_Frames[frameIdx].pMaterial = pMaterial;
893 if (pMaterial != NULL)
894 {
895 pMaterial->SetTextureDirty();
896 }
897 }
898
899 Material*
GetContentMaterial() const900 Window::GetContentMaterial() const
901 {
902 return m_pMaterial;
903 }
904
SetContentMaterial(Material * pMaterial)905 void Window::SetContentMaterial(Material* pMaterial)
906 {
907 if (m_pMaterial == pMaterial)
908 {
909 return;
910 }
911
912 if (m_pMaterial != NULL && !m_pMaterial->IsUserAllocated())
913 {
914 Layout::DeleteObj(m_pMaterial);
915 }
916
917 m_pMaterial = pMaterial;
918 if (m_pMaterial != NULL)
919 {
920 m_pMaterial->SetTextureDirty();
921 }
922 }
923
924
925 #ifdef NW_LYT_DRAWER_ENABLE
926 //----------------------------------------------------------
927 // Window
928 void
MakeUniformDataSelf(DrawInfo * pDrawInfo,Drawer * pDrawer) const929 Window::MakeUniformDataSelf( DrawInfo* pDrawInfo, Drawer* pDrawer ) const
930 {
931 #ifdef NW_LYT_DRAWER_DISABLE_DRAW_WINOOW
932 return;
933 #endif
934
935 // 使わないぽい
936 NW_UNUSED_VARIABLE( pDrawInfo );
937
938 const WindowFrameSize frameSize( GetFrameSize(m_FrameNum, m_Frames) );
939 const math::VEC2 basePt( GetVtxPos() );
940
941 { // Contentについての設定
942
943 { // TexEnv設定
944 pDrawer->SetUpTexEnv( m_pMaterial );
945 }
946
947 { // テクスチャの設定
948 pDrawer->SetUpTextures( m_pMaterial );
949 }
950
951 { // テクスチャ座標の設定
952
953 if ( !m_IsTexCoordInited || m_pMaterial->IsTextureDirty() )
954 {
955 m_UniformTexCoordNum = pDrawer->CalcTextureCoords( m_pMaterial,
956 m_Content.texCoordAry.GetArray(),
957 m_UniformTexCoords );
958 m_IsTexCoordInited = true;
959 m_pMaterial->SetTextureDirty( false );
960 }
961 pDrawer->SetUpTextureCoords( m_UniformTexCoords, m_UniformTexCoordNum );
962 }
963
964 { // 頂点座標の計算に必要な情報の設定
965 pDrawer->SetUpMtx( GetGlobalMtx() );
966
967 // TODO: lyt_Windowにキャッシュすることを検討
968 Size size( GetSize().width - frameSize.l + m_ContentInflation.l - frameSize.r + m_ContentInflation.r,
969 GetSize().height - frameSize.t + m_ContentInflation.t - frameSize.b + m_ContentInflation.b );
970
971 nw::math::VEC2 pos( basePt.x + frameSize.l - m_ContentInflation.l,
972 basePt.y - frameSize.t + m_ContentInflation.t );
973
974 pDrawer->SetUpQuad( size, pos );
975 }
976
977 { // 頂点カラーの設定
978 pDrawer->SetUpVtxColors( m_Content.vtxColors, GetGlobalAlpha() );
979 }
980
981 { // UniformDataの設定終了
982 pDrawer->SetUniformDataEnd();
983 }
984 }
985
986
987 { // 頂点カラーの設定
988 ut::Color8 white[ 4 ] = { 0xffffffff,0xffffffff,0xffffffff,0xffffffff };
989 pDrawer->SetUpVtxColors( white, GetGlobalAlpha() );
990 }
991
992 const u8 texCoordNum = 1;
993 int uniformTexCoordNum;
994 nw::math::VEC4 uniformTexCoords[ TexMapMax * 2 ];
995 Size polSize;
996 math::VEC2 polPt;
997 math::VEC2 texCds[ texCoordNum ][ VERTEX_MAX ];
998
999 // Frameについての設定
1000 switch ( m_FrameNum )
1001 {
1002 case 1 :
1003 {
1004 const Frame& frame = m_Frames[ WINDOWFRAME_LT ];
1005
1006 // フレームのテクスチャがない場合は何もしない
1007 if ( frame.pMaterial->GetTexMapNum() == 0 ) return;
1008
1009 // TexEnv設定
1010 pDrawer->SetUpTexEnv( frame.pMaterial );
1011
1012 // テクスチャの設定
1013 pDrawer->SetUpTextures( frame.pMaterial );
1014 const TexSize texSize = frame.pMaterial->GetTexMap(0).GetSize();
1015
1016 local::GetLTFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
1017 local::GetLTTexCoord( texCds[0], polSize, texSize, TEXTUREFLIP_NONE );
1018
1019 uniformTexCoordNum = pDrawer->CalcTextureCoords( frame.pMaterial, texCds, uniformTexCoords );
1020 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1021 pDrawer->SetUpQuad( polSize, polPt );
1022 pDrawer->SetUniformDataEnd();
1023
1024 local::GetRTFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
1025 local::GetRTTexCoord(texCds[0], polSize, texSize, TEXTUREFLIP_FLIPH);
1026
1027 uniformTexCoordNum = pDrawer->CalcTextureCoords( frame.pMaterial, texCds, uniformTexCoords );
1028 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1029 pDrawer->SetUpQuad( polSize, polPt );
1030 pDrawer->SetUniformDataEnd();
1031
1032 local::GetRBFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
1033 local::GetRBTexCoord(texCds[0], polSize, texSize, TEXTUREFLIP_ROTATE180);
1034
1035 uniformTexCoordNum = pDrawer->CalcTextureCoords( frame.pMaterial, texCds, uniformTexCoords );
1036 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1037 pDrawer->SetUpQuad( polSize, polPt );
1038 pDrawer->SetUniformDataEnd();
1039
1040 local::GetLBFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
1041 local::GetLBTexCoord(texCds[0], polSize, texSize, TEXTUREFLIP_FLIPV);
1042
1043 // TODO: uniformTexCoordsをキャッシュしたい
1044 uniformTexCoordNum = pDrawer->CalcTextureCoords( frame.pMaterial, texCds, uniformTexCoords );
1045 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1046 pDrawer->SetUpQuad( polSize, polPt );
1047 pDrawer->SetUniformDataEnd();
1048 }
1049 break;
1050 case 4 :
1051 {
1052 const Frame* pFrame = &m_Frames[ WINDOWFRAME_LT ];
1053 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1054 {
1055 // TexEnv設定
1056 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1057
1058 // テクスチャの設定
1059 pDrawer->SetUpTextures( pFrame->pMaterial );
1060
1061 local::GetLTFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
1062 local::GetLTTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1063
1064 // TODO: uniformTexCoordsをキャッシュしたい
1065 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1066 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1067 pDrawer->SetUpQuad( polSize, polPt );
1068 pDrawer->SetUniformDataEnd();
1069 }
1070
1071 pFrame = &m_Frames[ WINDOWFRAME_RT ];
1072 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1073 {
1074 // TexEnv設定
1075 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1076
1077 // テクスチャの設定
1078 pDrawer->SetUpTextures( pFrame->pMaterial );
1079
1080 local::GetRTFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
1081 local::GetRTTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1082
1083 // TODO: uniformTexCoordsをキャッシュしたい
1084 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1085 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1086 pDrawer->SetUpQuad( polSize, polPt );
1087 pDrawer->SetUniformDataEnd();
1088
1089 }
1090
1091 pFrame = &m_Frames[ WINDOWFRAME_RB ];
1092 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1093 {
1094 // TexEnv設定
1095 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1096
1097 // テクスチャの設定
1098 pDrawer->SetUpTextures( pFrame->pMaterial );
1099
1100 local::GetRBFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
1101 local::GetRBTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1102
1103 // TODO: uniformTexCoordsをキャッシュしたい
1104 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1105 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1106 pDrawer->SetUpQuad( polSize, polPt );
1107 pDrawer->SetUniformDataEnd();
1108
1109 }
1110
1111 pFrame = &m_Frames[ WINDOWFRAME_LB ];
1112 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1113 {
1114 // TexEnv設定
1115 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1116
1117 // テクスチャの設定
1118 pDrawer->SetUpTextures( pFrame->pMaterial );
1119
1120 local::GetLBFrameSize(&polPt, &polSize, basePt, GetSize(), frameSize);
1121 local::GetLBTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1122
1123 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1124 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1125 pDrawer->SetUpQuad( polSize, polPt );
1126 pDrawer->SetUniformDataEnd();
1127 }
1128 }
1129 break;
1130 case 8 :
1131 {
1132 const Frame* pFrame = &m_Frames[ WINDOWFRAME_LT ];
1133 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1134 {
1135 // TexEnv設定
1136 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1137
1138 // テクスチャの設定
1139 pDrawer->SetUpTextures( pFrame->pMaterial );
1140
1141 polSize = Size(frameSize.l, frameSize.t);
1142 polPt = basePt;
1143
1144 local::GetLTTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1145
1146 // TODO: uniformTexCoordsをキャッシュしたい
1147 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1148 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1149 pDrawer->SetUpQuad( polSize, polPt );
1150 pDrawer->SetUniformDataEnd();
1151 }
1152
1153 pFrame = &m_Frames[ WINDOWFRAME_T ];
1154 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1155 {
1156 // TexEnv設定
1157 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1158
1159 // テクスチャの設定
1160 pDrawer->SetUpTextures( pFrame->pMaterial );
1161
1162 polSize = Size(GetSize().width - frameSize.l - frameSize.r, frameSize.t);
1163 polPt = math::VEC2(basePt.x + frameSize.l, basePt.y);
1164
1165 local::GetLTTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1166
1167 // TODO: uniformTexCoordsをキャッシュしたい
1168 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1169 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1170 pDrawer->SetUpQuad( polSize, polPt );
1171 pDrawer->SetUniformDataEnd();
1172 }
1173
1174 pFrame = &m_Frames[ WINDOWFRAME_RT ];
1175 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1176 {
1177 // TexEnv設定
1178 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1179
1180 // テクスチャの設定
1181 pDrawer->SetUpTextures( pFrame->pMaterial );
1182
1183 polSize = Size(frameSize.r, frameSize.t);
1184 polPt = math::VEC2(basePt.x + GetSize().width - frameSize.r, basePt.y);
1185
1186 local::GetRTTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1187
1188 // TODO: uniformTexCoordsをキャッシュしたい
1189 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1190 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1191 pDrawer->SetUpQuad( polSize, polPt );
1192 pDrawer->SetUniformDataEnd();
1193
1194 }
1195
1196 pFrame = &m_Frames[ WINDOWFRAME_R ];
1197 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1198 {
1199 // TexEnv設定
1200 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1201
1202 // テクスチャの設定
1203 pDrawer->SetUpTextures( pFrame->pMaterial );
1204
1205 polSize = Size(frameSize.r, GetSize().height - frameSize.t - frameSize.b);
1206 polPt = math::VEC2(basePt.x + GetSize().width - frameSize.r, basePt.y - frameSize.t);
1207
1208 local::GetRTTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1209
1210 // TODO: uniformTexCoordsをキャッシュしたい
1211 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1212 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1213 pDrawer->SetUpQuad( polSize, polPt );
1214 pDrawer->SetUniformDataEnd();
1215 }
1216
1217 pFrame = &m_Frames[ WINDOWFRAME_RB ];
1218 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1219 {
1220 // TexEnv設定
1221 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1222
1223 // テクスチャの設定
1224 pDrawer->SetUpTextures( pFrame->pMaterial );
1225
1226 polSize = Size(frameSize.r, frameSize.b);
1227 polPt = math::VEC2(basePt.x + GetSize().width - frameSize.r, basePt.y - GetSize().height + frameSize.b);
1228
1229 local::GetRBTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1230
1231 // TODO: uniformTexCoordsをキャッシュしたい
1232 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1233 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1234 pDrawer->SetUpQuad( polSize, polPt );
1235 pDrawer->SetUniformDataEnd();
1236 }
1237
1238 pFrame = &m_Frames[ WINDOWFRAME_B ];
1239 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1240 {
1241 // TexEnv設定
1242 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1243
1244 // テクスチャの設定
1245 pDrawer->SetUpTextures( pFrame->pMaterial );
1246
1247 polSize = Size(GetSize().width - frameSize.l - frameSize.r, frameSize.b);
1248 polPt = math::VEC2(basePt.x + frameSize.l, basePt.y - GetSize().height + frameSize.b);
1249
1250 local::GetRBTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1251
1252 // TODO: uniformTexCoordsをキャッシュしたい
1253 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1254 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1255 pDrawer->SetUpQuad( polSize, polPt );
1256 pDrawer->SetUniformDataEnd();
1257 }
1258
1259 pFrame = &m_Frames[ WINDOWFRAME_LB ];
1260 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1261 {
1262 // TexEnv設定
1263 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1264
1265 // テクスチャの設定
1266 pDrawer->SetUpTextures( pFrame->pMaterial );
1267
1268 polSize = Size(frameSize.l, frameSize.b);
1269 polPt = math::VEC2(basePt.x, basePt.y - GetSize().height + frameSize.b);
1270
1271 local::GetLBTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1272
1273 // TODO: uniformTexCoordsをキャッシュしたい
1274 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1275 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1276 pDrawer->SetUpQuad( polSize, polPt );
1277 pDrawer->SetUniformDataEnd();
1278 }
1279
1280 pFrame = &m_Frames[ WINDOWFRAME_L ];
1281 if ( pFrame->pMaterial->GetTexMapNum() != 0 )
1282 {
1283 // TexEnv設定
1284 pDrawer->SetUpTexEnv( pFrame->pMaterial );
1285
1286 // テクスチャの設定
1287 pDrawer->SetUpTextures( pFrame->pMaterial );
1288
1289 polSize = Size(frameSize.l, GetSize().height - frameSize.t - frameSize.b);
1290 polPt = math::VEC2(basePt.x, basePt.y - frameSize.t);
1291
1292 local::GetLBTexCoord(texCds[0], polSize, pFrame->pMaterial->GetTexMap(0).GetSize(), pFrame->textureFlip);
1293
1294 // TODO: uniformTexCoordsをキャッシュしたい
1295 uniformTexCoordNum = pDrawer->CalcTextureCoords( pFrame->pMaterial, texCds, uniformTexCoords );
1296 pDrawer->SetUpTextureCoords( uniformTexCoords, uniformTexCoordNum );
1297 pDrawer->SetUpQuad( polSize, polPt );
1298 pDrawer->SetUniformDataEnd();
1299 }
1300 }
1301 break;
1302 }
1303
1304 // 同じテクスチャを使用するWindowとPictureの描画で、フレームの
1305 // 描画位置がおかしくなる不具合への対処 <BTS:536>
1306 pDrawer->FlushBuffer();
1307 }
1308 #endif
1309
1310 } // namespace nw::lyt
1311 } // namespace nw
1312