OpenBarnyard
 
Loading...
Searching...
No Matches
T2RenderContext_GL.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef TRENDERINTERFACE_GL
4
5# include "T2Viewport_GL.h"
6# include "T2GLTexture_GL.h"
7# include "T2Shader_GL.h"
8# include "Math/TMatrix44.h"
9# include "Math/TSphere.h"
10
12
13typedef TUINT32 FRUSTUMPLANE;
14enum FRUSTUMPLANE_ : FRUSTUMPLANE
15{
16 FRUSTUMPLANE_LEFT,
17 FRUSTUMPLANE_RIGHT,
18 FRUSTUMPLANE_BOTTOM,
19 FRUSTUMPLANE_TOP,
20 FRUSTUMPLANE_NEAR,
21 FRUSTUMPLANE_FAR,
22 FRUSTUMPLANE_NUMOF
23};
24
25//-----------------------------------------------------------------------------
26// Note: This is a custom class.
27//-----------------------------------------------------------------------------
28class T2RenderContext
29{
30public:
31 using Frustum = TPlane[ FRUSTUMPLANE_NUMOF ];
32
33 struct Projection
34 {
35 TVector2 vecCenter;
36 TVector2 vecProj;
37 TFLOAT fNearClip;
38 TFLOAT fFarClip;
39 };
40
41public:
42 T2RenderContext();
43 ~T2RenderContext();
44
45 TMatrix44& GetProjectionMatrix() { return m_matProjection; }
46 const TMatrix44& GetProjectionMatrix() const { return m_matProjection; }
47
48 TBOOL SetShaderProgram( const T2Shader& a_rcShaderProgram );
49
50 GLuint GetTexture2D( TINT a_iTextureIndex );
51 void SetTexture2D( TINT a_iTextureIndex, GLuint a_uiTexture );
52 void SetTexture2D( TINT a_iTextureIndex, const T2GLTexture& a_rcTexture );
53 void ResetTexture2D( TINT a_iTextureIndex );
54
55 void EnableDepthTest( TBOOL a_bEnable );
56 void EnableBlend( TBOOL a_bEnable );
57
58public:
59 static void ComputePerspectiveProjection( TMatrix44& a_rOutProjection, const T2Viewport& a_rViewportParams, const Projection& a_rProjParams );
60 static void ComputeOrthographicProjection( TMatrix44& a_rOutProjection, const T2Viewport& a_rViewportParams, const Projection& a_rProjParams );
61
62 static void ComputePerspectiveFrustum( Frustum& a_rcFrustum, const T2Viewport& a_rViewportParams, const Projection& a_rProjParams );
63 static void ComputeOrthographicFrustum( Frustum& a_rcFrustum, const T2Viewport& a_rViewportParams, const Projection& a_rProjParams );
64
65 static TBOOL CullSphereToFrustumSimple( const TSphere& a_rSphere, const TPlane* a_pPlanes, TINT a_iNumPlanes );
66 static TINT CullSphereToFrustum( const TSphere& a_rSphere, const TPlane* a_pPlanes, TINT a_iClipFlags, TINT a_iClipFlagsMask );
67
68private:
69 TMatrix44 m_matProjection;
70 GLuint m_uiCurrentShaderProgram = -1;
71 TINT m_iCurrentTextureUnit = 0;
72 GLuint m_aCurrentTextures[ 8 ];
73
74 TBOOL m_bDepthTest : 1;
75 TBOOL m_bBlend : 1;
76};
77
79
80#endif // TRENDERINTERFACE_GL
4x4 matrix implementation for the Toshi engine
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
float TFLOAT
Definition Typedefs.h:4
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7
bool TBOOL
Definition Typedefs.h:6