70 if (t->cpuQueueInitialized && json_object_object_length(t->cpuData))
73 glBindTexture(t->glTextureTarget, t->glTextureName);
74 GLenum format = GL_BGRA;
75 if (t->glInternalFormat == GL_DEPTH_COMPONENT)
76 format = GL_DEPTH_COMPONENT;
79 glTexImage2D(t->glTextureTarget, 0, t->glInternalFormat, t->pixelsWide, t->pixelsHigh, 0, format, type, NULL);
80 glBindTexture(t->glTextureTarget, 0);
84 VuoGlTexture_release(VuoGlTexturePool_Allocate, t->glTextureTarget, t->glInternalFormat, t->pixelsWide, t->pixelsHigh, t->glTextureName);
86 if (t->cpuQueueInitialized)
88 dispatch_release(t->cpuQueue);
90 json_object_object_foreach(t->cpuData, key, value)
94 json_object_object_get_ex(value,
"buffer", &o);
95 void *buffer = (
void *)json_object_get_int64(o);
97 json_object_object_get_ex(value,
"freeCallback", &o);
98 void (^freeCallback)(
void *) = (
void (^)(
void *))json_object_get_int64(o);
100 freeCallback(buffer);
102 Block_release(freeCallback);
105 json_object_put(t->cpuData);
261 if (!pixelsWide || !pixelsHigh)
264 __block GLenum internalformat;
265 __block GLuint glTextureName;
266 __block
int alignment = 1;
267 __block
bool customRowLength =
false;
272 glTextureName =
VuoGlTexturePool_use(cgl_ctx, VuoGlTexturePool_Allocate, GL_TEXTURE_2D, internalformat, pixelsWide, pixelsHigh, format, NULL);
278 if (colorDepth == VuoImageColorDepth_8)
280 else if (colorDepth == VuoImageColorDepth_16)
282 glType = GL_HALF_FLOAT_ARB;
292 || bytesPerRow == bytesPerPixel * pixelsWide)
297 if (bytesPerRow % 4 == 0)
299 else if (bytesPerRow % 8 == 0)
301 else if (bytesPerRow % 2 == 0)
303 else if (bytesPerRow % bytesPerPixel == 0)
305 GLuint rowPixels = bytesPerRow / bytesPerPixel;
306 glPixelStorei(GL_UNPACK_ROW_LENGTH, rowPixels);
307 customRowLength =
true;
311 VUserLog(
"Not sure how to handle this stride:");
312 VUserLog(
" %dx%d",pixelsWide,pixelsHigh);
313 VUserLog(
" bytesPerRow = %d",bytesPerRow);
314 VUserLog(
" bytesPerPixel = %d",bytesPerPixel);
315 GLint leftoverBytes = bytesPerRow - bytesPerPixel*pixelsWide;
316 VUserLog(
" leftoverBytes = %d",leftoverBytes);
321 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
323 glBindTexture(GL_TEXTURE_2D, glTextureName);
324 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
326 glTexImage2D(GL_TEXTURE_2D, 0, internalformat, pixelsWide, pixelsHigh, 0, format, glType, (GLvoid *)pixels);
327 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
328 glBindTexture(GL_TEXTURE_2D, 0);
331 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
333 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
338 glFlushRenderAPPLE();
347 dispatch_once(&image->cpuQueueInitialized, ^{});
348 image->cpuQueue = dispatch_queue_create(
"org.vuo.image.cpu", NULL);
349 image->cpuData = json_object_new_object();
353 char *keyWithAlignment;
354 asprintf(&keyWithAlignment,
"%s alignment=%d", key, alignment);
356 key = keyWithAlignment;
360 char *keyWithRowLength;
361 asprintf(&keyWithRowLength,
"%s rowLength=%d", key, bytesPerRow);
363 key = keyWithRowLength;
365 json_object *cpuEntry = json_object_new_object();
366 json_object_object_add(cpuEntry,
"buffer", json_object_new_int64((
long long)pixels));
367 json_object_object_add(cpuEntry,
"freeCallback", json_object_new_int64((
long long)Block_copy(freeCallback)));
368 json_object_object_add(image->cpuData, key, cpuEntry);
404 if (image->glInternalFormat == GL_DEPTH_COMPONENT && requestedFormat != GL_DEPTH_COMPONENT16)
406 VUserLog(
"Error: Image has format GL_DEPTH_COMPONENT, which must be fetched as GL_DEPTH_COMPONENT16.");
410 dispatch_once(&image->cpuQueueInitialized, ^{
411 image->cpuQueue = dispatch_queue_create(
"org.vuo.image.cpu", NULL);
412 image->cpuData = json_object_new_object();
415 __block
unsigned char *pixels = NULL;
416 dispatch_sync(image->cpuQueue, ^{
417 char *key = VuoGl_stringForConstant(requestedFormat);
418 struct json_object *value;
419 if (json_object_object_get_ex(image->cpuData, key, &value))
422 json_object_object_get_ex(value,
"buffer", &o);
423 pixels = (unsigned char *)json_object_get_int64(o);
427 unsigned int channels;
428 if (requestedFormat == GL_LUMINANCE
429 || requestedFormat == GL_R16
430 || requestedFormat == GL_DEPTH_COMPONENT16)
432 else if (requestedFormat == GL_LUMINANCE_ALPHA)
434 else if (requestedFormat == GL_RGB
435 || requestedFormat == GL_BGR)
437 else if (requestedFormat == GL_RGBA
438 || requestedFormat == GL_BGRA
439 || requestedFormat == GL_RGBA16I_EXT
440 || requestedFormat == GL_RGBA16F_ARB
441 || requestedFormat == GL_RGBA32F_ARB)
445 VUserLog(
"Error: Unknown format %s.", VuoGl_stringForConstant(requestedFormat));
449 unsigned int bytesPerChannel = 1;
450 GLuint type = GL_UNSIGNED_BYTE;
451 if (requestedFormat == GL_RGBA16I_EXT
452 || requestedFormat == GL_R16
453 || requestedFormat == GL_DEPTH_COMPONENT16)
456 type = GL_UNSIGNED_SHORT;
458 else if (requestedFormat == GL_RGBA16F_ARB)
461 type = GL_HALF_FLOAT_ARB;
463 else if (requestedFormat == GL_RGBA32F_ARB)
469 GLuint actualFormat = requestedFormat;
470 if (requestedFormat == GL_RGBA16I_EXT
471 || requestedFormat == GL_RGBA16F_ARB
472 || requestedFormat == GL_RGBA32F_ARB)
473 actualFormat = GL_BGRA;
474 else if (requestedFormat == GL_DEPTH_COMPONENT16)
475 actualFormat = GL_DEPTH_COMPONENT;
476 else if (requestedFormat == GL_R16)
477 actualFormat = GL_RED;
479 size_t pixelBufferSize = image->pixelsWide * image->pixelsHigh * channels * bytesPerChannel;
480 pixels = (
unsigned char *)malloc(pixelBufferSize);
484 const char *tamperEvidentSeal =
"Vuo\0Ima\0ge_\0get\0Buf\0fer\0()\0";
485 int tamperEvidentSealLength = strlen(tamperEvidentSeal);
486 if (pixelBufferSize > tamperEvidentSealLength)
487 strlcpy((
char *)pixels, tamperEvidentSeal, pixelBufferSize);
492 bool openGLAddsPadding = ((image->pixelsWide * channels * bytesPerChannel) % 4 != 0);
493 if (openGLAddsPadding)
495 glPixelStorei(GL_PACK_ALIGNMENT, 1);
497 glBindTexture(image->glTextureTarget, image->glTextureName);
499 glGetTexImage(image->glTextureTarget, 0, actualFormat, type, (GLvoid *)pixels);
500 glBindTexture(image->glTextureTarget, 0);
502 if (openGLAddsPadding)
504 glPixelStorei(GL_PACK_ALIGNMENT, 4);
506 if (pixelBufferSize > tamperEvidentSealLength && strncmp((
char *)pixels, tamperEvidentSeal, strlen(tamperEvidentSeal)) == 0)
508 GLenum error = glGetError();
509 if (error == GL_NO_ERROR)
513 VUserLog(
"Warning: glGetTexImage() says it was successful, but it didn't actually copy any data. This might happen if the input texture has an IOSurface bound to it.");
515 VUserLog(
"OpenGL Error: %d", error);
525 json_object *cpuEntry = json_object_new_object();
526 json_object_object_add(cpuEntry,
"buffer", json_object_new_int64((
long long)pixels));
527 json_object_object_add(cpuEntry,
"freeCallback", json_object_new_int64((
long long)Block_copy( ^(
void *buffer){ free(buffer); } )));
528 json_object_object_add(image->cpuData, key, cpuEntry);
699 if (a->pixelsWide != b->pixelsWide
700 || a->pixelsHigh != b->pixelsHigh)
703 if (a->glTextureName == b->glTextureName)
711 if (aChannels == 4 && bChannels == 1)
714 for (
unsigned int i = 0; i < a->pixelsWide * a->pixelsHigh; ++i)
715 if (abs(aPixels[i*4+0] - bPixels[i*4+2]) > tolerance
716 || abs(aPixels[i*4+1] - bPixels[i*4+2]) > tolerance
717 || abs(aPixels[i*4+2] - bPixels[i*4+2]) > tolerance
718 || abs(aPixels[i*4+3] - bPixels[i*4+3]) > tolerance)
720 VDebugLog(
"Difference found at pixel coordinate (%ld,%ld): RGBA %d,%d,%d,%d vs %d,%d,%d,%d",
721 i%a->pixelsWide, i/a->pixelsWide,
722 aPixels[i*4+2],aPixels[i*4+1],aPixels[i*4+0],aPixels[i*4+3],
723 bPixels[i*4+2],bPixels[i*4+2],bPixels[i*4+2],bPixels[i*4+3]);
728 else if (aChannels == 1 && bChannels == 4)
731 for (
unsigned int i = 0; i < a->pixelsWide * a->pixelsHigh; ++i)
732 if (abs(aPixels[i*4+2] - bPixels[i*4+0]) > tolerance
733 || abs(aPixels[i*4+2] - bPixels[i*4+1]) > tolerance
734 || abs(aPixels[i*4+2] - bPixels[i*4+2]) > tolerance
735 || abs(aPixels[i*4+3] - bPixels[i*4+3]) > tolerance)
737 VDebugLog(
"Difference found at pixel coordinate (%ld,%ld): RGBA %d,%d,%d,%d vs %d,%d,%d,%d",
738 i%a->pixelsWide, i/a->pixelsWide,
739 aPixels[i*4+2],aPixels[i*4+2],aPixels[i*4+2],aPixels[i*4+3],
740 bPixels[i*4+2],bPixels[i*4+1],bPixels[i*4+0],bPixels[i*4+3]);
746 for (
unsigned int i = 0; i < a->pixelsWide * a->pixelsHigh * 4; ++i)
747 if (abs(aPixels[i] - bPixels[i]) > tolerance)
749 unsigned int p = (i/4)*4;
750 VDebugLog(
"Difference found at pixel coordinate (%ld,%ld): abs(%d - %d) > %d (RGBA %d,%d,%d,%d vs %d,%d,%d,%d)",
751 i%a->pixelsWide, i/a->pixelsWide,
752 aPixels[i], bPixels[i], tolerance,
753 aPixels[p+2],aPixels[p+1],aPixels[p+0],aPixels[p+3],
754 bPixels[p+2],bPixels[p+1],bPixels[p+0],bPixels[p+3]);
863 return VuoImageColorDepth_8;
865 if (image->glInternalFormat == GL_LUMINANCE8
866 || image->glInternalFormat == GL_LUMINANCE8_ALPHA8
867 || image->glInternalFormat == GL_RGB
868 || image->glInternalFormat == GL_RGBA
869 || image->glInternalFormat == GL_RGBA8
870 || image->glInternalFormat == GL_BGRA
871 || image->glInternalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT
872 || image->glInternalFormat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)
873 return VuoImageColorDepth_8;
874 else if (image->glInternalFormat == GL_LUMINANCE16F_ARB
875 || image->glInternalFormat == GL_LUMINANCE_ALPHA16F_ARB
876 || image->glInternalFormat == GL_DEPTH_COMPONENT
877 || image->glInternalFormat == GL_RGB16
878 || image->glInternalFormat == GL_RGBA16
879 || image->glInternalFormat == GL_RGB16F_ARB
880 || image->glInternalFormat == GL_RGBA16F_ARB)
881 return VuoImageColorDepth_16;
882 else if (image->glInternalFormat == GL_LUMINANCE32F_ARB
883 || image->glInternalFormat == GL_LUMINANCE_ALPHA32F_ARB
884 || image->glInternalFormat == GL_RGB32F_ARB
885 || image->glInternalFormat == GL_RGBA32F_ARB)
886 return VuoImageColorDepth_32;
889 VUserLog(
"Error: Unknown glInternalFormat %x (%s)", image->glInternalFormat, formatString);
891 return VuoImageColorDepth_8;
970 if (json_object_object_get_ex(js,
"pointer", &o))
973 if ((requestedPixelsWide == 0 && requestedPixelsHigh == 0)
974 || (im->pixelsWide == requestedPixelsWide && im->pixelsHigh == requestedPixelsHigh))
981 VuoImage outputImage =
VuoImage_make(im->glTextureName, im->glInternalFormat, requestedPixelsWide, requestedPixelsHigh);
982 outputImage->glTextureTarget = im->glTextureTarget;
983 outputImage->scaleFactor = im->scaleFactor;
990 __block
unsigned int glInternalFormat = 0;
991 unsigned long int pixelsWide;
992 unsigned long int pixelsHigh;
993 float scaleFactor = 1;
997 if (json_object_object_get_ex(js,
"pixelsWide", &o))
998 pixelsWide = json_object_get_int64(o);
1004 if (json_object_object_get_ex(js,
"pixelsHigh", &o))
1005 pixelsHigh = json_object_get_int64(o);
1009 if (pixelsWide == 0 || pixelsHigh == 0)
1014 if (json_object_object_get_ex(js,
"scaleFactor", &o))
1015 scaleFactor = json_object_get_double(o);
1020 if (json_object_object_get_ex(js,
"color", &o))
1026 if (json_object_object_get_ex(js,
"ioSurface", &o))
1028 IOSurfaceID surfID = json_object_get_int(o);
1032 __block IOSurfaceRef surf = NULL;
1033 __block GLuint textureRect;
1035 glInternalFormat = GL_RGBA;
1036 surf = IOSurfaceLookup(surfID);
1039 VUserLog(
"Error: IOSurfaceLookup(%d) failed.", surfID);
1042 textureRect =
VuoGlTexturePool_use(cgl_ctx, VuoGlTexturePool_AllocateIOSurface, GL_TEXTURE_RECTANGLE_ARB, glInternalFormat, pixelsWide, pixelsHigh, GL_BGRA, surf);
1043 glFlushRenderAPPLE();
1053 imageRect->glTextureTarget = GL_TEXTURE_RECTANGLE_ARB;
1060 requestedPixelsWide ? requestedPixelsWide : pixelsWide,
1061 requestedPixelsHigh ? requestedPixelsHigh : pixelsHigh,
1068 image2d->scaleFactor = scaleFactor;
1101 if (!json_object_object_get_ex(js,
"pixelsWide", &o))
1103 *outputPixelsWide = json_object_get_int64(o);
1105 if (!json_object_object_get_ex(js,
"pixelsHigh", &o))
1107 *outputPixelsHigh = json_object_get_int64(o);
1109 if (!json_object_object_get_ex(js,
"ioSurface", &o))
1111 IOSurfaceID surfID = json_object_get_int(o);
1113 GLuint textureRect = provider(*outputPixelsWide, *outputPixelsHigh);
1118 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textureRect);
1120 IOSurfaceRef *surf = outputIOSurface;
1121 *surf = IOSurfaceLookup(surfID);
1124 VUserLog(
"Error: IOSurfaceLookup(%d) failed.", surfID);
1128 CGLError err = CGLTexImageIOSurface2D(cgl_ctx, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA, (GLsizei)*outputPixelsWide, (GLsizei)*outputPixelsHigh, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, *surf, 0);
1129 if(err != kCGLNoError)
1131#pragma clang diagnostic push
1132#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1133 VUserLog(
"Error in CGLTexImageIOSurface2D(): %s", CGLErrorString(err));
1134#pragma clang diagnostic pop
1137 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
1138 glFlushRenderAPPLE();
1169 if (!clientTextureName)
1174 if (!json_object_object_get_ex(js,
"pixelsWide", &o))
1176 unsigned long inputPixelsWide = json_object_get_int64(o);
1178 if (!json_object_object_get_ex(js,
"pixelsHigh", &o))
1180 unsigned long inputPixelsHigh = json_object_get_int64(o);
1182 if (!json_object_object_get_ex(js,
"ioSurface", &o))
1184 IOSurfaceID surfID = json_object_get_int(o);
1186 __block
bool success =
true;
1188 IOSurfaceRef *surf = outputIOSurface;
1189 *surf = IOSurfaceLookup(surfID);
1192 VUserLog(
"Error: IOSurfaceLookup(%d) failed.", surfID);
1197 bool shouldResize = (inputPixelsWide != pixelsWide
1198 || inputPixelsHigh != pixelsHigh);
1203 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, clientTextureName);
1204 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, pixelsWide, pixelsHigh, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
1205 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
1207 GLuint outputFramebuffer;
1208 glGenFramebuffers(1, &outputFramebuffer);
1209 glBindFramebuffer(GL_FRAMEBUFFER, outputFramebuffer);
1210 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, clientTextureName, 0);
1212 glViewport(0, 0, pixelsWide, pixelsHigh);
1216 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, 0, 0);
1217 glBindFramebuffer(GL_FRAMEBUFFER, 0);
1218 glDeleteFramebuffers(1, &outputFramebuffer);
1222 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, clientTextureName);
1224 CGLError err = CGLTexImageIOSurface2D(cgl_ctx, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA, (GLsizei)inputPixelsWide, (GLsizei)inputPixelsHigh, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, *surf, 0);
1225 if (err != kCGLNoError)
1227#pragma clang diagnostic push
1228#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1229 VUserLog(
"Error in CGLTexImageIOSurface2D(): %s", CGLErrorString(err));
1230#pragma clang diagnostic pop
1235 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
1238 glFlushRenderAPPLE();
1319 CGLContextObj cgl_ctx = (CGLContextObj)context;
1321 static bool openGL32Core;
1322 static GLuint vertexArray;
1323 static GLuint program;
1324 static GLuint receiveTextureOffsetAndSizeUniform;
1328 char *vertexShaderSource;
1329 char *fragmentShaderSource;
1333 CGLSetCurrentContext(cgl_ctx);
1340 in vec2 textureCoordinate;
1341 out vec2 fragmentTextureCoordinate;
1344 fragmentTextureCoordinate = textureCoordinate;
1345 gl_Position = vec4(position.x, position.y, 0., 1.);
1349 uniform sampler2DRect receiveTexture;
1350 uniform vec4 receiveTextureOffsetAndSize;
1351 in vec2 fragmentTextureCoordinate;
1355 FragColor = texture(receiveTexture, receiveTextureOffsetAndSize.xy + fragmentTextureCoordinate * receiveTextureOffsetAndSize.zw);
1363 glGenVertexArraysAPPLE(1, &vertexArray);
1364 glBindVertexArrayAPPLE(vertexArray);
1367 attribute vec2 position;
1368 attribute vec2 textureCoordinate;
1369 varying vec2 fragmentTextureCoordinate;
1372 fragmentTextureCoordinate = textureCoordinate;
1373 gl_Position = vec4(position.x, position.y, 0., 1.);
1377 uniform sampler2DRect receiveTexture;
1378 uniform vec4 receiveTextureOffsetAndSize;
1379 varying vec2 fragmentTextureCoordinate;
1382 gl_FragColor = texture2DRect(receiveTexture, receiveTextureOffsetAndSize.xy + fragmentTextureCoordinate * receiveTextureOffsetAndSize.zw);
1388 const GLfloat quadPositionsAndTextureCoordinates[] = {
1398 GLuint quadPTCBuffer;
1399 glGenBuffers(1, &quadPTCBuffer);
1400 glBindBuffer(GL_ARRAY_BUFFER, quadPTCBuffer);
1401 glBufferData(GL_ARRAY_BUFFER,
sizeof(quadPositionsAndTextureCoordinates), quadPositionsAndTextureCoordinates, GL_STATIC_DRAW);
1404 GLuint vertexShader =
CompileShader(context, GL_VERTEX_SHADER, vertexShaderSource);
1405 GLuint fragmentShader =
CompileShader(context, GL_FRAGMENT_SHADER, fragmentShaderSource);
1406 program = glCreateProgram();
1407 glAttachShader(program, vertexShader);
1408 glAttachShader(program, fragmentShader);
1409 glLinkProgram(program);
1410 GLuint positionAttribute = glGetAttribLocation(program,
"position");
1411 GLuint textureCoordinateAttribute = glGetAttribLocation(program,
"textureCoordinate");
1412 GLuint receiveTextureUniform = glGetUniformLocation(program,
"receiveTexture");
1413 receiveTextureOffsetAndSizeUniform = glGetUniformLocation(program,
"receiveTextureOffsetAndSize");
1415 glUseProgram(program);
1417 glVertexAttribPointer(positionAttribute, 2, GL_FLOAT, GL_FALSE,
sizeof(GLfloat)*4, (
void*)0);
1418 glEnableVertexAttribArray(positionAttribute);
1420 glVertexAttribPointer(textureCoordinateAttribute, 2, GL_FLOAT, GL_FALSE,
sizeof(GLfloat)*4, (
void*)(
sizeof(GLfloat)*2));
1421 glEnableVertexAttribArray(textureCoordinateAttribute);
1423 glUniform1i(receiveTextureUniform, 0);
1429 CGLSetCurrentContext(cgl_ctx);
1433 glBindVertexArrayAPPLE(vertexArray);
1435 GLuint textureRect =
VuoGlTexturePool_use(cgl_ctx, VuoGlTexturePool_AllocateIOSurface, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA, pixelsWide, pixelsHigh, GL_BGRA, surf);
1438 VUserLog(
"Error: Couldn't allocate texture.");
1444 glActiveTexture(GL_TEXTURE0);
1445 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textureRect);
1447 glUseProgram(program);
1450 glUniform4f(receiveTextureOffsetAndSizeUniform, 0, flip ? pixelsHigh : 0, pixelsWide, pixelsHigh * (flip ? -1 : 1));
1455 glGetIntegerv(GL_VIEWPORT, viewport);
1457 glUniform4f(receiveTextureOffsetAndSizeUniform,
1458 ((
float)pixelsWide - viewport[2]) / 2,
1459 flip ? viewport[3] : 0,
1461 viewport[3] * (flip ? -1 : 1));
1464 glDrawArrays(GL_TRIANGLES, 0, 6);
1466 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
1467 VuoGlTexture_release(VuoGlTexturePool_AllocateIOSurface, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA, pixelsWide, pixelsHigh, textureRect);
1472 glBindVertexArrayAPPLE(0);
1474 glBindBuffer(GL_ARRAY_BUFFER, 0);
1511 __block IOSurfaceID surfID = 0;
1515 if (value->glTextureTarget == GL_TEXTURE_2D)
1517 else if (value->glTextureTarget == GL_TEXTURE_RECTANGLE_ARB)
1521 surfID = VuoImageRenderer_draw_internal(shader, value->pixelsWide, value->pixelsHigh,
VuoImage_getColorDepth(value),
true,
true, 0, NULL);
1526 glFlushRenderAPPLE();
1531 json_object * js = json_object_new_object();
1533 json_object * o = json_object_new_int(surfID);
1534 json_object_object_add(js,
"ioSurface", o);
1538 json_object * o = json_object_new_int64(value->pixelsWide);
1539 json_object_object_add(js,
"pixelsWide", o);
1542 json_object * o = json_object_new_int64(value->pixelsHigh);
1543 json_object_object_add(js,
"pixelsHigh", o);
1546 json_object *o = json_object_new_double(value->scaleFactor);
1547 json_object_object_add(js,
"scaleFactor", o);