PDA

View Full Version : Rendering an image



slungu
03-04-2009, 02:56 AM
Hello everybody,

I am trying to render a image that I read from the disk. The image is ok, and it renders, but if renders differently under Windows and Linux. The Linux version is ok, that is, the image is scaled to fit the window, but under Windows, only the upper left corner is rendered with a strange scale. Now, there is one code part :

void myGlutDisplay(void){
GLboolean pos_ok;
GLenum format;
GLenum type;

int tx, ty, tw, th;
float scale;

GLUI_Master.get_viewport_area( &tx, &ty, &tw, &th );


glClearColor( .9f, .9f, .9f, 1.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(left,right,top,down,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glPixelStorei(GL_UNPACK_ROW_LENGTH,0);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);

switch(samplesPerPixel){
case 1:
format = GL_LUMINANCE;
break;
case 3:
format = GL_RGB;
break;
}

glRasterPos2i(left,down);

scale = (float)tw / (float)imageWidth;
glPixelZoom(scale ,-scale);

glDrawPixels(imageWidth,imageHeight,format,GL_UNSI GNED_BYTE ,imageData);

glutSwapBuffers();
}

where imageWidth is the width of the image and the margins with top,down,left,right have been computed somewhere else ( when loading the image ). Does anybody have an idea why this is working under one environment and not under the other ?

Thanks,
Stefan

slungu
03-20-2009, 09:18 AM
Well, after some testing around and skipping the loading image part, it looks like under Windows I get a strange behavior if my imageData for glDrawPixels is exceeding about 2000x2000 pixels ( in this case, 2000x2000 displayed normal, but 2000x2500 or 3000x3000 displayed abnormal ). Of course, the scale becomes smaller and smaller. Anybody experienced this ? Some workaround ?

regards, Stefan