• Advertisement

Archived

This topic is now archived and is closed to further replies.

Passing Dynamic Arrays to glDrawPixels

This topic is 5023 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This works fine (static array):
GLubyte screenImage[screenImageHeight][screenImageWidth][3];

// array is filled with zeros


glDrawPixels(screenImageWidth, screenImageHeight, GL_RGB,GL_UNSIGNED_BYTE, screenImage);
 
This freezes my system (no errors, just freeze):
GLubyte ***screenImage;

// array is initialized dynamically; 

// because this code is taken out of context, I am omittting

// the initializtion for the sake of clarity;

// I am very confident in the correctness of the initialization;


// array is filled with zeros


glDrawPixels(screenImageWidth, screenImageHeight, GL_RGB,GL_UNSIGNED_BYTE, screenImage);
  
In the call to glDrawPixels using the dynamic array, I have tried dereferencing (***screenImage) and casting (const GLvoid*). Neither fixed the problem. Go [edited by - orikal on May 25, 2004 11:51:24 AM]

Share this post


Link to post
Share on other sites
Advertisement
use:
GLubyte * screenImage = new [screenImageHeight*screenImageWidth*3];

passing in GLubyte *** doesnt make much sence. The function wants a "pointer to the pixel data" not a pointer to a bunch of pointers that point to a bunch of pointers to GLubytes :D

also

GLubyte screenImage[screenImageHeight][screenImageWidth][3] is not the same as GLubyte ***screenImage (the first one statically creates one big block of memory)

Share this post


Link to post
Share on other sites
Okay, I suspected I would have to use a single dimension dynamic array. Could you clarify the accesses for me?

Right now I'm using:


y = screenImageHeight;
x = screenImageWidth;
GLubyte* screenImage = new GLubyte[x*y*3];

screenImage[sImgCY + sImgCX*y + y*x*1] = (GLubyte)intens;

where the equivalent 3D array access would be

screenImage[sImgCY][sImgCX][1]

At least that's what it was when I was using a static array. The truth is I have no idea how the dynamic array is stored. For all I know, it could be organized like [sImgCX][1][sImgCY].


[edited by - orikal on May 25, 2004 1:16:39 PM]

Share this post


Link to post
Share on other sites
unsigned int index = 0; //pixelindex

GLubyte* pixel = screenImage[ (x + y*sImgCX) * index*3 ];
pixel++ = r;
pixel++ = g;
pixel++ = b;


I'm not sure about the ++increments, but you get the point. I hope.

--
You're Welcome,
Rick Wong
- Google | Google for GameDev.net | GameDev.net's DirectX FAQ. (not as cool as the Graphics and Theory FAQ)


[edited by - Pipo DeClown on May 26, 2004 12:57:07 PM]

Share this post


Link to post
Share on other sites

  • Advertisement