opensubscriber
   Find in this group all groups
 
Unknown more information…

m : mac-opengl@lists.apple.com 17 January 2006 • 10:43PM -0500

FXPLUG / texture createData
by Bret Battey

REPLY TO AUTHOR
 
REPLY TO GROUP




Since none of the Apple discussion lists explicitly mention the Motion
FXPLUG API as being within their range, I start here in the OpenGL list. If
there IS a better place to get FXPLUG clarifications, I'd be grateful for
that information.

I'm creating a plugin for Motion using the FXPLUG API. I am making it a
hardware-accelerated (openGL texture-based) plugin.

In my algorithm, I need to be able to sample colors from the input image in
order to make decisions.

The input image is provided as an FxTexture, so I can't sample those colors
directly.

>From my reading of the API, I should be able to use the createData:withType:
method to copy the input FxTexture's pixels into a new pixel buffer.
Presumably I can then index into the pixel buffer to reference the bytes I
need to get the colors of individual pixels.

However, when I do this, I'm just getting pixel values of 0, even though the
input image is decidely not black!

Any clues? Or am I misunderstanding the function of createData:withType: ?

Code selections, within the renderOutput fxplug routine:
---------

FxTexture *inTex = (FxTexture *)inputImage;

GLubyte* NewMemBuffer = [inTex createData: GL_RGBA withType:
GL_UNSIGNED_INT_8_8_8_8] ;

UInt32 x,y,index;
GLubyte *point, cv0, cv1, cv2, cv3;

for ( y = 0; y < 5; y=y+1 ) {
for ( x = 0; x < 5; x=x+1 ) {

index = ((y * [inTex width]) + x) * 4 ;
point = NewMemBuffer+index ;
if(logErrors) NSLog( @"Point address %x", point ) ;

cv0 = *point++ ;
cv1 = *point++ ;
cv2 = *point++ ;
cv3 = *point ;

if(logErrors) NSLog( @"color values %u %u %u %u", cv0, cv1,
cv2, cv3 ) ;



}
}

results

2006-01-17 14:44:49.971 Motion[1222] Point address 621c000

2006-01-17 14:44:49.971 Motion[1222] color values 0 0 0 0

2006-01-17 14:44:49.971 Motion[1222] Point address 621c004

2006-01-17 14:44:49.972 Motion[1222] color values 0 0 0 0

2006-01-17 14:44:49.972 Motion[1222] Point address 621c008

2006-01-17 14:44:49.972 Motion[1222] color values 0 0 0 0

etc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (Mac-opengl@list...)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/subscriber%40opensubscriber.com

This email sent to subscriber@open...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

opensubscriber is not affiliated with the authors of this message nor responsible for its content.