Problem with images!

Hi! I had posted a message before about displayin the images well I got it sorted but still I wanted to ask one question. I read in two different images and draw them using in different buffers but I dont think so it is displaying both the images. Please can anyone suggest what the problem is and how can I do go about it.

Many thanks
pran

I have not tried out your program but I did look at it.

I think the reason it never would draw is due to a problem in the ‘if’ logic of drawing the bitmaps. I could not see where you make the logic “TRUE” in order to draw the image.

I do not understand what you mean on this question?

Ok my question is :

  1. I am trying to display two images on the screen simultaneously well like stereo images.

But the problem is glutMainLoop() function is not mutli threaded so it just displays one image and not the second one!!!. Is it possible to display both the images at one time ? . And thanks for looking at the code it is wrong I know I am trying to fix. It just displays one image and not the second. How can I get it to display both the images ??

Thanks
pran

I also should point out a few other errors:

glutMainLoop, never exits so anything after it is never called. You need to move any file, memory clean up to the exit routine.

To swap the images, you can use a glutTimerFunc.

glutTimerFunc(100(time in milli-seconds), swap_images, (int)0);

void swap_image(int te)
{
if (image_swap)
{
image_swap = 0; // change image
}else image_swap = 1;

glutPostRedisplay();
glutTimerFunc(100(time in milli-seconds), swap_images, (int)0); // Restart the timer
}

By adjusting the time, you can change the rate in which it flips between images.

Originally posted by pran1:
[b]Ok my question is :

  1. I am trying to display two images on the screen simultaneously well like stereo images.

But the problem is glutMainLoop() function is not mutli threaded so it just displays one image and not the second one!!!. Is it possible to display both the images at one time ? . And thanks for looking at the code it is wrong I know I am trying to fix. It just displays one image and not the second. How can I get it to display both the images ??

Thanks
pran[/b]

[This message has been edited by nexusone (edited 03-09-2004).]

Hey I have done what you told me to do. But still its not working I am posting the program please van you highlight where I am going wrong.

Many thanks
pran

[This message has been edited by pran1 (edited 03-12-2004).]

Ugh, lots of problems.

1.)
BitmapBits1 = LoadDIBitmap(“earth.bmp”, &BitmapInfo2);
free(BitmapInfo1);
free(BitmapBits1);
BitmapBits2 = LoadDIBitmap(“pic.bmp”, &BitmapInfo1);
free(BitmapInfo2);
free(BitmapBits2);

This looks wrong, check the free() parameters.

2.) You’re requesting a stereo pixelformat. Do you have an OpenGL quadbuffered stereo capable graphics board? (Mostly a workstation board) if not, you’re stuck here.

3.) Check what glGetBooleanv(GL_STEREO, &b) says.

4.) The drawing routine draws only one image?

And the draw buffer settings should be different. You set GL_BACK for the clear which is basically ok, though not for depth buffered rendering in case you want that in the future.
You must draw different images into GL_BACK_LEFT and GL_BACK_RIGHT to get a stereo effect.

You should do this:
glDrawBuffer(GL_BACK_LEFT)
glClear(GL_COLOR_BUFFER_BIT);
// Watch out, for depth buffered drawing there is only one depth buffer, you need to clear it for each eye!
…// Draw your image for the left eye here

glDrawBuffer(GL_BACK_LEFT);
glClear(GL_COLOR_BUFFER_BIT);
…// Draw your image for the right eye here.

[This message has been edited by Relic (edited 03-10-2004).]

well I have got quad buffering in my graphic card as I have enabled it and have modified the draw code to :

[This message has been edited by pran1 (edited 03-12-2004).]

Hey guys Well I managed to get the code work its displaying both the images now thanks alot for your help. Just last question when I display the images the color information for both images is lost and for some wiered reason I am not able to resize the image. Any suggestions.

Thanks a ton

Pran

You should not free() the images if you still need them for display. This should avoid the crash, you seemed to have figured that out.
Does GLUT offer a clean exit function? Use that to delete your resources.
OpenGL is a state machine, no need to set the ClearColor more than once at inint time.

No idea about the pixelzoom, it sucks anyway. Make sure you have nice values there.
It would be much faster and nicer to put the images onto two texture objects and use textured quads to display them with linear or better filtering.

[This message has been edited by Relic (edited 03-10-2004).]

What are you doing to scale the image now?

Another option is make you images into textures, then map them to a quad. Resize now can be done, by changing the size of the quad.

As for clearing memory, as I suggested do it on exit.

keyboard(…)
{

if(key==‘ESC’)
{
//clear memory here then exit
free(…)
etc…
exit(0);
}

Originally posted by pran1:
[b]Hey guys Well I managed to get the code work its displaying both the images now thanks alot for your help. Just last question when I display the images the color information for both images is lost and for some wiered reason I am not able to resize the image. Any suggestions.

Thanks a ton

Pran[/b]

Hmm… thinking about the problem lets forget resizing for a while but what suprises me and trust me I have been trying hard and a question comes up … Is it possible to display the image on the screen with the actual size of the image using glutInitWindowSize() ??

Any pointer…

Thanks
pranay

p.s- Just wanted to tell you guys it resizes the images now if you free the memory after the ESC key has been pressed.

Thanks
pranay

If I try to do glutInitWindowSize(BitmapInfo1->bmiHeader.biWidth,
BitmapInfo1->bmiHeader.biHeight); it crached baldy.

Please help

Pran

[This message has been edited by pran1 (edited 03-11-2004).]

It is bad practice to set window size this way, what if the image is bigger then the screen?
Better first to get windows max size and then scale image to fix it, then resize by user if needed.

The routine it looking for a int value, what type of variable is your pointer?

Could try something like this to force conversion:
glutInitWindowSize( (int) BitmapInfo1->bmiHeader.biWidth, (int) BitmapInfo1->bmiHeader.biHeight);

Originally posted by pran1:
[b]If I try to do glutInitWindowSize(BitmapInfo1->bmiHeader.biWidth,
BitmapInfo1->bmiHeader.biHeight); it crached baldy.

Please help

Pran

[This message has been edited by pran1 (edited 03-11-2004).][/b]

[This message has been edited by nexusone (edited 03-11-2004).]

Thanks I tried your function and it works…

Thanks a ton
Pran