Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
   Copyright (c) 2017 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _FRAME_LISTENER_H_
#define _FRAME_LISTENER_H_

#include "Core/Headers/GUIDWrapper.h"
#include "Core/TemplateLibraries/Headers/String.h"
#include "Platform/Headers/PlatformDefines.h"

/// As you might of guessed it, it's the same system used in Ogre3D
/// (http://www.ogre3d.org/docs/api/html/OgreFrameListener_8h_source.html)
/// I decided to use something that people already know and are comfortable with
///-Ionut

namespace Divide {

enum class FrameEventType : U32 {
    FRAME_EVENT_ANY = 0,
    FRAME_EVENT_STARTED,
    FRAME_PRERENDER_START,
    FRAME_PRERENDER_END,
    FRAME_POSTRENDER_START,
    FRAME_POSTRENDER_END,
    FRAME_EVENT_PROCESS,
    FRAME_EVENT_ENDED,
};

struct FrameEvent {
    U64 _timeSinceLastEventUS;
    U64 _timeSinceLastFrameUS;
    U64 _currentTimeUS;
    FrameEventType _type;
};

/// FrameListener class.
/// Has 3 events, associated with the start of rendering a frame,
/// the end of rendering and the end of buffer swapping after frames
/// All events have timers associated with them for update timing
class FrameListener : public GUIDWrapper {
   public:
    /// Either give it a name
    FrameListener(const stringImpl& name) 
        : GUIDWrapper(),
          _callOrder(0)
    {
        _listenerName = name;
    }

    /// Or the frame listenr manager will assing it an ID
    FrameListener()
        : FrameListener("")
    {
    }

    virtual ~FrameListener()
    {
    }

    inline const stringImpl& getListenerName() const {
        return _listenerName;
    }

    bool operator<(FrameListener& that) {
        return this->_callOrder < that._callOrder;
    }

   protected:
    friend class FrameListenerManager;
    inline void setName(const stringImpl& name) { _listenerName = name; }
    inline void setCallOrder(U32 order) { _callOrder = order; }
    /// Adapter patern instead of pure interface for the same reason as the Ogre
    /// boys pointed out:
    /// Implement what you need without filling classes with dummy functions
    /// frameStarted is calld at the beggining of a new frame before processing
    /// the logic aspect of a scene
    virtual bool frameStarted(const FrameEvent& evt) { ACKNOWLEDGE_UNUSED(evt); return true; }
    /// framePreRenderStarted is called when we need to start processing the
    /// visual aspect of a scene
    virtual bool framePreRenderStarted(const FrameEvent& evt) { ACKNOWLEDGE_UNUSED(evt); return true; }
    /// framePreRenderEnded is called after all the prerendering has finished
    /// and rendering should start
    virtual bool framePreRenderEnded(const FrameEvent& evt) { ACKNOWLEDGE_UNUSED(evt); return true; }
    /// frameRendering Queued is called after all the frame setup/rendering but
    /// before the call to SwapBuffers
    virtual bool frameRenderingQueued(const FrameEvent& evt) { ACKNOWLEDGE_UNUSED(evt); return true; }
    /// framePostRenderStarted is called after the main rendering calls are
    /// finished (e.g. use this for debug calls)
    virtual bool framePostRenderStarted(const FrameEvent& evt) { ACKNOWLEDGE_UNUSED(evt); return true; }
    /// framePostRenderEnded is called after all the postrendering has finished
    virtual bool framePostRenderEnded(const FrameEvent& evt) { ACKNOWLEDGE_UNUSED(evt); return true; }
    /// frameEnded is called after the buffers have been swapped
    virtual bool frameEnded(const FrameEvent& evt) { ACKNOWLEDGE_UNUSED(evt); return true; }

   private:
    /// not _name so that it doesn't conflict with Resource base class
    stringImpl _listenerName;
    /// if multiple frame listeners are handling the same event, this call order
    /// variable is used for sorting
    U32 _callOrder;
};

};  // namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Rendering/Headers/FrameListener.h

Diff revisions: vs.
Revision Author Commited Message
970 Diff Diff IonutCava picture IonutCava Mon 13 Nov, 2017 17:16:44 +0000

[Ionut]
- ImWindow <-> DisplayWindow fixes

968 Diff Diff IonutCava picture IonutCava Tue 07 Nov, 2017 17:32:31 +0000

[Ionut]
- Consistent naming between timing variables

962 Diff Diff IonutCava picture IonutCava Fri 03 Nov, 2017 17:17:55 +0000

[Ionut]
- Fix creation/destruction of multiple DisplayWindows
- Add an InputInterface per DisplayWindow
- More work on the ImWindow based Editor

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

817 Diff Diff IonutCava picture IonutCava Sun 15 Jan, 2017 21:29:59 +0000

[IonutCava]
- Add a new Unit component to SGNs that holds NPC/Player/etc. objects
- Add support for multiple keyboard+mouse combos and joysticks and add mapping between these and players

807 Diff Diff IonutCava picture IonutCava Mon 09 Jan, 2017 17:06:26 +0000

[IonutCava]
- Split PlatformDefines.h into 2. Move data type defines to PlatformDataTypes.h
- Continue to improve velocity map calculation
- Remove “destroy()” calls from most classes. Attempt to move as many classes to the RAII system.

680 Diff Diff IonutCava picture IonutCava Thu 14 Apr, 2016 16:15:38 +0000

[IonutCava]
- Added a mat2 class (untested)
- Added static asserts to matrices, vectors and quaternions to allow only arithmetic (sans bool) data types
- Added more vector unit tests
- Added unit tests for matrices
- D32 finally renamed to D64 as the VC++ compiler is considered as the reference compiler

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

625 Diff Diff IonutCava picture IonutCava Mon 18 Jan, 2016 17:19:59 +0000

[IonutCava]
- Limit number of shader compilations per frame
- Add initial support for deferred SGN postLoad calls (think multi-threaded loading support in the future)
- Various small profile-guided optimizations
- Removed some indirections in draw command submission

540 IonutCava picture IonutCava Wed 28 Oct, 2015 19:06:28 +0000

[IonutCava]
- Remove the “Platform” folder from the Platform project as the name is redundant. Move files one level up