Changeset 37382 in vbox for trunk/src/VBox/HostServices/SharedOpenGL/render
- Timestamp:
- Jun 8, 2011 2:48:56 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r37333 r37382 797 797 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 798 798 799 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId);800 glReadBuffer(m_FBOAttFrontId);801 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);802 glDrawBuffer(GL_BACK);803 804 799 DEBUG_MSG(("OVIW(%p): makeCurrent (non shared) %p\n", (void*)self, (void*)m_pGLCtx)); 805 800 [m_pGLCtx makeCurrentContext]; … … 953 948 * others are also valid, but might incur a costly software translation. */ 954 949 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOTexBackId); 955 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB , m_FBOTexSize.width, m_FBOTexSize.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);950 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, m_FBOTexSize.width, m_FBOTexSize.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); 956 951 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOTexFrontId); 957 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB , m_FBOTexSize.width, m_FBOTexSize.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);952 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, m_FBOTexSize.width, m_FBOTexSize.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); 958 953 959 954 /* Now attach the textures to the FBO as its color destinations */ … … 983 978 DEBUG_MSG(("OVIW(%p): Framebuffer Object creation or update failed!\n", (void*)self)); 984 979 980 // glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); 985 981 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, oldTexId); 986 982 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, (GLuint)oldFBId ? (GLuint)oldFBId : m_FBOId); … … 1166 1162 { 1167 1163 GLint sw = 0; 1164 GLint readFBOId = 0; 1165 GLint drawFBOId = 0; 1168 1166 GLint readId = 0; 1169 1167 GLint drawId = 0; … … 1172 1170 1173 1171 #ifdef FBO 1174 glBindFramebufferEXT(GL_FRAMEBUFFER_BINDING_EXT, m_FBOId);1175 1176 1172 /* Don't use flush buffers cause we are using FBOs here! */ 1177 1173 1178 if ([self isCurrentFBO]) 1179 { 1180 /* Fetch the current used read and draw buffers. */ 1181 glGetIntegerv(GL_READ_BUFFER, &readId); 1182 glGetIntegerv(GL_DRAW_BUFFER, &drawId); 1183 1184 /* Do the swapping of our internal ids */ 1185 sw = m_FBOTexFrontId; 1186 m_FBOTexFrontId = m_FBOTexBackId; 1187 m_FBOTexBackId = sw; 1188 sw = m_FBOAttFrontId; 1189 m_FBOAttFrontId = m_FBOAttBackId; 1190 m_FBOAttBackId = sw; 1191 1192 /* We also have to swap the real ids on the current context. */ 1174 /* Before we swap make sure everything is done (This is really 1175 * important. Don't remove.) */ 1176 glFlush(); 1177 1178 /* Fetch the current used read and draw buffers. */ 1179 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFBOId); 1180 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFBOId); 1181 glGetIntegerv(GL_READ_BUFFER, &readId); 1182 glGetIntegerv(GL_DRAW_BUFFER, &drawId); 1183 1184 /* Do the swapping of our internal ids */ 1185 sw = m_FBOTexFrontId; 1186 m_FBOTexFrontId = m_FBOTexBackId; 1187 m_FBOTexBackId = sw; 1188 sw = m_FBOAttFrontId; 1189 m_FBOAttFrontId = m_FBOAttBackId; 1190 m_FBOAttBackId = sw; 1191 1192 DEBUG_MSG_1(("read FBO: %d draw FBO: %d readId: %d drawId: %d\n", readFBOId, drawFBOId, readId, drawId)); 1193 /* We also have to swap the real ids on the current context. */ 1194 if ((GLuint)readFBOId == m_FBOId) 1195 { 1193 1196 if ((GLuint)readId == m_FBOAttFrontId) 1194 {1195 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId);1196 1197 glReadBuffer(m_FBOAttBackId); 1197 } 1198 if ((GLuint)readId == m_FBOAttBackId) 1199 glReadBuffer(m_FBOAttFrontId); 1200 } 1201 if ((GLuint)drawFBOId == m_FBOId) 1202 { 1198 1203 if ((GLuint)drawId == m_FBOAttFrontId) 1199 {1200 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_FBOId);1201 1204 glDrawBuffer(m_FBOAttBackId); 1202 } 1203 1204 [self tryDraw]; 1205 } 1205 if ((GLuint)drawId == m_FBOAttBackId) 1206 glDrawBuffer(m_FBOAttFrontId); 1207 } 1208 1209 [self tryDraw]; 1206 1210 #else 1207 1211 [m_pGLCtx flushBuffer]; … … 1212 1216 { 1213 1217 GLint drawId = 0; 1218 GLint FBOId = 0; 1214 1219 1215 1220 DEBUG_MSG(("OVIW(%p): flushFBO\n", (void*)self)); … … 1224 1229 { 1225 1230 /* Only reset if we aren't currently front. */ 1231 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &FBOId); 1226 1232 glGetIntegerv(GL_DRAW_BUFFER, &drawId); 1227 if ((GLuint)drawId != m_FBOAttFrontId) 1233 if (!( (GLuint)FBOId == m_FBOId 1234 && (GLuint)drawId == m_FBOAttFrontId)) 1228 1235 m_fFrontDrawing = false; 1229 1236 [self tryDraw]; … … 1245 1252 - (void)stateInfo:(GLenum)pname withParams:(GLint*)params 1246 1253 { 1247 DEBUG_MSG_1(("StateInfo requested: %d\n", pname)); 1254 GLint test; 1255 // DEBUG_MSG_1(("StateInfo requested: %d\n", pname)); 1248 1256 1249 1257 glGetIntegerv(pname, params); … … 1261 1269 } 1262 1270 case GL_READ_BUFFER: 1271 { 1272 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &test); 1273 if ((GLuint)test == m_FBOId) 1274 { 1275 if ((GLuint)*params == m_FBOAttFrontId) 1276 *params = GL_FRONT; 1277 else 1278 if ((GLuint)*params == m_FBOAttBackId) 1279 *params = GL_BACK; 1280 } 1281 break; 1282 } 1263 1283 case GL_DRAW_BUFFER: 1264 1284 { 1265 if ((GLuint)*params == m_FBOAttFrontId) 1266 *params = GL_FRONT; 1267 else 1268 if ((GLuint)*params == m_FBOAttBackId) 1269 *params = GL_BACK; 1285 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &test); 1286 if ((GLuint)test == m_FBOId) 1287 { 1288 if ((GLuint)*params == m_FBOAttFrontId) 1289 *params = GL_FRONT; 1290 else 1291 if ((GLuint)*params == m_FBOAttBackId) 1292 *params = GL_BACK; 1293 } 1270 1294 break; 1271 1295 } … … 1282 1306 { 1283 1307 if (mode == GL_FRONT) 1308 { 1309 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId); 1284 1310 glReadBuffer(m_FBOAttFrontId); 1311 } 1285 1312 else if (mode == GL_BACK) 1313 { 1314 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId); 1286 1315 glReadBuffer(m_FBOAttBackId); 1316 } 1287 1317 else 1288 1318 glReadBuffer(mode); … … 1303 1333 { 1304 1334 DEBUG_MSG(("OVIW(%p): front\n", (void*)self)); 1335 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_FBOId); 1305 1336 glDrawBuffer(m_FBOAttFrontId); 1306 1337 m_fFrontDrawing = true; … … 1309 1340 { 1310 1341 DEBUG_MSG(("OVIW(%p): back\n", (void*)self)); 1342 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_FBOId); 1311 1343 glDrawBuffer(m_FBOAttBackId); 1312 1344 } 1313 1345 else 1314 1346 { 1315 DEBUG_MSG(("OVIW(%p): other \n", (void*)self));1347 DEBUG_MSG(("OVIW(%p): other: %d\n", (void*)self, mode)); 1316 1348 glDrawBuffer(mode); 1317 1349 } … … 1348 1380 1349 1381 /* Fetch the current used read and draw buffers. */ 1350 glGetIntegerv(GL_READ_FRAMEBUFFER_ EXT, &oldReadFBOId);1351 glGetIntegerv(GL_DRAW_FRAMEBUFFER_ EXT, &oldDrawFBOId);1382 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &oldReadFBOId); 1383 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &oldDrawFBOId); 1352 1384 glGetIntegerv(GL_READ_BUFFER, &oldReadId); 1353 1385 glGetIntegerv(GL_DRAW_BUFFER, &oldDrawId); … … 1393 1425 glClear(GL_COLOR_BUFFER_BIT); 1394 1426 1395 /* Blit the content of the FBO to the screen. todo: check for 1396 * optimization with display lists. */ 1427 /* Blit the content of the FBO to the screen. */ 1397 1428 for (i = 0; i < m_cClipRects; ++i) 1398 1429 { … … 1409 1440 glFinish(); 1410 1441 */ 1442 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1411 1443 [m_pSharedGLCtx flushBuffer]; 1412 1444 1413 1445 [m_pGLCtx makeCurrentContext]; 1414 1446 /* Reset to previous buffer bindings. */ 1415 if ( (GLuint)oldReadId == m_FBOAttBackId 1416 || (GLuint)oldReadId == m_FBOAttFrontId) 1417 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_FBOId); 1447 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, oldReadFBOId); 1418 1448 glReadBuffer(oldReadId); 1419 if ( (GLuint)oldDrawId == m_FBOAttBackId 1420 || (GLuint)oldDrawId == m_FBOAttFrontId) 1421 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_FBOId); 1449 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, oldDrawFBOId); 1422 1450 glDrawBuffer(oldDrawId); 1423 1451 } 1424 1452 } 1453 #else 1454 [m_pGLCtx flushBuffer]; 1425 1455 #endif 1426 1456 } … … 1939 1969 NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init]; 1940 1970 1941 DEBUG_MSG_1(("getIntergerv called: %d\n", pname));1971 // DEBUG_MSG_1(("getIntergerv called: %d\n", pname)); 1942 1972 1943 1973 performSelectorOnViewTwoArgs(@selector(stateInfo:withParams:), (id)pname, (id)params);
Note:
See TracChangeset
for help on using the changeset viewer.