chisum
01-12-2006, 12:15 AM
Hello,
now I give up to search an infinite room (the internet) to match a tiny little problem that steels my sleep at the moment. So.
What I want:
Reading Pixels out of a rectangular subregion of the window. Then I shift this region by doing some kind of translation. So far everything is working. I've seen the results on the command line per printf().
Then I want the shifted Pixels to be drawn anywhere on the screen. Depending on glRaster (I know)
What I have:
- I can move an image on the window, if it's passing the region I'm reading with glReadPixels, the values stored in my pixel Array pixels, are changing. So I get proper pixel-values per glReadPixels().
- Proper shift-values.
- glDrawPixels() fills the rectangle with only one color for each pixel, but the values in my pixel array are different/varying.
My code:
float pixels[120*120*4]; //stores rgba values for the subregion 120*120 pixels
int PIXEL_RES=120;
static void readPixels(){
glReadBuffer(GL_FRONT); glReadPixels(0,0,PIXEL_RES,PIXEL_RES,GL_RGBA,GL_FL OAT,pixels);
printPixels();
}
static void printPixels(){
int i=0;
while(i<PIXEL_RES*PIXEL_RES*4){
printf("(%i)=(%.4f,%.4f,%.4f)\n",i,pixels[i],pixels[i+1],pixels[i+2],pixels[i+3]);
i +=4;
}
}
static void drawPixels(){
glDrawBuffer(GL_BACK);
glRasterPos2i(0,0);
glDrawPixels(PIXEL_RES,PIXEL_RES,GL_RGBA,GL_FLOAT, pixels);
}So if anyone has got an idea why drawPixels is not working properly, answer and get me to sleep again :eek:
Thank you.
now I give up to search an infinite room (the internet) to match a tiny little problem that steels my sleep at the moment. So.
What I want:
Reading Pixels out of a rectangular subregion of the window. Then I shift this region by doing some kind of translation. So far everything is working. I've seen the results on the command line per printf().
Then I want the shifted Pixels to be drawn anywhere on the screen. Depending on glRaster (I know)
What I have:
- I can move an image on the window, if it's passing the region I'm reading with glReadPixels, the values stored in my pixel Array pixels, are changing. So I get proper pixel-values per glReadPixels().
- Proper shift-values.
- glDrawPixels() fills the rectangle with only one color for each pixel, but the values in my pixel array are different/varying.
My code:
float pixels[120*120*4]; //stores rgba values for the subregion 120*120 pixels
int PIXEL_RES=120;
static void readPixels(){
glReadBuffer(GL_FRONT); glReadPixels(0,0,PIXEL_RES,PIXEL_RES,GL_RGBA,GL_FL OAT,pixels);
printPixels();
}
static void printPixels(){
int i=0;
while(i<PIXEL_RES*PIXEL_RES*4){
printf("(%i)=(%.4f,%.4f,%.4f)\n",i,pixels[i],pixels[i+1],pixels[i+2],pixels[i+3]);
i +=4;
}
}
static void drawPixels(){
glDrawBuffer(GL_BACK);
glRasterPos2i(0,0);
glDrawPixels(PIXEL_RES,PIXEL_RES,GL_RGBA,GL_FLOAT, pixels);
}So if anyone has got an idea why drawPixels is not working properly, answer and get me to sleep again :eek:
Thank you.