LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   OpenGL exit problem - screen corruption (https://www.linuxquestions.org/questions/programming-9/opengl-exit-problem-screen-corruption-202028/)

deveraux83 07-07-2004 12:05 AM

OpenGL exit problem - screen corruption
 
Hi all, I'm currently doing some programming involving OpenGL in C++. My question is this, whenever I run the program at the same resolution as the desktop and in fullscreen the screen usually gets corrupted on program exit. The program exit is not abnormal hence I have no clues on which I can track down the problem. When I swap the screen (CTRL+ALT+F6) and swap back (ATL+F7) the screen returns to normal. And this ONLY happens when the program runs fullscreen at the same resolution as the desktop. Any ideas? Thanks!

The_Nerd 07-07-2004 12:22 PM

Corrupt? What do you mean? Please explain how it goes currupt a little better.

Maybe you are not properly shutting down what ever you are using to open the Window (glut, SDL, X11).

deveraux83 07-07-2004 10:57 PM

well, basically the whole screen gets "distorted" with the previous screen image. Everything gets "stretched" horizontally and stays that way. No movement whatsoever. However, when you move the mouse ard, the icon changes appropriately to what is on the desktop (ie. chgs to writing cursor in a text editor - stuff like that). That's basically the best way I can think of describing the corrupted screen.

motub 07-08-2004 03:30 AM

Now I don't know anything about programming, but just listening to that tale, the logical place to start troubleshooting would seem to be that something in your code is not completely restoring the desktop as it is supposed to. The mouse cursor is clearly released (since it does properly respond to desktop icons and the like), but something like Xrandr (as a random example of items that might affect this-- as I said, I don't know anything about it) isn't.

The next thing I notice is that you say this only happens when your program is running at "the same resolution as the desktop". This would seem to imply "conscious" behaviour (that the program knows that it, as well as the desktop, are running at 1280x1024, for example), but what if it was a fluke? Is it possible that your program is not accurately recording the original dimensions of the desktop, and the only one who knows that they are both running at "the same resolution" is in fact you? If you change your desktop to run at 640x480 (rather than whatever you run the desktop in normally) or 800x600, and then run the program at the same resolution as the desktop, does the problem still occur? If not, then at least you know it's a problem with the particular resolution rather than the program as a whole. Plus, are you running at a "non-standard" resolution (like on a laptop display, for instance)? That could conceivably also be a problem.

Lastly, I would suggest that you try to look at the code for an Open Source, full-screen, OpenGL game that does restore the desktop properly, and see how it does it. That might help you identify what you're doing (or not doing) properly.

Just some ideas from a non-coder; hope they're helpful in some way.

The_Nerd 07-08-2004 01:23 PM

What library are you using? SDL? If SDL (and maybe other libraries), then if you have your resolution set to 650x470, SDL will actually set the video mode to 800x600 and make a little window centered inside the screen that is 650x470. If this is the case then you could have acidentally have your resolution off by one and you could actually have a different video mode then your desktop. Your problem is that you are not restoring the video mode properly. To help I will need to know HOW you are setting the video mode in the first place. I still might not be able to help though. So you should probably look up the video mode functions for what ever library you are using.

You could actually even have set the same video mode as your desktop and get this anommily if you don't restore the proper video mode.

Basicly, it's bad not to restore the video mode to what it previously was.

deveraux83 07-08-2004 08:02 PM

First off, it ONLY happens when desktop resolution = fullscreen resolution. I have tested this theory at both 1280x1024 and 1024x768. Secondly, to answer The_Nerd, I am not using SDL, was thinking of but I kept on getting the problem where it seems that I get no video acceleration and when memory is initialised, it says that I am using system RAM, not video RAM hence I stopped using it for a while until I figure out the problem. The window is being set up by glX in gnome 2.6 (if that helps) but I also noticed the same problem in gnome 2.4 (haven't tried it on any other versions of gnome yet). The code is obtained from NeHe's tutorials ported to linux in glX form. I usually run my desktop @ 1280x1024 and the program @ 1024x768 but since I'm not at uni right now (where I left my monitor), I'm using my home monitor which can run only 1024x768 with > 60 Hz refresh rates.

Also, I made my code in such a way that if ever any resize occurs, it will display to the screen the new resolution (even if set my OS) and as far as I can tell, no such resizes have occured.

The_Nerd 07-10-2004 12:59 AM

Look up glX video mode functions on google and I am sure you will find what you need.


All times are GMT -5. The time now is 09:55 PM.