|
From what I can see, you can still use MFC in an OpenGL app.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Of course you can. My first MFC project was a CAD application with a heavy use of OpenGL.
I vote pro drink
|
|
|
|
|
Because if you're doing an OpenGL app, it's likely you don't *need* MFC for anything, and not using MFC gets you closer to the main message loop for rendering etc, plus while I think the effect MFC has on speed is overrated, I still think it's probably there and to be avoided when you're not going to do any real GUI anyhow.
Also, for me personally GL was a good excuse to learn Win32, which I always recommend.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I should probably reiterate the main reason for me. While there is no doubt you most certainly *can* do OpenGL in an MFC app, I recall that doing a Direct Draw game using MFC became a major pain when I started trying to get it to render in idle time, although as I recall that was actually because I started with a dialog based app and it was through this project I learned about WM_KICKIDLE.
Nevertheless, the main reason for me is the nehe tutorials, because they are an excellent source of info, and they do not use MFC, nor do any of the major OpenGL books. Therefore it's simply a case of conforming to the way information is being presented.
I guess also my bias is starting to lean towards only using MFC when I need it, based on the amount of time I'm spending without it. But I did not mean to imply you COULDN'T do it with MFC, only that there are reasons I personally wouldn't.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I would rather not use MFC but my project requires that I do. Anyway I am not sure if the OnSize will work, but I'll try. Also I am not drawing outside the box, it is that the picture leaks outside the box.
|
|
|
|
|
I would rather not use MFC but my project requires that I do. Anyway I am not sure if the OnSize will work, but I'll try. Also I am not drawing outside the box, it is that the picture leaks outside the box.
|
|
|
|
|
1. Make sure your window is created with CS_OWNDC
2. Make sure you've select a double buffered rendering mode
3. You can optionally stop rendering while the user drags the window. This is usually desirable anyways. If you want to drag with the image then consider buffering the image yourself with glcopypixels or something similar. Then do a blit while you drag instead of a render. That works well for CAD style apps where rendering may not be real-time.
I've seen the rendering bleed outside the window. I forget the specifics as to why it happends but it doesn't always happen with all video cards.
Todd Smith
|
|
|
|
|
Todd what do you mean by your number 3.
3. You can optionally stop rendering while the user drags the window. This is usually desirable anyways. If you want to drag with the image then consider buffering the image yourself with glcopypixels or something similar. Then do a blit while you drag instead of a render. That works well for CAD style apps where rendering may not be real-time.
I am not understanding it.
|
|
|
|
|
Hi,
I am writing an MFC application which has a menu called IDR_MAINFRAME. Now in the menu I have a menu item File>Listen (ID_FILE_LISTEN).
I want the message handler for this menu item in the view class of my application (CUDPView). So I used the Class Wizard to add the message handler, and it created the following function in the CUDPView.cpp file:
void CUDPView::OnFileListen()
{
// TODO: Add your command handler code here
AfxMessageBox("Ok Code Reachable"); // added by me
}
I added the AfxMessageBox line in the code to see if this function was indeed called when I clicked File>Listen, but it was not called!
Tell me please, what's wrong?
Mike
|
|
|
|
|
|
No I dont have any message hanlders anywhere else. Is that necessary? If yes then tell me what I should do?
|
|
|
|
|
No, it's not necessary, but other handlers may be invoked first.
Did you override OnCmdMsg in any class?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Nope! I did on override OnCmdMsg anywhere....I haven't over ridden any functions!
|
|
|
|
|
|
Well I know, it is all my fault. I haven't really understood how to add a message handler for a menu bar item. I just created an empty MFC project and then added a new menu item (ID_FILE_SOMEITEM).
Then through the Class Wizard on Mesage Maps tab I chose the view class CMyAppView and chose ID_FILE_SOMEITEM in ObjectIDs and then clicked on Command in Messages and clicked the Add Function button.
The class wizard created the function OnFileListen.
I added the same AfxMessageBox("Code Reachable"); line inside the function and when I built the project.....I was expecting it to give me a message box alert on clicking File>SomeItem
But Nothing Happens. Evidently I am making a pretty basic mistake in creation of message handlers.
Tell me what to correct.
|
|
|
|
|
I think you've performed the necessary steps. Is the menu item enabled or it remains grayed?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Ofcourse it is enabled!!!!
|
|
|
|
|
Go into the class wizard for the view class, click on the ID_FILELISTEN item and then tell me if COMMAND or UPDATE_COMMAND_UI is in bold ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Yes COMMAND is in bold...with the Member function
OnFileListen (ON_ID_FILE_LISTEN:COMMAND)
|
|
|
|
|
Then there is no reason in the world for it not to work. Have you done any manual editing to the files in the command handler area EVER ? Because if you have, it's possible you've confused the Class Wizard. What references to ID_FILE_LISTEN are there in the .h and .cpp file ?
Oh, it's generally good not to ask the same question over and over, especially when two people are already helping you.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I am sorry, but this is really annoying. Apparently I've done everything right.
I had to implement it in a real project, but since it was creating complications, I tried this on an empty (new) project.
I just created a new project, added an item to the menu bar, then used the Class wizard to create a message handling function. Inside the function that the Class wizard created, I just added one line
AfxMessageBox("Code Reachable");
That's it!
But it just does not seem to work!
|
|
|
|
|
I understand what you've done, I want to know if you search all files for the ID_FILE_LISTEN, what comes up. You should have al ine like this in the header:
afx_msg void OnFileListen();
and in your .cpp file
BEGIN_MESSAGE_MAP(CMyView, CView)
ON_COMMAND(ID_FILE_LISTEN, OnFileListen)
END_MESSAGE_MAP()
These are what links the message to the command, are they there ?
As to being frustrated, I can appreciate that, but I'm right here trying to help, and Tomasz also seems to be online, so there is no reason to keep asking while you wait for our replies, it only clogs up the forum with the same question over and over. If I ask a question and don't get an answer, I usually wait at least a day to ask again.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Ok I searched all the files for ID_FILE_LISTEN
Here is what I got
Searching for 'ID_FILE_LISTEN'...
C:\Sockets Programming\111\111.rc(82): MENUITEM "Listen Port", ID_FILE_LISTEN
C:\Sockets Programming\111\111View.cpp(23): ON_COMMAND(ID_FILE_LISTEN, OnFileListen)
C:\Sockets Programming\111\resource.h(5):#define ID_FILE_LISTEN 0
3 occurrence(s) have been found.
Then I searched all the files for OnFileListen and here is what I got
Searching for 'OnFileListen'...
C:\Sockets Programming\111\111View.cpp(23): ON_COMMAND(ID_FILE_LISTEN, OnFileListen)
C:\Sockets Programming\111\111View.cpp(105):void CMy111View::OnFileListen()
C:\Sockets Programming\111\111View.h(51): afx_msg void OnFileListen();
3 occurrence(s) have been found.
|
|
|
|
|
I think I may have it. Is your app an MDI application ? Because if it is, you need to click File:New in order to have an instance of your view class to execute.
Have you tried putting a breakpoint in your message handler and tracing to see if it somehow gets there but fails to show a dialog ?
Apart from that, I'd be overriding WM_COMMAND and doing something like this
if (LOWORD(wParam)== ID_FILE_LISTEN)
{
AfxMessageBox("You clicked ID_FILE_LISTEN");
}
I'd also try adding the handler to the CMainFrame class, or adding them for other handlers not in the ID_FILE_ domain, just to try and narrow down where it's going wrong.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I think I know the problem.
Change the menu ID to something nonzero (in C:\Sockets Programming\111\resource.h(5))
#define ID_FILE_LISTEN 32771
Hope this helps.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|