source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp @ 2840

Revision 2840, 871 bytes checked in by mattausch, 16 years ago (diff)
Line 
1#include "Transform3.h"
2#include "Matrix4x4.h"
3#include "RenderState.h"
4
5
6namespace CHCDemoEngine
7{
8
9CGparameter Transform3::sModelMatrixParam;
10
11Transform3::Transform3(Matrix4x4 *trafo): mMatrix(trafo)
12{
13}
14
15
16Transform3::~Transform3()
17{
18        DEL_PTR(mMatrix);
19}
20
21
22void Transform3::Load(RenderState *state)
23{
24        if (!mMatrix) return;
25
26        if (state->GetRenderType() == RenderState::DEFERRED)
27        {
28                cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix->x);
29        }
30        else
31        {
32                glPushMatrix();
33                glMultMatrixf((float *)mMatrix->x);
34        }
35}
36
37
38void Transform3::Unload(RenderState *state)
39{
40        if (!mMatrix) return;
41
42        if (state->GetRenderType() == RenderState::DEFERRED)
43        {
44                static Matrix4x4 identity = IdentityMatrix();
45                cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x);
46        }
47        else
48        {
49                glPopMatrix();
50        }
51}
52
53}
Note: See TracBrowser for help on using the repository browser.