View Full Version : OGL Framerate Limited by DirectX?

06-17-2002, 11:57 AM
WARNING! MS Visual C++ Inside ...

I have a problem that I just don't understand ... Poor framerates (actually a constant 50 FPS) when combining OpenGL with a DirectX 8.1 SDK class wizard generated application.

Here is what I see ... I create a new project by File->New->Projects->DirectX AppWizard->Single Document Window/DirectInput->Action Mapping ... I then remove all the GDI code, set up a rendering context, and render a few lines of text with OpenGL. I monitor the framerate and display it on one of the text lines.

It caps at 50 FPS ALWAYS ...

I have written my own DirectInput mouse/kbd/jstick claasses and used them fine with OpenGL and NeHe's framework and in a generic MFC SDI app generated w/the standard MFC app wizard. Doing so, I have reached framerates in excess of 1500 FPS with light graphics. Therefore, I know that the 50 FPS I am getting from the class wizard generated app is bogus. I just don't know why ...

Does anyone have a clue why this is happening? Could it be that the DirectX action mapping is somehow interfering with OpenGL?

I sure would like to use this technique because the action mapping functions are ooohhhh soooo kewl ....

Any help would be much appreciated ...


[This message has been edited by pleopard (edited 06-17-2002).]

06-17-2002, 12:26 PM
Where'd you get the DirectX Appwizard from? It doesn't come with VC++, and I didn't see it anywhere in the Dx 8.1 SDK either. Maybe that does something weird behind the scenes. Have you tried to setup the Action Mapping stuff manually? I can't say that I've ever really used it much myself.

06-17-2002, 12:41 PM
You can download the dx8 appwizard seperately from the microsoft website.

This isn't an opengl question. If you're relying on a wizard, and can't work out the code it generates, then you should get yourself a good book to learn c++.

06-17-2002, 02:17 PM
Deiussum you can find it in DXVCSDK\bin\DXUtils\AppWizard where 'DXVCSDK' is the installation directory you specified when using the SDK setup installer.

Knackered, I have been writing C++ hard core for over 12 years now and I don't need a book to introduce me to it. I suspect that the problem is due to some sort of interaction between DX and OpenGL hence this is an appropriate place to ask for help.

06-17-2002, 05:23 PM
If you're relying on a wizard, and can't work out the code it generates, then you should get yourself a good book to learn c++.

That makes sense. Never mind that it was a DirectX wizard that he's using. I suppose all C++ book go in-depth with DX these days. [/sarcasm]

In answer to your question, pleopard, I would suggest not using the DX appwizard if you want OpenGL code. I've seen an OpenGL appwizard somewhere, but I don't remember where. In any case, DirectX (the graphics part, anyway) and OpenGL don't get along very well, especially since they're both trying to gain access to the same rendering window.

06-17-2002, 06:00 PM
I was using the App wizard in an attempt to understand the utilization of the action mapping in DirectInput. No DirectSound, Direct3D, DirectWhatever is in use other than DirectInput. I dont normally care to use the app wizards as i have 10 or 12 templates of my own i use for various purposes....

The question(s) is(are) ...

Has anyone had any experience using the DirectInput action mapping with OpenGL?

Has anyone tried the app wizard and had similar results?

Has anyone found the problem and/or solution?

[This message has been edited by pleopard (edited 06-17-2002).]

06-17-2002, 11:16 PM
pleopard, no offense but...your question is basically -
"I've bastardised the code generated from an obscure downloadable direct3d wizard to support an opengl context, and its frame rate caps at 50hz - why?"

No code, no details on what you've done or where you've done it. No apparent effort to reason anything out.
It isn't an opengl related question, in my opinion.

As far as opengl and d3d goes - they work fine together...I've now got lots of experience to confirm this. Hope at least that bit of my answer helps in some way.

BTW, you are all aware that you can create your own app wizards in vc++6 with little effort?

06-17-2002, 11:18 PM
This might sound obvious, but are you sure vsync is disabled ?

In addition, how is redrawing the window done ? Is it done by event, with a timer, or what ? If so, check how fast the events are emitted, i wouldn't be surprised if this is the cause of the problem..


06-18-2002, 04:40 AM
I thought I had downloaded the full DirectX SDK, but I don't appear to have that Appwizard folder under DXUtils. The only folder under there is the XFiles folder with the tools for converting .3ds to .x files.

Korval, I've got an OpenGL appwizard I wrote awhile back. http://www.lycanth.com/MiscFiles/scrnapp.zip

So far as the original problem, wish I could help. Ysaneya's suggestion to check if the rendering is done with a timer is a good one, though.

06-18-2002, 07:16 AM
Ysaneya you hit the nail on the head ...
Deissum, your intuition was right on ...

I followed your hint and found that the updates are issued during idle time away from the windows message pump. In the message handler, if no messages are pending, it issues a call to the renderer method. It also inserts a wait state here that is limiting the framerate. I removed the wait state and all is fine.

Thanks for the tip, you guys rock!


This problem was not caused by a conflict between OpenGL and DirectInput.

Using OpenGL and DirectInput together is fine and there is no apparent conflict between the two.

For those of you that are using DI with OpenGL, I highly suggest that you look into the code generated by this app wizard as it yields code with a good action mapping model and the slickest interface I have seen yet for reassigning keyboard/mouse/joystick controls to specific functions.

For those of you without the app wizard, email me and I will do what I can to help.

[This message has been edited by pleopard (edited 06-18-2002).]