View Full Version : MFC & OpenGL
02-14-2000, 01:44 PM
okay, first and foremost, i'm learning how
to program with MFC withOUT using AppWizard.
i'm doing this because i want to do it by
myself before i use this tool.
the reason why i'm stating this ahead of time
is because every time i've posted to other
forums, i kept getting yelled at about this
and my question was never answered.
okay, i created a FrameWnd, and i want
to set up opengl on this, right?
well, ChoosePixelFormat fails when i do this.
so, i asked someone, and he explained
that a FrameWnd just holds a View, so
i create a View and i looked at it,
and there's no way to "attach" it to the
framewnd, so that obviously wouldn't work.
well, i read more about them, and
apparently, you need to use a document, right?
am i completely wrong?
or close but not close enough?
i really love the way MFC is structured,
because it just looks soo nice, and i'd
really like to use it, but if it's THIS
much trouble, then i'll just stick to
Mike The Spike
02-14-2000, 03:33 PM
"Normal" C? lol!
Never met a "Normal" C language before, only "Abnormal" C! http://www.opengl.org/discussion_boards/ubb/smile.gif
What you should do is start coding with the Win32 API using C instead of that lame MicroCrap MFC using C++!
MFC isn't at all certified to create high-speed 3D applications with, especialy with a 3D API (OpenGL) that's written in a different programming language then the one MFC requires.
If you mean drawing GL stuff onto a FrameWnd with "set up opengl", then get a Device Context handle to the FrameWnd, at output you're data there!
Setting the Pixel Format should work then...
Mike The Spike
PS. Forget Documents and views! Ever seen "Document Quake"? lol!
[This message has been edited by Mike The Spike (edited 02-14-2000).]
02-14-2000, 07:07 PM
i program with C++, but i mean like...
yeah, that's what i originally thought.
you create a framewnd, and then get the DC
to that, and Setup the pel format, etc...
i'm doing this on the OnCreate function (or method, whatever) of the framewnd.
but, for some reason, it won't let me Set the format. i'm guessing maybe i should just
do a stupid little "hack" and set it on the
initial WM_PAINT of the window to do all of
the gl settings in there. but i want to do
this the "proper" way.
it's really annoying, but i just want to get
it right, even if i'm not going to end up
using MFC with OpenGL.
thanx for replying rather then screaming at
me saying i should stay completely away MFC
and not answering my question like every
other person that i've asked.
I am the one who told you that you had to create a view inside your Frame window.
As I thought you were familiar with MFC, I didn't specify that a view is linked to a document (you guessed right !).
Basically, for each of your application using MFC, you should have a CDocument-derived class and a CView-derived class.
You connect them to the CFrameWnd using AddDocTemplate in the InitInstance of your application...
I know this is not a full answer to your question but : if you are to use MFC WITHOUT AppWizard, you should at least create dummy programs with it to look at what it creates... Then you can understand it and reproduce it....
I know it sounds stupid to tell you that (look and copy) but, in the end, if you are to use MFC, whatever you do, your code will look like what the AppWizard produces........
If you need more things about MFC / OpenGL, contact me on my e-mail.
P.S. : I have been developping "professional" apps for my company using MFC/OpenGL since one year now and I can not see any problem with that (hey Mike ! http://www.opengl.org/discussion_boards/ubb/smile.gif)
Mike The Spike
02-15-2000, 11:30 AM
LoL! Anonymous,why would someone scream? lol http://www.opengl.org/discussion_boards/ubb/smile.gif
And Eric, I was just thinking about something 3D Realms and ID said about the use of MFC and OpenGL, I guess MFC isn't so bad if you've got some sort of OpenGL Class created or something. Anonymous,what you should do is
use the OnPaint() event from MFC,because as it looks like it from here,you're FrameWnd doesn't have a Device Context yet when the OnCreate() event is fired. Allthough I don't know anything about MFC,here's what I think you should do.
/* Create you're FrameWnd object */
BOOL firstTime = TRUE; /* Are we starting?*/
HDC FrameWndDC = NULL; /* myView's DC! */
void myView::OnPaint(HDC itsDC)
FrameWndDC = itsDC;
/* Do one-time OpenGL stuff */
firstTime = FALSE; /* Don't do it again */
Now you've got it's DC!
Place the OpenGL code anywhere between the if()'s braces, and it will be executed the first time the FrameWnd is drawn!
Offcourse,I don't know what parameters come with the OnPaint() event, I presume it sends you the HDC of the window needing to be drawn. I stored the FrameWnd's HDC so it can be used by calls out of scope asswell.
Tell me if it works.
Mike The Spike
MFC and OpenGL, what a pain in the butt. I had the most trouble with PICKING in MFC.
I thought I would recommend the book "OpenGL Programming for Win95 and NT" I think that is what it is called. It is the famous 'Red book' but the cover is white and it is written with MFC in mind. Although it tells you to use the appwizzard, it also tells you what to change in what functions created by the appwizzard as well as what functions to add. From this you should be able to do it from scratch. It turned out to be a pretty handy reference.
(PS If YOU guys happen to master picking in MFC let me know.)
Hi Mike !
If you have problems with Picking using MFC, do not hesitate to contact me on my e-mail.
I am not a master but I have implements two techniques (GL_SELECT and back-buffer trick) and it works fine on all machines in my company....
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.