PDA

View Full Version : OpenGL + Builder C++ 6.0



Orzech
08-02-2003, 01:08 AM
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. http://www.opengl.org/discussion_boards/ubb/smile.gif 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

yaro_dup1
08-02-2003, 01:20 AM
What is the method which you are using to call swap buffers every time? Is is Application->OnIdle() ?

P.S. Pozdrowienia z Polski http://www.opengl.org/discussion_boards/ubb/smile.gif

Orzech
08-02-2003, 01:29 AM
I am suing SwapBuffers() and everything is placed in Application->OnIdle().

PS. Dziekuje. Nawzajem. http://www.opengl.org/discussion_boards/ubb/smile.gif

yaro_dup1
08-02-2003, 01:57 AM
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.

Orzech
08-02-2003, 03:17 AM
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... http://www.opengl.org/discussion_boards/ubb/wink.gif

08-02-2003, 11:41 AM
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);

}

08-02-2003, 11:45 AM
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);

}

yaro_dup1
08-02-2003, 01:42 PM
Yeah, Done = false works excellent!

yaro_dup1
08-02-2003, 01:49 PM
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... http://www.opengl.org/discussion_boards/ubb/wink.gif

I didn't mean drawing components but I thought about something like window message event queue - every component is a kind of window http://www.opengl.org/discussion_boards/ubb/wink.gif.

P.S. Skad Jestes?

Orzech
08-03-2003, 01:23 AM
OK. I'll try it. That's how examples works but I thought it was something different...


Originally posted by glYaro:

P.S. Skad Jestes?



Z Wroclawia. A ty? http://www.opengl.org/discussion_boards/ubb/smile.gif

Orzech
08-03-2003, 11:16 AM
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

yaro_dup1
08-04-2003, 01:16 AM
Originally posted by Orzech:
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

OK, no problem.

starman
08-04-2003, 02:00 AM
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.

Orzech
08-04-2003, 03:03 AM
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.

starman
08-05-2003, 02:50 PM
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?

Orzech
08-05-2003, 11:10 PM
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

starman
08-06-2003, 07:59 AM
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?

Orzech
08-07-2003, 01:17 AM
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

starman
08-07-2003, 03:48 AM
I tried removing components a couple at a time and it didn't do anything noticably to the frame rate.

Orzech
08-07-2003, 04:11 AM
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... http://www.opengl.org/discussion_boards/ubb/smile.gif

Great thanks for your help, starman!

Orzech

Orzech
08-08-2003, 07:04 AM
I did like you said, starman. I placed everything on a "panel" and everything seems to work much better. From what I observed every component (no matter which) takes nearly 50% of actual performance. I can't tell you why but when I put a panel (it took away some FPS) and placed some buttons nothing changed. Now it seems that the application is loosing speed only because of the panel (components placed on it aren't any problem). This "trick" is a sufficent method for me. But still... what makes the program work this way? (I am just curious) http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanx

starman
08-08-2003, 11:01 AM
I'm equally novice at both Builder and OpenGL :-) I actually probably know more about OpenGL than Builder now. I use Builder so I can quickly slap together a GUI around my OpenGL app.

I can't even remember how I got my first GL app to work - I either downloaded somebody's GL class or snagged the code from the web. Either way, it doesn't matter much. My programs' GUIs are quite minimal anyway.

[This message has been edited by starman (edited 08-08-2003).]