[Gcblue-commits] gcb_wx/src/graphics tc3DWindow.cpp,1.2,1.3 tcCreditView.cpp,1.3,1.4 tcStartView.cpp
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-09-16 02:25:01
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11156/src/graphics Modified Files: tc3DWindow.cpp tcCreditView.cpp tcStartView.cpp Log Message: Index: tcStartView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcStartView.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcStartView.cpp 5 Sep 2004 01:02:02 -0000 1.1 --- tcStartView.cpp 16 Sep 2004 02:24:50 -0000 1.2 *************** *** 1,6 **** ! /* ! ** tcStartView.cpp ! ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcStartView.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 25,44 **** #ifndef WX_PRECOMP #include "wx/wx.h" - #ifdef WIN32 - #include "wx/msw/private.h" // for MS Windows specific definitions - #endif #endif #include "tcStartView.h" #include "tcSound.h" #include "tcOptions.h" ! #include "aerror.h" #include "wxcommands.h" - using namespace Gdiplus; bool tcStartView::Init() { ! char zBuff[96]; for(int i=0; i < N_START_BUTTONS; i++) --- 25,44 ---- #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcStartView.h" + + #include <osg/Texture2D> + #include <osg/Vec4> + #include "tcSound.h" #include "tcOptions.h" ! #include "AError.h" #include "wxcommands.h" bool tcStartView::Init() { ! wxString s; for(int i=0; i < N_START_BUTTONS; i++) *************** *** 46,67 **** tsButtonInfo *pButton = &maButton[i]; ! sprintf(zBuff,"%sstart%d%s",IMAGE_PATH,i,"_off.jpg"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! pButton->mpiButtonOff = new Image(mzwchar,false); ! pButton->mnButtonWidth = pButton->mpiButtonOff->GetWidth(); ! pButton->mnButtonHeight = pButton->mpiButtonOff->GetHeight(); ! sprintf(zBuff,"%sstart%d%s",IMAGE_PATH,i,"_on.jpg"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! pButton->mpiButtonOver = new Image(mzwchar,false); ! sprintf(zBuff,"%sstart%d%s",IMAGE_PATH,i,"_on.jpg"); ! MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); ! pButton->mpiButtonOn = new Image(mzwchar,false); ! if ((pButton->mpiButtonOff == NULL)||(pButton->mpiButtonOver == NULL)|| ! (pButton->mpiButtonOn == NULL)) ! { ! WTL("tcStartView - button image load error, possible missing file"); ! } } --- 46,60 ---- tsButtonInfo *pButton = &maButton[i]; ! s = wxString::Format("start%d%s", i, "_off.jpg"); ! ! pButton->mpiButtonOff = LoadTexture(s.c_str()); ! pButton->mnButtonWidth = buttonSize; ! pButton->mnButtonHeight = buttonSize; ! s = wxString::Format("start%d%s", i, "_on.jpg"); ! pButton->mpiButtonOver = LoadTexture(s.c_str()); ! s = wxString::Format("start%d%s", i, "_on.jpg"); ! pButton->mpiButtonOn = LoadTexture(s.c_str()); } *************** *** 74,97 **** PlaceButtons(); - FontFamily ff(L"Arial"); - mpFont = new Font(&ff,10,FontStyleRegular,UnitPixel); - if (mpFont == NULL) - { - WTL("tcStartView - mpFont creation failed\n"); - return false; - } - mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB - if (mpBrush == NULL) - { - WTL("tcStartView - mpBrush creation failed\n"); - return false; - } - mpPen = new Pen(Color(255,200,200,200),2); - if (mpPen == NULL) - { - WTL("tcStartView - mpPen creation failed\n"); - return false; - } - return true; } --- 67,70 ---- *************** *** 99,175 **** int tcStartView::Draw() { ! static WCHAR szwchar[256]; ! static nTestCount = 0; ! ! Graphics *pGraphics; ! ! Erase(); ! if (!GetGraphics(pGraphics)) ! { ! return false; ! } ! ! DrawBackground(pGraphics); ! /*** Draw buttons ***/ ! mpBrush->SetColor(Color(0xFEFFFFFF)); // font color ! for(int i=0;i<N_START_BUTTONS;i++) { ! DrawButtonLine(pGraphics, i); } ! for(int i=0;i<N_START_BUTTONS;i++) { ! DrawButton(pGraphics, i); } ! ReleaseGraphics(pGraphics); DrawBorder(); return true; } ! void tcStartView::DrawButton(Graphics *apGraphics, int anButton) { ! Image *pButtonImage; ! static WCHAR szwchar[256]; // wide char array buffer for string conversion ! int x,y,nState; - if (apGraphics == NULL) {return;} if ((anButton < 0)||(anButton >= N_START_BUTTONS)) {return;} tsButtonInfo *pButton = &maButton[anButton]; nState = pButton->mnState; ! if (nState == 0) {pButtonImage = pButton->mpiButtonOff;} ! else {pButtonImage = (nState == 1) ? pButton->mpiButtonOver : pButton->mpiButtonOn;} if (pButtonImage != NULL) { x = pButton->mnButtonX; ! y = pButton->mnButtonY; ! // not using size fields causes errors (stretching) with non power of 2 bitmap size ! apGraphics->DrawImage(pButtonImage,x,y,pButton->mnButtonWidth,pButton->mnButtonHeight); } if (nState != 0) { ! RectF textbox; ! textbox.X = (float)pButton->mnTextX; ! textbox.Y = (float)pButton->mnTextY; ! textbox.Width = pButton->mnButtonWidth * 2.5f; ! textbox.Height = 30; ! DrawTextInRectWrap(apGraphics, mpFont, mpBrush, pButton->mzCaption.GetBuffer(),textbox); ! mpPen->SetColor(0xFFFBFADE); ! } ! else ! { ! mpPen->SetColor(0xFF858476); } ! apGraphics->DrawRectangle(mpPen,pButton->mnButtonX,pButton->mnButtonY, ! pButton->mnButtonWidth,pButton->mnButtonHeight); } ! void tcStartView::DrawButtonLine(Graphics *apGraphics, int anButton) { int nState; - if (apGraphics == NULL) {return;} if ((anButton < 0)||(anButton >= N_START_BUTTONS)) {return;} --- 72,142 ---- int tcStartView::Draw() { ! //static nTestCount = 0; ! /*** Draw buttons ***/ ! ! for(int i=0; i<N_START_BUTTONS; i++) { ! DrawButtonLine(i); } ! ! for(int i=0; i<N_START_BUTTONS; i++) { ! DrawButton(i); } ! DrawBorder(); + + HideUnusedObjects(); return true; } ! void tcStartView::DrawButton(int anButton) { ! osg::Texture2D* pButtonImage; ! int x, y, nState; if ((anButton < 0)||(anButton >= N_START_BUTTONS)) {return;} + osg::Vec4 captionColor(1, 1, 1, 1); + tsButtonInfo *pButton = &maButton[anButton]; nState = pButton->mnState; ! if (nState == 0) {pButtonImage = pButton->mpiButtonOff.get();} ! else {pButtonImage = (nState == 1) ? pButton->mpiButtonOver.get() : ! pButton->mpiButtonOn.get();} if (pButtonImage != NULL) { x = pButton->mnButtonX; ! y = mnHeight - pButton->mnButtonY - pButton->mnButtonHeight; ! ! DrawImage(pButtonImage, x, y, pButton->mnButtonWidth, pButton->mnButtonHeight, ! ALIGN_BOTTOM_LEFT); } if (nState != 0) { ! float textx = (float)pButton->mnTextX; ! float texty = float(mnHeight) - float(pButton->mnTextY); ! //textbox.Width = pButton->mnButtonWidth * 2.5f; ! //textbox.Height = 30; ! //DrawTextInRectWrap(apGraphics, mpFont, mpBrush, pButton->mzCaption.GetBuffer(),textbox); ! //mpPen->SetColor(0xFFFBFADE); ! DrawText(pButton->mzCaption.GetBuffer(), textx, texty, defaultFont.get(), ! captionColor, 10.0f, LEFT_BASE_LINE); } ! // mpPen->SetColor(0xFF858476); ! ! ! osg::Vec4 outlineColor(0.45, 0.55, 0.55, 1.0f); ! DrawRect(pButton->mnButtonX, mnHeight-pButton->mnButtonY-pButton->mnButtonHeight, ! pButton->mnButtonWidth, pButton->mnButtonHeight, outlineColor); } ! void tcStartView::DrawButtonLine(int anButton) { int nState; if ((anButton < 0)||(anButton >= N_START_BUTTONS)) {return;} *************** *** 177,195 **** nState = pButton->mnState; if (nState != 0) { ! mpPen->SetColor(0xFFFBFADE); } else { ! mpPen->SetColor(0xFF858476); } int nLineY = pButton->mnButtonY + pButton->mnButtonHeight/2; int nLineX1 = pButton->mnButtonX; int nLineX2 = pButton->mnButtonX + pButton->mnButtonWidth; const int nMargin = 50; ! apGraphics->DrawLine(mpPen,nMargin,nLineY,nLineX1,nLineY); ! apGraphics->DrawLine(mpPen,nLineX2,nLineY,mnWidth-nMargin,nLineY); } --- 144,166 ---- nState = pButton->mnState; + osg::Vec4 color; + if (nState != 0) { ! color = osg::Vec4(0.7f, 0.92f, 0.92f, 1.0f); } else { ! color = osg::Vec4(0.45f, 0.55f, 0.55f, 1.0f); } int nLineY = pButton->mnButtonY + pButton->mnButtonHeight/2; + nLineY = mnHeight - nLineY; int nLineX1 = pButton->mnButtonX; int nLineX2 = pButton->mnButtonX + pButton->mnButtonWidth; const int nMargin = 50; ! ! DrawLine(nLineX1-50, nLineY, nLineX1, nLineY, color); ! DrawLine(nLineX2, nLineY, nLineX2+50, nLineY, color); } *************** *** 313,317 **** pButton->mnTextX = xpos; ! pButton->mnTextY = ypos+pButton->mnButtonHeight+2; pButton->mnButtonX = xpos; pButton->mnButtonY = ypos; --- 284,288 ---- pButton->mnTextX = xpos; ! pButton->mnTextY = ypos+pButton->mnButtonHeight+8; pButton->mnButtonX = xpos; pButton->mnButtonY = ypos; *************** *** 330,334 **** pPlayButton->mnButtonY = pScenarioButton->mnButtonY; pPlayButton->mnTextX = pPlayButton->mnButtonX; ! pPlayButton->mnTextY = pPlayButton->mnButtonY+pPlayButton->mnButtonHeight+2; // place Multiplay button to right of Options button --- 301,305 ---- pPlayButton->mnButtonY = pScenarioButton->mnButtonY; pPlayButton->mnTextX = pPlayButton->mnButtonX; ! pPlayButton->mnTextY = pPlayButton->mnButtonY+pPlayButton->mnButtonHeight+8; // place Multiplay button to right of Options button *************** *** 341,345 **** pMultiButton->mnButtonY = pOptionButton->mnButtonY; pMultiButton->mnTextX = pMultiButton->mnButtonX; ! pMultiButton->mnTextY = pMultiButton->mnButtonY+pMultiButton->mnButtonHeight+2; } --- 312,316 ---- pMultiButton->mnButtonY = pOptionButton->mnButtonY; pMultiButton->mnTextX = pMultiButton->mnButtonX; ! pMultiButton->mnTextY = pMultiButton->mnButtonY+pMultiButton->mnButtonHeight+8; } *************** *** 372,376 **** const wxPoint& pos, const wxSize& size, ! const wxString& name) : tcWindow(parent, pos, size, name) { wxSize parentSize = parent->GetSize(); --- 343,349 ---- const wxPoint& pos, const wxSize& size, ! const wxString& name) : ! tc3DWindow(parent, pos, size, name) , ! buttonSize(96) { wxSize parentSize = parent->GetSize(); *************** *** 393,398 **** mpOptions = NULL; ! mpFont = NULL; ! mpBrush = NULL; for (int i=0; i < N_START_BUTTONS; i++) --- 366,370 ---- mpOptions = NULL; ! for (int i=0; i < N_START_BUTTONS; i++) *************** *** 415,449 **** tcStartView::~tcStartView() { - if (mpFont != NULL) - { - delete mpFont; - } - - if (mpBrush != NULL) - { - delete mpBrush; - } - if (mpPen != NULL) - { - delete mpPen; - } - - for(int i=0; i < N_START_BUTTONS; i++) - { - if (maButton[i].mpiButtonOff != NULL) - { - delete maButton[i].mpiButtonOff; - } - - if (maButton[i].mpiButtonOver != NULL) - { - delete maButton[i].mpiButtonOver; - } - - if (maButton[i].mpiButtonOn != NULL) - { - delete maButton[i].mpiButtonOn; - } - } } \ No newline at end of file --- 387,390 ---- Index: tcCreditView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcCreditView.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcCreditView.cpp 14 Sep 2004 02:01:46 -0000 1.3 --- tcCreditView.cpp 16 Sep 2004 02:24:50 -0000 1.4 *************** *** 1,6 **** ! /* ** @file tcCreditView.cpp ! ** ! ** Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ** @file tcCreditView.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 24,32 **** #ifndef WX_PRECOMP #include "wx/wx.h" - #ifdef WIN32 - #include "wx/msw/private.h" - #endif #endif #include "tcCreditView.h" #include "aerror.h" --- 24,33 ---- #ifndef WX_PRECOMP #include "wx/wx.h" #endif + + #include <osgText/Text> + #include <osgText/Font> + #include "tcCreditView.h" #include "aerror.h" *************** *** 35,39 **** #include "tcTime.h" ! using namespace Gdiplus; void tcCreditView::AddCredit(tcString& s, float afTrailSpace, int effect) --- 36,40 ---- #include "tcTime.h" ! void tcCreditView::AddCredit(tcString& s, float afTrailSpace, int effect) *************** *** 168,199 **** - FontFamily ff(L"Arial"); - mpFont = new Font(&ff,16,FontStyleRegular,UnitPixel); - if (mpFont == NULL) { - WTL("tcCreditView - mpFont creation failed\n"); - return false; - } - mpFontLarge = new Font(&ff,20,FontStyleBold,UnitPixel); - if (mpFontLarge == NULL) { - WTL("tcCreditView - mpFontLarge creation failed\n"); - return false; - } - mpFontSmall = new Font(&ff,12,FontStyleRegular,UnitPixel); - if (mpFontSmall == NULL) { - WTL("tcCreditView - mpFontSmall creation failed\n"); - return false; - } - - mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB - if (mpBrush == NULL) { - WTL("tcCreditView - mpBrush creation failed\n"); - return false; - } - mpPen = new Pen(Color(255,200,200,200),2); - if (mpPen == NULL) { - WTL("tcCreditView - mpPen creation failed\n"); - return false; - } - Rewind(); return true; --- 169,172 ---- *************** *** 203,236 **** int tcCreditView::Draw() { ! static WCHAR szwchar[256]; ! UINT32 nDeltaTime = tcTime::Get()->Get30HzCount() - mnStartTime; ! ! Graphics *pGraphics; ! ! Erase(); ! if (!GetGraphics(pGraphics)) ! { ! return false; ! } ! ! DrawBackground(pGraphics); ! ! // Get the text rendering hint. ! TextRenderingHint oldhint = pGraphics->GetTextRenderingHint(); ! ! // Set the text rendering hint to TextRenderingHintAntiAlias. ! pGraphics->SetTextRenderingHint(TextRenderingHintAntiAlias); ! ! float fY = (float)mnHeight - 0.5f*(float)nDeltaTime; float fX = 0.5f*(float)mnWidth; ! const UINT32 nColorFade = 0x8E328032; ! const UINT32 nColorBright = 0xFE64FF64; ! mpBrush->SetColor(Color(nColorBright)); // font color //DrawTextCentered(pGraphics, mpFont, mpBrush, crawlstring.GetBuffer(), fX,fY); static int nFlashId = -1; static bool bFlash = false; ! static UINT32 snFocusTime; static tcString szFocus; --- 176,196 ---- int tcCreditView::Draw() { ! //static WCHAR szwchar[256]; ! unsigned int nDeltaTime = tcTime::Get()->Get30HzCount() - mnStartTime; ! const float height = float(mnHeight); ! float fY = 0.5f*(float)nDeltaTime; float fX = 0.5f*(float)mnWidth; ! //const UINT32 nColorFade = 0x8E328032; ! //const UINT32 nColorBright = 0xFE64FF64; ! const osg::Vec4 nColorFade(0.2f, 0.5f, 0.2f, 0.5f); ! const osg::Vec4 nColorBright(0.4f, 1.0f, 0.4f, 1.0f); ! ! //mpBrush->SetColor(Color(nColorBright)); // font color //DrawTextCentered(pGraphics, mpFont, mpBrush, crawlstring.GetBuffer(), fX,fY); static int nFlashId = -1; static bool bFlash = false; ! static unsigned int snFocusTime; static tcString szFocus; *************** *** 247,257 **** if (nFlashId >= 0) {szFocus = maCredit[nFlashId].mzCaption;} snFocusTime = tcTime::Get()->Get30HzCount(); ! mpBrush->SetColor(Color(255,255,255,255)); ! pGraphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); //tcSound::Get()->PlayEffect(SEFFECT_EXPLOSION2); } if (nFlashId >= 0) { ! UINT32 nDeltaFocusTime = (tcTime::Get()->Get30HzCount() - snFocusTime); } for (int n=0;n<(int)mnCredits;n++) --- 207,217 ---- if (nFlashId >= 0) {szFocus = maCredit[nFlashId].mzCaption;} snFocusTime = tcTime::Get()->Get30HzCount(); ! //mpBrush->SetColor(Color(255,255,255,255)); ! //pGraphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); //tcSound::Get()->PlayEffect(SEFFECT_EXPLOSION2); } if (nFlashId >= 0) { ! unsigned int nDeltaFocusTime = (tcTime::Get()->Get30HzCount() - snFocusTime); } for (int n=0;n<(int)mnCredits;n++) *************** *** 259,280 **** tcString s = maCredit[n].mzCaption; const float fEffectZone = 60.0f; ! float dyeffect = fY - ((float)mnHeight - fEffectZone); ! if ((dyeffect >= 0)&&(dyeffect <= fEffectZone)) { ! mpBrush->SetColor(Color(nColorFade)); // font color ! DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), ! fX - 40.0f*dyeffect,fY); ! DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), ! fX + 40.0f*dyeffect,fY); ! DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), ! fX - 30.0f*dyeffect,fY); ! DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), ! fX + 30.0f*dyeffect,fY); ! DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), ! fX - 20.0f*dyeffect,fY); ! DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), ! fX + 20.0f*dyeffect,fY); ! mpBrush->SetColor(Color(nColorBright)); // font color } ! else if (fY <= (float)mnHeight) { if ((n > nFlashId)&&(maCredit[n].mnEffect == 1)) --- 219,234 ---- tcString s = maCredit[n].mzCaption; const float fEffectZone = 60.0f; ! float dyeffect = fEffectZone - fY; ! if ((dyeffect >= 0)&&(dyeffect <= fEffectZone)) ! { ! for (float dx = 20.0f; dx <= 40.0f; dx += 10.0f) ! { ! DrawText(s.GetBuffer(), fX + dx*dyeffect, fY, defaultFont.get(), ! nColorFade, 12.0f, CENTER_CENTER); ! DrawText(s.GetBuffer(), fX - dx*dyeffect, fY, defaultFont.get(), ! nColorFade, 12.0f, CENTER_CENTER); ! } } ! else if ((fY >= 0) && (fY <= height)) { if ((n > nFlashId)&&(maCredit[n].mnEffect == 1)) *************** *** 287,319 **** bFlash = false; } ! Font *pFont = mpFont; if (maCredit[n].mnEffect == 1) { ! pFont = mpFontLarge; } else if (maCredit[n].mnEffect == 2) { ! pFont = mpFontSmall; } ! mpBrush->SetColor(Color(nColorFade)); // font color ! DrawTextCentered(pGraphics, pFont, mpBrush, s.GetBuffer(), ! fX + 1.0f,fY + 1.0f); ! mpBrush->SetColor(Color(nColorBright)); // font color ! DrawTextCentered(pGraphics, pFont, mpBrush, s.GetBuffer(), fX,fY); } ! fY += maCredit[n].mfTrailSpace; } ! pGraphics->SetTextRenderingHint(oldhint); ! ReleaseGraphics(pGraphics); DrawBorder(); // rewind after credits are done crawling ! if (fY < -100.0f) { Rewind(); } return true; } --- 241,279 ---- bFlash = false; } ! ! float fontSize = 12.0; if (maCredit[n].mnEffect == 1) { ! fontSize = 18.0f; //pFont = mpFontLarge; } else if (maCredit[n].mnEffect == 2) { ! fontSize = 12.0f; //pFont = mpFontSmall; } ! DrawText(s.GetBuffer(), fX + 1.0f, fY + 1.0f, defaultFont.get(), ! nColorFade, fontSize, CENTER_CENTER); ! DrawText(s.GetBuffer(), fX, fY, defaultFont.get(), ! nColorBright, fontSize, CENTER_CENTER); } ! fY -= maCredit[n].mfTrailSpace; } ! static unsigned int frameCount = 0; ! wxString infoString = wxString::Format("%d Y:%f\n", frameCount, fY); ! frameCount++; ! DrawText(infoString.c_str(), 10, 10, defaultFont.get(), ! nColorBright, 16.0f, LEFT_BASE_LINE); ! DrawBorder(); // rewind after credits are done crawling ! if (fY > height + 100.0f) { Rewind(); } + + HideUnusedObjects(); return true; } *************** *** 343,353 **** tcCreditView::tcCreditView(wxWindow *parent, const wxPoint& pos, const wxSize& size, ! const wxString& name, tcWindow *sharedSurface) ! : tcWindow(parent, pos, size, name, sharedSurface) { - mpFont = NULL; - mpFontLarge = NULL; - mpFontSmall = NULL; - mpBrush = NULL; mnCredits = 0; mbDrawRewind = false; --- 303,309 ---- tcCreditView::tcCreditView(wxWindow *parent, const wxPoint& pos, const wxSize& size, ! const wxString& name) ! : tc3DWindow(parent, pos, size, name) { mnCredits = 0; mbDrawRewind = false; *************** *** 356,364 **** tcCreditView::~tcCreditView() { ! if (mpFont != NULL) {delete mpFont;} ! if (mpFontLarge != NULL) {delete mpFontLarge;} ! if (mpFontSmall != NULL) {delete mpFontSmall;} ! if (mpBrush != NULL) {delete mpBrush;} ! if (mpPen != NULL) {delete mpPen;} } --- 312,316 ---- tcCreditView::~tcCreditView() { ! } Index: tc3DWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DWindow.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tc3DWindow.cpp 14 Sep 2004 23:17:16 -0000 1.2 --- tc3DWindow.cpp 16 Sep 2004 02:24:50 -0000 1.3 *************** *** 27,30 **** --- 27,31 ---- #include <osg/ClipNode> + #include <osg/Depth> #include <osg/DrawPixels> #include <osg/Geode> *************** *** 244,248 **** stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); ! stateSet->setRenderBinDetails(1, "RenderBin"); --- 245,253 ---- stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); ! stateSet->setRenderBinDetails(-10, "RenderBin"); ! ! osg::Depth* depth = new osg::Depth(osg::Depth::ALWAYS, 1, 1, false); ! depth->setWriteMask(0); ! stateSet->setAttribute(depth); *************** *** 289,296 **** --- 294,312 ---- } wxWindow::Enable(true); + + if (!root->getNumParents()) + { + clipNode->addChild(root.get()); + } + } else { wxWindow::Enable(false); + + if (root->getNumParents()) + { + clipNode->removeChild(root.get()); + } } mbActive=abActive; *************** *** 572,575 **** --- 588,593 ---- stateset->setTextureAttributeAndModes(0, backgroundTexture.get(), osg::StateAttribute::ON); + + SetBackgroundDraw(true); } *************** *** 596,599 **** --- 614,638 ---- } + + osg::Texture2D* tc3DWindow::LoadTexture(const char* fileName) + { + wxString fileWithPath = PrependImagePath(fileName); + osg::Image* image = osgDB::readImageFile(fileWithPath.c_str()); + + if (!image) + { + fprintf(stderr, "Failed to load image: %s\n", fileName); + return 0; + } + + osg::Texture2D* tex = new osg::Texture2D; + tex->setDataVariance(osg::Object::STATIC); + tex->setImage(image); + + return tex; + } + + + void tc3DWindow::SetBackground(UINT32 anColor) { *************** *** 651,657 **** * @param x center x coord * @param y center y coord */ void tc3DWindow::DrawImage(osg::Texture2D* texture, float x, float y, ! float width, float height) { wxASSERT(texture); --- 690,697 ---- * @param x center x coord * @param y center y coord + * @param alignMode CENTER (default) or ALIGN_BOTTOM_LEFT */ void tc3DWindow::DrawImage(osg::Texture2D* texture, float x, float y, ! float width, float height, int alignMode) { wxASSERT(texture); *************** *** 664,673 **** if (osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(quad->getVertexArray())) { ! const float half_width = 0.5f * width; ! const float half_height = 0.5f * height; ! float left = x - half_width; ! float right = x + half_width; ! float top = y + half_height; ! float bottom = y - half_height; (*vertices)[0] = osg::Vec3(left, top, 0); --- 704,724 ---- if (osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(quad->getVertexArray())) { ! float left, right, top, bottom; ! if (alignMode == CENTER) ! { ! const float half_width = 0.5f * width; ! const float half_height = 0.5f * height; ! left = x - half_width; ! right = x + half_width; ! top = y + half_height; ! bottom = y - half_height; ! } ! else ! { ! left = x; ! right = x + width; ! top = y + height; ! bottom = y; ! } (*vertices)[0] = osg::Vec3(left, top, 0); *************** *** 849,853 **** if (textIdx < nPool) { ! return textPool[textIdx++].get(); } else if (textIdx == nPool) --- 900,910 ---- if (textIdx < nPool) { ! osgText::Text* text = textPool[textIdx++].get(); ! wxASSERT(text); ! if (text->getNumParents() == 0) ! { ! root->addDrawable(text); ! } ! return text; } else if (textIdx == nPool) *************** *** 862,865 **** --- 919,923 ---- text->setText("UNINTIALIZED"); + text->setUseDisplayList(false); osg::StateSet* stateSet = text->getOrCreateStateSet(); stateSet->setRenderBinDetails(10, "RenderBin"); *************** *** 890,894 **** for (unsigned idx = textIdx; idx < textPool.size(); ++idx) { ! textPool[idx]->setPosition(osg::Vec3(10000.0f, 10000.0f, -10000.0f)); } textIdx = 0; --- 948,953 ---- for (unsigned idx = textIdx; idx < textPool.size(); ++idx) { ! root->removeDrawable(textPool[idx].get()); ! //textPool[idx]->setPosition(osg::Vec3(10000.0f, 10000.0f, -10000.0f)); } textIdx = 0; *************** *** 1014,1017 **** --- 1073,1081 ---- root = new osg::Geode; + osg::StateSet* stateSet = root->getOrCreateStateSet(); + + osg::Depth* depth = new osg::Depth(osg::Depth::ALWAYS, 0, 0, false); + stateSet->setAttributeAndModes(depth, osg::StateAttribute::ON); + clipNode = new osg::ClipNode; clipNode->createClipBox( *************** *** 1063,1072 **** CreateBackgroundQuad(); ! LoadBackgroundImage("console_b.jpg"); ! SetBackgroundDraw(true); ! ! ! LEFT_BASE_LINE = osgText::Text::LEFT_BASE_LINE; ! CENTER_CENTER = osgText::Text::CENTER_CENTER; } --- 1127,1132 ---- CreateBackgroundQuad(); ! //LoadBackgroundImage("console_b.jpg"); ! //SetBackgroundDraw(true); } |