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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
   Copyright (c) 2015 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 _IM_EMULATION_H_
#define _IM_EMULATION_H_

#include "Core/Math/Headers/MathMatrices.h"
#include "Utility/Headers/GUIDWrapper.h"

namespace Divide {

class Texture;
class ShaderProgram;
enum class PrimitiveType : U32;
/// IMPrimitive replaces immediate mode calls to VB based rendering
class NOINITVTABLE IMPrimitive : public GUIDWrapper, private NonCopyable {
   public:
    inline void setRenderStates(const DELEGATE_CBK<>& setupStatesCallback,
                                const DELEGATE_CBK<>& releaseStatesCallback) {
        _setupStates = setupStatesCallback;
        _resetStates = releaseStatesCallback;
    }

    inline void clearRenderStates() {
        _setupStates = nullptr;
        _resetStates = nullptr;
    }

    inline void setupStates() {
        if (_setupStates) {
            _setupStates();
        }
    }

    inline void resetStates() {
        if (_resetStates) {
            _resetStates();
        }
    }

    inline void drawShader(ShaderProgram* const shaderProgram) {
        _drawShader = shaderProgram;
    }

    inline ShaderProgram* const drawShader() const {
        return _drawShader;
    }

    virtual void render(bool forceWireframe = false, U32 instanceCount = 1) = 0;
    virtual void beginBatch(bool reserveBuffers, unsigned int vertexCount) = 0;

    virtual void begin(PrimitiveType type) = 0;
    virtual void vertex(F32 x, F32 y, F32 z) = 0;
    inline void vertex(const vec3<F32>& vert) {
        vertex(vert.x, vert.y, vert.z);
    }
    virtual void attribute1i(U32 attribLocation, I32 value) = 0;
    virtual void attribute1f(U32 attribLocation, F32 value) = 0;
    virtual void attribute4ub(U32 attribLocation, U8 x, U8 y, U8 z,  U8 w) = 0;
    virtual void attribute4f(U32 attribLocation, F32 x, F32 y, F32 z, F32 w) = 0;
    inline void attribute4ub(U32 attribLocation, const vec4<U8>& value) {
        attribute4ub(attribLocation, value.x, value.y, value.z, value.w);
    }
    inline void attribute4f(U32 attribLocation, const vec4<F32>& value) {
        attribute4f(attribLocation, value.x, value.y, value.z, value.w);
    }

    virtual void end() = 0;
    virtual void endBatch() = 0;

    void clear();

    inline void paused(bool state) { _paused = state; }
    inline bool paused() const { return _paused; }
    inline void inUse(bool state) { _inUse = state; }
    inline bool inUse() const { return _inUse; }
    inline void zombieCounter(U8 count) { _zombieCounter = count; }
    inline U8   zombieCounter() const { return _zombieCounter; }
    inline void forceWireframe(bool state) { _forceWireframe = state; }
    inline bool forceWireframe() const { return _forceWireframe; }
    inline bool hasRenderStates() const {
        return (!_setupStates && !_resetStates);
    }

    /// State management
    inline U32 stateHash() const { return _stateHash; }
    inline void stateHash(U32 hashValue) { _stateHash = hashValue; }

    inline const mat4<F32>& worldMatrix() const { return _worldMatrix; }
    inline void worldMatrix(const mat4<F32>& worldMatrix) {
        _worldMatrix.set(worldMatrix);
    }
    inline void resetWorldMatrix() { _worldMatrix.identity(); }

    inline void name(const stringImpl& name) {
#       ifdef _DEBUG
        _name = name;
#       else
        ACKNOWLEDGE_UNUSED(name);
#       endif
    }
   protected:
    IMPrimitive();
#ifdef _DEBUG
    stringImpl _name;
#endif
   public:
    virtual ~IMPrimitive();

   public:

    ShaderProgram* _drawShader;
    Texture* _texture;
    bool _canZombify;

   protected:
    // render in wireframe mode
    bool _forceWireframe;

   private:
    U8   _zombieCounter;
    bool _inUse;
    /// If _pause is true, rendering for the current primitive is skipped and
    /// nothing is modified (e.g. zombie counters)
    bool _paused;
    /// 2 functions used to setup or reset states
    DELEGATE_CBK<> _setupStates;
    DELEGATE_CBK<> _resetStates;
    /// The state hash associated with this render instance
    U32 _stateHash;
    /// The transform matrix for this element
    mat4<F32> _worldMatrix;
};

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Platform/Video/Headers/IMPrimitive.h

Diff revisions: vs.
Revision Author Commited Message
557 Diff Diff IonutCava picture IonutCava Tue 10 Nov, 2015 12:00:20 +0000

[IonutCava]
- Gather all rendering calls from glVertexArray and glGenericVertexData into a single function in glResources: submitRenderCommand.
— This allows both classes to interpret GenericDrawCommands in the same way
- Use unsigned ints for all hasehs instead of size_t to avoid negative number hashes (useful for debugging)

514 Diff Diff IonutCava picture IonutCava Fri 25 Sep, 2015 16:18:42 +0000

[IonutCava]
- Split fullscreen quad rendering system in two and use the most performant one depending on the situation:
— The old GL_POINTS expanded in Geometry shader method. (e.g. useful for blurs / fxaa)
— Single triangle 2x width and 2xheight of the screen with scaled UVs (e.g. useful for fullscreen rendering)
- Attempt to change line rendering system to support custom start and end widths
- First attempt at splitting vertex specifications from buffers (with glVertexAttribFormat) and use only one VAO per specification instead of one per object
- Code cleanups and small optimizations where appropriate

484 Diff Diff IonutCava picture IonutCava Sun 09 Aug, 2015 13:48:51 +0000

[Ionut]
- Use explicit attribute locations with IMPrimitive objects (reducing the number of glGetAttribLocation calls to zero)
- Remove “renderCallback” system in scenes as it wasn’t used and caused unnecessary indirections
- A few cleanups and const correctness changes

439 Diff Diff IonutCava picture IonutCava Sun 17 May, 2015 21:18:15 +0000

[Ionut]
- Added start and end color options to the Line structure
- Changed the root node’s BB calculation algorithm
- Improved IMInterface garbage collection
- Simplified hacky scene line rendering system

436 Diff Diff IonutCava picture IonutCava Thu 14 May, 2015 16:09:08 +0000

[Ionut]
- Initial cleanup of RenderStateBlock and RenderStateBlockDescriptor classes
- lineWith is now part of the render state and as such, must be explicitly set in the state hash
— This affects all IMPrimitives, especially those rendered via drawBox3D and drawLines

425 Diff Diff IonutCava picture IonutCava Thu 07 May, 2015 16:03:29 +0000

[Ionut]
- Profile guided optimizations:
— Removed the need for a temporary mat4 in operator*= body
— Optimized addition, subtraction and scalar multiplication for mat4
— Added the possibility to reserve memory for GLIM vectors when BeginBatch is called (reducing the number of mem allocs needed for each vertex specified)
— Transform class' dirty flags moved before locking the mutex to reduce lock duration (dirty flags are atomic booleans anyway)
— GraphPlots can now be created with a name instead of just specifying one later on (avoids useless string allocations)
- Added a Quaternion.inl file to hold actual Quaternion implementation details

403 Diff Diff IonutCava picture IonutCava Fri 17 Apr, 2015 16:06:14 +0000

[Ionut]
- Improved the DSA wrapper
- Improved IMPrimitive debugging info
- Added sync objects for multi-threaded texture and shader loading
- Cleaned up the animation system a bit:
— Still to do: Create skeleton per sub-mesh starting from the sub meshes' parent node instead of the root scene node. SubMeshes should not have identical skeletons but only the skeletons for their own geometry!

397 Diff Diff IonutCava picture IonutCava Fri 10 Apr, 2015 15:33:01 +0000

[Ionut]
- Disabled VTable initialization for abstract classes on windows
- Fixed an erroneous delegate bind in Kernel for graph plotting

364 Diff Diff IonutCava picture IonutCava Fri 06 Mar, 2015 16:55:21 +0000

[Ionut]
- Part 1 of type safe enum replacement (does not compile)

350 IonutCava picture IonutCava Tue 10 Feb, 2015 16:25:39 +0000

[Ionut]
- Simplified some Util-namespace level functions by using STL algorithms where possible
- Formatted the entire codebase using clang-format with the following style: "{BasedOnStyle: Google, IndentWidth: 4}"
- Attempted to make ProfileTimer thread-safe (temp fix until std::chrono works properly in Visual Studio)