Sign in to follow this  
mynameisnafe

C++ TBB simple/silly 2D->1D array question

Recommended Posts

mynameisnafe    258

So I've got mandelbrot running in OpenCL: I am to compare it to Intels TBB.

 

This is something I really should know by now and I feel silly asking.

 

I have a struct that represents an RGBA pixel, and I create a buffer of them - a bitmap

BGRA8* buffer = (BGRA8*)malloc( width * height * sizeof(BGRA8) );

Then I iterate through x and y doing whatever using parallel_for

 

Where do I put my x, y in terms of

buffer[ index ]

?

 

Thanks in advance, I know this is a silly question!

Share this post


Link to post
Share on other sites
AgPF6    165

You would access it by the same way you access anything:  by the way you defined it in your struct, except that you don't use this "->" you use this ".". 

 

buffer [index].x

Share this post


Link to post
Share on other sites
alexisgreene    499

For some reason I assumed that buffer was a pointer to bytes and not a pointer to BGRA8. That was a mistake on my part. I have edited my previous answer to take that into account.

 

Sorry for the mistake.

Edited by Deortuka

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this