Changeset 29427 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
- Timestamp:
- May 12, 2010 3:20:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r29371 r29427 29 29 //#define SHOW_WINDOW_BACKGROUND 1 /* Define this to see the window background even if the window is clipped */ 30 30 //#define DEBUG_VERBOSE /* Define this could get some debug info about the messages flow. */ 31 //#define DEBUG_poetzsch 1 31 32 32 33 #ifdef DEBUG_poetzsch … … 56 57 { 57 58 GLenum g = glGetError(); 58 59 if (g != GL_NO_ERROR) 59 60 { 60 61 char *errStr; … … 509 510 * call in the OpenGL thread. */ 510 511 // [m_pOverlayView performSelector:@selector(reshape) onThread:m_Thread withObject:nil waitUntilDone:YES]; 512 DEBUG_MSG(("parentWindowFrameChanged\n")); 511 513 [m_pOverlayView reshape]; 512 514 } … … 515 517 { 516 518 [[NSNotificationCenter defaultCenter] removeObserver:self]; 519 DEBUG_MSG(("parentWindowChanged\n")); 517 520 if(pWindow != nil) 518 521 { … … 530 533 // [NSTimer scheduledTimerWithTimeInterval:0.2 target:m_pOverlayView selector:@selector(reshape) userInfo:nil repeats:NO]; 531 534 [m_pOverlayView reshape]; 532 533 535 } 534 536 } … … 554 556 m_FBOTexSize = NSZeroSize; 555 557 m_FBODepthStencilPackedId = 0; 558 m_FBOThumbId = 0; 559 m_FBOThumbTexId = 0; 556 560 m_cClipRects = 0; 557 561 m_paClipRects = NULL; … … 650 654 { 651 655 m_Size = size; 652 [self reshape]; 653 [self updateFBO]; 656 657 if (!m_FBOId) 658 { 659 DEBUG_MSG(("Set size (no fbo) %p\n", self)); 660 [self reshape]; 661 [self updateFBO]; 662 } 663 else 664 { 665 DEBUG_MSG(("Set size FBO %p\n", self)); 666 [self reshape]; 667 [self updateFBO]; 668 /* have to rebind GL_TEXTURE_RECTANGLE_ARB as m_FBOTexId could be changed in updateFBO call */ 669 [self updateViewport]; 670 } 654 671 } 655 672 … … 661 678 - (void)updateViewport 662 679 { 680 DEBUG_MSG(("updateViewport %p\n", self)); 663 681 if (m_pSharedGLCtx) 664 682 { 665 683 /* Update the viewport for our OpenGL view */ 684 DEBUG_MSG(("MakeCurrent (shared) %X\n", m_pSharedGLCtx)); 666 685 [m_pSharedGLCtx makeCurrentContext]; 667 686 [m_pSharedGLCtx update]; … … 686 705 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOTexId); 687 706 707 DEBUG_MSG(("MakeCurrent %X\n", m_pGLCtx)); 688 708 [m_pGLCtx makeCurrentContext]; 689 709 } … … 692 712 - (void)reshape 693 713 { 714 DEBUG_MSG(("(%p)reshape %p\n", RTThreadSelf(), self)); 694 715 /* Getting the right screen coordinates of the parents frame is a little bit 695 716 * complicated. */ … … 745 766 746 767 - (void)createFBO 747 { 768 { 769 GLuint fboid = m_FBOId; 770 771 DEBUG_MSG(("createFBO %p\n", self)); 748 772 [self deleteFBO]; 749 773 774 if (0&&!fboid) 750 775 GL_SAVE_STATE; 751 776 … … 769 794 /* & the texture as well the depth/stencil render buffer */ 770 795 glGenTextures(1, &m_FBOTexId); 771 DEBUG_MSG _1(("Create FBO %d %d\n", m_FBOId, m_FBOTexId));796 DEBUG_MSG(("Create FBO %d %d\n", m_FBOId, m_FBOTexId)); 772 797 773 798 glGenRenderbuffersEXT(1, &m_FBODepthStencilPackedId); … … 790 815 if (m_FBOTexSize.width > maxTexSize || m_FBOTexSize.height > maxTexSize) 791 816 { 792 filter = GL_ NICEST;817 filter = GL_LINEAR; 793 818 if (imageAspectRatio > 1) 794 819 { … … 828 853 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); 829 854 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 855 glDisable(GL_TEXTURE_RECTANGLE_ARB); 830 856 831 857 /* Is there a dock tile preview enabled in the GUI? If so setup a … … 843 869 /* Initialize FBO Texture */ 844 870 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOThumbTexId); 845 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_ NICEST);846 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_ NICEST);871 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 872 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 847 873 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP); 848 874 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP); … … 875 901 m_paClipRects[2] = m_FBOTexSize.width; 876 902 m_paClipRects[3] = m_FBOTexSize.height; 877 903 904 if (0&&!fboid) 878 905 GL_RESTORE_STATE; 879 906 } … … 881 908 - (void)deleteFBO 882 909 { 883 if ([NSOpenGLContext currentContext] != nil) 884 { 885 GL_SAVE_STATE; 910 DEBUG_MSG(("deleteFBO %p\n", self)); 911 if (m_pSharedGLCtx) 912 { 913 DEBUG_MSG(("MakeCurrent (shared) %X\n", m_pSharedGLCtx)); 914 [m_pSharedGLCtx makeCurrentContext]; 915 [m_pSharedGLCtx update]; 916 917 glEnable(GL_TEXTURE_RECTANGLE_ARB); 918 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); 919 } 920 921 if (m_pGLCtx) 922 { 923 DEBUG_MSG(("MakeCurrent %X\n", m_pGLCtx)); 924 [m_pGLCtx makeCurrentContext]; 886 925 887 926 if (m_FBODepthStencilPackedId > 0) … … 899 938 if (m_FBOId > 0) 900 939 { 901 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 902 940 GLint tmpFB; 941 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &tmpFB); 942 943 if (tmpFB == m_FBOId) 944 { 945 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 946 } 947 903 948 glDeleteFramebuffersEXT(1, &m_FBOId); 904 949 m_FBOId = 0; 905 950 } 906 907 GL_RESTORE_STATE; 908 } 951 } 952 909 953 if (m_DockTileView != nil) 910 954 { … … 917 961 - (void)updateFBO 918 962 { 963 DEBUG_MSG(("updateFBO %p\n", self)); 919 964 [self makeCurrentFBO]; 920 965 … … 950 995 // if ([NSOpenGLContext currentContext] != m_pGLCtx) 951 996 { 997 DEBUG_MSG(("MakeCurrent %X\n", m_pGLCtx)); 952 998 [m_pGLCtx makeCurrentContext]; 953 999 CHECK_GL_ERROR(); … … 972 1018 glFlush(); 973 1019 // glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 974 1020 if (tmpFB == m_FBOId) 975 1021 { 976 1022 if ([self lockFocusIfCanDraw]) … … 993 1039 // glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 994 1040 DEBUG_MSG_1 (("Flush GetINT %d\n", tmpFB)); 995 1041 if (tmpFB == m_FBOId) 996 1042 { 997 1043 if ([self lockFocusIfCanDraw]) … … 1011 1057 // glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1012 1058 DEBUG_MSG_1 (("Finish GetINT %d\n", tmpFB)); 1013 1059 if (tmpFB == m_FBOId) 1014 1060 { 1015 1061 if ([self lockFocusIfCanDraw]) … … 1051 1097 if (m_FBOTexId > 0) 1052 1098 { 1099 if ([m_pSharedGLCtx view] != self) 1100 { 1101 DEBUG_MSG(("renderFBOToView: not currect view of shared ctx!")); 1102 [m_pSharedGLCtx setView: self]; 1103 [self updateViewport]; 1104 } 1105 1106 //DEBUG_MSG(("MakeCurrent (shared) %X\n", m_pSharedGLCtx)); 1053 1107 [m_pSharedGLCtx makeCurrentContext]; 1054 1108 1055 1109 if (m_FBOThumbTexId > 0 && 1056 1110 [m_DockTileView thumbBitmap] != nil) … … 1146 1200 glClear(GL_COLOR_BUFFER_BIT); 1147 1201 1202 glEnable(GL_TEXTURE_RECTANGLE_ARB); 1203 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOTexId); 1204 1148 1205 /* Blit the content of the FBO to the screen. todo: check for 1149 1206 * optimization with display lists. */ … … 1166 1223 glFinish(); 1167 1224 [m_pSharedGLCtx flushBuffer]; 1225 //DEBUG_MSG(("MakeCurrent %X\n", m_pGLCtx)); 1168 1226 [m_pGLCtx makeCurrentContext]; 1169 1227 } … … 1457 1515 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1458 1516 1517 DEBUG_MSG(("cocoaViewMakeCurrentContext(%p, %p)\n", pView, pCtx)); 1518 1459 1519 [(OverlayView*)pView setGLCtx:pCtx]; 1460 1520 [(OverlayView*)pView makeCurrentFBO]; … … 1532 1592 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1533 1593 1534 DEBUG_MSG _1(("glRenderspuBindFramebufferEXT called %d\n", framebuffer));1594 DEBUG_MSG(("glRenderspuBindFramebufferEXT called %d\n", framebuffer)); 1535 1595 1536 1596 #ifdef FBO
Note:
See TracChangeset
for help on using the changeset viewer.