Solved

Problem with my small window program with opengl graphic in it

Posted on 2001-06-19
5
215 Views
Last Modified: 2006-11-17
I wrote a windowing class in C++ to create windows.  I'm a newbie to C++ and Windows programming.  The
small program I wrote uses the windowing class to create a window and put an opengl cube in it.

My problem is this: Every once in a while, the program doesn't shutdown properly (remains in task list).
 This could be due to one of 2 things as far as I can tell:

1)  My code sucks
2)  I added the ability to toggle from fullscreen to windowed mode (and vice versa).  Using SetWindowLong,
I give the window a new style.  I'm thinking that maybe this changes the hWnd, so because I can't/don't
update the device context and rendering contexts, when it comes time to shutdown and I call like ReleaseDC(hWnd,
hDC), it might not work properly.

I've been posting this in a few OpenGL forum but they aren't much help.    

I've posted my source at:

http://members.home.net/l-reynolds/myCode.zip

I wrote the code using VC++ 6.

Any help and/or suggestions, code modifications(even unrelated to my current problem) or whatever can
be sent to l-reynolds@home.com as well as posted here.

Thanks in advance...
0
Comment
Question by:Sketchy
  • 3
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 300 total points
ID: 6209098
this solved the problem

case WM_KILLFOCUS:
{
     //WaitMessage();  // comment this one
     return(0);
}

try it out and tell me
0
 

Author Comment

by:Sketchy
ID: 6209124
What sucks is that its really hard to tell when the problem is there or not.  

I thought WaitMessage might be the problem, so I commented it out earlier, and I didn't get any crashes.  So I uncommented it to see if then I would get a crash, but I still didn't.  For the life of me I couldn't get it to crash.

One other thing I noticed is that if you are in windowed mode and you move the mouse onto the title bar, like back and forth over the icons in the top right, then after a while the cube will stutter in its motion (like it lagged or something), just one time.  I thought that was pretty weird.  It should maintain a fluid continuous rotation.    
0
 

Author Comment

by:Sketchy
ID: 6209128
oh BTW why do you think that the waitmessage is the problem?  Is it being called right before the destruction of the window or something?

But if that were the case, wouldn't it happen every time?

 
0
 

Author Comment

by:Sketchy
ID: 6209136
Ok I'm halfa$$ retarded.  The stuttering I mentioned happens because I have the cursor over the MINIMIZE button, and the little textbox is popping up and lagging it for a second.  It has nothing to do with my code problems...
0
 
LVL 22

Expert Comment

by:ambience
ID: 6212838
hmm .... wont your code get stuck at WaitMessage because it executes at KillFocus , the last killfocus(one due to window closing) would cause the app to wait for another message to come , which wouldn't come normaly .... however while debugging there is no such problem which i think is because of minimizing the app and bringing the debugger infront...

i maybe wrong , correct me if i am wrong ...
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question