| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #ifndef RenderThread_H
- #define RenderThread_H
- #include <functional>
- #include "Critical.h"
- #include "Thread.h"
- namespace Framework
- {
- class Bildschirm; //! Bildschirm.h
- class ZeitMesser; //! ZeitMesser.h
- class Bild; //! Bild.h
- //! A thread that manages a screen. It calls the render() and
- //! tick() functions automatically
- class RenderTh : public Thread
- {
- private:
- bool stoppen;
- Bildschirm* bildschirm;
- ZeitMesser* zeit;
- double renderTickZeit;
- void* renderParameter;
- void* tickParameter;
- std::function<void(void*, void*, Bild*)> renderFunktion;
- std::function<void(void*, void*, double)> tickFunktion;
- bool pause;
- Critical cs;
- int maxFps;
- bool quiet;
- public:
- //! Constructor
- DLLEXPORT RenderTh();
- //! Destructor
- DLLEXPORT ~RenderTh();
- //! This is necessary if multiple threads use the object simultaneously.
- //! If lock() is called by two threads, the latter waits until the
- //! first has called unlock().
- DLLEXPORT void lock();
- //! This is necessary if multiple threads use the object simultaneously.
- //! If lock() is called by two threads, the latter waits until the
- //! first has called unlock().
- DLLEXPORT void unlock();
- //! Sets the screen object to be managed
- //! \param bildschirm The screen
- DLLEXPORT void setBildschirm(Bildschirm* bildschirm);
- //! The function that is automatically executed in a new thread
- DLLEXPORT void thread() override;
- //! Starts the render thread
- DLLEXPORT void beginn();
- //! Stops the render thread
- DLLEXPORT void beenden();
- //! if true, then nothing will be printed to std::cout
- DLLEXPORT void setQuiet(bool quiet);
- //! Sets the maximum frames per second
- //! \param fps Maximum frames per second
- DLLEXPORT void setMaxFps(int fps);
- //! Pauses the render thread
- //! \param p 1 if the thread should be paused
- DLLEXPORT void setPause(bool p);
- //! Sets the callback function that is always called before drawing
- //! \param rF The callback function
- DLLEXPORT void setRenderFunktion(
- std::function<void(void*, void*, Bild*)> rF);
- //! Sets the callback function that is always called before updating
- //! all objects \param tF The callback function
- DLLEXPORT void setTickFunktion(
- std::function<void(void*, void*, double)> tF);
- //! Sets the parameter of the callback function that is always called
- //! before drawing \param p The parameter
- DLLEXPORT void setRenderFunktionParameter(void* p);
- //! Sets the parameter of the callback function that is always called
- //! before updating all objects
- DLLEXPORT void setTickFunktionParameter(void* p);
- //! Returns the screen managed by this thread
- DLLEXPORT Bildschirm* getBildschirm() const;
- //! Returns the screen without increased reference counter managed
- //! by this thread
- DLLEXPORT Bildschirm* zBildschirm() const;
- //! Returns the time with which the tick() function of the screen
- //! was last called
- DLLEXPORT double getRenderTickZeit() const;
- };
- } // namespace Framework
- #endif
|