|
@@ -43,7 +43,8 @@ Bildschirm::Bildschirm(WFenster* f)
|
|
|
tips(new RCArray<ToolTip>()),
|
|
|
testRend(1),
|
|
|
fill(1),
|
|
|
- rend(0)
|
|
|
+ rend(0),
|
|
|
+ handleUserInputsOnTick(0)
|
|
|
{}
|
|
|
|
|
|
// Destruktor
|
|
@@ -61,6 +62,11 @@ Bildschirm::~Bildschirm()
|
|
|
unlock();
|
|
|
}
|
|
|
|
|
|
+void Bildschirm::setHandleUserInputsOnTick(bool handleOnTick)
|
|
|
+{
|
|
|
+ handleUserInputsOnTick = handleOnTick;
|
|
|
+}
|
|
|
+
|
|
|
// nicht konstant
|
|
|
void Bildschirm::lock()
|
|
|
{
|
|
@@ -506,55 +512,69 @@ void Bildschirm3D::tick(double tickval)
|
|
|
for (Kam3D* k : *kameras)
|
|
|
rend3D |= k->tick(tickval);
|
|
|
unlock();
|
|
|
+ if (handleUserInputsOnTick)
|
|
|
+ {
|
|
|
+ queueCs.lock();
|
|
|
+ while (meQueue.getEintragAnzahl() > 0)
|
|
|
+ {
|
|
|
+ MausEreignis me = meQueue.get(0);
|
|
|
+ __super::doMausEreignis(me);
|
|
|
+ for (int i = kameras->getEintragAnzahl() - 1; i >= 0; i--)
|
|
|
+ kameras->z(i)->doMausEreignis(me);
|
|
|
+ meQueue.remove(0);
|
|
|
+ }
|
|
|
+ while (teQueue.getEintragAnzahl() > 0)
|
|
|
+ {
|
|
|
+ TastaturEreignis te = teQueue.get(0);
|
|
|
+ __super::doTastaturEreignis(te);
|
|
|
+ for (int i = kameras->getEintragAnzahl() - 1; i >= 0; i--)
|
|
|
+ kameras->z(i)->doTastaturEreignis(te);
|
|
|
+ teQueue.remove(0);
|
|
|
+ }
|
|
|
+ queueCs.unlock();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void Bildschirm3D::doMausEreignis(MausEreignis& me) // sendet maus Ereignis
|
|
|
{
|
|
|
- std::unique_lock<std::mutex> lk(mutex);
|
|
|
- waitingUserInput++;
|
|
|
- lk.unlock();
|
|
|
- lock();
|
|
|
- __super::doMausEreignis(me);
|
|
|
- for (int i = kameras->getEintragAnzahl() - 1; i >= 0; i--)
|
|
|
- kameras->z(i)->doMausEreignis(me);
|
|
|
- unlock();
|
|
|
- lk.lock();
|
|
|
- waitingUserInput--;
|
|
|
- if (waitingUserInput == 0)
|
|
|
+ if (handleUserInputsOnTick)
|
|
|
{
|
|
|
- lk.unlock();
|
|
|
- waiting.notify_all();
|
|
|
+ queueCs.lock();
|
|
|
+ meQueue.add(me);
|
|
|
+ queueCs.unlock();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lock();
|
|
|
+ __super::doMausEreignis(me);
|
|
|
+ for (int i = kameras->getEintragAnzahl() - 1; i >= 0; i--)
|
|
|
+ kameras->z(i)->doMausEreignis(me);
|
|
|
+ unlock();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void Bildschirm3D::doTastaturEreignis(
|
|
|
TastaturEreignis& te) // sendet tastatur Ereignis
|
|
|
{
|
|
|
- std::unique_lock<std::mutex> lk(mutex);
|
|
|
- waitingUserInput++;
|
|
|
- lk.unlock();
|
|
|
- lock();
|
|
|
- __super::doTastaturEreignis(te);
|
|
|
- for (int i = kameras->getEintragAnzahl() - 1; i >= 0; i--)
|
|
|
- kameras->z(i)->doTastaturEreignis(te);
|
|
|
- unlock();
|
|
|
- lk.lock();
|
|
|
- waitingUserInput--;
|
|
|
- if (waitingUserInput == 0)
|
|
|
+ if (handleUserInputsOnTick)
|
|
|
{
|
|
|
- lk.unlock();
|
|
|
- waiting.notify_all();
|
|
|
+ queueCs.lock();
|
|
|
+ teQueue.add(te);
|
|
|
+ queueCs.unlock();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lock();
|
|
|
+ __super::doTastaturEreignis(te);
|
|
|
+ for (int i = kameras->getEintragAnzahl() - 1; i >= 0; i--)
|
|
|
+ kameras->z(i)->doTastaturEreignis(te);
|
|
|
+ unlock();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void Bildschirm3D::render() // Zeichnet das Bild
|
|
|
{
|
|
|
- if (!rend && !rend3D && testRend) return;
|
|
|
- std::unique_lock<std::mutex> lk(mutex);
|
|
|
- if (waitingUserInput > 0)
|
|
|
- waiting.wait(lk);
|
|
|
rendering = 1;
|
|
|
- lk.unlock();
|
|
|
lock();
|
|
|
renderZeit->messungStart();
|
|
|
// Clear the back buffer.
|