gegnal
04-05-2002, 10:51 AM
Hello,
I'm trying to make an application where the user can translate around an image. When the image moves upwards or rightwards, all is well. I simply adjust the raster position. Also, when the user translates leftwards, I adjust GL_UNPACK_SKIP_PIXELS, and it works well (although it redisplays the lefmost part of the image on the righthand side).
My problem is when the user wants to translate downwards. I try to adjust GL_UNPACK_SKIP_ROWS, and it crashes at the glDrawPixels call (I put printf's before and after).
Any ideas on where to start debugging?
I should mention that the image is contained within its own window, separately from another window displaying a 3d model.
I'll post my redisplay function below.
Thanks,
Geoff
void imageWindow::CallBackDisplayFunc(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (myImage.GetData()){
zoom = (zoom < 0.0) ? .1 : zoom;
glPixelZoom(zoom,zoom);
if (trans_XY[0] < 0.0){
int transx = (int)ceil(trans_XY[0]);
glPixelStorei(GL_UNPACK_SKIP_PIXELS,-transx);
trans_XY[0] = 0.0;
}else{
glPixelStorei(GL_UNPACK_SKIP_PIXELS,0);
}
int transy = (int)floor(trans_XY[1]);
if (trans_XY[1] < 0.0 ) {
glPixelStorei(GL_UNPACK_SKIP_ROWS,-transy);
trans_XY[1] = 0.0;
}else{
glPixelStorei(GL_UNPACK_SKIP_ROWS,0);
}
glRasterPos2f( trans_XY[0],trans_XY[1]);
glDrawPixels( myImage.GetWidth(), myImage.GetHeight(), GL_RGB,
GL_UNSIGNED_BYTE, myImage.GetData());
}
glutSwapBuffers();
}
I'm trying to make an application where the user can translate around an image. When the image moves upwards or rightwards, all is well. I simply adjust the raster position. Also, when the user translates leftwards, I adjust GL_UNPACK_SKIP_PIXELS, and it works well (although it redisplays the lefmost part of the image on the righthand side).
My problem is when the user wants to translate downwards. I try to adjust GL_UNPACK_SKIP_ROWS, and it crashes at the glDrawPixels call (I put printf's before and after).
Any ideas on where to start debugging?
I should mention that the image is contained within its own window, separately from another window displaying a 3d model.
I'll post my redisplay function below.
Thanks,
Geoff
void imageWindow::CallBackDisplayFunc(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (myImage.GetData()){
zoom = (zoom < 0.0) ? .1 : zoom;
glPixelZoom(zoom,zoom);
if (trans_XY[0] < 0.0){
int transx = (int)ceil(trans_XY[0]);
glPixelStorei(GL_UNPACK_SKIP_PIXELS,-transx);
trans_XY[0] = 0.0;
}else{
glPixelStorei(GL_UNPACK_SKIP_PIXELS,0);
}
int transy = (int)floor(trans_XY[1]);
if (trans_XY[1] < 0.0 ) {
glPixelStorei(GL_UNPACK_SKIP_ROWS,-transy);
trans_XY[1] = 0.0;
}else{
glPixelStorei(GL_UNPACK_SKIP_ROWS,0);
}
glRasterPos2f( trans_XY[0],trans_XY[1]);
glDrawPixels( myImage.GetWidth(), myImage.GetHeight(), GL_RGB,
GL_UNSIGNED_BYTE, myImage.GetData());
}
glutSwapBuffers();
}