glDrawPixels and memory layout

Hi,

Can anyone tell me if it is possible to call glDrawPixels where the pixels are not stored in contiguous rows in processor memory? (I can call glPixelStorei with GL_UNPACK_ROW_LENGTH where different rows are not contiguous but the pixels themselves are in contiguous blocks, row by row).

Just to clarify, in processor memory I have:

p0 b b b b b p1 b b b b b p2 b b b b b
p3 b b b b b p4 b b b b b p5 b b b b b

where b are buffer values (regular for a given image but ranging from 0 -> inf) and pN represent the desired image pixels, from which I want to draw the image:

p0 p1 p2
p3 p4 p5

by calling glDrawPixels(3, 2, format, type, &p0);

I am not sure if this is something that cannot be done (short of copying all the desired values to a single block of memory) or if there is some combination of GL states that can achieve this?

Thanks

:confused: K

Hi !

I am not sure I got you right here, if you do mean that you have an array of pointers to pixels, then you cannot do that with glDrawPixels, the pixels has to be in linear memory so you can only give it one single pointer to the memory area and then you can control how each pixels is located in that memory area with glPixelStorei/f.

Mikael

I do have a linear array of pixels.

I can still reference every pixel knowing only the address of the first. The problems is that I need to express an image width, an image height and some sort of a pixel skip value.

A similar problem might be if I have RGB pixels and only want to use the R value (as luminance for example) - all you have to do is add a ‘skip’ value between components, for RGB it would be 2. I would like the value to be arbitrary at my choosing and skip pixels not components.

The question is whether there is a value that can be used somewhere along the line.

I think this could be accomplished using the GL_UNPACK_IMAGE_HEIGHT parameter - I am in effect selecting a sub-volume of a 3d texture (1 pixel by by height pixels by depth pixels) and want to draw that as a 2d image.

Unfortunately, these parameters only seem to work on the glTex*3D functions (and I can’t use a 3d texture as the data is larger than any implementation I have allows me to use in 3d textures which was my inital attempt. The same problem could be described as sliceing along the 3 principle axes of a ‘volume’ texture, I am just not sure how best to describe the problem).

I am beginning to think this isn’t possible though from reading glPixelStore*() documentation, I either can’t find or don’t understand the descriptions.

Thanks for your input - hope I have clarified things a bit and not made them worse :wink:

Hi !

I think the setting the UNPACK_ALIGNMENT can help a few, but in limeted way. Read in specification about this parameter.