LibCarna Version 3.4.0
Loading...
Searching...
No Matches
RenderState.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 - 2016 Leonid Kostrykin
3 *
4 * Chair of Medical Engineering (mediTEC)
5 * RWTH Aachen University
6 * Pauwelsstr. 20
7 * 52074 Aachen
8 * Germany
9 *
10 *
11 * Copyright (C) 2021 - 2025 Leonid Kostrykin
12 *
13 */
14
15#ifndef RENDERSTATE_H_6014714286
16#define RENDERSTATE_H_6014714286
17
18#include <LibCarna/LibCarna.hpp>
20#include <memory>
21
27namespace LibCarna
28{
29
30namespace base
31{
32
33
34
35// ----------------------------------------------------------------------------------
36// RenderState
37// ----------------------------------------------------------------------------------
38
88class LIBCARNA RenderState
89{
90
92
93 struct Details;
94 const std::unique_ptr< Details > pimpl;
95
96protected:
97
98 friend class GLContext;
99
103 explicit RenderState( GLContext& glContext );
104
108 void commit() const;
109
110public:
111
116 {
117
122
127
131 cullFront
132
133 }; // CullFace
134
140
145
149 void setDepthTest( bool dt );
150
154 void setDepthWrite( bool dw );
155
163
168 void setBlend( bool b );
169
177
181 void setBlendEquation( int be );
182
187
192 void setFrontFace( bool ccw );
193
198 void setPointSize( float pointSize );
199
203 void setLineWidth( float lineWidth );
204
205private:
206
207 void commitDepthTest() const;
208
209 void commitDepthWrite() const;
210
211 void commitDepthTestFunction() const;
212
213 void commitBlend() const;
214
215 void commitBlendFunction() const;
216
217 void commitBlendEquation() const;
218
219 void commitCullFace() const;
220
221 void commitFrontFace() const;
222
223 void commitPointSize() const;
224
225 void commitLineWidth() const;
226
227}; // RenderState
228
229
230
231} // namespace LibCarna :: base
232
233} // namespace LibCarna
234
235#endif // RENDERSTATE_H_6014714286
Contains forward-declarations.
Represents an association.
Defines how alpha blending is to be performed.
Wraps and represents an OpenGL context.
Definition GLContext.hpp:66
Manages the OpenGL render state.
void setDepthWrite(bool dw)
Enables or disables depth writing.
void commit() const
Commits the full state. For internal usage only.
void setBlendEquation(int be)
Sets glBlendEquation to be.
void setLineWidth(float lineWidth)
Sets glLineWidth to lineWidth if lineWidth is positive.
CullFace
Lists supported face culling modes.
@ cullNone
All polygons will pass the cull test.
@ cullBack
Polygons recognized as back-faces will be discarded.
void setCullFace(CullFace cf)
Configures face culling. Also see setFrontFace.
void setBlendFunction(const BlendFunction &bf)
Configures how alpha blending is to be done. Alpha blending only applies if it is activated....
RenderState()
Derives new render state from the current one of the current OpenGL context.
RenderState(GLContext &glContext)
Creates the root instance of glContext. For internal usage only.
void setBlend(bool b)
Enables or disables alpha blending. Alpha blending is configured through setBlendFunction and setBlen...
~RenderState()
Restores previous render state.
void setDepthTest(bool dt)
Enables or disables depth testing.
void setFrontFace(bool ccw)
Sets whether front faces are winded contra-clockwise. Also see setCullFace.
void setDepthTestFunction(int dtf)
Configures how the depth test is to be performed. Depth test only applies if it is activated....
void setPointSize(float pointSize)
Sets glPointSize to pointSize if point size is non-negative. Enables GL_PROGRAM_POINT_SIZE and leaves...
Defines LibCarna::base::noncopyable and NON_COPYABLE.
#define NON_COPYABLE
Marks the class that it is placed in as non-copyable.