OpenGL + Builder C++ 6.0

Hello

I tried to do some OpenGL stuff with Borland Builder C++ 6.0, recently. I made a simple application which was drawing a triangle. I started the program and everything was fine -about 1000 FPS is nice enough. Problem began when I add a single command button to the form. FPS felt down to about 400. Hmmm… After adding some components (8 or something) FPS counter showed 40!!! The performance decrased for 96%! Is it always like that in Builder 6.0?

Meaby this problem comes from my lack of knowledge about Builder since I just started using it.

What can I do?

Thanks

Orzech

What is the method which you are using to call swap buffers every time? Is is Application->OnIdle() ?

P.S. Pozdrowienia z Polski

I am suing SwapBuffers() and everything is placed in Application->OnIdle().

PS. Dziekuje. Nawzajem.

The problem could be with OnIdle() func. In my application (c++ builder5) this function is called only when windows recievs some event for example mouse move, or key press.
I have to read something about OnIdle() routing, but I think that C++ Builder 5 app also have to send the events too all of its componets and that might be some of reasons for decreasing performance.

Originally posted by glYaro:

I have to read something about OnIdle() routing, but I think that C++ Builder 5 app also have to send the events too all of its componets and that might be some of reasons for decreasing performance.

Hmmm… that sounds possible. I’ll also try to find something about OnIdle() but that’s how they used OpenGL in examples of Builder 6.0. I don’t think that drawing components takes this whole time…

You have to set done variable false to get more time from the system.
When i remove these assignment my fps decreased 2100 to 54.May be
this is the solution that you need.

void __fastcall TForm1::IdleLoop(TObject*, bool& done)
{

done = false;  /**** This is the key
Render();
SwapBuffers(gl->hdc);

}

You have to set done variable false to get more time from the system.
When i remove these assignment my fps decreased 2100 to 54.May be
this is the solution that you need.

void __fastcall TForm1::IdleLoop(TObject*, bool& done)
{

done = false;  /**** This is the key
Render();
SwapBuffers(gl->hdc);

}

Yeah, Done = false works excellent!

Originally posted by Orzech:
Hmmm… that sounds possible. I’ll also try to find something about OnIdle() but that’s how they used OpenGL in examples of Builder 6.0. I don’t think that drawing components takes this whole time…

I didn’t mean drawing components but I thought about something like window message event queue - every component is a kind of window .

P.S. Skad Jestes?

OK. I’ll try it. That’s how examples works but I thought it was something different…

Originally posted by glYaro:
[b]
P.S. Skad Jestes?

[/b]

Z Wroclawia. A ty?

Well I just discovered that I already have “done = false” in my idle function. Nothing changed. Performance decreases dramatically when I am trying to add some components. Have you seen something like that? Meaby I’ll show you this program… What do you think?

Thanks

Originally posted by Orzech:
[b]Well I just discovered that I already have “done = false” in my idle function. Nothing changed. Performance decreases dramatically when I am trying to add some components. Have you seen something like that? Meaby I’ll show you this program… What do you think?

Thanks[/b]

OK, no problem.

I’ve not seen this with Builder. My current app’s only component is a context menu, but previous ones had buttons. If it’s not too large, you can email me a zip file with your project and I’ll try to run it at home.

Originally posted by starman:
If it’s not too large, you can email me a zip file with your project and I’ll try to run it at home.

Sure. I hope it isn’t any problem for you.

Orzech - I loaded up your project in my Builder Professional 6. I got a linker error - it was complaining that it couldn’t find some “webdsnap” package that I apparently don’t have. I clicked on Options->Packages and disabled “Build with Runtime Packages” and the linker error went away.

When I ran the app, it registered ~194 FPS consistently at its normal size. I maximized the program window and it registered ~48 FPS.

I didn’t really look at the code or fiddle with it at all…just the package thing I mentioned above. Not sure what to tell you. Do you have all the lastest updates from Borland for Builder 6? Latest OpenGL drivers?

Originally posted by starman:
I didn’t really look at the code or fiddle with it at all…just the package thing I mentioned above. Not sure what to tell you. Do you have all the lastest updates from Borland for Builder 6? Latest OpenGL drivers?

I hope so. But did you try to remove components from the form? What was the effect?

Thanks

Rats. Didn’t try that. I will when I get home. One thing I do recall, though, is that you appear to be placing components on the actual form where GL is drawing. In my few Builder efforts, I’ve always created a Panel on the side to hold input controls, and kept my OpenGL form clear for GL drawing. Maybe there’s something going on with GL and Builder fighting for the same drawing area?

Originally posted by starman:
Maybe there’s something going on with GL and Builder fighting for the same drawing area?

I have no idea really but I think that’s the real problem. Altough I’ll check that.

Thanks

I tried removing components a couple at a time and it didn’t do anything noticably to the frame rate.

Hmmm… That’s wierd. On my computer the application without any components gives me 1000 FPS and WITH components 40 FPS. Meaby that’s just how Builder works? So meaby I should get used to it…

Great thanks for your help, starman!

Orzech