Changeset 25442 in vbox
- Timestamp:
- Dec 16, 2009 5:22:15 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h
r25441 r25442 442 442 } 443 443 444 const QRect &rect() 445 { 446 return mpTex[0]->rect(); 447 } 444 448 size_t memSize() 445 449 { … … 655 659 GLuint mPBO; 656 660 uchar* mAddress; 657 };658 659 class VBoxVHWAFBO660 {661 public:662 VBoxVHWAFBO() :663 mFBO(0)664 {}665 666 ~VBoxVHWAFBO()667 {668 if(mFBO)669 {670 vboxglDeleteFramebuffers(1, &mFBO);671 }672 }673 674 void init()675 {676 VBOXQGL_CHECKERR(677 vboxglGenFramebuffers(1, &mFBO);678 );679 }680 681 void bind()682 {683 VBOXQGL_CHECKERR(684 vboxglBindFramebuffer(GL_FRAMEBUFFER, mFBO);685 );686 }687 688 void unbind(VBoxVHWATexture *pTex)689 {690 VBOXQGL_CHECKERR(691 vboxglBindFramebuffer(GL_FRAMEBUFFER, 0);692 );693 }694 695 void attachBound(VBoxVHWATexture *pTex)696 {697 VBOXQGL_CHECKERR(698 vboxglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pTex->texTarget(), pTex->texture(), 0);699 );700 }701 702 private:703 GLuint mFBO;704 };705 706 template <class T>707 class VBoxVHWATextureImageFBO : public T708 {709 public:710 VBoxVHWATextureImageFBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr) :711 T(size, format, aMgr),712 mFBOTex(size, VBoxVHWAColorFormat(32, 0xff0000, 0xff00, 0xff), aMgr)713 {714 }715 716 virtual void init(uchar *pvMem)717 {718 mFBO.init();719 mFBOTex.init(NULL);720 T:init(pvMem);721 mFBO.bind();722 mFBO.attachBound(mFBOTex.mpTex[0]);723 mFBO.unbind();724 }725 726 virtual int createDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect,727 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected,728 GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram)729 {730 T::createDisplay(&mFBOTex, &mFBOTex.rect(), &rect(),731 NULL, NULL, false,732 pDisplay, ppProgram);733 734 return mFBOTex.createDisplay(pDst, pDstRect, pSrcRect,735 pDstCKey, pSrcCKey, bNotIntersected,736 pDisplay, ppProgram);737 }738 739 virtual void update(const QRect * pRect)740 {741 mFBO.bind();742 T:update(pRect);743 744 VBoxGLWidget::pushSettingsAndSetupViewport(rect(), rect());745 mFBO.bind();746 mFBOTex.draw();747 mFBO.unbind();748 VBoxGLWidget::popSettingsAfterSetupViewport();749 }750 751 virtual void display(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect,752 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected)753 {754 mFBOTex.display(pDst, pDstRect, pSrcRect, pDstCKey, pSrcCKey, bNotIntersected);755 }756 757 virtual void display()758 {759 mFBOTex.display();760 }761 private:762 VBoxVHWAFBO mFBO;763 VBoxVHWATextureImage mFBOTex;764 661 }; 765 662 … … 1626 1523 }; 1627 1524 1525 class VBoxVHWAFBO 1526 { 1527 public: 1528 VBoxVHWAFBO() : 1529 mFBO(0) 1530 {} 1531 1532 ~VBoxVHWAFBO() 1533 { 1534 if(mFBO) 1535 { 1536 vboxglDeleteFramebuffers(1, &mFBO); 1537 } 1538 } 1539 1540 void init() 1541 { 1542 VBOXQGL_CHECKERR( 1543 vboxglGenFramebuffers(1, &mFBO); 1544 ); 1545 } 1546 1547 void bind() 1548 { 1549 VBOXQGL_CHECKERR( 1550 vboxglBindFramebuffer(GL_FRAMEBUFFER, mFBO); 1551 ); 1552 } 1553 1554 void unbind() 1555 { 1556 VBOXQGL_CHECKERR( 1557 vboxglBindFramebuffer(GL_FRAMEBUFFER, 0); 1558 ); 1559 } 1560 1561 void attachBound(VBoxVHWATexture *pTex) 1562 { 1563 VBOXQGL_CHECKERR( 1564 vboxglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pTex->texTarget(), pTex->texture(), 0); 1565 ); 1566 } 1567 1568 private: 1569 GLuint mFBO; 1570 }; 1571 1572 template <class T> 1573 class VBoxVHWATextureImageFBO : public T 1574 { 1575 public: 1576 VBoxVHWATextureImageFBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr) : 1577 T(size, format, aMgr), 1578 mFBOTex(size, VBoxVHWAColorFormat(32, 0xff0000, 0xff00, 0xff), aMgr) 1579 { 1580 } 1581 1582 virtual void init(uchar *pvMem) 1583 { 1584 mFBO.init(); 1585 mFBOTex.init(NULL); 1586 T:init(pvMem); 1587 mFBO.bind(); 1588 mFBO.attachBound(mFBOTex.mpTex[0]); 1589 mFBO.unbind(); 1590 } 1591 1592 virtual int createDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 1593 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected, 1594 GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram) 1595 { 1596 T::createDisplay(&mFBOTex, &mFBOTex.rect(), &rect(), 1597 NULL, NULL, false, 1598 pDisplay, ppProgram); 1599 1600 return mFBOTex.createDisplay(pDst, pDstRect, pSrcRect, 1601 pDstCKey, pSrcCKey, bNotIntersected, 1602 pDisplay, ppProgram); 1603 } 1604 1605 virtual void update(const QRect * pRect) 1606 { 1607 mFBO.bind(); 1608 T:update(pRect); 1609 1610 VBoxGLWidget::pushSettingsAndSetupViewport(rect(), rect()); 1611 mFBO.bind(); 1612 mFBOTex.draw(); 1613 mFBO.unbind(); 1614 VBoxGLWidget::popSettingsAfterSetupViewport(); 1615 } 1616 1617 virtual void display(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect, 1618 const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected) 1619 { 1620 mFBOTex.display(pDst, pDstRect, pSrcRect, pDstCKey, pSrcCKey, bNotIntersected); 1621 } 1622 1623 virtual void display() 1624 { 1625 mFBOTex.display(); 1626 } 1627 private: 1628 VBoxVHWAFBO mFBO; 1629 VBoxVHWATextureImage mFBOTex; 1630 }; 1628 1631 1629 1632 class VBoxQGLOverlay
Note:
See TracChangeset
for help on using the changeset viewer.