OpenGL in a MFC DLL

anyone know any good sites that outline using OpenGL in a MFC DLL? I’m making a plug-in DLL using MFC, and would like to use OpenGL. thanks in advance!

jebus

Hi !

There is nothing special too it. If you have a CView in the dll that you want to render to, you have to setup that correct, but that’s an MFC problem, for OpenGL you don’t need to do anything special.

Mikael

thanks for the reply! now, when i created my MFC DLL project (called GLRender) the only MFC class the wizard created was CGLRenderApp, declared as a public child of CWinApp. would i need to add my own view class, based off of CView? (class CGLRenderView : public CView) this seems right to me. from there, i guess i could set up the pixel format and rendering context in my view class.

jebus

my DLL project does not have a CView class. only the CGLRenderApp class. any suggestions?

jebus

I’m not sure if you want to use a CView class. Views are used in Document/View architecture as either SDI (single document interface) or MDI (multiple document interface). If you are going to use a view then you will probably also want a document (CDocument class). If I remember correctly, views must be registered with the document. Typically the document contains the data and the view(s) draw the screen. And you can have multiple views (using same data to do different things) attached to the same document. Really, it depends on what your are trying to do.

Otherwise, just use a CWnd or CFrameWnd derived class.

And, yes, whatever you decide on you will have to add it into your project.

When you create a project, xxxCtrl class must be generated.
Use that class, so you can override the methods like OnDraw, OnEraseBkgnd.

must i create this xxxCtrl class myself, using Class Wizard? the project i create is MFC AppWizard (dll). this brings up a dialog window asking to create 1 of three DLLs: regular with static MFC, regular with shared MFC, and MFC extension. the extension just makes an ampty DLLMain for you, while the other 2 make a class inherited from CWinApp. should i add a class derived off of CWnd/CFrameWnd and have an instance of this class in my CWinApp class? (i’m terribly sorry for the way this thread has deviated into MFC 101, but…oh well)

jebus

Hi !

There is a Qxxxxx something on MSDN about how to put a view class inside a dll, but I don’t rember where it is, you have search for it.

Mikael

If you use “MFC ActiveX wizard”, xxCtrl class will be automatically generated.

I am not sure if you can create a OpenGL view from a simple dll.

You can define a CWnd class, the GL function must work with the hDC of this Wnd.

Last, you will create a CWnd instance being child of your ATL Wnd object.

Originally posted by Ryo:
[b]If you use “MFC ActiveX wizard”, xxCtrl class will be automatically generated.

I am not sure if you can create a OpenGL view from a simple dll.

[/b]