GLTeapot: Add setting to limit FPS

* Plus renaming "File" menu to "GLTeapot". No files involved.

Fixes #18599

Change-Id: Ifd47eea8eb11d7c94d8f6cc0d4db48eaa0b0bf59
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6954
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
Humdinger 2023-09-26 10:29:23 +02:00 committed by waddlesplash
parent 9dc5767db6
commit 493d3c69f3
3 changed files with 16 additions and 3 deletions

View File

@ -126,7 +126,8 @@ simonThread(void* cookie)
noPause = 0;
waitEvent(objectView->drawEvent);
}
screen.WaitForRetrace();
if (objectView->LimitFps())
screen.WaitForRetrace();
}
return 0;
}
@ -138,6 +139,7 @@ ObjectView::ObjectView(BRect rect, const char *name, ulong resizingMode,
fHistEntries(0),
fOldestEntry(0),
fFps(true),
fLimitFps(true),
fLastGouraud(true),
fGouraud(true),
fLastZbuf(true),
@ -391,6 +393,10 @@ ObjectView::MessageReceived(BMessage* msg)
fFog = !fFog;
toggleItem = true;
break;
case kMsgLimitFps:
fLimitFps = !fLimitFps;
toggleItem = true;
break;
}
if (toggleItem && msg->FindPointer("source", reinterpret_cast<void**>(&item)) == B_OK){

View File

@ -16,6 +16,7 @@
#include <GLView.h>
#define kMsgFPS 'fps '
#define kMsgLimitFps 'lfps'
#define kMsgAddModel 'addm'
#define kMsgGouraud 'gour'
#define kMsgZBuffer 'zbuf'
@ -66,6 +67,7 @@ class ObjectView : public BGLView {
virtual void DetachedFromWindow();
virtual void FrameResized(float width, float height);
bool SpinIt();
bool LimitFps() { return fLimitFps; };
int ObjectAtPoint(const BPoint &point);
virtual void DrawFrame(bool noPause);
virtual void Pulse();
@ -82,7 +84,7 @@ class ObjectView : public BGLView {
BLocker fObjListLock;
uint64 fLastFrame;
int32 fHistEntries,fOldestEntry;
bool fFps, fLastGouraud, fGouraud;
bool fFps, fLimitFps, fLastGouraud, fGouraud;
bool fLastZbuf, fZbuf, fLastCulling, fCulling;
bool fLastLighting, fLighting, fLastFilled, fFilled;
bool fLastPersp, fPersp, fLastTextured, fTextured;

View File

@ -31,7 +31,7 @@ TeapotWindow::TeapotWindow(BRect rect, const char* name, window_type wt,
BMenu* menu;
BMessage msg(kMsgAddModel);
menuBar->AddItem(menu = new BMenu(B_TRANSLATE("File")));
menuBar->AddItem(menu = new BMenu(B_TRANSLATE_SYSTEM_NAME("GLTeapot")));
AddChild(menuBar);
menuBar->ResizeToPreferred();
@ -90,6 +90,11 @@ TeapotWindow::TeapotWindow(BRect rect, const char* name, window_type wt,
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Fog"),
new BMessage(kMsgFog)));
item->SetTarget(fObjectView);
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Limit FPS to refresh rate"),
new BMessage(kMsgLimitFps)));
item->SetTarget(fObjectView);
item->SetMarked(true);
BMenu *subMenu;
menuBar->AddItem(menu = new BMenu(B_TRANSLATE("Lights")));