May 12, 2008

Opengl And Mfc Dialog Based Application - some comments about using it together

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > C/C++ Programming

free web hosting

Opengl And Mfc Dialog Based Application - some comments about using it together

Keeper
AS you probably know you can create a simple OpenGL applications using WinAPI functionality only (you can create it using Microsoft Visual Studio), but if you are making somethink with real windows interface and want to create application with multiple windows/dialogs/buttons with Windows Styles etc... you can use MFC (Microsoft Foundation Classes) to do it ...
But i did a 2 hours web search to find example of using OpenGL windows inside MFC created Dialog window.

I found it and want to share my results now.

My application is a simple OpenGL based tool, which shows OpenGL viewport on the Window. In the OpenGL viewport showed plane with reflection of sphere which rotates over it. My project uses 2 textures.

You can download it here :
Source files: http://mechwarrior.nm.ru/files/opengl.rar

P.S. This application were created using Andre Stein's "An VC++ example that shows you how to use OpenGL n a Mfc Dialog."
Internet: http://www.steinsoft.net

By the way i want to ask the question about OpenGL performance...
My application takes 60% of CPU time ... Anybody knows where is problem and how to optimise it?

____________________________________________
Keeper, Sons of the Dragon http://mercenaries.net.ru

 

 

 


Reply

osknockout
I would love to take a look at it, but according to your http://mechwarrior.nm.ru/files/ directory, it does not exist on the server.

By the way, why would you want to use MFC with OpenGL anyway? Take a look at the majority of high-quality games out there, most of them don't even touch MFC.
QUOTE
By the way i want to ask the question about OpenGL performance...
My application takes 60% of CPU time ... Anybody knows where is problem and how to optimise it?
You are using MFC aren't you? laugh.gif Sorry, but that's usually it.

OpenGL performs at the same rate your program (and you) understand video card and CPU interactions, it's all software based stuff. Like all other programs, OpenGL apps have the same limits (except the video card and CPU, of course).

 

 

 


Reply

Keeper
Oops i put wrong link to the source code....

Here is right one: http://mechwarrior.nm.ru/opengl.rar
It was only practical work at the univercity, but i'm interested why the hell it takes so many resources??? It's not great game to count lots of polygons... blink.gif

Anyway take a look and answer me what will be ur CPU time % given to my program...

Best reguards...

____________________________________________
Keeper, Sons of the Dragon http://mercenaries.net.ru

Reply

dexter
Strange, that -should- work out of the box, no?

Anyway, I had to add glaux.lib to the linker's list of libs to include. It uses 99% CPU time. Though, I assume it's just using whatever it can get it's hands onto, if I did a lot of other things, it'd prolly drop down, with no performance loss.

And with optimization, as long as you're using MFC, it ain't going to happen. Use pure API calls instead for more power. All I'd say MFC is good for is general apps, and even then I'd still rather not touch them.

You'd think that since they're wrapper classes for the Win32 APIs, they'd be easier to use, too... tongue.gif

Reply

osknockout
To think that I could port the code to Dev-C++ unscathed... well, I tried (I don't have VC++) but it failed, so I couldn't play around with the exe. Can any of you compile this without it?

Reply

dexter
I just tried too, and failed. Although, that's because I'm missing all the MFC libs. As I understand it, the only way for you to be able to use MFC would be to build custom libs for MingW, and since no-one has access to source, it's most likely not going to happen.

Reply

Trap FeedBacker
Iam new to vc++ .While following books and starting for doing programsin 2 ways.
First when choosing an MFCAppWizard(exe) and compiling filename.Cpp and build filename.Exe it always gives a error like

--------------------Configuration: hello - Win32 Debug--------------------
Compiling resources...
D:\MSDev98\hello\hello.Rc(11) : fatal error RC1015: cannot open include file 'afxres.H'.
Error executing rc.Exe.

Hello.Exe - 1 error(s), 0 warning(s)

Second,Here I choose Win32 Console application
--------------------Configuration: hello1 - Win32 Debug--------------------
Compiling...
Error spawning cl.Exe

Hello1.Exe - 1 error(s), 0 warning(s)

In both ways the see++ source I wrote is

#include <iostream.H>
Void main()
{
cout<<"Hello...";
}


Please anybody help me?


-Radhiya

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. example opengl dialog c - 1.84 hr back.
  2. example opengl dialog - 1.91 hr back.
  3. create listbox opengl - 3.65 hr back.
  4. how to add progress bar in dialog win32 - 20.70 hr back.
  5. opengl viewport win32 - 31.46 hr back.
  6. opengl dialog box mfc - 38.88 hr back.
  7. remove mfc dialog error - 42.16 hr back.
Similar Topics

Keywords : opengl, mfc, dialog, based, application, comments

  1. Opengl
    (2)
  2. Detailed C Beginner Tut
    basis for learning any application programming language (2)
    QUOTE The best way to learn programming is to dive right in and start writing real programs.
    This way, concepts which would otherwise seem abstract make sense, and the positive feedback you get
    from getting even a small program to work gives you a great incentive to improve it or write the
    next one. Diving in with ``real'' programs right away has another advantage, if
    only pragmatic: if you're using a conventional compiler, you can't run a fragment of a
    program and see what it does; nothing will run until you have a complete (if tiny or trivi....
  3. Opengl
    how to... (1)
    How can enable OpenGL in my C++? I mean the Borland C++, not Visual C++. What do I need other than
    glut.h that I've found, and how to use it? Thanks in advance.....
  4. Win32: Dialog Box And Accelerator
    Win32 API programming (0)
    ok my problem is how do i make or assign a keyboard accelerator with modal dialog boxes since the
    message loop is inside the function call of DailogBox() functions, unlike the modeless dialog box in
    which you are the one who will create the message loop for the dialog box... is it even possible?....
  5. Opengl Pointer To Array
    Value Pointed..? (1)
    I'm playing around wtih openGL and trying to get the hang of c/c++(very frustrating at times). I
    pass a pointer to an array from an object to my main via a get method. If I print out(cout) the
    pointer(p) and the value pointed to (*p) from main, *p prints the decimal equivilent of the memory
    address p, not the value that p should be pointing to. Within the object, everything is peachy, its
    just when I pass the pointer to to main that this happens. The arrays plist and vlist in
    meshloader are the ones im having trouble with. Any ideas? Thanks in advance. Feel free t....
  6. Best 'c' Based Language?
    (4)
    Hi, I have been doing C and a bit of C++ for a while now, however I am unsure where to go next or
    what to concenrate on. People have told me about Visual C#, however I am not too sure how much like
    C/C++ it is. I have also been told about Visual C++ but I always thought it was a Microsoft C++ IDE.
    Could someone please explain the differences in all of the C variants (ojective C ), and if
    possible what each ones pros and cons are. I am mainly looking into optimised windows applications.
    Thanks for all of your help. ....
  7. Program Flow
    dialog problem (2)
    Hi, i have a quick question. I have a program that does alot of calculations near its completion.
    To indicate to the user that it is still working so they dont close it I have a dialog box with a
    progress bar pop up. when the dialog comes up, the regular execution of the original program stops
    until I close the dialog, so I was wondering if there is a way to tell the origianl program to keep
    running while the dialog is open(since the original program would be updating the progress metre).
    p.s. using MFC(not by choice) Thanks alot!....
  8. Mfc Dialog Trouble
    involving listboxes (3)
    hi, im trying to add stuff to a listbox in a dialog called by my CDocument class ie. CODE
    CMyDocument::DoSomeStuff() { CMyDialog dlg;
    dlg.listbox.addString("whatever"); ******** dlg.listbox.doModal(); }
    do i need to add something at the ******* to refresh my listbox because at the moment it is
    appearing downright empty. i created it by making a dialog in the resource editor of vc++ .NET 2003
    and then using add class wizard, and add member wizard to make the listbox an accessable control.
    thanks for your time!....

    1. Looking for opengl, mfc, dialog, based, application, comments

Searching Video's for opengl, mfc, dialog, based, application, comments
advertisement



Opengl And Mfc Dialog Based Application - some comments about using it together



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE